1
$\begingroup$

During a calculation for a physics lab, I ran into the following six non-linear equations with unknowns $x_1,x_2,x_3,x_4,x_5,x_6 \in \mathbb{R}$

Solve[{(1 + x1*0.405^2/((0.405)^2 - x2) + 
     x3*0.405^2/((0.405)^2 - x4) + x5*0.405^2/((0.405)^2 - x6) == 
    2.337053326), (1 + x1*(0.635)^2/((0.635)^2 - x2) + 
     x3*(0.635)^2/((0.635)^2 - x4) + x5*(0.635)^2/((0.635)^2 - x6) == 
    2.293038467), (1 + x1*(0.670)^2/((0.670)^2 - x2) + 
     x3*(0.670)^2/((0.670)^2 - x4) + x5*(0.670)^2/((0.670)^2 - x6) == 
    2.289560279), (1 + x1*(0.780)^2/((0.780)^2 - x2) + 
     x3*(0.780)^2/((0.780)^2 - x4) + x5*(0.780)^2/((0.780)^2 - x6) == 
    2.277436534), (1 + x1*(0.808)^2/((0.808)^2 - x2) + 
     x3*(0.808)^2/((0.808)^2 - x4) + x5*(0.808)^2/((0.808)^2 - x6) == 
    2.275719732), (1 + x1*(0.850)^2/((0.850)^2 - x2) + 
     x3*(0.850)^2/((0.850)^2 - x4) + x5*(0.850)^2/((0.850)^2 - x6) == 
    2.272264106), (1 + x1*(0.880)^2/((0.880)^2 - x2) + 
     x3*(0.880)^2/((0.880)^2 - x4) + x5*(0.880)^2/((0.880)^2 - x6) == 
    2.268823405), (1 + x1*(0.980)^2/((0.980)^2 - x2) + 
     x3*(0.980)^2/((0.980)^2 - x4) + x5*(0.980)^2/((0.980)^2 - x6) == 
    2.265389225)}, {x1, x2, x3, x4, x5, x6}]

This code does not yield any output by Mathematica, and I cannot figure out wether I'm using the wrong command or wrong syntax or something else...

Assuming that Mathematica knows methods to solving this, how do I tell the program to do so and return the values of my $x_1,\ldots,x_6$ ?

Any help is very much appreciated. ;)

EDIT: By deleting the last two equations and writing it as

Solve[
 1 + x1*0.405^2/((0.405)^2 - x2) + x3*0.405^2/((0.405)^2 - x4) + 
    x5*0.405^2/((0.405)^2 - x6) == 2.337053326
  &&
  1 + x1*(0.635)^2/((0.635)^2 - x2) + x3*(0.635)^2/((0.635)^2 - x4) + 
    x5*(0.635)^2/((0.635)^2 - x6) == 2.293038467
  &&
  1 + x1*(0.670)^2/((0.670)^2 - x2) + x3*(0.670)^2/((0.670)^2 - x4) + 
    x5*(0.670)^2/((0.670)^2 - x6) == 2.289560279
  &&
  1 + x1*(0.780)^2/((0.780)^2 - x2) + x3*(0.780)^2/((0.780)^2 - x4) + 
    x5*(0.780)^2/((0.780)^2 - x6) == 2.277436534
  &&
  1 + x1*(0.808)^2/((0.808)^2 - x2) + x3*(0.808)^2/((0.808)^2 - x4) + 
    x5*(0.808)^2/((0.808)^2 - x6) == 2.275719732
  &&
  1 + x1*(0.850)^2/((0.850)^2 - x2) + x3*(0.850)^2/((0.850)^2 - x4) + 
    x5*(0.850)^2/((0.850)^2 - x6) == 2.272264106
 , {x1, x2, x3, x4, x5, x6}
 ]

the computer returns a result, but one that I do not understand. The following output was generated by Mathematica:

{{x1 -> 1.27242, x2 -> 0.00816205, x3 -> -0.000117262, x4 -> 0.563865,
   x5 -> 0.0192823, x6 -> 1.70608},
 {x1 -> 1.27242, x2 -> 0.00816205, 
  x3 -> 0.0192823, x4 -> 1.70608, x5 -> -0.000117262, 
  x6 -> 0.563865},
 {x1 -> -0.000117262, x2 -> 0.563865, x3 -> 1.27242,
   x4 -> 0.00816205, x5 -> 0.0192823, 
  x6 -> 1.70608},
 {x1 -> -0.000117262, x2 -> 0.563865, 
  x3 -> 0.0192823, x4 -> 1.70608, x5 -> 1.27242, 
  x6 -> 0.00816205},
 {x1 -> 0.0192823, x2 -> 1.70608, x3 -> 1.27242, 
  x4 -> 0.00816205, x5 -> -0.000117262, 
  x6 -> 0.563865},
 {x1 -> 0.0192823, x2 -> 1.70608, 
  x3 -> -0.000117262, x4 -> 0.563865, x5 -> 1.27242, 
  x6 -> 0.00816205}}

Shouldn't this just be one value for each of the variables, instead of six each???

$\endgroup$
6
  • 2
    $\begingroup$ Reduce returns false, which suggests that the equations are inconsistent. $\endgroup$
    – mikado
    Apr 27 at 19:41
  • $\begingroup$ You have 8 equations and only 6 unknowns. $\endgroup$ Apr 27 at 19:54
  • $\begingroup$ Would deleting the last two equations yield a problem that can be solved by the program? (I care less about the actual answer than about the method of how to correctly asking Mathematica to do such a thing) $\endgroup$ Apr 27 at 19:57
  • $\begingroup$ Yes it would (I know because I did that). The last two then have fairly large residuals so it seems unlikely that minor numeric tweaking would make the full set consistent. $\endgroup$ Apr 27 at 20:05
  • 2
    $\begingroup$ Nonlinear equations often have multiple solutions. Mathematica finds six. $\endgroup$
    – Michael E2
    Apr 27 at 20:13
3
$\begingroup$

One approach is to convert this to a minimisation problem. If we assume that the errors are in the values on the right hand side of each expression, and that these errors are independent and follow a Gaussian distribution the appropriate way to do it is, I think, as follows:

eqns = {(1 + x1*0.405^2/((0.405)^2 - x2) + 
      x3*0.405^2/((0.405)^2 - x4) + x5*0.405^2/((0.405)^2 - x6) == 
     2.337053326), (1 + x1*(0.635)^2/((0.635)^2 - x2) + 
      x3*(0.635)^2/((0.635)^2 - x4) + x5*(0.635)^2/((0.635)^2 - x6) ==
      2.293038467), (1 + x1*(0.670)^2/((0.670)^2 - x2) + 
      x3*(0.670)^2/((0.670)^2 - x4) + x5*(0.670)^2/((0.670)^2 - x6) ==
      2.289560279), (1 + x1*(0.780)^2/((0.780)^2 - x2) + 
      x3*(0.780)^2/((0.780)^2 - x4) + x5*(0.780)^2/((0.780)^2 - x6) ==
      2.277436534), (1 + x1*(0.808)^2/((0.808)^2 - x2) + 
      x3*(0.808)^2/((0.808)^2 - x4) + x5*(0.808)^2/((0.808)^2 - x6) ==
      2.275719732), (1 + x1*(0.850)^2/((0.850)^2 - x2) + 
      x3*(0.850)^2/((0.850)^2 - x4) + x5*(0.850)^2/((0.850)^2 - x6) ==
      2.272264106), (1 + x1*(0.880)^2/((0.880)^2 - x2) + 
      x3*(0.880)^2/((0.880)^2 - x4) + x5*(0.880)^2/((0.880)^2 - x6) ==
      2.268823405), (1 + x1*(0.980)^2/((0.980)^2 - x2) + 
      x3*(0.980)^2/((0.980)^2 - x4) + x5*(0.980)^2/((0.980)^2 - x6) ==
      2.265389225)};

vars = Union[Cases[eqns, _Symbol, ∞]];

The objective function is given by

obj = Total[eqns /. a_ == b_ -> (a - b)^2]
(* (-1.33705 + (0.164025 x1)/(0.164025 - x2) + (0.164025 x3)/(
   0.164025 - x4) + (0.164025 x5)/(0.164025 - x6))^2 + (-1.29304 + (
   0.403225 x1)/(0.403225 - x2) + (0.403225 x3)/(0.403225 - x4) + (
   0.403225 x5)/(0.403225 - x6))^2 + (-1.28956 + (0.4489 x1)/(
   0.4489 - x2) + (0.4489 x3)/(0.4489 - x4) + (0.4489 x5)/(
   0.4489 - x6))^2 + (-1.27744 + (0.6084 x1)/(0.6084 - x2) + (
   0.6084 x3)/(0.6084 - x4) + (0.6084 x5)/(
   0.6084 - x6))^2 + (-1.27572 + (0.652864 x1)/(0.652864 - x2) + (
   0.652864 x3)/(0.652864 - x4) + (0.652864 x5)/(
   0.652864 - x6))^2 + (-1.27226 + (0.7225 x1)/(0.7225 - x2) + (
   0.7225 x3)/(0.7225 - x4) + (0.7225 x5)/(
   0.7225 - x6))^2 + (-1.26882 + (0.7744 x1)/(0.7744 - x2) + (
   0.7744 x3)/(0.7744 - x4) + (0.7744 x5)/(
   0.7744 - x6))^2 + (-1.26539 + (0.9604 x1)/(0.9604 - x2) + (
   0.9604 x3)/(0.9604 - x4) + (0.9604 x5)/(0.9604 - x6))^2 *)

Minimize seeks a global minimum of this (but I haven't checked whether it succeeds in finding it)

soln = Minimize[obj, vars]
(* {3.30637*10^-6, {x1 -> 1.36007, x2 -> -0.0064115, 
  x3 -> -0.484192, x4 -> -0.0807497, x5 -> 0.361731, 
  x6 -> -0.00424008}} *)

We can see how close the solution is to the original right hand side values

(List @@@ eqns) /. Last[soln]
(* {{2.33707, 2.33705}, {2.29335, 2.29304}, {2.2889, 
  2.28956}, {2.27766, 2.27744}, {2.27535, 2.27572}, {2.27221, 
  2.27226}, {2.2702, 2.26882}, {2.26456, 2.26539}} *)

This looks like quite a good match.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.