Rouben Rostamian

MaplePrimes Activity


These are answers submitted by Rouben Rostamian

restart;

kernelopts(version);

`Maple 2020.1, X86 64 LINUX, Jun 8 2020, Build ID 1474533`

eq1 := diff(f_n(zeta), zeta$2)-h_n(zeta)*(diff(f_n(zeta), zeta))-f_n(zeta)^2+g_n(zeta)^2 = 0;
eq2 := diff(g_n(zeta), zeta$2)-h_n(zeta)*(diff(g_n(zeta), zeta))-2*f_n(zeta)*g_n(zeta) = 0;
eq3 := 2*f_n(zeta)+diff(h_n(zeta), zeta) = 0;
ics := f_n(0) = 0, f_n(L) = 0, g_n(0) = 1, g_n(L) = 0, h_n(0) = 0;

diff(diff(f_n(zeta), zeta), zeta)-h_n(zeta)*(diff(f_n(zeta), zeta))-f_n(zeta)^2+g_n(zeta)^2 = 0

diff(diff(g_n(zeta), zeta), zeta)-h_n(zeta)*(diff(g_n(zeta), zeta))-2*f_n(zeta)*g_n(zeta) = 0

2*f_n(zeta)+diff(h_n(zeta), zeta) = 0

f_n(0) = 0, f_n(L) = 0, g_n(0) = 1, g_n(L) = 0, h_n(0) = 0

L := 10.0;
dsol := dsolve({eq1,eq2,eq3,ics}, numeric, initmesh = 16):   # default initmesh is 8
plots:-odeplot(dsol,
   [[zeta,f_n(zeta)], [zeta, g_n(zeta)], [zeta,h_n(zeta)]], color=[red,green,blue]);

10.0

 

Download mw.mw

 

restart;

pde := diff(w(x,t), x$4) + diff(w(x,t), t$2)/c^2 = 0;

diff(diff(diff(diff(w(x, t), x), x), x), x)+(diff(diff(w(x, t), t), t))/c^2 = 0

We look for solutions of the form w(x, t) = u(x)*cos(omega*t):

eval(pde, w(x,t)=u(x)*cos(omega*t));
de_tmp := expand(%/cos(omega*t));

(diff(diff(diff(diff(u(x), x), x), x), x))*cos(omega*t)-u(x)*omega^2*cos(omega*t)/c^2 = 0

diff(diff(diff(diff(u(x), x), x), x), x)-u(x)*omega^2/c^2 = 0

The coefficient omega^2/c^2 is not convenient.  It's better to work with dimensionless quantities.

Therefore we introduce a new unknown, mu, related to omega through

mu_def := omega = c/L^2*mu^2;

omega = c*mu^2/L^2

Then express the differential equation de_tmp in terms of mu

de := eval(de_tmp, mu_def);

diff(diff(diff(diff(u(x), x), x), x), x)-u(x)*mu^4/L^4 = 0

Here is the general solution of the de:

dsolve(de):
U := unapply(rhs(%), x);

proc (x) options operator, arrow; _C1*exp(mu*x/L)+_C2*exp(-mu*x/L)+_C3*sin(mu*x/L)+_C4*cos(mu*x/L) end proc

We want to apply the boundary conditions U(0) = 0, U*('0 = 0, U(L) = 0, U')(L) = 0, but of course
Maple will pick the trivial solution U(x) = 0.  The get around that, we temporarily suspend the
boundary condition "U '(L)=0," and instead substitute a boundary condition (diff(U(x), x, x))*0 = a, where a
is an unspecified symbol.  Applying the four boundary conditions, we obtain four equations in

the four unknowns _C1, _C2, _C3, _C4 which we solve:

U(0) = 0, D(U)(0)=0, (D@@2)(U)(0) = a, U(L) = 0:
C_vals := solve({%}, {_C1, _C2, _C3, _C4});

{_C1 = -(1/2)*a*L^2*(-cos(mu)+sin(mu)+exp(-mu))/(mu^2*(exp(mu)-exp(-mu)-2*sin(mu))), _C2 = (1/2)*a*L^2*(exp(mu)-cos(mu)-sin(mu))/((exp(mu)-exp(-mu)-2*sin(mu))*mu^2), _C3 = (1/2)*a*L^2*(exp(mu)-2*cos(mu)+exp(-mu))/(mu^2*(exp(mu)-exp(-mu)-2*sin(mu))), _C4 = -(1/2)*a*L^2/mu^2}

Plug these into the expression for U(x), compute the derivative, and set the derivative to zero
in order to assert the boundary condition "U '(L)=0" which we had left out.

eval(U(x), C_vals):
diff(%, x):
eval(%, x=L) = 0:
simplify(%);

a*L*(exp(2*mu)*cos(mu)-2*exp(mu)+cos(mu))/(mu*(exp(2*mu)-2*sin(mu)*exp(mu)-1)) = 0

The denominator of that equation is a multiple of sinh(mu)-sin(mu) and therefore nonzero.
We conclude that

exp(2*mu)*cos(mu) - 2*exp(mu) + cos(mu) = 0;
eq_tmp := isolate(%, cos(mu));

exp(2*mu)*cos(mu)-2*exp(mu)+cos(mu) = 0

cos(mu) = 2*exp(mu)/(exp(2*mu)+1)

Let's verify that the right-hand side of this equation is 1/cosh(mu)NULL

simplify(1/cosh(mu) - rhs(eq_tmp));

0

Okay, therefore eq_tmp is equivalent to:

eq := cos(mu) = 1/cosh(mu);

cos(mu) = 1/cosh(mu)

This equation has infinitely many roots, as can be seen in this graph:

plot([cos(mu),1/cosh(mu)], mu=0..5*Pi, color=[blue,red], thickness=3, size=[700,300]);

Here are the first few roots:

seq(fsolve(cos(mu)=1/cosh(mu), mu=(2*n+1)*Pi/2), n=1..5);

4.730040745, 7.853204624, 10.99560784, 14.13716549, 17.27875966

Call the roots `μ__j`, j = 1, 2, () .. ()..  For each root there is a mode function given by

subs(C_vals, mu=mu[j], U(x));

-(1/2)*a*L^2*(-cos(mu[j])+sin(mu[j])+exp(-mu[j]))*exp(mu[j]*x/L)/(mu[j]^2*(exp(mu[j])-exp(-mu[j])-2*sin(mu[j])))+(1/2)*a*L^2*(exp(mu[j])-cos(mu[j])-sin(mu[j]))*exp(-mu[j]*x/L)/((exp(mu[j])-exp(-mu[j])-2*sin(mu[j]))*mu[j]^2)+(1/2)*a*L^2*(exp(mu[j])-2*cos(mu[j])+exp(-mu[j]))*sin(mu[j]*x/L)/(mu[j]^2*(exp(mu[j])-exp(-mu[j])-2*sin(mu[j])))-(1/2)*a*L^2*cos(mu[j]*x/L)/mu[j]^2

where the factors a may be dropped since a mode function is determined modulo a

multiplicative constant.  Also for each `μ__j` there corresponds a frequency `ω__j`  given through

the equation mu_def, that is, "`omega__j`=(c*`mu__j`^(2))/(L^(2))."  You should be all set now for eigenfunction expansion

of the solutions of your PDE.

 


 

Download mw.mw

restart;

d := 6/7;  # the delay

6/7

Plot the history function

p[0] := plot(cos(t), t=-d..0):

The solution on the interval 0, d picks up the history function (colored green)

diff(x(t),t,t) + 2/25*diff(x(t),t) + 4*x(t)
  = (1/25*diff(x(t),t,t) + 2/3*diff(x(t),t) + 5/2*x(t))*cos(t-d),
  x(0)=1, D(x)(0)=0:
dsol := dsolve({%}, numeric, output=operator, range=0..d):
myx[1] := eval(x, dsol):
mydx[1] := eval(D(x), dsol):
p[1] := plot(myx[1](t), t=0..d):

On each subsequent interval [(i-1)*d, i*d], the differential equation picks up the solution

calculated in the preceding interval (colored green)

for i from 2 to 14 do
sys := diff(x(t),t,t) + 2/25*diff(x(t),t) + 4*x(t)
  = (1/25*diff(x(t),t,t) + 2/3*diff(x(t),t) + 5/2*x(t))*myx[i-1](t-d),
  x((i-1)*d)=myx[i-1]((i-1)*d), D(x)((i-1)*d)=mydx[i-1]((i-1)*d):
dsol := dsolve({sys}, numeric, output=operator, range=(i-1)*d..i*d):
myx[i] := eval(x, dsol):
mydx[i] := eval(D(x), dsol):
p[i] := plot(myx[i](t), t=(i-1)*d..i*d);
end do:
plots:-display(seq(p[j], j=0..i-1));


 

Download mw.mw

Here is the solution with no explanations.  See if you can figure it out.

restart;

C1 := x^2 + y^2 = L^2;
C2 := (x-R)^2 + y^2 = R^2;

x^2+y^2 = L^2

(x-R)^2+y^2 = R^2

solve(C1, y):
c1 := %[1];

(L^2-x^2)^(1/2)

solve(C2, y):
c2 := %[1];

(2*R*x-x^2)^(1/2)

X := solve(c1=c2, x);

(1/2)*L^2/R

A1 := int(c1, x=X..L) assuming L>0, 2*R>L;

-(1/8)*L^2*(4*arcsin((1/2)*L/R)*R^2-2*Pi*R^2+L*(-L^2+4*R^2)^(1/2))/R^2

A2 := int(c2, x=0..X) assuming L>0, 2*R>L;

(1/8)*(2*R^4*Pi+4*R^4*arcsin((1/2)*(L^2-2*R^2)/R^2)+L^3*(-L^2+4*R^2)^(1/2)-2*L*(-L^2+4*R^2)^(1/2)*R^2)/R^2

A := simplify(2*(A1+A2));

(1/2)*(-2*arcsin((1/2)*L/R)+Pi)*L^2-(1/2)*L*(-L^2+4*R^2)^(1/2)+(arcsin((1/2)*(L^2-2*R^2)/R^2)+(1/2)*Pi)*R^2

A = Pi*R^2/2:
eval(%, R=1):
fsolve(%, L=0..2);

1.158728473

 

Such a rational function does not exist!  Is that a trick question?

Since you are not in the habit of posting a worksheet, I won't post a  worksheet either.  I will give my comments as text.

Make the following corrections in your code:

  1. The mathematical π is written Pi (with uppercase P) in Maple.
  2. The gamma function is written GAMMA (all uppercase) in Maple.
  3. Call your differential equations de1 and de2.
  4. In the line that defines M1, change "=" to ":=".
  5. Enter the initial conditions as
    ic := U1(0)=M1, phi(0)=0, D(phi)(0)=0.001;
  6. Set T:=0.1;  beta:=0.6;  k:=3.5;

After these changes you should be able to call Maple's dsolve to solve your system numerically:

dsol := dsolve({de1,de2,ic}, numeric);

To plot U1, phi, and the derivative of phi over the time interval 0 to 30, do

plots:-odeplot(dsol, [x,U1(x)], x=0..30, view=0..1);
plots:-odeplot(dsol, [x,phi(x)], x=0..30);
plots:-odeplot(dsol, [x,diff(phi(x),x)], x=0..30);

You will see that Maple issues a warning, saying that it cannot go beyond 23.53.  If you look closely for the reason for that, you will see that at t=23.53 the value of phi is zero and the value of its derivative is negative, therefore at the next timestep the value of phi is going to turn negative.  But that is problematic since your differential equation contains the 3/2 power of phi.  What is the 3/2 power of a negative number?  Is there a reason why you have that term in your equation?  Perhaps it shouldn't be there.  Or perhaps it should be the absolute value of phi raised to the 3/2 power.  Go back to the origin of the equation and investigate.

 

Here is my paraphrasing of the problem's statement.


The longitudinal vibration of a homogeneous one-dimensional rod of fixed cross-sectional area A, modulus of elasticity E, and density (mass per unit volume) of rho, satisfies the PDE   rho*u__tt = E*u__xx"," where u = u(x, t) is the displacement of the point at x at time t, and the subscripts x and t indicate derivatives.  It is customary to let c^2 = E/rho, and write the PDE in the form of the standard wave equation u__tt = c^2*u__xx. The strain at any cross-section is u__x, and therefore the stress is E*u__x, and the force acting on that cross-section is E*A*u__x.

 

Consider such a rod of length L, one end of which is fixed at x = 0, and the other end is free to move along the x axis.  The rod's mass is "M=rho*A*L."  We attach a block of mass m to the moving tip of the rod and set it into motion.  We wish to model the rod's motion. The initial conditions are "u(x,0)=0,"and
"((&PartialD; u)/(&PartialD; t)) ? ()|() ? (t=0)={[[0,        0<=x<L],[V,x=L]]"

This is a somewhat tricky problem since the initial velocity is discontinuous at the boundary. In the attached worksheet I show that the displacement u(x, t) of the rod is given by
u(x, t) = r*L*V*(sum(K__j^2*sin(`&mu;__j`)*sin(`&mu;__j`*x/L)*sin(c*`&mu;__j`*t/L)/`&mu;__j`, j = 1 .. infinity))/c,
where "r=m/(M),"   K__j^2 = 1/(r*sin(`&mu;__j`)^2+1/2*(1-sin(2*mu[j])/(2*mu[j]))),
and the `&mu;__j` are the solutions of the equation mu*tan(mu) = 1/r.
Here is a sample of what the solution looks like (u(x,t) versus x, at various times t):

and here is an animation of the rod itself:

 

The short vertical lines are equally-spaced markers etched on the rod to help visualize the rod's motion.

 

Download worksheet: longitudinal-motion.mw

 

 

restart;

T := v -> sum(v(i)*x^(i-1),i=1..n);

proc (v) options operator, arrow; sum(v(i)*x^(i-1), i = 1 .. n) end proc

We want to show that T(x)+T(y) = T(x+y), and T(c*x) = c*T(x) for all
n-tuples x and y, and all scalars c. The first one is easy:

combine(T(x)+T(y)) = T(x+y);
is(%);

sum(x(i)*x^(i-1)+y(i)*x^(i-1), i = 1 .. n) = sum((y(i)+x(i))*x^(i-1), i = 1 .. n)

true

The second one takes a bit more of effort since we need to tell Maple that
x is an n-tuple while c is a scalar.  We have

T(c*x);

sum(c(i)*x(i)*x^(i-1), i = 1 .. n)

which is not what we want since c(i) should be just c.  To fix that, we define c
to be the constant function that assigns the constant c to any t, that is, c = (proc (t) options operator, arrow; c end proc)

eval(T(c*x), c=(t->c));

sum(c*x(i)*x^(i-1), i = 1 .. n)

Now that's better.  Let's verify that T(c*x) = c*T(x):

eval(T(c*x), c=(t->c)) = c*T(x);
is(expand(%));

sum(c*x(i)*x^(i-1), i = 1 .. n) = c*(sum(x(i)*x^(i-1), i = 1 .. n))

true

QED


 

restart;

Don't begin with the differential equations.  Define their right-hand sides first:

f[0] := (x,y1,y2) -> alpha*x*(1 - x/N) - beta[1]*sqrt(x)*y1/(1 + h[1]*beta[1]*sqrt(x)) - beta[2]*sqrt(x)*y2/(1 + h[2]*beta[2]*sqrt(x)) - d*E*x;

proc (x, y1, y2) options operator, arrow; alpha*x*(1-x/N)-beta[1]*sqrt(x)*y1/(1+h[1]*beta[1]*sqrt(x))-beta[2]*sqrt(x)*y2/(1+h[2]*beta[2]*sqrt(x))-d*E*x end proc

f[1] := (x,y1,y2) -> -omega[1]*y1 + Mu[1]*beta[1]*sqrt(x)*y1*(1 - y1/(beta[1]*sqrt(x)))/(1 + h[1]*beta[1]*sqrt(x));

proc (x, y1, y2) options operator, arrow; -omega[1]*y1+Mu[1]*beta[1]*sqrt(x)*y1*(1-y1/(beta[1]*sqrt(x)))/(1+h[1]*beta[1]*sqrt(x)) end proc

f[2] := (x,y1,y2) -> -omega[2]*y2 + Mu[2]*beta[2]*sqrt(x)*y2*(1 - y2/(beta[2]*sqrt(x)))/(1 + h[2]*beta[2]*sqrt(x));

proc (x, y1, y2) options operator, arrow; -omega[2]*y2+Mu[2]*beta[2]*sqrt(x)*y2*(1-y2/(beta[2]*sqrt(x)))/(1+h[2]*beta[2]*sqrt(x)) end proc

Now define the differential equations:

de[0] := diff(x(t),t) = f[0](x(t),y1(t),y2(t));

diff(x(t), t) = alpha*x(t)*(1-x(t)/N)-beta[1]*x(t)^(1/2)*y1(t)/(1+h[1]*beta[1]*x(t)^(1/2))-beta[2]*x(t)^(1/2)*y2(t)/(1+h[2]*beta[2]*x(t)^(1/2))-d*E*x(t)

de[1] := diff(y1(t),t) = f[1](x(t),y1(t),y2(t));

diff(y1(t), t) = -omega[1]*y1(t)+Mu[1]*beta[1]*x(t)^(1/2)*y1(t)*(1-y1(t)/(beta[1]*x(t)^(1/2)))/(1+h[1]*beta[1]*x(t)^(1/2))

de[2] := diff(y2(t),t) = f[2](x(t),y1(t),y2(t));

diff(y2(t), t) = -omega[2]*y2(t)+Mu[2]*beta[2]*x(t)^(1/2)*y2(t)*(1-y2(t)/(beta[2]*x(t)^(1/2)))/(1+h[2]*beta[2]*x(t)^(1/2))

Numbers come last:

params := alpha = 0.75, omega[1] = 0.15, omega[2] = 0.20, N = 0.8, beta[1] = 0.65, beta[2] = 0.70, Mu[1] = 0.75, Mu[2] = 0.74, h[1] = 0.005, h[2] = 0.004, d = 0.05, E = 0.35;

alpha = .75, omega[1] = .15, omega[2] = .20, N = .8, beta[1] = .65, beta[2] = .70, Mu[1] = .75, Mu[2] = .74, h[1] = 0.5e-2, h[2] = 0.4e-2, d = 0.5e-1, E = .35

Here is the system:

sys := eval({de[0], de[1],de[2]}, {params});

{diff(x(t), t) = .75*x(t)*(1-1.250000000*x(t))-.65*x(t)^(1/2)*y1(t)/(1+0.325e-2*x(t)^(1/2))-.70*x(t)^(1/2)*y2(t)/(1+0.280e-2*x(t)^(1/2))-0.175e-1*x(t), diff(y1(t), t) = -.15*y1(t)+.4875*x(t)^(1/2)*y1(t)*(1-1.538461538*y1(t)/x(t)^(1/2))/(1+0.325e-2*x(t)^(1/2)), diff(y2(t), t) = -.20*y2(t)+.5180*x(t)^(1/2)*y2(t)*(1-1.428571429*y2(t)/x(t)^(1/2))/(1+0.280e-2*x(t)^(1/2))}

Need some trial-and-error, and some insight, to find a good range for plotting.

xmin, xmax := 0.1, 0.6;
y1min, y1max := 0.0, 0.6;
y2min, y2max := 0.1, 0.2;

.1, .6

0., .6

.1, .2

Select a good set of initial conditions:

ic := seq([x(0)=xmax, y1(0)=y1max, y2(0)=(1-i/5)*y2min+i/5*y2max], i=0..5),
      seq([x(0)=xmax, y1(0)=0.5*y1max, y2(0)=(1-i/5)*y2min+i/5*y2max], i=0..5),
      seq([x(0)=0.5*xmax, y1(0)=y1max, y2(0)=(1-i/5)*y2min+i/5*y2max], i=0..5),
      seq([x(0)=xmax, y1(0)=0.1, y2(0)=(1-i/5)*y2min+i/5*y2max], i=0..5):

Now plot:

DEtools:-DEplot3d(sys, [x(t),y1(t),y2(t)], t=0..40, stepsize=0.1,
    [ic], x=xmin..xmax, y1=y1min..y1max, y2=y2min..y2max,
    arrows=cheap, linecolor=black, thickness=1, orientation=[30,72,0]);

We see that there is a stable equilibrium near x=0.3, y1=0.2, y2=0.15.  Let's find it:

eval({f[0](x,y1,y2),f[1](x,y1,y2),f[2](x,y1,y2)}, {params}):
fsolve(%, {x=0.3, y1=0.2, y2=0.15});

{x = .3697176032, y1 = .1948334234, y2 = .1549004442}

 

 

 

Download mw.mw

 

I will show how to solve the PDE with the Method of Lines.  For no particular reason I have changed all your coefficients to "1"s, and have added boundary conditions which are missing in your worksheet.

Additionally, I should point out that you may solve the PDE directly with Maple's pdsolve. In this worksheet I solve and plot the solutions both with pdsolve, and with Method of Lines, and of course the two solutions agree.

restart;

 1.  Solving the PDE with Maple's pdsolve

 

Here is how to solve the PDE with Maple's pdsolve.

pde := diff(u(x,t),t) = - diff(u(x,t),x$2) - diff(u(x,t),x$4) - u(x,t)*diff(u(x,t),x);

diff(u(x, t), t) = -(diff(diff(u(x, t), x), x))-(diff(diff(diff(diff(u(x, t), x), x), x), x))-u(x, t)*(diff(u(x, t), x))

ic := u(x,0) = sin(Pi*x/L);

u(x, 0) = sin(Pi*x/L)

bc := u(0,t)=0, D[1,1](u)(0,t)=0, u(L,t)=0, D[1,1](u)(L,t)=0;

u(0, t) = 0, (D[1, 1](u))(0, t) = 0, u(L, t) = 0, (D[1, 1](u))(L, t) = 0

pdsol := pdsolve(pde, eval({ic,bc}, L=1), numeric, spacestep=0.01);

_m140335696338400

pdsol:-plot3d(t=0..0.020);

 

 

 2.  Solving the PDE with the Method of Lines

 

We divide the interval [0, L] into n >= 4equal subintervals and write h = L/n

for the length of each subinterval.  Let x__i = ih, i = 0 .. n be the coordinates

of the endpoints (the nodes) of the intervals .  Note that there are
n+1 nodes altogether, with nodes 0 and n on the boundary, and nodes
1 through n-1 in the interior.  In my comments below, I write u_x
for the derivative of u(x, t) with respect to "x."

 

The finite difference discretizations seen below are pretty standard

in numerical analysis.

# discretize u_x, i=1,..,n-1
d1 := add([-1,0,1] *~ [u[i+k](t) $k=-1..1])/(2*h);

(1/2)*(-u[i-1](t)+u[i+1](t))/h

# discretize u_xx, i=1,..,n-1
d2 := add([1,-2,1] *~ [u[i+k](t) $k=-1..1])/h^2;

(u[i-1](t)-2*u[i](t)+u[i+1](t))/h^2

# discretize u_xx at i=0
d2_left := add([2,-5,4,-1] *~ [u[k](t) $k=0..3])/h^2;

(2*u[0](t)-5*u[1](t)+4*u[2](t)-u[3](t))/h^2

# discretize u_xx at i=n
d2_right := add([-1,4,-5,2] *~ [u[n+k](t) $k=-3..0])/h^2;

(-u[n-3](t)+4*u[n-2](t)-5*u[n-1](t)+2*u[n](t))/h^2

# discretize u_xxxx, i=2,..,n-2
d4 := add([1,-4,6,-4,1] *~ [u[i+k](t) $k=-2..2])/h^4;

(u[i-2](t)-4*u[i-1](t)+6*u[i](t)-4*u[i+1](t)+u[i+2](t))/h^4

# the discretized PDE at any i=2..n-2
eq__i := diff(u[i](t),t) = - d2 - d4 - u[i](t)*d1;  

diff(u[i](t), t) = -(u[i-1](t)-2*u[i](t)+u[i+1](t))/h^2-(u[i-2](t)-4*u[i-1](t)+6*u[i](t)-4*u[i+1](t)+u[i+2](t))/h^4-(1/2)*u[i](t)*(-u[i-1](t)+u[i+1](t))/h

Boundary conditions at the left end are u=0 and u_xx=0.
These determine u[0] and u[1] in terms of u[2] and u[3].

u[0](t)=0, d2_left = 0:
bc_left := solve({%}, {u[0](t), u[1](t)});

{u[0](t) = 0, u[1](t) = (4/5)*u[2](t)-(1/5)*u[3](t)}

Boundary conditions at the right end are u=0 and u_xx=0.
These determine u[n-1] and u[n] in terms of u[n-2] and u[n-3].

u[n](t)=0, d2_right = 0:
bc_right := solve({%}, {u[n-1](t), u[n](t)});

{u[n](t) = 0, u[n-1](t) = -(1/5)*u[n-3](t)+(4/5)*u[n-2](t)}

We pick a reasonable n and generate the system of ODEs

n := 15:
L := 1:
h := L/n:
T := 0.02:   # solution will be computed on the time interval 0..T
sys := { seq(eq__i, i=2..n-2) } union bc_left union bc_right:

and here are the corresponding initial conditions

IC := {seq(u[i](0)=eval(rhs(ic), x=i*h), i=2..n-2)}:

At this point, the PDE has been converted into a system of n+1 ODEs

in n+1 unknowns.  (That's the purpose of the Methods of Lines.)

We call Maple's dsolve to solve that system.

dsol := dsolve(sys union IC, numeric,
    output=operator, range=0..T, maxfun=0):

Here is the plot of u__5(t)

plots:-odeplot(dsol, [t, u[5](t)]);

This proc plots the solution u(x, t) produced by Method of Lines:

my_plot3d := proc()
  local i, j, V, m:=40, k:= T/m;
  V := Array(0..n, 0..m, datatype=float[8]):
  for i from 0 to m do
    V[0..n,i] := Array([eval('u[j](i*k)' $j=0..n, dsol)]);
  end do;
  plots:-display(GRID(0..L, 0..T, V), labels=['x','t','u'], _rest);
end proc:

Here is what the solution looks like.  Compare to that produced by Maple's pdsolve:

my_plot3d();

 

Download method-of-lines-illustration.mw

 

Here's an alternative to what Carl wrote.  This one avoids implicitplot, and therefore produces crisper graphics.

restart;

with(plots):

with(plottools):

Let's see what the overall picture looks like

display([
  sphere([0,0,0], 4, color=red),
  sphere([-4,0,2], 7, color=blue)
], scaling=constrained, transparency=0.6, labels=[x,y,z], orientation=[180,90,-90]);

Here is a 2D cross sectional diagram

display([
  circle([ 0,0], 4, color=red),
  circle([-4,2], 7, color=blue),
  line([0,0], [-4,2], color="Green", thickness=3)
], scaling=constrained);

The green line segment in the diagram above connects the centers of the

circles and makes an angle of sigma with respect to the vertical axis:

sigma := arctan(4/2);

arctan(2)

If we rotate the above diagram by an angle sigmaso that the green line segment

becomes vertical, the diagram simplifies for subsequent calculations:

display([
  circle([0,0], 4, color=red),
  circle([0,4], 7, color=blue),
  line([0,0], [0, sqrt(2^2+4^2)], color="Green", thickness=3),
  line([0,0], [7*sqrt(15)/8, -17/8], color=red, thickness=3),
  line([0,4], [7*sqrt(15)/8, -17/8], color=blue, thickness=3)
], scaling=constrained, labels=[x,r]);

Write down the equations of the two circles, and then find their intersection points:

x^2+r^2=16, x^2+(r-4)^2=49;
rx := allvalues(solve({%}));

r^2+x^2 = 16, x^2+(r-4)^2 = 49

{r = -17/8, x = (7/8)*15^(1/2)}, {r = -17/8, x = -(7/8)*15^(1/2)}

The angles of the red and blue line segments in the diagram above, relative

to the vertical axis:

alpha := Pi/2 + arctan(  17/8,7*sqrt(15)/8);
beta :=  Pi/2 + arctan(4+17/8,7*sqrt(15)/8);

(1/2)*Pi+arctan((17/105)*15^(1/2))

(1/2)*Pi+arctan((7/15)*15^(1/2))

Now we plot the object in the spherical coordinates:

p1 := display([
  plot3d([4*sin(theta)*cos(phi), 4*sin(theta)*sin(phi), 4*cos(theta)], theta=0..alpha, phi=0..2*Pi),
  plot3d([7*sin(theta)*cos(phi), 7*sin(theta)*sin(phi), 4+7*cos(theta)], theta=beta..Pi, phi=0..2*Pi)
], color=["Red","Green"]);

Restore the original orientation by rotating about the y axis by sigma

plottools:-rotate(p1, sigma, [[0,0,0],[0,1,0]]):
display(%, labels=[x,y,z], scaling=constrained, style=surface, orientation=[-125,75,0]);

 

 

Download mw.mw

Here is a slightly modified and extended version of your worksheet.   The edited parts are in green.
 

restart:

with(PDEtools):

with(LinearAlgebra):

alias(f=f(x,t),g=g(x,t));

f, g

eq1:=diff(f,x)=-I*eta*f +I*exp(-I*t)*g;

diff(f, x) = -I*eta*f+I*exp(-I*t)*g

eq2:=diff(g,x)=-I*eta*g +I*exp(I*t)*f;

diff(g, x) = -I*eta*g+I*exp(I*t)*f

eq3:=diff(f,t)=(I*eta^2-I/2)*f +I*eta*exp(-I*t)*g;

diff(f, t) = (I*eta^2-(1/2)*I)*f+I*eta*exp(-I*t)*g

eq4:=diff(g,t)=(-I*eta^2+I/2)*g +I*eta*exp(I*t)*f;

diff(g, t) = (-I*eta^2+(1/2)*I)*g+I*eta*exp(I*t)*f

#### The solution of (2)-(5) is

#eq5:=f=I*(c1*exp(A)-c2*exp(-A))*exp(-i*t/2);
 eq5:=f=I*(c1*exp(A)-c2*exp(-A))*exp(-I*t/2);  # changed i to I  

f = I*(c1*exp(A)-c2*exp(-A))*exp(-((1/2)*I)*t)

#eq6:=g=(c2*exp(A)-c1*exp(-A))*exp(i*t/2);
 eq6:=g=(c2*exp(A)-c1*exp(-A))*exp(I*t/2);     # changed i to I

g = (c2*exp(A)-c1*exp(-A))*exp(((1/2)*I)*t)

#### where

#c1=sqrt(h-sqrt(h^2-1))/sqrt(h^2-1);c2=sqrt(h+sqrt(h^2-1))/sqrt(h^2-1);A=sqrt(h^2-1)*(x+I*h*t);

# replaced the three semicolons with commas:

vals := c1=sqrt(h-sqrt(h^2-1))/sqrt(h^2-1), c2=sqrt(h+sqrt(h^2-1))/sqrt(h^2-1), A=sqrt(h^2-1)*(x+I*h*t);

c1 = (h-(h^2-1)^(1/2))^(1/2)/(h^2-1)^(1/2), c2 = (h+(h^2-1)^(1/2))^(1/2)/(h^2-1)^(1/2), A = (h^2-1)^(1/2)*(x+I*h*t)

#### How to verify (6) and (7) is the solution of (2)-(5)?

z1 := eval({eq5, eq6}, {vals}):   # plug in the values of c1, c2, A

# Test the proposed solution.  If the test is successful,

# we will get a list of zeros.

z2 := pdetest(z1, [eq1,eq2,eq3,eq4]);

[exp(-((1/2)*I)*t-(h^2-1)^(1/2)*x)*(I*exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)*(h^2-1)^(1/2)-I*exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)-exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)*eta+I*exp(-I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)*(h^2-1)^(1/2)+I*exp(-I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)+exp(-I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)*eta)/(h^2-1)^(1/2), exp(((1/2)*I)*t-(h^2-1)^(1/2)*x)*(I*exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)*eta+exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)*(h^2-1)^(1/2)-I*exp(-I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)*eta+exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)+exp(-I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)*(h^2-1)^(1/2)-exp(-I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2))/(h^2-1)^(1/2), -exp(-((1/2)*I)*t-(h^2-1)^(1/2)*x)*(I*exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)*eta+exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)*(h^2-1)^(1/2)*h-exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)*eta^2-I*exp(-I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)*eta+exp(-I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)*(h^2-1)^(1/2)*h+exp(-I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)*eta^2)/(h^2-1)^(1/2), exp(((1/2)*I)*t-(h^2-1)^(1/2)*x)*(I*exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)*(h^2-1)^(1/2)*h+I*exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)*eta^2+I*exp(-I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)*(h^2-1)^(1/2)*h-I*exp(-I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)*eta^2+exp(2*(h^2-1)^(1/2)*x+I*(h^2-1)^(1/2)*h*t)*(h-(h^2-1)^(1/2))^(1/2)*eta-exp(-I*(h^2-1)^(1/2)*h*t)*(h+(h^2-1)^(1/2))^(1/2)*eta)/(h^2-1)^(1/2)]

# Those expressions are too complicated to see whether
# or not they are zeros.  
We plug in numbers for x, t, eta,
# and h, to see whether at least 
for these numbers we get
# zeros.

evalf(eval(z2, {x=0, t=0, eta=0, h=5}));

[2.886751346*I, 2.886751346, -17.32050808, 17.32050808*I]

# We see that the result is not a list of zeros.  Therefore
# the proposed "solution" is not a solution.

 

 

Download verification-2.mw

 

restart;

eq := x^2/3^2 + y^2/4^2=1;

(1/9)*x^2+(1/16)*y^2 = 1

x(t) = 1/sqrt(coeff(lhs(eq), x, 2))*cos(t);
y(t) = 1/sqrt(coeff(lhs(eq), y, 2))*sin(t);

x(t) = 3*cos(t)

y(t) = 4*sin(t)

 

Here is how to plot a general ellipsoid with semiaxis lengths a, b, c, centered at x0, y0, z0. The variables t and s are the polar and azimuthal angles in spherical coordinates.

restart;
a, b, c, x0, y0, z0 := 2, 3, 1, 10, 11, 12:
plot3d([x0 + a*sin(t)*cos(s), y0 + b*sin(t)*sin(s), z0 + c*cos(t)],
    t=0..Pi, s=0..2*Pi, scaling=constrained, labels=[x,y,z]);

We can read off the y values of the function at 9 points x=-4, -3, ... , 4, 5 (except for x=2) on the graph that you have provided.  To that collection I added estimated values of the function at -4.25 and 5.25, making for a total of eleven (x,y) pairs.  Then we fit the data with a 10th degree polynomial (which has 11 coefficients) and solve for the coefficients.

Note that the graph does not quite look like the given graph.  One reason for that is that in the given graph the coordinates are not spaced uniformly.  For instance, the point with coordinate −5 on the y axis falls where −3 would be.

That said, I agree with Kitonum's recommendation of using splines in such problems.  We are just lucky that a tenth degree polynomial provides a reasonable answer in this particular case.  In general, fitting a single polynomial to arbitrary data will not produce good results.

restart;

f := x -> add(a[i]*x^i, i=0..10);

proc (x) local i; options operator, arrow; add(a[i]*x^i, i = 0 .. 10) end proc

eqns := f(-4.25)= 4, f(-4) = 3, f(-3) = 1, f(-2) = 1, f(-1) = 1,
        f(0) = 0, f(1) = -1, f(3) = -5, f(4) = -5, f(5) = 1, f(5.25)=3:

sol := solve({eqns}):

plot(eval(f(x), sol), x=-4..5.25, gridlines);

 

Download mw.mw

 

First 20 21 22 23 24 25 26 Last Page 22 of 58