Author Topic: Nspire IF bug? :O  (Read 3176 times)

0 Members and 1 Guest are viewing this topic.

Offline kyllopardiun

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 178
  • Rating: +14/-4
  • Kyllopardiun over 2000 results in google.
    • View Profile
    • Kyllo's blog (a blog about poetry, videos and computing)
Nspire IF bug? :O
« 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?
« Last Edit: October 22, 2010, 04:55:01 pm by kyllopardiun »

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: Nspire IF bug? :O
« Reply #1 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
« Last Edit: October 22, 2010, 05:02:18 pm by apcalc »


Offline kyllopardiun

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 178
  • Rating: +14/-4
  • Kyllopardiun over 2000 results in google.
    • View Profile
    • Kyllo's blog (a blog about poetry, videos and computing)
Re: Nspire IF bug? :O
« Reply #2 on: October 22, 2010, 05:10:37 pm »
Thanks Apcalc, it worked =D

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Nspire IF bug? :O
« Reply #3 on: October 22, 2010, 05:16:50 pm »
BTW, what means :=?

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: Nspire IF bug? :O
« Reply #4 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.


Offline kyllopardiun

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 178
  • Rating: +14/-4
  • Kyllopardiun over 2000 results in google.
    • View Profile
    • Kyllo's blog (a blog about poetry, videos and computing)
Re: Nspire IF bug? :O
« Reply #5 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
« Last Edit: October 22, 2010, 05:49:59 pm by kyllopardiun »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Nspire IF bug? :O
« Reply #6 on: October 22, 2010, 05:26:16 pm »
The nspire still has the -> character, too.

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: Nspire IF bug? :O
« Reply #7 on: October 22, 2010, 05:29:27 pm »
a:="conteudo" is the same as "conteudo"→a

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Nspire IF bug? :O
« Reply #8 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).




Offline kyllopardiun

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 178
  • Rating: +14/-4
  • Kyllopardiun over 2000 results in google.
    • View Profile
    • Kyllo's blog (a blog about poetry, videos and computing)
Re: Nspire IF bug? :O
« Reply #9 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]