Items tagged with fsolve fsolve Tagged Items Feed

If there is  an equation or are several equations, I need to obtain all the roots, how can I do???


fsolve ? rootfindings? or what?


If an examples of actual is given,  That will be perfect  !!!



Hi Everyone,

I have a bunch polynomial systems of equations (all form zero-dimensional ideals, i.e. there is a finite number of complex solutions), and I would like to get a real solution for each of them, if available.

fsolve would be the tool to use. But it lead to some strange behaviour for me. Among some other inputs, the input

fsolve({81*x3^12+72*x3^10-614*x3^9+16*x3^8-384*x3^7+1884*x3^6+480*x3^4-2760*x3^3+1600, 81*x2*x3^11+72*x2*x3^9-452*x2*x3^8+16*x2*x3^7-240*x2*x3^6+980*x2*x3^5+32*x2*x3^4-144*x2*x3^3-800*x2*x3^2-220*x3^3+160*x2^2+480*x2+520, 81*x3^11+72*x3^9-452*x3^8+16*x3^7-240*x3^6+980*x3^5+32*x3^4-144*x3^3-800*x3^2+160*x1+160*x2+480},{x1, x2, x3});

somehow outputs itself, i.e.

fsolve({81*x3^12+72*x3^10-614*x3^9+16*x3^8-384*x3^7+1884*x3^6+480*x3^4-2760*x3^3+1600, 81*x2*x3^11+72*x2*x3^9-452*x2*x3^8+16*x2*x3^7-240*x2*x3^6+980*x2*x3^5+32*x2*x3^4-144*x2*x3^3-800*x2*x3^2-220*x3^3+160*x2^2+480*x2+520, 81*x3^11+72*x3^9-452*x3^8+16*x3^7-240*x3^6+980*x3^5+32*x3^4-144*x3^3-800*x3^2+160*x1+160*x2+480},{x1, x2, x3})

I know that this system has no real solutions, but only complex ones. But wouldn't the expected output then be just nothing (as e.g. "solve" does)?

I am confused by this output. Furthermore, how can I "check" with Maple if the output was a solution? By checking the type? There must be less hacky solutions. Thank you all in advance for your help.


PS.: When I add the keyword "complex" to the function call, then I receive a complex solution; hence, the syntax at least is correct (if someonw might have doubted that).

When I use fsolve with equation 

-x^2 + 2*x + 5 + (x^2 + 2*x - 1)* sqrt(2 - x^2)=0

I got only one solution.

fsolve(-x^2 + 2*x + 5 + (x^2 + 2*x - 1)* sqrt(2 - x^2)=0,x);

In fact, it have two reals solutions.  

I posted at here


Dear Colleges

I have a problem with the following code. As you can see, procedure Q1 converges but I couldn't get the resutls from Q2.

I would be most grateful if you could help me on this problem.


Sincerely yours




reynolds:=12734151.135786774055543653356602;     #10^6;   #1.125*10^8:

Q:=proc(pp2) local res,F0,F1,F2;
if not type(pp2,numeric) then return 'procname(_passed)' end if:
end proc;

Q2:=proc(rr2) local solT,T0,T1;
if not type(rr2,numeric) then return 'procname(_passed)' end if:
end proc;




we want to know what is the meaning of this statement?

We expect to have the following statement . But unfortunately we don,t get it

> with(difforms);
> sol := fsolve({diff(S, x) = 0, diff(S, y) = 0}, {x, y});

I do not take values above code.

Hello there

I'm quite an amature so please don't judge.  I'm trying to use fsolve to solve a system of non-linear equations but Maple is just "spitting" on me the equations with no intention to solve them:

> delta5 := P*(1+mu5)*((1-2*mu5)*x/(sqrt(x^2+zeq^2)*(sqrt(x^2+zeq^2)*x))+x*zeq/sqrt(x^2+zeq^2)^3)/(2*Pi*E5);
print(`output redirected...`); # input placeholder
> shrinkage := P*(1+mu5)*((1-2*mu5)*x/(sqrt(x^2+Zb^2)*(sqrt(x^2+Zb^2)*x))+x*Zb/sqrt(x^2+Zb^2)^3)/(2*Pi*E5)-P*(1+mu5)*((1-2*mu5)*x/(sqrt(x^2+Za^2)*(sqrt(x^2+Za^2)*x))+x*Za/sqrt(x^2+Za^2)^3)/(2*Pi*E5);
> eq10 := subs(x = 1800, delta5)+subs(x = 1800, Zb = z2, Za = z1, shrinkage)+subs(x = 1800, Zb = z3, Za = z2, shrinkage)+subs(x = 1800, Zb = z4, Za = z3, shrinkage)+subs(x = 1800, Zb = z5, Za = z4, shrinkage) = 36.7*10^(-3);
print(`output redirected...`); # input placeholder
> eq9 := subs(x = 1500, delta5)+subs(x = 1500, Zb = z2, Za = z1, shrinkage)+subs(x = 1500, Zb = z3, Za = z2, shrinkage)+subs(x = 1500, Zb = z4, Za = z3, shrinkage)+subs(x = 1500, Zb = z5, Za = z4, shrinkage) = 47.2*10^(-3);
print(`output redirected...`); # input placeholder
> eq8 := subs(x = 1200, delta5)+subs(x = 1200, Zb = z2, Za = z1, shrinkage)+subs(x = 1200, Zb = z3, Za = z2, shrinkage)+subs(x = 1200, Zb = z4, Za = z3, shrinkage)+subs(x = 1200, Zb = z5, Za = z4, shrinkage) = 63.8*10^(-3);
> eq7 := subs(x = 900, delta5)+subs(x = 900, Zb = z2, Za = z1, shrinkage)+subs(x = 900, Zb = z3, Za = z2, shrinkage)+subs(x = 900, Zb = z4, Za = z3, shrinkage)+subs(x = 900, Zb = z5, Za = z4, shrinkage) = 91.1*10^(-3);
print(`output redirected...`); # input placeholder
> eq6 := subs(x = 600, delta5)+subs(x = 600, Zb = z2, Za = z1, shrinkage)+subs(x = 600, Zb = z3, Za = z2, shrinkage)+subs(x = 600, Zb = z4, Za = z3, shrinkage)+subs(x = 600, Zb = z5, Za = z4, shrinkage) = 137.9*10^(-3);
> eq5 := subs(x = 450, delta5)+subs(x = 450, Zb = z2, Za = z1, shrinkage)+subs(x = 450, Zb = z3, Za = z2, shrinkage)+subs(x = 450, Zb = z4, Za = z3, shrinkage)+subs(x = 450, Zb = z5, Za = z4, shrinkage) = 175.2*10^(-3);
> eq4 := subs(x = 300, delta5)+subs(x = 300, Zb = z2, Za = z1, shrinkage)+subs(x = 300, Zb = z3, Za = z2, shrinkage)+subs(x = 300, Zb = z4, Za = z3, shrinkage)+subs(x = 300, Zb = z5, Za = z4, shrinkage) = 230.9*10^(-3);
print(`output redirected...`); # input placeholder
> sys := {eq10, eq5, eq6, eq7, eq8, eq9};
print(`output redirected...`); # input placeholder
> fsolve(sys, {E1 = 1000 .. 2000, E2 = 0 .. 2000, E3 = 0 .. 2000, E4 = 0 .. 2000, E5 = 0 .. 2000, h4 = 100 .. 400});

and this is what Maple gives after the fsolve


fsolve({(3937.500000*(.2/(202500+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)+(450*(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3)))/(202500+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)^(3/2)))/E5-0.3888888889e-2/E5+(3937.500000*(.2/(202500+(650+h4)^2)+(450*(650+h4))/(202500+(650+h4)^2)^(3/2)))/E5 = .1752000000, (3937.500000*(.2/(360000+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)+(600*(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3)))/(360000+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)^(3/2)))/E5-0.2187500000e-2/E5+(3937.500000*(.2/(360000+(650+h4)^2)+(600*(650+h4))/(360000+(650+h4)^2)^(3/2)))/E5 = .1379000000, (3937.500000*(.2/(810000+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)+(900*(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3)))/(810000+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)^(3/2)))/E5-0.9722222220e-3/E5+(3937.500000*(.2/(810000+(650+h4)^2)+(900*(650+h4))/(810000+(650+h4)^2)^(3/2)))/E5 = 0.9110000000e-1, (3937.500000*(.2/(1440000+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)+(1200*(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3)))/(1440000+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)^(3/2)))/E5-0.5468750000e-3/E5+(3937.500000*(.2/(1440000+(650+h4)^2)+(1200*(650+h4))/(1440000+(650+h4)^2)^(3/2)))/E5 = 0.6380000000e-1, (3937.500000*(.2/(2250000+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)+(1500*(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3)))/(2250000+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)^(3/2)))/E5-0.3500000000e-3/E5+(3937.500000*(.2/(2250000+(650+h4)^2)+(1500*(650+h4))/(2250000+(650+h4)^2)^(3/2)))/E5 = 0.4720000000e-1, (3937.500000*(.2/(3240000+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)+(1800*(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3)))/(3240000+(146.0507832*(E1/E5)^(1/3)+197.1094212*(E2/E5)^(1/3)+295.6641318*(E3/E5)^(1/3)+1.*h4*(E4/E5)^(1/3))^2)^(3/2)))/E5-0.2430555555e-3/E5+(3937.500000*(.2/(3240000+(650+h4)^2)+(1800*(650+h4))/(3240000+(650+h4)^2)^(3/2)))/E5 = 0.3670000000e-1}, {E1, E2, E3, E4, E5, h4}, {E1 = 1000 .. 2000, E2 = 0 .. 2000, E3 = 0 .. 2000, E4 = 0 .. 2000, E5 = 0 .. 2000, h4 = 100 .. 400})

Hi everyone,


i'm trying to find out the euler angles from a rotation matrix.

I have a matrix that contains the result of multpilying the 3 axis rotation R(z,c)*R(y,b)*R(x,a) without knowing the values of the angles a,c,b (that's what I want to find out), so there are sinus and cosinus everywhere. There is another matrix containing the expected values that each equation in the first matrix will match.

My problem is that I eventually will change the order of the multiplication of the axis (i.e. R(x,a)*R(z,c)*R(y,b)) and I'm try to make maple compute this for me.

I defined R(x,a), R(y,b) and R(z,c) as follows:

Rx := Matrix (3,3, [1,0,0,0,cos(a),-sin(a),0,sin(a),cos(a)]);    
Ry := Matrix (3,3, [sin(b), 0, cos(b), 0, 1, 0, -sin(b), 0, cos(b)]);
Rz := Matrix (3,3, [cos(c), -sin(c), 0, sin(c), cos(c), 0, 0, 0, 1]);
RT := Multiply(Multiply(Rx,Rz),Ry);

Since here is alright. Now I want to match RT to the solution matrix.

g1 := RT[1,1] = mat[1,1];
g2 := RT[1,2] = mat[1,2];
g3 := RT[1,3] = mat[1,3];
g4 := RT[2,1] = mat[2,1];
g5 := RT[2,2] = mat[2,2];
g6 := RT[2,3] = mat[2,3];
g7 := RT[3,1] = mat[3,1];
g8 := RT[3,2] = mat[3,2];
g9 := RT[3,3] = mat[3,3];

soll := fsolve({g1,g2,g3,g4,g5,g6,g7,g8,g9},{a,b,c});

At this point I'm getting an error. I know that there are more equations than variables but the system is solvable anyway.
What maple trick can I do to solve this system or to find the good 3 equations?


Extra question:

Is there any method to match RT to mat without all those gX equations?


Thank you everyone.

The issue I am currently having is that, while analyticity (and physics) indicates a certain function must have roots, fsolve is having trouble finding them. In fact, I have even found roots manually in a certain region myself, simply inputting into the function various values until I found them. However, fsolve does not seem to want to find these roots, and I believe it is a numerics issue: when I changed the digits around, for extremely low values of Digits, it would find a root (even though it was incorrect). Further, this problem arose elsewhere in the domain of interest for other values of Digits (in particular, for Digits:=5, fsolve failed in a region it had not failed before).

The region of interest is the "peak" of the output of poleR(M0, 0.935, mK), which should be somewhere around M0 = 0.95 or so. However, because fsolve cannot find the roots, the plot cannot be made.

Anyone have any ideas as to why fsolve cannot find the roots? I was also experiencing issues with some of these functions having multiple roots, which itself is weird as well (note that I am working over the complex plane).

Attached is the document.

Any ideas?

How can this error be corrected '' error, (in fsolve) fsolve cannot solve on 0=0 ''. See the worksheet



I have a problem solving two equations.  They are as follows:

s := 1/(273.16+50); s1 := 1/(273.16+145); s3 := 1/(273.16+250); s2 := 1/(273.16+197.5); gamma0 := 0.1e-3; gamma1 := .5; gamma2 := 0.15e-2; beta := -3800:

c := 300; n := 200; tau1 := 99; tau2 := 120;

Delta := solve(1-exp(-(gam0*tau1+(1/2)*gam1*tau1^2)*exp(beta*s1)) = 1-exp(-(gam0*a+(1/2)*gam1*a^2)*exp(beta*s2)), a);
a := Delta[1];

Theta := solve(1-exp(-(gam0*(a+tau2-tau1)+(1/2)*gam1*(a+tau2-tau1)^2)*exp(beta*s2)) = 1-exp(-(gam0*b+(1/2)*gam1*b^2)*exp(beta*s3)), b);
b := Theta[1];

n1 := int((gam1*t+gam0)*exp(beta*s1)*exp(-(gam0*t+(1/2)*gam1*t^2)*exp(beta*s1)), t = 0 .. tau1);
n22 := (n-n1)*(int((gam1*t+gam0)*exp(beta*s2)*exp(-(gam0*t+(1/2)*gam1*t^2)*exp(beta*s2)), t = a1 .. a1+tau2-tau1));
n2 := eval(n22, a1 = a);
n33 := (n-n1-n2)*(Int((gam1*t+gam0)*exp(beta*s3)*exp(-(gam0*t+(1/2)*gam1*t^2)*exp(beta*s3)), t = b1 .. c));
n3 := eval(n33, a1 = a);
n4 := n-n1-n2-n3;

g1 := -n1*(Int((1/(gam1*t+gam0)-t*exp(beta*s1))*(gamma2*t^2+gamma1*t+gamma0)*exp(beta*s1)*exp(-(gamma0*t+(1/2)*gamma1*t^2+(1/3)*gamma2*t^3)*exp(beta*s1)), t = 0 .. tau1))-n2*(Int((1/(gam0+gam1*(a+t-tau1))-(a+t-tau1)*exp(beta*s2))*(gamma0+gamma1*(a+t-tau1)+gamma2*(a+t-tau1)^2)*exp(beta*s2)*exp(-(gamma0*(a+t-tau1)+(1/2)*gamma1*(a+t-tau1)^2+(1/3)*gamma2*(a+t-tau1)^3)*exp(beta*s2)), t = tau1 .. tau2))-n3*(Int((1/(gam0+gam1*(b+t-tau2))-(b+t-tau2)*exp(s3))*(gamma0+gamma1*(b+t-tau2)+gamma2*(b+t-tau2)^2)*exp(beta*s3)*exp(-(gamma0*(b+t-tau2)+(1/2)*gamma1*(b+t-tau2)^2+(1/3)*gamma2*(b+t-tau2)^3)*exp(beta*s3)), t = tau2 .. c))+(n-n1-n2-n3)*(1/(gam0+gam1*(b+c-tau2))-(b+c-tau2)*exp(s3))*(gamma0+gamma1*(b+c-tau2)+gamma2*(b+c-tau2)^2)*exp(beta*s3)*exp(-(gamma0*(b+c-tau2)+(1/2)*gamma1*(b+c-tau2)^2+(1/3)*gamma2*(b+c-tau2)^3)*exp(beta*s3));

g2 := -n1*(Int((t/(gam1*t+gam0)-(1/2)*t^2*exp(beta*s1))*(gamma2*t^2+gamma1*t+gamma0)*exp(beta*s1)*exp(-(gamma0*t+(1/2)*gamma1*t^2+(1/3)*gamma2*t^3)*exp(beta*s1)), t = 0 .. tau1))-n2*(Int(((a+t-tau1)/(gam0+gam1*(a+t-tau1))-(1/2)*(a+t-tau1)^2*exp(beta*s2))*(gamma0+gamma1*(a+t-tau1)+gamma2*(a+t-tau1)^2)*exp(beta*s2)*exp(-(gamma0*(a+t-tau1)+(1/2)*gamma1*(a+t-tau1)^2+(1/3)*gamma2*(a+t-tau1)^3)*exp(beta*s2)), t = tau1 .. tau2))-n3*(Int(((b+t-tau2)/(gam0+gam1*(b+t-tau2))-(1/2)*(b+t-tau2)^2*exp(s3))*(gamma0+gamma1*(b+t-tau2)+gamma2*(b+t-tau2)^2)*exp(beta*s3)*exp(-(gamma0*(b+t-tau2)+(1/2)*gamma1*(b+t-tau2)^2+(1/3)*gamma2*(b+t-tau2)^3)*exp(beta*s3)), t = tau2 .. c))+(n-n1-n2-n3)*((b+c-tau2)/(gam0+gam1*(b+c-tau2))-(1/2)*(b+c-tau2)^2*exp(s3))*(gamma0+gamma1*(b+c-tau2)+gamma2*(b+c-tau2)^2)*exp(beta*s3)*exp(-(gamma0*(b+c-tau2)+(1/2)*gamma1*(b+c-tau2)^2+(1/3)*gamma2*(b+c-tau2)^3)*exp(beta*s3));

solve({g1 = 0, g2 = 0}, {gam0, gam1});

Warning, solutions may have been lost.

What do I do wrong?

Thanks for advice in advance.


I have a rather complex expression that I want to find the zero for as a function of two other parameters, i.e. I have a function

Denom := (s,M,g) -> stuff

that I want to find the zero of for a variety of values of M and g. In some cases the solution will be complex, which is entirely acceptable. However, the real part of the solution should never be negative, and yet that is the kind of result I am getting.

As an example (illustrated in the worksheet, when attempting to find the zero for M = 3 and g = 0.2, fsolve gives me s = -6.1 -1.4i. However, when I plot the function with the parameters input already, I can clearly see a zero at s = 9 with no imaginary component. Why won't fsolve find this zero? How can I make it do so?

See the bottom of the attached worksheet for the main problem.

Could anyone assist in rectifying this error ''Error, (in fsolve) {f[1], f[2], f[3], f[4], f[5], f[6], f[7], f[8], f[9], f[10], f[11], theta[11]} are in the equation, and are not solved for''. Here is the worksheet

I am trying to find the root of an equation that involves a procedure and a definite integral (solved numerically). Of course, I don't need the root to be found symbolically, but numerically would be fine. The problem is, I keep getting the error

"Error, (in fsolve) Can't handle expressions with typed procedures"

whenever I try to solve it. Anyone have any ideas? My worksheet is here: 


What are the stopping criteria for fsolve?
I cannot find anything in the help page and there seems to be no way of adding an optional argument to fsolve about errors.

I was initially surprised by the results of the first two fsolve commands below:

fsolve(x->1,0.4); #OK, returns unevaluated
fsolve([1,1],{x,y}); #OK, returns NULL

I assume that in the first two examples the criterion used is that at some point in the process the iterates [x(n+1),y(n+1)] and [x(n),y(n)] are close enough together and the difference between results from the two is small enough (clearly 0).

hello, i went solve these equation ,with a & b take any value


thank you

1 2 3 4 5 6 7 Last Page 1 of 9