Items tagged with fsolve fsolve Tagged Items Feed

Dear Friends

I have a problem in CPU time in MAPLE.

I write the codes in maple related to the nonlinear heat conduction problem in one dimension by Collocation method, but after 30 minutes no solution has been observed!!!

My codes are for N=4!, i.e., I have 25 equations with 25 unknowns!!!

If MAPLE can not solve this simple system, How can I solve 3 dimensional pdes by N=9,

In this case, I have 1000 equations with 1000 unknowns!!!

please help me and suggest me a fast iterative solver.

I should remark that my problem is stated in this paper

http://www.sciencedirect.com/science/article/pii/S1018364713000025

If there exist any other suitable method, I will be happy to receive any support.

 

With kind regards,

Emran Tohidi.

 

> restart;
> Digits := 20; N := 4; st := time(); u := sum(sum(a[m, n]*x^m*t^n, m = 0 .. N), n = 0 .. N); u := unapply(u, x, t); ut := diff(u(x, t), `$`(t, 1)); ut := unapply(ut, x, t); ku := simplify(1+u(x, t)^2); ku := unapply(ku, x, t); ux := diff(u(x, t), `$`(x, 1)); ux := unapply(ux, x, t); K := ku(x, t)*ux(x, t); K := unapply(K, x, t); Kx := diff(K(x, t), `$`(x, 1)); Kx := unapply(Kx, x, t); f := proc (x, t) options operator, arrow; x*exp(t)*(1-2*exp(2*t)) end proc;
print(`output redirected...`); # input placeholder
> S1 := {seq(u(i/N, 0)-i/N = 0, i = 0 .. N)}; S2 := {seq(u(0, j/N) = 0, j = 1 .. N)}; S3 := {seq(u(1, j/N)+ux(1, j/N)-2*exp(j/N) = 0, j = 1 .. N)}; S4 := {seq(seq(Kx(i/N, j/N)+f(i/N, j/N)-ut(i/N, j/N) = 0, i = 1 .. N-1), j = 1 .. N)}; S := `union`(`union`(`union`(S1, S2), S3), S4); sol := DirectSearch:-SolveEquations([op(S)], tolerances = 10^(-4), evaluationlimit = 1000000);
print(`output redirected...`); # input placeholder
> assign(sol);
%;
> u(x, t);
> CPUTIME := time()-st;
plot3d(u(x, t) - x exp(t), x = 0 .. 1, t = 0 .. 1)

Hy all.

I want to solve this equation, with„dd” as numerical result. What do I do wrong? Thanks. Nico

restart;
TTot := 70;
TC := 17;
GM := .26;
QMax := 870;
V := 3600*GM*QMax*TTot;
eq := V = int(QMax*exp((-t+TC)/dd)*(1+(t-TC)/TC)^(TC/dd), t = 0 .. TTot);
fsolve(eq, dd);

hello

this is my program and fsolve for low intensity solve the equations but for high intensity cannot solve why?

this is my code:

ep0 := 1/(4*3.14);

el := 8.54*10^(-2);

hbar := 1;

vf := 1/300;

kb := 1;

tem := 2.586*10^(-2);

ci := 1;

p := 1.458*10^16;

beta := 2;

ai := 7.1*10^(-4);

bi := ai/sqrt(3);

enph := .196;

d := enph/(kb*tem);

n0 := 1/(exp(enph/(kb*tem))-1);

gama := hbar*vf;

intensity:=9000000

 

w := 7.28;

impurity := 7.2*10^3;

g := hbar*beta/(bi^2*sqrt(2*p*enph));

aa := g^2*(n0+1)/(2*Pi*hbar*gama^2);

bb := g^2*n0/(2*Pi*hbar*gama^2);

cc := 2/(Pi*gama^2);

l := (1*hbar)*w/(2*kb*tem);

 

u := el^2*intensity/(32*w*hbar^2);

[fsolve({op([((enph*ln(1+exp(c+enph/(kb*tem)))/(kb*tem)-polylog(2, -exp(c))+polylog(2, -exp(c+enph/(kb*tem))))*enph*(kb*tem)^2-(enph^2*ln(1+exp(c+enph/(kb*tem)))/(kb^2*tem^2)+2*enph*polylog(2, -exp(c+enph/(kb*tem)))/(kb*tem)+2*polylog(3, -exp(c))-2*polylog(3, -exp(c+enph/(kb*tem))))*(kb*tem)^3+(-exp(b)*enph*ln(1+exp(c+enph/(kb*tem)))+exp(c+d)*enph*ln(1+exp(b-d+enph/(kb*tem)))+exp(b)*kb*tem*polylog(2, -exp(c))-exp(c+d)*kb*tem*polylog(2, -exp(b-d))-exp(b)*kb*tem*polylog(2, -exp(c+enph/(kb*tem)))+exp(c+d)*kb*tem*polylog(2, -exp(b-d+enph/(kb*tem))))*enph*(kb*tem)^2/((exp(b)-exp(c+d))*kb*tem)+(exp(b)*enph^2*ln(1+exp(c+enph/(kb*tem)))-exp(c+d)*enph^2*ln(1+exp(b-d+enph/(kb*tem)))+2*exp(b)*enph*kb*tem*polylog(2, -exp(c+enph/(kb*tem)))-2*exp(c+d)*enph*kb*tem*polylog(2, -exp(b-d+enph/(kb*tem)))+2*exp(b)*kb^2*tem^2*polylog(3, -exp(c))-2*exp(c+d)*kb^2*tem^2*polylog(3, -exp(b-d))-2*exp(b)*kb^2*tem^2*polylog(3, -exp(c+enph/(kb*tem)))+2*exp(c+d)*kb^2*tem^2*polylog(3, -exp(b-d+enph/(kb*tem))))*(kb*tem)^3/((exp(b)-exp(c+d))*kb^2*tem^2))*bb+u*(1/(1+exp(-l-c))-1/((1+exp(-l-c))*(1+exp(l-b))))-(((1*enph)*(enph-2*kb*tem*ln(1+exp(-b+enph/(kb*tem))))/(2*kb^2*tem^2)+2*kb^2*tem^2*(-polylog(2, -exp(-b+enph/(kb*tem)))+polylog(2, -cosh(b)+sinh(b))))*enph*(kb*tem)^2-(enph^2*(enph-3*kb*tem*ln(1+exp(-b+enph/(kb*tem))))-6*kb^2*tem^2*(enph*polylog(2, -exp(-b+enph/(kb*tem)))+kb*tem*(-polylog(3, -exp(-b+enph/(kb*tem)))+polylog(3, -cosh(b)+sinh(b)))))*(kb*tem)^3/(3*kb^3*tem^3)-(-exp(b)*enph^2+exp(c+d)*enph^2-2*exp(c+d)*enph*kb*tem*ln(1+exp(-b+enph/(kb*tem)))+2*exp(b)*enph*kb*tem*ln(1+exp(-c-d+enph/(kb*tem)))+2*exp(c+d)*kb^2*tem^2*polylog(2, -exp(-b))-2*exp(b)*kb^2*tem^2*polylog(2, -exp(-c-d))-2*exp(c+d)*kb^2*tem^2*polylog(2, -exp(-b+enph/(kb*tem)))+2*exp(b)*kb^2*tem^2*polylog(2, -exp(-c-d+enph/(kb*tem))))*enph*(kb*tem)^2/((2*(-exp(b)+exp(c+d)))*kb^2*tem^2)-(exp(b)*enph^3-exp(c+d)*enph^3+3*exp(c+d)*enph^2*kb*tem*ln(1+exp(-b+enph/(kb*tem)))-3*exp(b)*enph^2*kb*tem*ln(1+exp(-c-d+enph/(kb*tem)))+6*exp(c+d)*enph*kb^2*tem^2*polylog(2, -exp(-b+enph/(kb*tem)))-6*exp(b)*enph*kb^2*tem^2*polylog(2, -exp(-c-d+enph/(kb*tem)))+6*exp(c+d)*kb^3*tem^3*polylog(3, -exp(-b))-6*exp(b)*kb^3*tem^3*polylog(3, -exp(-c-d))-6*exp(c+d)*kb^3*tem^3*polylog(3, -exp(-b+enph/(kb*tem)))+6*exp(b)*kb^3*tem^3*polylog(3, -exp(-c-d+enph/(kb*tem))))*(kb*tem)^3/((3*(-exp(b)+exp(c+d)))*kb^3*tem^3))*aa-u*(1/(1+exp(l-b))-1/((1+exp(-l-c))*(1+exp(l-b)))) = 0, -cc*polylog(2, -exp(b))+cc*polylog(2, -exp(-c))-impurity = 0])}, {op([b, c])})];

 

thank you.

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);

Hello,

 

  I have a question. Consider

 

fsolve(x^2+3*x+1=3, x);

 

  I want to save the two roots into two variables. What kind of commend shall I use? 

 

P.S. My further aim comes from solving an equation without analytical solution. Therefore I cannot plug in the solution formula. 

 

 

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?

solve(eq_system,{_C1,_C2,_C3,_C4,_C5,_C6,_C7,_C8});

I'm trying to interpolate values using spline (data,x,degrees=2).

So I'm setting curvefit:=spline(data,x,degrees=2);

fsolve(curvefit=4,x);

However, I'm trying to solve this over a range of values in matrix M:=1..2000;

I'm sifting through the online documentation, but I can't find a proper way to do this. Ideally, i'd want to store the results as a seperate matrix.

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);

 

Dear All,

I analyzed some example of linear equation systems and tried to distinguish the difference between the solve and fsolve in these cases.

1. In general case, the deviation between solve and fsolve is less than 10^-8, for example:

But, in some case, the deviation is more than 10^-7, for example:

how to reduce the error of solving the problem by fsolve?

2. It seems that solve will automatically translate the answer into numerical result while the system is composed with decimals, for example, we redo the second case with no decimals:

Is it possible to get the exact solution while the decimal is involved in the system?

The related file is attached. I'd appreciate any help on this topic. Thank a lot.

solve_and_fsolve.mw

 

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]]);

gives:

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.

thanks

 

Here is the full code:

restart:

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);
                                   1.271553303

> identify(%);
                                   1.271553303

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

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

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:

knn:=Matrix(10,1):

for m from 1 to 10 do
P:=fsolve({y=1/kn,y=-tan(kn)},{kn=(m-1)*Pi..m*Pi,y=0..5});
knn[m,1]:=P[1];
end do:

knn[3,1];

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.

1 2 3 4 5 6 7 Page 1 of 7