This code works:
x=2
y/.Solve[y==x^2]
Out[138]= 2
Out[139]= {4}
So above I put number in variable x
and getting the result of corresponding y
Now I want to give list with several values in list in variable x
and get evaluated values of corresponding y
's. How can I do that?
I tried this but it does not works:
x={1,2,3,4}
y/.Solve[y==x^2]
Out[140]= {1,2,3,4}
Out[141]= y
Expected output is:
{1,4,9,16}
Solve
needs the variable you're solving for in the second argument, and you want to solve for the array -Array[y, 4]/.First[Solve[Array[y, 4] == x^2, Array[y, 4]]]
. But obviously you can just do{1,2,3,4}^2
$\endgroup$x = {1, 2, 3, 4} y /. Solve[Array[y, 4] == x^2, Array[y, 4]]
. How can I fix it? $\endgroup$Array[y, 4]/.
noty/.
$\endgroup$