Items tagged with fsolve


Dear All


I have a question about applying fsolve in MAPLE.

These codes come from an applicable model from heat transfer.

I previously solve such systems, but the fsolve takes long time, for example for N=2, I have 12 equations with 12 unknowns. But the fsolve does not work!

I try by N=3 or N=4, but a similar result has been obtained.


If kindly is possible, please give me a help for using fsolve more efficiently that solve my problem.

I have MAPLE 13 in my PC.


With kind regards,

Emran Tohidi.


> restart;
> with(orthopoly);
print(`output redirected...`); # input placeholder
> Digits := 20;
> N := 3; f := proc (x) options operator, arrow; cos(Pi*(x-1/2)) end proc; h1 := proc (t) options operator, arrow; 0 end proc; h2 := proc (t) options operator, arrow; 0 end proc; E := proc (t) options operator, arrow; cos(.2*Pi)*exp(-t^2) end proc;
print(`output redirected...`); # input placeholder
> u := sum(sum(b[m, n]*P(m, 2*x-1)*P(n, 2*t-1), m = 0 .. N), n = 0 .. N);
print(`output redirected...`); # input placeholder
> u := unapply(u, x, t);
print(`output redirected...`); # input placeholder
> ut := diff(u(x, t), `$`(t, 1)); ut := unapply(ut, x, t);
print(`output redirected...`); # input placeholder
> uxx := diff(u(x, t), `$`(x, 2)); uxx := unapply(uxx, x, t);
print(`output redirected...`); # input placeholder
> a := sum(c[m]*P(m, 2*t-1), m = 0 .. N); a := unapply(a, t);
print(`output redirected...`); # input placeholder
> A := fsolve(P(N+1, 2*x-1) = 0);
print(`output redirected...`); # input placeholder
> S1 := {seq(seq(ut(A[i], A[j])-a(A[j])*uxx(A[i], A[j]) = 0, i = 2 .. N), j = 2 .. N+1)}; S2 := {seq(u(A[i], 0)-f(A[i]) = 0, i = 2 .. N)}; S3 := {seq(u(0, A[j])-h1(A[j]) = 0, j = 1 .. N+1)}; S4 := {seq(u(1, A[j])-h2(A[j]) = 0, j = 1 .. N+1)}; S5 := {seq(u(.3, A[j])-E(A[j]) = 0, j = 1 .. N+1)}; S := `union`(`union`(`union`(`union`(S1, S2), S3), S4), S5);
print(`output redirected...`); # input placeholder
> sol := fsolve(S);

Dear Users

I have a problem for solving a system of linear equations that arise from collocation method for getting approximate solution of a coupled PDE and ODE in Food engineering problems.

When it reach to the fsolve command it takes long time!!!

I used maple 13.

If kindly is possible, please help me in this special case.

With kind regards,

Emran Tohidi.


> Restart;
print(`output redirected...`); # input placeholder
> h := 50; hm := 0.1e-3; rhodp := 1500; Y := 0.5e-1; T0 := 20; rhoair := 1.2041; Dair := 0.2e-8; DD := 0.85e-9; C := 3240; L := 0.4e-1; X0 := 1.5; V := .2; delta := 0.2e-2; Yair := 0.5e-1; nu := .2; Tair := 60; Hnu := 2400; rho := 1359; tt := 3;
> N := 5; Digits := 20;
> X := sum(sum(a[m, n]*z^m*t^n, m = 0 .. N), n = 0 .. N); X := unapply(X, z, t); Xt := diff(X(z, t), `$`(t, 1)); Xt := unapply(Xt, z, t); Xz := diff(X(z, t), `$`(z, 1)); Xz := unapply(Xz, z, t); Xzz := diff(X(z, t), `$`(z, 2)); Xzz := unapply(Xzz, z, t); T := sum(b[n]*t^n, n = 0 .. (N+1)^2-1); T := unapply(T, t); Tt := diff(T(t), `$`(t, 1)); Tt := unapply(Tt, t); aw := exp(.914)*X(z, t)^.5639-.5*exp(1.828)*X(z, t)^(2*.5639); aw := unapply(aw, z, t); TT := 8.3036+3816.44*(1+T(t)/(46.13)+T(t)^2/46.13^2)/(46.13); TT := unapply(TT, t); pwv := 133.3*(1+TT(t)+(1/2)*TT(t)^2); pwv := unapply(pwv, t); Yi := .622*pwv(t)*aw(z, t)*(1+pwv(t)*aw(z, t)/rho+(pwv(t)*aw(z, t)/rho)^2)/rho; Yi := unapply(Yi, z, t);
> S1 := {seq(seq(Xt(delta*i/N, tt*j/N)-DD*Xzz(delta*i/N, tt*j/N) = 0, i = 1 .. N-1), j = 1 .. N)};
> S2 := {seq(DD*rhodp*Xz(delta, tt*j/N)+hm*rhoair*Yi(delta, tt*j/N) = 0, j = 0 .. N)};
> S3 := {seq(Xz(0, tt*j/N) = 0, j = 0 .. N)};
> S4 := {seq(X(delta*i/N, 0) = 0, i = 1 .. N-1)};
> S5 := {seq(seq(rho*delta*C*Tt(tt*j/N)-h*(Tair-T(tt*j/N))+hm*Hnu*rhoair*(Yair-Yi(delta*i/N, tt*j/N)) = 0, j = 1 .. N), i = 0 .. N)};
print(`output redirected...`); # input placeholder
> S6 := {seq(rho*delta*C*Tt(0)-h*(Tair-T0)+hm*Hnu*rhoair*(Yair-Yi(delta*i/N, 0)) = 0, i = 0 .. N)};
> SS := `union`(`union`(`union`(`union`(`union`(S1, S2), S3), S4), S5), S6);
> sol := fsolve(SS);

Can someone help me to solve system of equations please. I have a system of 8 complex valued equations, with 8 unknowns: _C1,_C2........_C8

Equation system looks like:

eq_system:={ -3.248046797 10 _C1 + 1.773373463 10 _C2 + (2.182313824 10 - 9.987524076 10 I) _C3 + 1.773373463 10 _C4 = -7.389056097 10 _C2- 7.389056097 10 _C4+ (4.161468365 10 + 9.092974265 10 I)_C3,

............}  its only 1st equation, others are similar.

It looks rather simple though I am not able to solve it with solve or fsolve commands. What I'm doing wrong?


Dear All

Please help me for using fsolve

the fsolve command doesnt work!

> restart;
> with(LinearAlgebra); Digits := 20;
print(`output redirected...`); # input placeholder
> Z := Matrix(2); N := 3; y11 := sum(a[n]*x^n, n = 0 .. N); y12 := sum(b[n]*x^n, n = 0 .. N); y21 := sum(c[n]*x^n, n = 0 .. N); y22 := sum(d[n]*x^n, n = 0 .. N); y11 := unapply(y11, x); y12 := unapply(y12, x); y21 := unapply(y21, x); y22 := unapply(y22, x);
print(`output redirected...`); # input placeholder
> A := linalg[matrix](2, 2, [1, -1, 1, exp(x)]); B := linalg[matrix](2, 2, [-3*exp(-x)-1, 2-2*exp(-x), -3*exp(-x)-2, 1-2*cosh(x)]);
print(`output redirected...`); # input placeholder
> C := eval(B, [x = 1]);
print(`output redirected...`); # input placeholder
> Y := linalg[matrix](2, 2, [y11(x), y12(x), y21(x), y22(x)]);
print(`output redirected...`); # input placeholder
> yy11 := diff(y11(x), x); yy12 := diff(y12(x), x); yy21 := diff(y21(x), x); yy22 := diff(y22(x), x); yy11 := unapply(yy11, x); yy12 := unapply(yy12, x); yy21 := unapply(yy21, x); yy22 := unapply(yy22, x);
> YY := linalg[matrix](2, 2, [yy11(x), yy12(x), yy21(x), yy22(x)]);
print(`output redirected...`); # input placeholder
> S := {seq(eval(YY, [x = n/N])-(eval(A, [x = n/N]))*(eval(Y, [x = n/N]))-(eval(B, [x = n/N])) = Matrix(2), n = 1 .. N)};
print(`output redirected...`); # input placeholder
> S1 := {eval(Y, [x = 0]) = linalg[matrix](2, 2, [3, 0, 1, 1])};
print(??); # input placeholder
> SS := `union`(S, S1);
print(??); # input placeholder
> sol := fsolve(SS);


I am trying to solve these equations:

eq1:=cot(theta[n])=(omega[a]^2 - omega[n]^2)/omega[n];

eq2:=cot(theta[n]+ omega[n])=-(omega[b]^2 - omega[n]^2)/omega[n];

for some values of omega[a] and omega[b]. I will in the end create two 3d plots for omega[n] and theta[n] as a funciton of ometga[a] and omega[b]

So for example for some particular values have:

eqs:=subs(omega[a]=0.2, omega[b]=1, [eq1, eq2]);

Then solving,

solve(eqs, [omega[n],theta[n]]);


I'm however only interested in solutions where omega[n]>=0, but doing this:

solve(eqs, [omega[n],theta[n]], UseAssumptions) assuming omega[n]>=0.0;

returns an empty list. Adding the condition omega[n]>=0.0 to the list of equations also does not work.

Is this a bug or am I missing something? Note, I realize that i can manually go through the entries myself and pick the right solutions, I am just asking how to force maple to do this automagically.



Here is the full code:


eq1:=cot(theta[n])=(omega[a]^2 - omega[n]^2)/omega[n];

eq2:=cot(theta[n]+ omega[n])=-(omega[b]^2 - omega[n]^2)/omega[n];

eqs:=subs(omega[a]=0.2, omega[b]=1, [eq1, eq2]);

solve(eqs, [omega[n],theta[n]]);

solve(eqs, [omega[n],theta[n]], UseAssumptions) assuming omega[n]>=0.0;

Greetings to all.

At the following Math.Stackexchange Discussion a certain constant was computed in relation to a Master Theorem Type recurrence being solved. This prompted me to try to identify it by the use of the eponymous command. What follows is the content of the Maple session. You may want to read the post in order to get an understanding of what the constant means and how its exact value is calculated.

> fsolve(2/2^a+1/4^a=1, a);

> identify(%);

> identify(%,all);
                                 1/2    1/2
                              2 2      3
                      arcsech(------ + ---- - 1/6 Zeta(5))
                                7       6

> evalf(log[2](1+sqrt(2)));

My questions/observations are:

  • Why does the algorithm fail to spot as simple a constant as the one above or am I just not invoking it correctly?
  • If that last formula were true the author of this code would certainly win a prize for calculating a closed form expression for an odd integer zeta function value! (To be fair here I did notice that the spurious identification disappears when the number of working digits is increased and I do understand that the identification depends critically on the number of digits.)

In concluding I would like to say, why the complicated formula and not the simple one? Let me congratulate you just the same on providing this very useful command. I have worked on pandigital approximations which are slightly related and I understand that adding an operation like the logarithm to an integer base up to some max base value can dramatically increase the search space and may not always be feasible.

Best regards,

Marko Riedel

I want to know which other maple in-built function does the same thing as fsolve and LinearSolve. I can use both to solve systems of equations either by passing the equations directly to fsolve or deciding to generate matrix to be used in LinearSolve while still getting the same result. So, i'm using this medium to ask if there are/is other inbuilt function that does the same/similar thing as the two.

Hello, I am trying to solve 2 equations, and write the solution in a matrix form. How do I do it? This is what i did:


for m from 1 to 10 do
end do:


Answer is kn=9.317...

How to I get knn[3,1]=9.317...? without the "kn="

I would like to have a matrix of 10x1 with just the values of kn. Thank you.

Using the fsolve commmand how does one solve for just the positive solutions and remove the dublicate values?


Hi everyone

I'm currently working on some mandate distribution using "Jefforson's Method" but I have run into some problems.

The general form of the calculations I do is as follows:

d:=fsolve(m = floor(v1/x)+floor(v2/x), x)

But in the case of m=5, v1=4969 and v2=208 it does not work. If I change v1 a bit it works as a charm but when 
4960=<v1=<4969 it does not.

Can any of you figure out why?


The equation surely has a solution (well, a lot of solutions). I can figure some out just by estimating and trying. Furthermore, wolfram alpha easily gives me several solutions:

So how come I cannot get Maple to solve it?


Thanks in advance!


I'm having some difficulty in figureing our how to store the results of an fsolve computation in an indexed variable that I can access subsequently to perform plots and do other calculations.  I have a do loop that, for every increment, has fsolve calculate five variable  (x,y,z.. )from a set of equations that have been entered.  It does the calculations just fine.  What I can't seem to do is set up an array variable (or other indexed variable like a vector) so that with every increment of the loop the values that fsolve generates for x, y, z  ect. can be stored.  That just doesn't seem to work, what am I getting wrong? Any help would be most appreciated.


Al Stiegman



I have a system of equations for which I want to get a solution around an initial guess, unfortunatly I cannot succed it. Here is the system and the initial guess


,(-((((0.005+0.009)/((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll))))*(Ladssec/Lfd))*((Ladssec*(-id0+(0.953/Lfd)+(0.849/L1d)))+Laqssec*id0)-(((0.072+1*(Laqssec+Ll))*Ladssec)/(((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll)))*Lfd))*((Laqssec*(-iq0+(0.468/L1q)))+Ladssec*iq0)+((Ladssec*iq0)/Lfd)) /(2*2.5))=0.1036
,(-((-((0.005+0.009)/((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll))))*(Ladssec/L1d))*((Ladssec*(-id0+(0.953/Lfd)+(0.849/L1d)))+Laqssec*id0)-(((0.072+1*(Laqssec+Ll))*Ladssec)/(((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll)))*L1d))*((Laqssec*(-iq0+(0.468/L1q)))+Ladssec*iq0)+((Ladssec*iq0)/L1d)) /(2*2.5))=0.2279
,(-((((0.072+1*(Ladssec+Ll))*Laqssec)/(((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll)))*L1q))*((Ladssec*(-id0+(0.953/Lfd)+(0.849/L1d)))+Laqssec*id0)-(-((0.005+0.009)/((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll))))*(Laqssec/L1q))*((Laqssec*(-iq0+(0.468/L1q)))+Ladssec*iq0)-((Laqssec*id0)/L1q)) /(2*2.5))=-2.3313

,(-(1*Rfd*(1-(Ladssec/Lfd)+((((0.072+1*(Laqssec+Ll))*Ladssec)/(((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll)))*Lfd)) *Ladssec)))/(Lfd))=-0.0054
,(-(1*Rfd*(-(Ladssec/Lfd)+((((0.072+1*(Laqssec+Ll))*Ladssec)/(((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll)))*L1d)) *Ladssec)))/(Lfd))= 0.0018

,(-(1*R1d*(1-(Ladssec/Lfd)+((((0.072+1*(Laqssec+Ll))*Ladssec)/(((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll)))*L1d)) *Ladssec)))/(L1d))= -0.3192

,(-(1*R1q*((1/((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll))))*((0.005+0.009)*sin(-0.785)+(0.072+1*(Ladssec+Ll))*cos(-0.785))) *Laqssec)/(L1q))=-0.1323
,(-(1*R1q*(-((0.005+0.009)/((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll))))*(Ladssec/L1d))*Laqssec)/(L1q))= 0.0051
,(-(1*R1q*(1-(Laqssec/L1q)+((((0.072+1*(Ladssec+Ll))*Laqssec)/(((0.005+0.009)^2+(0.072+1*(Ladssec+Ll))*(0.072+1*(Laqssec+Ll)))*L1q))*Laqssec)))/(L1q))=-0.2349}, {L1d, L1q, Ladssec, Laqssec, Lfd, R1d, R1q, Rfd},useassumptions)

Lfd ~=0.233, R1d~=0.0848, L1d~=0.2, L1q~=-0.09, Ladssec~=0.099, Laqssec~=-0.1, Rfd~=0.00173, R1q~=0.0129

So, newb question here. I've done my best to debug this line of code, but to no avail. For some reason this function is NOT getting solved correcting for the zeros:

cos(L*x) - x*sin(L*x)


This is not an extremely complex equation either, so I'm at a loss for why my while loop continues to sit there forever. I've got it set to find N number of zeros, but it'll just keep going forever never finding any zeros. I've tried mixing up the start point, and even changed the range which it's searching for them, but nothing seems to get me any closer. Please help!


> restart; with(plots);
> a := 0; b := 1/2; N := 5; w := 1; L := b-a;

Eigenvalue equation
> w := cos(L*x)-sin(L*x)*x;
> plot(w, x = 0 .. 50);

> lam := array(0 .. N+1);

> nn := 0; kk := 5; while nn < N do zz := fsolve(w(x) = 0, x = kk .. kk+1); if type(zz, float) then printf("lam(%d)=%f\n", nn, zz); lam[nn] := zz; nn := nn+1 end if; kk := kk+1 end do




I have the following system of equations to solve which is quite big.. Does anyone know how I can solve it faster or in a more simple way?






Does anyone know why I cannot solve the following system of equations?


solve({(-(0.1e-2+e+p)*j*(e*(-m+.68/d+.599/g)+j*m)/(((0.2e-2+0.1e-2)^2+(0.1e-2+e+p)*(0.1e-2+j+p))*i)+(0.2e-2+0.1e-2)*j*(j*(-n+0*(1/i)-.73/l)+e*n)/(((0.2e-2+0.1e-2)^2+(0.1e-2+e+p)*(0.1e-2+j+p))*i)-j*m/i)/(2*10) = -0.3e-2, (-(0.1e-2+e+p)*j*(e*(-m+.68/d+.599/g)+j*m)/(((0.2e-2+0.1e-2)^2+(0.1e-2+e+p)*(0.1e-2+j+p))*l)+(0.2e-2+0.1e-2)*j*(j*(-n+0*(1/i...

5 6 7 8 9 10 11 Page 7 of 13