Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: kyllopardiun on October 22, 2010, 04:54:17 pm

Title: Nspire IF bug? :O
Post by: kyllopardiun on October 22, 2010, 04:54:17 pm
I kind like nsolve [as solve isn't in my calc  ;D]
but it don't show all solutions, so I tried to do this:


Code: [Select]
Define LibPub nsolver(eq,x)=
Prgm
:Local a,b,c
:a:=−100
:b:=nSolve(eq,x=−100)
:Disp "Solutions: "
:Disp b
:While a≤100
:  a:=a+1
:  c:=nSolve(eq,x=a)
:  If b≠c Then
:     Disp c
:     b:=c
:  EndIf
:EndWhile
:EndPrgm
It actually does work, but not as wished I typed this:
nsolver((x^(2)+4*x-2)*(x+9)*x=0,x)

I got this as output:

Solutions:
−9.
−4.44949
−4.44949
0.
0.44949
0.44949

Look at the code, how can the same output be displayed twice?
Title: Re: Nspire IF bug? :O
Post by: apcalc on October 22, 2010, 05:00:45 pm
Well, the way I understand it, nsolve( gives a very crude approximation of the solution.  It is very likely that the repeated solutions are not equal out to the 12th decimal place.

Try:

Code: [Select]
Define LibPub nsolver(eq,x)=
Prgm
:Local a,b,c
:a:=−100
:b:=nSolve(eq,x=−100)
:Disp "Solutions: "
:Disp b
:While a≤100
:  a:=a+1
:  c:=nSolve(eq,x=a)
:  If round(b,5)≠round(c,5) Then
:     Disp c
:     b:=c
:  EndIf
:EndWhile
:EndPrgm
Title: Re: Nspire IF bug? :O
Post by: kyllopardiun on October 22, 2010, 05:10:37 pm
Thanks Apcalc, it worked =D
Title: Re: Nspire IF bug? :O
Post by: Munchor on October 22, 2010, 05:16:50 pm
BTW, what means :=?
Title: Re: Nspire IF bug? :O
Post by: apcalc on October 22, 2010, 05:19:28 pm
It is similar to the "->" key of the TI-84/89 calcs, only the syntax is opposite.  Instead of "5->x", you would type "x:=5".

The Nspire has the store command too, so I have no idea why they have this also.
Title: Re: Nspire IF bug? :O
Post by: kyllopardiun on October 22, 2010, 05:21:13 pm
BTW, what means :=?

When you define a variable it is done like:
a:="conteudo"

because it has to have some difference between = (logical operator)
and := (define operator)

it does happens in almost every programing language
Title: Re: Nspire IF bug? :O
Post by: fb39ca4 on October 22, 2010, 05:26:16 pm
The nspire still has the -> character, too.
Title: Re: Nspire IF bug? :O
Post by: apcalc on October 22, 2010, 05:29:27 pm
a:="conteudo" is the same as "conteudo"→a
Title: Re: Nspire IF bug? :O
Post by: Deep Toaster on October 22, 2010, 06:42:24 pm
Isn't there also a =: command? I've only used the normal →, though (I'm too used to 83 syntax ;D).
Title: Re: Nspire IF bug? :O
Post by: kyllopardiun on October 22, 2010, 06:57:30 pm
Isn't there also a =: command? I've only used the normal →, though (I'm too used to 83 syntax ;D).
Actually if you type a =:
it will be replaced to →

but, you can program with =: without a problem [it just won't remain after salved]