Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: persalteas on June 01, 2013, 11:57:30 am
-
Hello,
I am using this code found on TI-Calc to solve equations and inequalities :thumbsup:
It works very well... excepted that it always ends on an error NO SIGN CHNG, which means that the solve command cannot found another solution.
:ClrHome
:Input Str1
:For(I,1,length(Str1
:sub(Str1,I,1→Str0
:If inString("=≠>≥<≤",Str0
:Then
:I→A
:length(Str1→I
:End
:End
:sub(Str1,1,A-1→Y1
:sub(Str1,A+1,length(Str1)-A→Y2
:"Y1-Y2→Y3
:solve(Y3,X,1,{‾300,300→A
:nDeriv(Y3,X,A+E‾3→E
:Output(4,3,A
:4→I
:Disp "
:Goto 4
:Lbl 1
:solve(Y3/(X-A),X,{‾2,2},{‾E3,E3→B
:nDeriv(Y3,X,B+E‾3→E
:Output(5,3,B
:Goto 4
:Lbl 2
:solve(Y3/(X-A)/(X-B),X,{‾E2,E2},{‾E3,E3→C
:nDeriv(Y3,X,C+E‾3→E
:Output(6,3,C
:Goto 4
:Lbl 3
:solve(Y3/(X-A)/(X-B)/(X-C),X,0,{‾E3,E3→D
:nDeriv(Y3,X,D+E‾3→E
:Output(7,3,D
:Lbl 4
:Disp "
:Output(I,1,"X
:Output(I,2,"=
:If Str0="≠
:Output(I,2,"≠
:If Str0=">" or Str0="<
:Then
:Output(I,2,">
:If E<0 and Str0=">" or E>0 and Str0="<
:Output(I,2,"<
:End
:If Str0="≥" or Str0="≤
:Then
:Output(I,2,"≥
:If E<0 and Str0="≥" or E>0 and Str0="≤
:Output(I,2,"≤
:End
:I+1→I
:If I=5
:Goto 1
:If I=6
:Goto 2
:If I=7
:Goto 3
:Pause
:"
When you study how this program works, you can see that it always searches for 4 solutions to any equation, and gives the error if there is less than 4 solutions...
To prevent the error, is there any mean to know how many solutions the equation have ??? ?
If I could know it at the begining of the program, I could forbid it to search for more solutions... and give errors.
Thank you for your help...
-
When you study how this program works, you can see that it always searches for 4 solutions to any equation, and gives the error if there is less than 4 solutions...
And if there are more than 4, it only returns 4 solutions ?
(I am too lazy to study the code myself, especially since it's been a while since I last coded in Basic).
-
yes, obviously.
-
Maybe using the exp>list function ?
It returns the list of the different solutions from a "solve" result.
example :
exp>list(solve(x^2=1,x),x)
{1,-1}
And so the number of solution you're looking for is dim(the_list)..
EDIT :
Woops !
I thought it was on TI-68k/Nspire.. Sorry it's late. %)
Good luck anyway !
-
Thank you anyway, but no :P
We should reproduce this feature on a z80...