Hello everyone,
I write this message to see if somebody can help me with a specific question, please. I need to assign some results from Solve[] to new variables. Here there is an example:
Solve[{ x + y == 5 , x - y == 3 }, {x ,y} ]
Wolfram Mathematica gives me this:
{x --> 4} , {y --> 1}
Now I need to work with this solution in new variables, like “a” and “b”. It means, let “a” takes the x’s value (a = 4) and “b” takes the y’s value (b = 1). And continue working with a and b…
How can I do it?
Thank you very much in advance for your help.
Best regards.
Oscar.
Please study this carefully. Look up /. in the documentation and understand it.
In[1]:= Solve[{ x + y == 5 , x - y == 3 }, {x ,y} ]
Out[1]= {{x->4,y->1}}
In[2]:= {x,y}/.Solve[{ x + y == 5 , x - y == 3 }, {x ,y} ]
Out[2]= {{4,1}}
In[3]:= {{a,b}}={x,y}/.Solve[{ x + y == 5 , x - y == 3 }, {x ,y} ]
Out[3]= {{4,1}}
In[4]:= a
Out[4]= 4
In[5]:= b
Out[5]= 1
In[6]:= 2*a-3*b
Out[6]= 5