HP Forums
function analysis question - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: function analysis question (/thread-5275.html)



function analysis question - quinyu - 12-05-2015 05:49 AM

Given a function f(x), how do I find the domain and image/range of it? (The domain being the set of x values that the function can accept; and the range being the set of f(x) results that the function can have.)

For example, I have the function f(x)=ASIN(SQRT(x)), valid on reals. I know that it must have 0<=x<=1. I also know that (assuming you're working in radians) 0<=f(x)<=pi/2. How do you pull these results in the CAS in a symbolic form?

For the moment, let's not go into the ugly thicket of how to work it out on complex numbers. I know how to get the above results on an Nspire CAS, but couldn't for my life figure how it can be obtained on the HP Prime. Suggestions, please.


RE: function analysis question - parisse - 12-05-2015 07:17 AM

Try assume(x>0 and x<1)


RE: function analysis question - quinyu - 12-05-2015 01:22 PM

No, I want the calculator to tell me where it can interpret the function. That's the domain. I want the calculator to tell the domain of an arbitrary function f(x). What I showed was an example. Also, I want the calculator to tell the range - that is, the set of all the values that f(x) has, on the domain. How do I do this?

For your info, on the TI-nspire CAS, the command domain(asin(sqrt(x)),x) results in the output 0<=x<=1, which is what I'm looking for. (This is not the precise input but close enough to it.) While it cannot directly find the range (or at least I know of no method to do so), if I set x=asin(sqrt(y)), and have it solve for y, gives y=(sin(x))^2 (that is the inverse function), with the requirements that sin(x)>=0 and -pi/2<=x<=pi/2. From that point on, I can get a domain again for (sin(x))^2, which is obviously any real number, so that bit is irrelevant. If I solve for the other criteria, it gives max(-pi/2,2*n1*pi)<=x<=min(pi/2,2*n1*pi+pi) as a result. For the principal value (that is, n1=0) of the expression, that means that 0<=x<=pi/2. This is therefore our function range.

So, how do I execute the same sort of procedure on the HP Prime?


RE: function analysis question - parisse - 12-05-2015 03:23 PM

There is no domain function currently: most of the time you can see the domain with one plot and if required get the exact boundaries with one solve command (Giac/Xcas has a singular function that can help find the domain, but it is not available in the Prime).
For the abscissa of the minimum and maximum of an expression, try fMin or fMax(f(x),x=a..b)


RE: function analysis question - luisphysics - 12-05-2015 04:24 PM

(12-05-2015 01:22 PM)quinyu Wrote:  No, I want the calculator to tell me where it can interpret the function. That's the domain. I want the calculator to tell the domain of an arbitrary function f(x). What I showed was an example. Also, I want the calculator to tell the range - that is, the set of all the values that f(x) has, on the domain. How do I do this?

For your info, on the TI-nspire CAS, the command domain(asin(sqrt(x)),x) results in the output 0<=x<=1, which is what I'm looking for. (This is not the precise input but close enough to it.) While it cannot directly find the range (or at least I know of no method to do so), if I set x=asin(sqrt(y)), and have it solve for y, gives y=(sin(x))^2 (that is the inverse function), with the requirements that sin(x)>=0 and -pi/2<=x<=pi/2. From that point on, I can get a domain again for (sin(x))^2, which is obviously any real number, so that bit is irrelevant. If I solve for the other criteria, it gives max(-pi/2,2*n1*pi)<=x<=min(pi/2,2*n1*pi+pi) as a result. For the principal value (that is, n1=0) of the expression, that means that 0<=x<=pi/2. This is therefore our function range.

So, how do I execute the same sort of procedure on the HP Prime?

This may not be a satisfactory answer, but I believe the Ti-inspire has a built in option for imaginary or real inputs. If it is set to real, then the range for SINE or COSINE can be easily hard coded into the software. By definition Sqrt(x) where x <0 is imaginary, then it knows to spit out only the real part because it is set to spit out the real part. So the TI guys probably made a program to define the domain of functions, and formatted it all pretty.
Try domain(arcsin(sqrt(x))*1/((.5-x)*(.6-x))

And then the TI inspire CAS throws out a yellow triangle telling you....OHHH no be careful I'm guessing but if it gets harder than this I may be wrong.
That is what I have found the yellow warning triangle means.
This tells me that they have hard coded some stuff in the TI inspire CAS. Or have some basic algorithms to catch common items.

A calculator is a good teaching tool and "I agree that the HP Prime should have a domain function build in". In a way it does, if you plot the function, then press the Num key it will tell you the NaN which is out of bounds and it will give you values for stuff in bounds.

What I'm getting at is that the HP Prime might not do that by default for you, but you can program it to spit out the text and format it the way you want.

If your function in complex enough, use the right tool for the job. Use Wolfram alpha.


RE: function analysis question - quinyu - 12-05-2015 05:56 PM

Just tried what you proposed, namely domain(arcsin(sqrt(x))*1/((1/2-x)*(3/5-x)),x), and what I got was that x is not meant to be 1/2 or 3/5 and must be 0<=x<=1. With using decimal fractions, you do get the warning. Mine is not yellow, since I'm having the CAS, not the CX CAS - colors don't command such a big premium for me (I'd kill for a Classpad II though. :] ) In general, you are better off using proper fractions in CAS systems, and this isn't limited to those ones on various calculators.

The TI-89 Titanium has no domain function as of the last update, so I cannot test on that, nor on the TI-92 since that one lacks it as well.

Either way, even if it's at the level you say, it is handier than having no access to such functionality at all. Someone, perhaps, implement it for the next Prime firmware release? It should be easy, if what you wrote is true (namely, they are just having some basic algorithms to catch common items.) I wouldn't endeavour coding anything of the sort, I know that for sure =) but if Giac/Xcas already has it, maybe it won't take so long to get the HP developers enable it too... I can only hope.


RE: function analysis question - jte - 12-05-2015 11:04 PM

While not in the CAS, the Advanced Graphing app does keep track of function domains. You could do something like defining V1 as ASIN(SQRT(X))<9^9^9 and then plot that.


RE: function analysis question - quinyu - 12-05-2015 11:39 PM

(Advanced) Graphing, while it might be good for a quick check, wouldn't do much in way of getting an exact solution... in all likelihood, it's not feasible to do so for more complex functions. Thanks for the tip anyhow. I was never big on graphing.


RE: function analysis question - jte - 12-06-2015 07:16 AM

I'm not exactly sure what you mean by "not feasible to do so for more complex functions". Exact solutions are generally only possible for restricted classes of problems. They can, of course, be extremely useful when they're available.

When looking at exact solutions over multiple dimensions, a typical way of improving one's understanding is to … graph the solution set. A trivial toy example would be something like ASIN(2*COS(X*X-Y*Y))+ASIN(2*SIN(X*X+Y*Y)) with real (not complex) arithmetic. The graph of that <9^9^9 gives one a quick understanding of the (bulk of the) domain; now try writing down an explicit expression for the domain.