I was trying to solve a set of non linear equations using NSolve in mathematica. I got a result saying that no solution( {} ). My friend tried it in Matlab he was able to get a solution to the same set of equation for the same given parameters. Now my doubt is which one to trust?

I'm adding my functions bellow

    ClearAll[Evaluate[StringJoin[Context[], "*"]]]

d[xt_, xv_, xo_, xb_] := (1189*(3*xv^2*(8/5 + xt/10) + (6*xv*xt*xo)/5 + 
      (6/5 - xt/10)*xo^2)*Cos[xb]^3)/3000000;  

ma1[xt_, xv_, xo_, xb_] := (1189*((48*xv^2)/5 + (3*xv^2*xt)/5 + 
      (16*xv*xt*xo)/5 + (18*xo^2)/5 - (3*xt*xo^2)/10)*Cos[xb]^2)/48000000;  

ma2[xt_, xv_, xo_, xb_] := (5/4)*xo^2*Cos[xb]*Sin[xb];  

q1[xt_, xv_, xo_, xb_] := (1189*(3*xt*((16*xv^2)/5 + (6*xo^2)/5) + 
      (1/10)*(-6*xv^2 - 16*xv*xt*xo + 3*xo^2))*Cos[xb]^3)/48000000;  

f11[xt_] := NSolve[{q1[xt, xv, xo, xb] == 0 && 
     d[xt, xv, xo, xb] - 133.05 == 0 && 
     ma1[xt, xv, xo, xb] - ma2[xt, xv, xo, xb] == 0}, {xv, xo, xb}, Reals, 
   WorkingPrecision -> 5]


kindly any one help me

In Matlab he got these values xv=232.9328, xo =290.8831, xb=1.7934 10^(-4); And the solutions accuracy was up to 5 digits in matlab

  • 2
    $\begingroup$ You can quit the kernel instead of going through your four-step cleaning process. $\endgroup$
    – Roman
    Feb 17 '20 at 20:12
  • 2
    $\begingroup$ Plugging in the Matlab values does not get one close to zero for d[xt, xv, xo, xb] - 133.05 or ma1[xt, xv, xo, xb] - ma2[xt, xv, xo, xb]. Assuming that Matlab correctly did what it was asked, maybe the code in Matlab wasn't quite the same as the formulas here. Showing the Matlab code could resolve that issue. $\endgroup$
    – JimB
    Feb 17 '20 at 20:22

Rationalized the numbers and use Solve





f11[xt_] := 
 Solve[{q1[xt, xv, xo, xb] == 0, d[xt, xv, xo, xb] - 13305/100 == 0, 
   ma1[xt, xv, xo, xb] - ma2[xt, xv, xo, xb] == 0}, {xv, xo, xb}]

f11[1/100] // N


Mathematica graphics


Use exact numbers and Solve: redefine

f11[xt_] := 
  Solve[{q1[xt, xv, xo, xb] == 0 && d[xt, xv, xo, xb] - 2661/20 == 0 &&
         ma1[xt, xv, xo, xb] - ma2[xt, xv, xo, xb] == 0}, {xv, xo, xb}]

and compute


gets you 8 solutions.


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.