Mathematica: solving system of nonlinear equations

In summary, the conversation discusses a system of 2n variables with a given set of equations and the issue of getting multiple solutions due to the variables being able to switch positions. It is suggested to use the functions Reduce and Assumptions to make an assumption about the order of the variables and return only one solution.
  • #1
gothmogsbane
1
0
I am trying to solve the following system of 2n variables:

w1 + w2 + ... + wn = b0
w1x1 + w2x2 + ... + wnxn = b1
w1x12 + w2x22 + ... + wnxn2 = b2
...
w1x12n-1 + w2x22n-1 + ... + wnxn2n-1 = b2n-1

for w1, w2 ... wn and x1, x2 ... xn.

The problem is the using the Solve command returns n! solutions, because the xi are free to switch positions. For example, using n=2 and bi=1/(i+1):

{{w1 -> 1/2, w2 -> 1/2, x2 -> 1/6*(3 - Sqrt[3]), x1 -> 1/6*(3 + Sqrt[3])},
{w1 -> 1/2, w2 -> 1/2, x2 -> 1/6*(3 + Sqrt[3]), x1 -> 1/6*(3 - Sqrt[3])}}

Is there any way to force Mathematica to make the assumption that x1 <= x2 <= ... <= xn in order to return only one solution?
 
Physics news on Phys.org
  • #2
I think you need to use Reduce and Assumptions from memory
 

1. How do I input a system of nonlinear equations into Mathematica?

To input a system of nonlinear equations into Mathematica, you can use the Solve or NSolve function. The syntax for these functions is as follows: Solve[{eq1,eq2,...},{x1,x2,...}] or NSolve[{eq1,eq2,...},{x1,x2,...}], where {eq1,eq2,...} represents the equations and {x1,x2,...} represents the variables. Alternatively, you can use the == operator to represent equations, such as x^2 + y^2 == 25.

2. Can Mathematica solve systems of nonlinear equations with multiple solutions?

Yes, Mathematica can handle systems of nonlinear equations with multiple solutions. When using the Solve or NSolve function, the output will be a list of solutions in the form {{x1->sol1,y1->sol1,...},{x2->sol2,y2->sol2,...},...}. You can use the Table function to extract specific solutions, or use the Reduce function to get a more general solution.

3. How do I specify initial guesses for the variables when solving a system of nonlinear equations in Mathematica?

You can specify initial guesses for the variables by using the FindRoot function. The syntax for this function is FindRoot[{eq1,eq2,...},{x1,x2,...},{{x1,x1_0},{x2,x2_0},...}], where {{x1,x1_0},{x2,x2_0},...} represents the initial guesses for the variables. This function will attempt to find a numerical solution for the system of equations.

4. Can Mathematica handle systems of nonlinear equations with constraints?

Yes, Mathematica can handle systems of nonlinear equations with constraints. You can use the FindMinimum or FindMaximum functions, along with the And operator, to set constraints on the variables. For example, FindMinimum[{f[x,y],g[x,y]},{x,y}] with the constraint x>0 && y<10 will find the minimum value of f[x,y] subject to the constraint.

5. How do I plot the solutions to a system of nonlinear equations in Mathematica?

You can use the ContourPlot function in Mathematica to plot the solutions to a system of nonlinear equations. The syntax for this function is ContourPlot[{eq1,eq2,...},{x,xmin,xmax},{y,ymin,ymax}], where {eq1,eq2,...} represents the equations and {x,xmin,xmax} and {y,ymin,ymax} represent the range of values for the variables. This will create a contour plot of the solutions to the system of equations.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
876
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
881
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Replies
5
Views
355
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
Back
Top