DanM
DanM

Reputation: 1

Solutions in Mathematica NSolve

Mathematica NSolve returns a solution in the form: {var1-->num1, var2-->num2}. How do I assign those solutions to variables automatically? I want var1=num1 and var2=num2, from which I can then process var1 and var2 as needed. Currently I am forced to hand enter the solution before proceeding with subsequent computations using the solution.

Upvotes: 0

Views: 539

Answers (1)

Bill
Bill

Reputation: 3957

Here is Wolfram's tutorial on exactly this subject.

Applying Transformation Rules

Here is a one-line example

{x, y} = {x, y} /. NSolve[{x + y == 3, x - y == -1}, {x, y}][[1]]

which assigns 1 to x and 2 to y.

Upvotes: 2

Related Questions