axkr / symja_android_library

:coffee: Symja - computer algebra language & symbolic math library. A collection of popular algorithms implemented in pure Java.
https://matheclipse.org/
GNU General Public License v3.0
361 stars 81 forks source link

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

Open tranleduy2000 opened 1 year ago

tranleduy2000 commented 1 year ago

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:

axkr commented 1 year ago

Please help improving my first attempt a846be1

tranleduy2000 commented 1 year ago

For division node, the visitor should:

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]