D is a vector, so your eqn is a vector.

When you pass more than one equation to solve(), then you are asking solve() to find the values of the unknowns that satisfy all the equations at the same time. For example,

solve([x^2+y^2==17, x+y=11])

does not ask solve() to find the x and y that solve each of the two equations independently: it asks for the x and y pairs that solve all of the equations.

But there is no single x value that solves all 41 of your equations simultaneously.

You have several choices:

- You can make D symbolic for the purpose of the equation, and solve for x with respect to the symbolic variable D, and then you can subs() the vector of numeric D values into the solution to get out a vector of x values; OR
- You can call solve() once for each of the separate equations in the vector eqn.
- You can read the equations and realize that you can express the equations as a quadratic. You can then use the standard quadratic formula in vectorized form to get the solutions for D
- You can read the equations and realize that you can express the equations as a quadratic. You can then call roots() once with appropriate numeric coefficients for each D value to get out the two corresponding x values.

## 0 Comments

Sign in to comment.