symja_android_library icon indicating copy to clipboard operation
symja_android_library copied to clipboard

Implement `FunctionDomain` to find domain for real-valued univariate function

Open tranleduy2000 opened this issue 1 year ago • 2 comments

Examples:

>>> FunctionDomain(1/x, x, S.Reals)
Union(Interval.open(-oo, 0), Interval.open(0, oo))

>>> FunctionDomain(tan(x), x, Interval(0, pi))
Union(Interval.Ropen(0, Pi/2), Interval.Lopen(Pi/2, Pi))

>>> FunctionDomain(sqrt(x - 2), x, Interval(-5, 5))
Interval(2, 5)

>>> continuous_domain(log(2*x - 1), x, S.Reals)
Interval.open(1/2, oo)

Existing implementation:

  • Sympy https://github.com/sympy/sympy/blob/d2be7bacd2604e98a642f74028e8f0d7d6084f78/sympy/calculus/util.py#L24-L89

tranleduy2000 avatar May 28 '23 16:05 tranleduy2000

Please help improving my first attempt a846be1

axkr avatar May 28 '23 20:05 axkr

For division node, the visitor should:

  • Take the denominator and
  • Perform undefinedPoints = Solve[ denominator == 0, var, S.Reals]
  • Exclude undefinedPoints from domain

Test cases:

FunctionDomain[(x^2+x+1)/x, x]
FunctionDomain[1/(x^2), x]

For Sqrt[x], the domain should be x >= 0

Test cases:

FunctionDomain[Sqrt[x-3], x]

tranleduy2000 avatar May 29 '23 15:05 tranleduy2000