Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
Detectar si una expresión podría tener un resultado indefinido

Me gustaría determinar si una expresión dada puede tener un resultado indefinido.

Por ejemplo, tome el siguiente cálculo:

 a = rand() * 1000 // a real number >=0 and <1000 b = trunc( a )*2 // an even number between 0 and 1998 c = sin( a ) // a real number >=-1 and <=1 d = pow( c, b ) // a positive real number >=0 and <=1 e = log( a ) // either undefined (-Infinity), or a real number <6.907… f = sqrt( e ) // either undefined, or a real number >=0 and <2.628…

¿Cómo puedo escribir un programa que me diga que e y f pueden no estar definidos, mientras que los demás siempre están definidos?

¿Hay alguna biblioteca que pueda verificar esto por mí?

Actualmente estoy escribiendo en JavaScript, pero estoy dispuesto a cambiar el idioma si no existe tal biblioteca para JS, pero existe para otros idiomas.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Usando python y su biblioteca sympy, hay sympy.calculus.util.continuous_domain .

 from sympy import Symbol from sympy import sin, log, sqrt from sympy.sets import Interval from sympy.calculus.util import continuous_domain, function_range a = Symbol('a') b = 3 c = sin(a) d = c ** b e = log(a) f = sqrt(e) for y in (c,d,e,f): print(y) print('domain: ', continuous_domain(y, a, Interval(0,1000))) print('range: ', function_range(y, a, Interval(0,1000))) print()

Producción:

 sin(a) domain: Interval(0, 1000) range: Interval(-1, 1) sin(a)**3 domain: Interval(0, 1000) range: Interval(-1, 1) log(a) domain: Interval.Lopen(0, 1000) range: Interval(-oo, log(1000)) sqrt(log(a)) domain: Interval(1, 1000) range: Interval(0, sqrt(log(1000)))

Desafortunadamente, reemplazar b = 3 con b = Symbol('b', integer = True) o b = floor(a) resulta en un bloqueo espectacular de function_range(d, a, Interval(0,1000)) . Todavía puede obtener el continuous_domain , pero no el function_range .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!