Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Wretchedlout on October 07, 2012, 01:34:52 pm

Title: Critical point numbers
Post by: Wretchedlout on October 07, 2012, 01:34:52 pm
Hello there, I wish to create a program that finds the critical point numbers of a formula in Y1. (Critical point numbers are just x values where the derivative (or slope) is 0.) so that requires some equation solving.

Ex:
       4X4-16X2=0
       4X2(X2-4)=0
4X2(X-2)(X+2)=0

X=-2, 0, 2

Is there any way to do that without:
Code: [Select]
For(A,-50,50
if abs(nderiv(Y1,X,A)))<.0001
A->LZ(A+50
End
?
Title: Re: Critical point numbers
Post by: ben_g on October 07, 2012, 01:44:38 pm
Take a sheet of paper, find the derivative of the function in Y1 and solve it as an equation to see where it reaches 0. The program you suggested will only work if the x-coordinates of the critical points are integer values between -50 and 50.
Title: Re: Critical point numbers
Post by: Wretchedlout on October 07, 2012, 01:57:44 pm
I understand, is there a way for the calculator to do it very fast with no limits?
Title: Re: Critical point numbers
Post by: ben_g on October 07, 2012, 02:26:33 pm
Draw the graph, then do 2ND>CALC and select minimum or maximum, depending on if you want to know the minimum or maximum value of a point. Then, select a point in front of the critical point,  press enter, select a point behind it, then press enter twice. Repeat for every critical point.
Title: Re: Critical point numbers
Post by: Wretchedlout on October 07, 2012, 02:35:18 pm
not using the graph, just a formula to find each very fast
Title: Re: Critical point numbers
Post by: thepenguin77 on October 07, 2012, 03:01:55 pm
Ok, so there's no good way to do what you're trying to do.

Firstly, two functions you should know about:
nDeriv(expression, variable, value)
solve(expression, variable, guess)

Now, the way these work, is the first one will take the derivative for you, so nDeriv(x^2,x,2) will give you 4, and nDeriv(x^3,x,y) will behave like 3y^2 (though it will be far slower).

solve( is just the functional way to use solver. expression is what is set equal to zero, so if we want x^2 = 0, we would do solve(x^2,x,1) = 0. The trouble with this is that it will only find one of the zeros, and an example of this is x^2 = 4. If we rearrange that we get x^2 - 4 = 0. So solve(x^2,x,1) = 2 and solve(x^2,x,-1) = -2. But the key is you have to guess correctly for both.

Now, the actual code that does your work is going to look like this: solve(nDeriv(expression,variable,Y), Y, guess). Again, to find the critical point of x^2, you would do solve(nDeriv(x^2,x,y),y,1) and this will spit out 0.


Here's the trouble, that worked great for that equation because it only had one critical point. But if it has two, you need to run it twice with different guesses. I don't know how to detect the number of critical points nor decide where to guess, so that one will be up to you.

The best thing I can say for this would be to quickly graph the derivative and then decide how many critical points you think there are. Something like this might do the trick.

nDeriv(equation,x,x) -> Y1
ZoomFit
2->XRes
Trace
Prompt for number of zeros
Prompt for each guess

For(A,1, number of zeros)
solve(Y1, x, guess[A])
End


Edit:
   Sorry, missed your code example, so my post is a little less relevant, but still works.
Title: Re: Critical point numbers
Post by: Wretchedlout on October 08, 2012, 07:01:03 pm
well thanks
Title: Re: Critical point numbers
Post by: DrDnar on October 09, 2012, 12:24:58 am
I understand, is there a way for the calculator to do it very fast with no limits?
not using the graph, just a formula to find each very fast
If there was, they'd teach it to you in school. Slow, numeric methods and symbolic calculus methods are the only ways of doing it. The symbolic calculus functionality you're looking for is called a CAS (Computer Algebraic System), and it's why you're probably not allowed to use a TI-89 or Nspire-CAS.