Hi, i am using ti89.

Is there a way to put results for x1 and x2 in a variable?

Result of solve(x^2=4,x) is string:
"x=-2 and x=2"

Thanks.
Use left( and right(
DrDnar wrote:
Use left( and right(
Hey, I learned something new too, thanks DrDnar! I didn't realize that you were a 68k connoisseur as well as a z80 enthusiast.
Problem is, that for example result x1 can be an integer and x2 can be a number with decimal component.

It could work with mid() and right() but it's a bit messy.

Code:

:solve(system of 2 equations) -> expr_solution (example: x=1. and x=1.123)

string(expr_solution)->string_solution

:instring("x=1. and x=1.123"," and ") -> num1 (num1=5)
:expr(mid("x=1. and x=1.123",3,num1-3)) -> x1
:dim("x=1. and x=1.123") -> num2 (num2=16)
:expr(right("x=1. and x=1.123",num2-num1-6)) -> x1


I am not sure if this code will work in all cases. It depends on Exponetial format and Exact/Approx mode, but i can set those.

Edit: Solve() actually returns expression so i have to convert it into string, before i can extract what i need. For now, this is working for me.
The part( function may help. It's essentially a parsing tool.

solve(x^2=4,x) returns x=2 or x=-2

part(solve(x^2=4,x)) returns 2, the number of arguments to the top-level function/operator in the expression.

To get each of these two arguments:
part(solve(x^2=4,x),1) returns x=2
part(solve(x^2=4,x),2) returns x=-2

To get the top-level function:
part(solve(x^2=4,x),0) returns β€œor”

This can be applied recursively to parse the rest of the expression, for example:

part(solve(x^2=4,x),1)→a [returns x=2 and stores the expression into a]
part(a) returns 2
part(a,1) returns x
part(a,2) returns 2
part(a,0) returns β€œ=”

You could use this to make a subprogram or function that searches for the values and puts them in a list, or something like that.
I think this is one answer to the question. The method works for me. I am posting the answer I received from the respondent indicated below. Couldn't write the "store" symbol in the message below, so just used the word:

"What about, e.g., nsolve(5=2+x,x) store y
This will perform a numeric solve on 5=2+x and store the result (3) in y. I was mistaken about it returning an equation--the symbolic solve command does this, but the numeric nsolve just returns a straightforward value.

--
Travis Evans
The ticalc.org Project
http://www.ticalc.org/"►
Why did not use zeros() result will be a matrice and can be manipulate! If have this function in that calculator. Im presume is like a Ti-Nspire which I have it and try to found resolve this problem while ago. I hope can help.

PS: if u use solve and find a equation with more than one solution, e.g. 3 or 4 what u want to do to extract it the roots!?
I believe that the original question was about the TI-89, but since I have no idea about that calculator and it's similarities to the Nspire, I won't try to help out with it.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement