## plot numerical solution explicite schemae...

Dear All, I need your help to plot the numerical solution. many thanks.

The variable t in [0,T], x in [0,1], b in [0,2].

Difference finie for waves equation is :

pde:=diff(u(x, y,t), t\$2) = c^2*(diff(u(x, y,t),x\$2)+diff(u(x,y,t),y\$2));

i: according to x, j according to y, and k according to t.

u[i,j,k+1]=2*u[i,j,k]-u[i,j,k-1]+(c*dt/dx)^2*(u[i-1,j,k]-2*u[i,j,k]+u[i+1,j,k])+ (c*dt/dy)^2*(u[i,j-1,k]-2*u[i,j,k]+u[i,j+1,k])

Boundary condition: u(t=0)=1, diff(u(x,y,t),t=0)=0, and the normal derivative on the boundary of Omega =0.

How can solve this problem and plot the numerical solution.

## System of equations solve, solutions may be lost. ...

Hi MaplePrime-ers!

I've been using the Maple(17) toolbox in Matlab(2012b) to quickly enumerate systems of equations by: (i) solving them symbolically, (ii) using unapply to make them functions, (iii) then supplying the points (driver equations) to get the system solution.  Speed is a must, because there may be 3 million+ systems to solve.  Symbolics is also very important because I am evaluating topology, so the structure of the equations may change, and therefore a functional approach will not work.

I have had success (seen in the first code snippet).  I would like similiar behaviour in the second code snippet, but sometimes I get 'solutions may be lost' as an error message,  or 'Error, (in unapply) variables must be unique and of type name'

The system of equations include:  Linear equations, 5th order polynomials, absolute functions, and pieceiwse functions.

Here is code with a topology that solves:

#Interconnection Equations
eq2[1] := FD_T + EM2_T = 0;
eq2[2] := ICE_T + GEN_T = 0;
eq2[3] := EM2_A + GEN_A + BAT_A = 0;
eq2[4] := -FD_W + EM2_W = 0;
eq2[5] := -ICE_W + GEN_W = 0;
eq2[6] := -EM2_V + GEN_V = 0;
eq2[7] := -EM2_V + BAT_V = 0;

#ICE
eq_c[1] := ICE_mdot_g=((671.5) + (-21.94)*ICE_T + (0.1942)*ICE_W + (0.5113)*ICE_T^2 + (-0.01271)*ICE_T*ICE_W + ( -0.0008761)*ICE_W^2 + (-0.006071)*ICE_T^3 + (9.867e-07)*ICE_T^2*ICE_W + (5.616e-05)*ICE_T*ICE_W^2 + (1.588e-06)*ICE_W^3 + (3.61e-05)*ICE_T^4 + (8.98e-07)*ICE_T^3*ICE_W + (-2.814e-07)*ICE_T^2*ICE_W^2 + (-8.121e-08)*ICE_T*ICE_W^3 + ( -8.494e-08 )*ICE_T^5 + (-2.444e-09)*ICE_T^4*ICE_W + (-9.311e-10)*ICE_T^3*ICE_W^2 + ( 5.835e-10)*ICE_T^2*ICE_W^3 ) *1/3600/1000 * ICE_T * ICE_W;

#BAT
eq_c[2] := BAT = 271;

#EM2
EM2_ReqPow_eq := (-148.3) + (4.267)*abs(EM2_W) + (12.77)*abs(EM2_T) + (-0.0364)*abs(EM2_W)^2 + ( 1.16)*abs(EM2_W)*abs(EM2_T) + (-0.258)*abs(EM2_T)^2 + ( 0.0001181)*abs(EM2_W)^3 + (-0.0005994)*abs(EM2_W)^2*abs(EM2_T) + ( 0.0001171)*abs(EM2_W)*abs(EM2_T)^2 + (0.001739 )*abs(EM2_T)^3 + (-1.245e-07 )*abs(EM2_W)^4 + ( 1.2e-06)*abs(EM2_W)^3*abs(EM2_T) + ( -1.584e-06)*abs(EM2_W)^2*abs(EM2_T)^2 + ( 4.383e-07)*abs(EM2_W)*abs(EM2_T)^3 + (-2.947e-06)*abs(EM2_T)^4;
eq_c[3] := EM2_P = piecewise( EM2_T = 0, 0, EM2_W = 0, 0, EM2_W*EM2_T < 0,-1 * EM2_ReqPow_eq, EM2_ReqPow_eq);
eq_c[4] := EM2_A = EM2_P/EM2_V;

#GEN
GEN_ReqPow_eq:= (-5.28e-12) + ( 3.849e-14)*abs(GEN_W) + (-71.9)*abs(GEN_T) + (-1.168e-16)*abs(GEN_W)^2 +(1.296)*abs(GEN_W)*abs(GEN_T) + (2.489)*abs(GEN_T)^2 + (1.451e-19)*abs(GEN_W)^3 + (0.0001326)*abs(GEN_W)^2*abs(GEN_T) + (-0.008141)*abs(GEN_W)*abs(GEN_T)^2 + (-0.004539)*abs(GEN_T)^3 +(-6.325e-23)*abs(GEN_W)^4 + (-2.091e-07)*abs(GEN_W)^3*abs(GEN_T) + ( 3.455e-06)*abs(GEN_W)^2*abs(GEN_T)^2 + ( 2.499e-05)*abs(GEN_W)*abs(GEN_T)^3 + (-5.321e-05)*abs(GEN_T)^4;
eq_c[5] := GEN_P = piecewise( GEN_T = 0, 0, GEN_W = 0, 0, GEN_W*GEN_T < 0,-1 * GEN_ReqPow_eq, GEN_ReqPow_eq);
eq_c[6] := GEN_A = GEN_P/GEN_V;

#ASSUMPTIONS
assume(BAT_V::nonnegative);
assume(FD_W::nonnegative);

#FINAL EQUATIONS

sys_eqs2 := convert(eq2,set) union {eq_c[1],eq_c[2],eq_c[3],eq_c[4],eq_c[5],eq_c[6]};

#Selecting which variables to solve for:

drivers2:= { ICE_T,ICE_W,FD_T,FD_W};
symvarnames2:=select(type,indets(convert(sys_eqs2,list)),name);
notdrivers2:=symvarnames2 minus drivers2;

#Symbolic solve

sol2:=solve(sys_eqs2,notdrivers2) assuming real:
symb_sol2:=unapply(sol2,convert(drivers2,list)):

#Enumerate (there will generally be about 40, not 6)

count := 0;
for i1 from 1 to 40 do
for i2 from 1 to 40 do
for i3 from 1 to 40 do
for i4 from 1 to 40 do
count := count + 1;
solsol2(count) := symb_sol2(i1,i2,i3,i4);
od;
od;
od;
od;
count;

This works great!  I would like simliar output in my second code snippet, but this time with more inputs to symb_sol.  However, if I try and change the interconnection equations a little, and add a piecewise function, and another driver... (differences in bold)

#Interconnection Equations
eq1[1] := FD_T+EM2_T = 0;
eq1[2] := ICE_T+GBb_T = 0;
eq1[3] := GEN_T+GBa_T = 0;
eq1[4] := EM2_A+GEN_A+BAT_A = 0;
eq1[5] := -FD_W+EM2_W = 0;
eq1[6] := -GEN_W+GBa_W = 0;
eq1[7] := -ICE_W+GBb_W = 0;
eq1[8] := -EM2_V+GEN_V = 0;
eq1[9] := -EM2_V+BAT_V = 0;

#ICE
eq_c[1] := ICE_mdot_g=((671.5) + (-21.94)*ICE_T + (0.1942)*ICE_W + (0.5113)*ICE_T^2 + (-0.01271)*ICE_T*ICE_W + ( -0.0008761)*ICE_W^2 + (-0.006071)*ICE_T^3 + (9.867e-07)*ICE_T^2*ICE_W + (5.616e-05)*ICE_T*ICE_W^2 + (1.588e-06)*ICE_W^3 + (3.61e-05)*ICE_T^4 + (8.98e-07)*ICE_T^3*ICE_W + (-2.814e-07)*ICE_T^2*ICE_W^2 + (-8.121e-08)*ICE_T*ICE_W^3 + ( -8.494e-08 )*ICE_T^5 + (-2.444e-09)*ICE_T^4*ICE_W + (-9.311e-10)*ICE_T^3*ICE_W^2 + ( 5.835e-10)*ICE_T^2*ICE_W^3 ) *1/3600/1000 * ICE_T * ICE_W;

#BAT
eq_c[2] := BAT = 271;

#EM2
EM2_ReqPow_eq := (-148.3) + (4.267)*abs(EM2_W) + (12.77)*abs(EM2_T) + (-0.0364)*abs(EM2_W)^2 + ( 1.16)*abs(EM2_W)*abs(EM2_T) + (-0.258)*abs(EM2_T)^2 + ( 0.0001181)*abs(EM2_W)^3 + (-0.0005994)*abs(EM2_W)^2*abs(EM2_T) + ( 0.0001171)*abs(EM2_W)*abs(EM2_T)^2 + (0.001739 )*abs(EM2_T)^3 + (-1.245e-07 )*abs(EM2_W)^4 + ( 1.2e-06)*abs(EM2_W)^3*abs(EM2_T) + ( -1.584e-06)*abs(EM2_W)^2*abs(EM2_T)^2 + ( 4.383e-07)*abs(EM2_W)*abs(EM2_T)^3 + (-2.947e-06)*abs(EM2_T)^4;
eq_c[3] := EM2_P = piecewise( EM2_T = 0, 0, EM2_W = 0, 0, EM2_W*EM2_T < 0,-1 * EM2_ReqPow_eq, EM2_ReqPow_eq);
eq_c[4] := EM2_A = EM2_P/EM2_V;

#GEN
GEN_ReqPow_eq:= (-5.28e-12) + ( 3.849e-14)*abs(GEN_W) + (-71.9)*abs(GEN_T) + (-1.168e-16)*abs(GEN_W)^2 +(1.296)*abs(GEN_W)*abs(GEN_T) + (2.489)*abs(GEN_T)^2 + (1.451e-19)*abs(GEN_W)^3 + (0.0001326)*abs(GEN_W)^2*abs(GEN_T) + (-0.008141)*abs(GEN_W)*abs(GEN_T)^2 + (-0.004539)*abs(GEN_T)^3 +(-6.325e-23)*abs(GEN_W)^4 + (-2.091e-07)*abs(GEN_W)^3*abs(GEN_T) + ( 3.455e-06)*abs(GEN_W)^2*abs(GEN_T)^2 + ( 2.499e-05)*abs(GEN_W)*abs(GEN_T)^3 + (-5.321e-05)*abs(GEN_T)^4;
eq_c[5] := GEN_P = piecewise( GEN_T = 0, 0, GEN_W = 0, 0, GEN_W*GEN_T < 0,-1 * GEN_ReqPow_eq, GEN_ReqPow_eq);
eq_c[6] := GEN_A = GEN_P/GEN_V;

#GB
FiveSpeedGearbox_R := proc(ig)
local i ,eq;
i[1]:=3.32;
i[2]:=2;
i[3]:=1.36;
i[4]:=1.01;
i[5]:=0.82;
eq:= piecewise(ig=1,i[1],ig=2, i[2],ig=3,i[3],ig=4,i[4],ig=5,i[5],1);
return eq(ig);
end proc;

eq_c[7] := GBb_T = -1/GB_R * GBa_T;
eq_c[8] := GBb_W = GB_R * GBa_W;
eq_c[9] := GB_R = FiveSpeedGearbox_R(ig);

#System Equations
sys_eqs := convert(eq1,set) union convert(eq_c,set);

#Solve for variables
symvarnames:=select(type,indets(convert(sys_eqs,list)),name);
drivers:= {ig, ICE_T,ICE_W,FD_T,FD_W};
not_drivers := symvarnames minus drivers;

#Assumptinons

assume(BAT_V::nonnegative);
assume(FD_W::nonnegative);

sol:=(solve(sys_eqs,not_drivers) assuming real);

symb_sol:=unapply(sol,convert(drivers,list)): ---> Error, (in unapply) variables must be unique and of type name

Subsequent parts don't work...

count := 0;
for i1 from 1 to 40 do
for i2 from 1 to 40 do
for i3 from 1 to 40 do
for i4 from 1 to 40 do
for i5 from 1 to 40 do
count := count + 1;
solsol2(count) := symb_sol2(i1,i2,i3,i4,5);
od;
od;
od;
od;
od;
count;

While running the last line sol:, 1 of 2 things will happen, depending on the solver. Maple17 will take a long time (30+ minutes) to solve, then report nothing, or sol will solve, but will report "some solutions have been lost".

Afterwards, evaluating symb_sol(0,0,0,0,0) will return a viable solution (real values for each of the variables).  Whereas evaluating symb_sol(0,X,0,0,0), where X <> 0, will return and empty list [].

Does anyone know how to (i) speed up the symbolic solve time?  (ii) Return ALL of the solutions?

Thanks in advance for reading this.  I've really no idea why this isn't working.  I've also attached two worksheets with the code: noGB.mw   withGB.mw

## Solving cubic equation...

Hi all,

By solving cubic equation in maple (version 17), I got

 (1)

 (2)

Now I want to find these roots through the formula.

I solve it generally in Maple..

# Suppose

 (3)

 (4)

 (5)

 (6)

 (7)

 (8)

 (9)

 (10)

y1, y2, y3 formulas are computed by Maple by solving it for general formula.
But, now I got answers in real and imaginery parts, i.e

y1 = -119.0286907-1.*10^(-9)*I

y2 = .770924807+1.772050808*10^(-8)*I

y3 = 7.123944373-1.692050808*10^(-8)*I

Why, is it so?

I want answers in simple forum directly only by using these formulas. As i have to show the proof!

## Simple question, matrix, isolate...

Dear all,

Let A be a Matrix, X[1] and X[2] two vectors.

I have this equation:  X[2]= X[1]+ A*X[1]+A*X[2];  Using Maple how can I  writte X[2] =P*X[1]; where P is a matrix to be founded.

Here, P:=(Id-A)^(-1)*A; But how using maple.

## How do I plot this orthogonal trajectories equatio...

I'm taking calculus and my professor introduced us to maple software. The professor asked us to plot the families of curves for this orthogonal equation:

dy/dx = (x^2) - (2y^2) - C = 0

This is what I had so far:

restart;

with(DEtools):

with(plots):

Function:=unapply(simplify(x^2-2y^2-C),(x,y)):

'Function'(x,y) = Function(x,y);

plotFunction:=C->implicitplot(eval(F(x,y),a=C),x=-5..5,y=5..5,scaling=constrained):

plot1:=display(seq(plotFunction(a),a=-5..5)):

display(plot1);

This is only display one family. How do I code for it plot the other families?

(The graph should look like curves converging from left, top and right sides toward to the origin of the axes)

## how do i solve a nonlinear differential equation i...

hi, I am new here I want to solve these toe coupled equations with the following boundary condition numerically:

1)  diff(f(eta),eta\$3)+(1)/(2)*f(eta)*diff(f(eta),eta\$2)-xi*(2*f(eta)*(diff(f(eta),eta))*

(diff(f(eta),eta,eta))+f(eta)^2*(diff(f(eta),eta,eta,eta))+eta*(diff(f(eta),eta))^2*(diff(f(eta),eta\$2)))-K*

(diff(f(eta),eta)-1)=0

2)   diff(theta(eta),eta,eta)+(1)/(2)*Pr*f(eta)*(diff(theta(eta),eta))=0

boundary conditions: 1)  f(0) = 0   2)  D(f)(0) = 0   3)  D(f)(infinity=10) = 1

1) theta(infinity=10) = 1      2) theta(0)=0

xi=0.2 ... 1    K=0.2     pr=0.7

## Export system of equations into matrix form...

AOA... I want to convert system of equations into matirx form.

F[0] := u[0, n]-u[0, n-1]+u[1, n]-u[1, n-1]+u[2, n]-u[2, n-1]+u[3, n]-u[3, n-1]

F[1] := u[0, n]-u[0, n-1]-u[1, n]+u[1, n-1]+u[2, n]-u[2, n-1]-u[3, n]+u[3, n-1];

F[2] := u[0, n]/P-u[0, n-1]/P-.7071067810*u[1, n]/P+.7071067810*u[1, n-1]/P+.7071067810*u[3, n]/P-.7071067810*u[3, n-1]/P+0.4549512860e-1*exp(-1.*t)-.3431457508*u[2, n]+.3431457508*u[2, n-1]+1.556349186*u[3, n]-1.556349186*u[3, n-1] = 0;

F[3] := u[0, n]/P-u[0, n-1]/P-.7071067810*u[1, n]/P+.7071067810*u[1, n-1]/P+.7071067810*u[3, n]/P-.7071067810*u[3, n-1]/P+0.4549512860e-1*exp(-1.*t)-.3431457508*u[2, n]+.3431457508*u[2, n-1]+1.556349186*u[3, n]-1.556349186*u[3, n-1] = 0;

I want to export the above system of equation in to matrices of as

AU[n]+BU[n-1]-C = O;

where*U[n] = Typesetting[delayDotProduct](Vector(4, {(1) = u[0, n], (2) = u[1, n], (3) = u[2, n], (4) = u[3, n]}), a, true)*n*d*U[n-1] and Typesetting[delayDotProduct](Vector(4, {(1) = u[0, n], (2) = u[1, n], (3) = u[2, n], (4) = u[3, n]}), a, true)*n*d*U[n-1] = (Vector(4, {(1) = u[0, n-1], (2) = u[1, n-1], (3) = u[2, n-1], (4) = u[3, n-1]})), Help me plz;

Help_Constrct.mw

## How to solve it with Maple?...

Is it possible to find all the solutions of the equation

abs(tan(x)*tan(2*x)*tan(3*x))+abs(tan(x)+tan(2*x)) = tan(3*x)

which belong to the interval 0..Pi with Maple?

## Can you use solve for multiple data points?...

Hi, the title isn't great as I didn't know how to describe this really. I need to solve the following equation for b:

y = (1-exp(-x*b))/(1-exp(-50*b))

When I put a value for y in, this is fine and fsolve gives me a numeric real solution. However, even when using RealDomain, it does not give me a real solution if I leave y as it is, and instead gives a 'RootOf' solution, which I don't really understand. This is the same whether using solve or isolate:

b=-(1/50)RootOf(_Zx-50ln(-y+ye^(_Z)+1))

I have the values of x and y for multiple data points and can put them in an nx1 matrix. Is there a way to replace x and y with matrices (with real numbers in) and solve for each set of points for b (ie there would be n values of b)? Obviously I could go through and put in each value of x and y but this would take ages, so was just wondering if there's a quick way to do this.

I have tried by simply putting matrices instead of the letter but get the error:

Error, invalid input: exp expects its 1st argument, x, to be of type algebraic, but received Vector(50, {(1) = -50*b, (2) = -49*b,...

James

## Nonlinear DE - Need hints on how to solve...

I have the following nonlinear Differential Equation and don't know how to solve.  Can anyone give me any hints on how solvle for E__fd(t).  I don't even know the specific classification (other than nonlinear) of this DE can someone at least give me hint on that. Thanks.

.5*(diff(E__fd(t), t)) = -(-.132+.1*e^(.6*E__fd(t)))*E__fd(t)+0.5e-1

Thanks,

Melvin

## Solve This Equation...

Can anyone tell me how to solve the equation above using Maple.  I know that there is a solution around x=0.995, y=0.743, but I cannot induce Maple to find it.  Any help or suggestions would be appreciated.

Ratch

## How do I solve this system of PDEs in Maple?...

Hi there,

I'm quite new to Maple so please forgive me! I have a system of partial differential equations I'm trying to solve in Maple as such below

df/dt = f(1-f) - f * h

dh/dt = (g - h) + Laplacian(h),

where f,g,h are functions of space and time (i.e. f(x,y,z,t)). I guess my first question is - is this possible in Maple to evaluate? (I'm currently unsure on ICs as I'm figuring it out from the model - it's a model for cancer growth I'm trying to evaluate but have a rough idea of what I'd use).

If it is possible, can you please share how I'd write this? Everytime I've tried I seem to be failing to define anything properly, so your expertise would be greatly appreciated!

## Plotting simultaneous equation solutions, against ...

Hello,

So I have two simultaneous equations,

T= n1/(1+|T-S|) and S=n2/(n3+|T-S|)

Where n1, n2 and n3 are constant parameters (from here on I fix n1=1 and n3=0.3). So I want to plot T, S against n2 for different values of n2.

If I also fix n2 (say, n2=1.5) I  can get values for T and S no problem.

But I've no idea (after many hours of searching) how to progresss. I know I need the program to put various values of n2 into the two equations and then plot the solutions numerically but I'm unsure what to try next.

Could anyone please shed some light on this?!

Thanks!

## jacobi elliptical integrals...

How can I get solution of  the following equation of orbit for schwarzschild BH in form of Jacobi Elliptical Integrals on Maple 12 platform,

diff(r(phi), phi) = r^2*sqrt(e^2-(1-2*M/r)*(1+l^2/r^2))/l

## Heat Equation with Robin Boundary Condition and In...

I am trying to get a solution to the heat equation with multiple boundary conditions.

Most of them work but I am having trouble with two things: a Robin boundary condition and initial conditions.

First, here are my equations that work:

returns a solution (actually two including u(x,y,z,t)=0).

However, when I try to add:

or

I no longer get a solution.

Any guidance would be appreciated.

Regards.

I have uploaded a worksheet with the equations...