Hey !
This week I worked on implementing a method for finding the range of a function in a given domain. Following from last weeek’s research on the same, I tried to develop these utility functions.
Implementation Link to heading
Here, I have defined the two functions along with some of their implementation details:
continuous_in(f, x, interval)
The function returns the sub-domains as an Union
of Interval
in case a discontinuity exists in the interval
. If the function is continuous in the entire domain, the interval
itself is returned.
For this we need to consider 2 primary conditions:
Domain constraints for real functions I have also added some code for domain constraints in
sqrt
andlog
functions. Using thesolve_univariate_inequality
method (as the name suggests, it solves univariate inequalities), we calculate these constraints.
Givenf(x) = sqrt(g(x))
, we determine the range of values ofx
for which the functiong(x) >= 0
.
Similarly, forf(x) = log(g(x))
, the interval ofx
in whichg(x) > 0
is the constrained interval.Singularities For determining the discontinuities, I tried to solve the reciprocal of the given function using
solveset
:solveset(1/f, x, interval)
. Thesingularities
function can also be used here but its implementation is restricted to rational functions only. There are possibilities of improving this function to create a universal function which returns all the possible singularities of the function in a given domain.
function_range(f, x, domain)
Like the name suggests, this method returns the range of a univariate function in a given domain. This function is primarily designed for the purpose of solve_decomposition
.
This function calls the above implemented continuous_in
method for finding the actual domain of f
. Following this, we iterate over each Interval
object returned by continuous_in
.
By using the boundaries of the interval and first derivate test, we determine the crtical points in the interval and their corresponding critical values.
For determining the values of the function at the singularities, we determine its limit at that point.
For this, I use the limit
function of SymPy.
After calculating the local extremas, I calculate the global minima and maxima using the inf
(infimum) and sup
(supremum) of the FiniteSet
of all critical values. The range, which is the Interval
of these extremasm, is returned.
$ git log Link to heading
PR#11141: Method for solving equations using Decomposition and Rewriting
Opened this week
PR#11224: Methods for finding the range of a function in a given domain
Final Thoughts
That was all for this week.
My task for the upcoming days would be to update my solve_decomposition
method to accomodate these methods.
I aim to get all these PR merged before the midterm evaluation.