solve()
#1
Posted 19 February 2004 - 09:08 PM
have been trying to make a program and I need to isolate the result of a solve function, i get a result as {x=0.020615} to put it into a variable ant then make some operations, with this result I cant operate.
Is there any other function as eval() or similar to get only the expression? or any trick?
I've been trying to convert to a string eliminate "x=" and then use the strtoexp() but it doesn't change the type...
excuse my english, thankyou!
P.S. :What is the difference in use this and this
#2
Posted 19 February 2004 - 10:20 PM
solve(x=1,x)=>y
In var. y is the result {x=1}
now you can operate with expr. in var. y as with list.
You can access to result by this command: y
If you have more expressions ({x=1,x=-1}), you can use y , y , ...
"(-)" and "-" is same, I think.
#3
Posted 19 February 2004 - 10:25 PM
yes i belive they are:"(-)" and "-" is same, I think.
3' /> 2' /> = 1
3' /> 2' /> = 1
aswell, with no syn errors, so i guess they are the same
#4
Posted 19 February 2004 - 10:47 PM
You can get left or right part of expression ("=" is center) by these commands:I've been trying to convert to a string eliminate "x=" and then use the strtoexp() but it doesn't change the type...
getLeft(EXPR)
getRight(EXPR)
so for "x=1" you'll get number 1 as: getRight(x=1)
#5
Posted 19 February 2004 - 11:09 PM
solve(EQU,x)=>y
ExpToStr y,y //y is now a string
StrFind y,"=",smin
StrFind y,"}",smax
StrMid y,smin+1,y,smin-1 //the # part the y is stored in y
strToExp(y)=>y //y is a number
this is the programming method, in this case the mathmatical way is better.
#6
Posted 20 February 2004 - 11:15 AM
solve(f(x),x)=>sol
'to make expr the same size as sol
sol=>expr
'The first expression
getRight(sol )=>expr
'The 2nd expression - if there is one check it with dim(sol)
getRight(sol )=>expr
'The 3rd expression- if there is one check it with dim(sol)
getRight(sol )=>expr
#7
Posted 20 February 2004 - 03:38 PM
Ive been trying the getright() and it's what I needed.
Thankyou.Best regards
#8
Posted 20 February 2004 - 04:28 PM
#9
Posted 25 February 2004 - 05:46 PM
solve(x=1,x)=>y
In var. y is the result {x=1}
now you can operate with expr. in var. y as with list.
You can access to result by this command: y
By the way, this also works with ANS so you don't have to save the result to a variable, if it's to be used only once afterwards.
ANS will return the first list item. ANS the second, and so on.
tonyp AT acm.org
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users