I was wondering if there was a way to use the Mathematica NSolve
command to solve an equation that has a parameter with various values. An example of which is:
parameter = {1,2,3,4,5};
equation = x + parameter;
NSolve[equation == 0, {x}]
The output should be:
{-1,-2,-3,-4,-5}
Obviously, my NSolve
expression does not give the above output, but if it did, it would make my world MUCH easier. As my actual equations are much more complex and my parameter lists can sometimes contain a lot of values, copy and paste has been tedious, to say the least!
Any help would be greatly appreciated.
NSolve
should return a empty list, because the equations{1 + x == 0, 2 + x == 0, 3 + x == 0, 4 + x == 0, 5 + x == 0}
are incompatible with each other. What you really mean is solving them one by one , not simultaneously. In this case,NSolve[# == 0, {x}] & /@ equation
is what you want. $\endgroup$