Rouben Rostamian

MaplePrimes Activity


These are answers submitted by Rouben Rostamian

 

restart;

with(plots):

We wish to determine the equation of the surface obtained by rotating
 the line C: x = 0, y = z about the line L; y = 0, z = x-1, and plot that surface.

 

We observe that the rotation axis, "L," may be parameterized as
`<,>`(x, 0, x-1) or equivalently
L(t) = `<,>`(0, 0, -1)+u*t, where u = `<,>`(1, 0, 1):

u := < 1, 0, 1 >;
L := t -> <0,0,-1> + u*t;

Vector(3, {(1) = 1, (2) = 0, (3) = 1})

proc (t) options operator, arrow; `<,>`(0, 0, -1)+u*t end proc

Introduce the mutually orthogonal unit vectors v and w, both of which
are also orthogonal to
u:

v := <0,1,0>;

Vector(3, {(1) = 0, (2) = 1, (3) = 0})

LinearAlgebra:-CrossProduct(u,v):
w := %/sqrt(% . %);

Vector(3, {(1) = -(1/2)*sqrt(2), (2) = 0, (3) = (1/2)*sqrt(2)})

Also observe that the line C may be parametrized as

C := s -> <0,s,s>;

proc (s) options operator, arrow; `<,>`(0, s, s) end proc

For any point P on the line C there is a point Q on the line L so that the line segment

PQ is orthogonal to L,  that is, Q is the nearest point on the line L to the point P.

Let P = `<,>`(0, s, s),  and Q = `<,>`(t, 0, t-1)". "We determine Q by asserting that

Q-P is perpendicular to u:

P := <0, s, s>;
Q := <t, 0, t-1>;
(Q - P)^+ . u = 0;
isolate(%, t);
Q := eval(Q, %);

Vector(3, {(1) = 0, (2) = s, (3) = s})

Vector(3, {(1) = t, (2) = 0, (3) = t-1})

2*t-1-s = 0

t = 1/2+(1/2)*s

Vector[column](%id = 36893628651414056100)

As the line C rotates about L, the point P traces a circle about the point Q.

The circle's radius "r, "is the length of PQ:

r := sqrt(simplify((Q - P)^+ . (Q-P)));

(1/2)*(6*s^2+4*s+2)^(1/2)

The entire surface of revolution consists of a family of such circles.  We conclude that

the parametric equation of the surface of revolution is

S := Q + r*(v*cos(q) + w*sin(q));

Vector(3, {(1) = 1/2+(1/2)*s-(1/4)*sqrt(6*s^2+4*s+2)*sin(q)*sqrt(2), (2) = (1/2)*sqrt(6*s^2+4*s+2)*cos(q), (3) = -1/2+(1/2)*s+(1/4)*sqrt(6*s^2+4*s+2)*sin(q)*sqrt(2)})

Plotting

display(
        tubeplot([seq](L(t)), t=-1..2, radius=0.06, color="Red"),   # the line L
        tubeplot([seq](C(s)), s=-2..2, radius=0.06, color="Green"), # the line C
        plot3d(S, s=-2..2, q=-Pi..Pi, color="Gold"),
        scaling=constrained, style=surface, lightmodel=light2);

 

Download surface-of-revolution.mw

 

You are right, the equation has no (real) solutions.

If you were solving that equation by hand, you would square both sides and get

x^2 - 10*x + 1 = -8*x^2 + 9*x - 1

and then solve the quadratic and obtain x = 1/9, 2.  Then you would substitute these into the original equation to check whether they solve the original equation.  If it happens that they don't, they are referred to as spurious solutions and should be thrown out.

In the present case, x = 1/9 and 2 are both spurious.  Ideally Maple should check for that but it doesn't.  Just be aware of the issue and check it yourself.

Your equ4 is
Z1T = ZL*(I1T + I2)/I1T

which is equivalent to 

Z1T*I1T = ZL*(I1T + I2)

The left-hand side of that equation is the product of two of your unknowns:

vars_unknown := [V1, I1T, V1T, Z1, Z1T]

and therefore your system of equations is nonlinear.  It's no wonder that 
LinearAlgebra:-GenerateMatrix produces nonsense.

It seems that you believe that the system of equations should be linear.  If so, then you must have entered some of the equations incorrectly.  Check!

After you calculate your w, do:

latex(w);

That produces a latex code for your expression.  Copy and paste that code into your latex document.

If that does not answer your question, be sure to upload your worksheet so that we can see what you see.

I will show you how to solve the problem if we are looking for a quadratic (2nd degree) polynomial that goes through three prescribed points.  I leave it to you to adapt it to the case of a cubic (3rd degree) polynomial that goes through four prescribed points.

restart;

Want to fund a quadratic function f as in:

f := x -> a[2]*x^2 + a[1]*x + a[0];

proc (x) options operator, arrow; a[2]*x^2+a[1]*x+a[0] end proc

so that it fits the following data:

eqns := { f(-2) = -5, f(1) = 1, f(4) = 61 };

{a[2]+a[1]+a[0] = 1, 4*a[2]-2*a[1]+a[0] = -5, 16*a[2]+4*a[1]+a[0] = 61}

Solve that system of equations to get the quadratic's coefficients:

the_coeffs := solve(eqns);

{a[0] = -7, a[1] = 5, a[2] = 3}

Substitute the calculated coefficients into the quadratic's formula

to see what it looks like:

y = eval(f(x), the_coeffs);

y = 3*x^2+5*x-7

Download quadratic-fit.mw

You will find that in the Common Symbols palette, fourth row, fourth column.

In your failed version you attempt to solve three equations for two unknowns.  That's not good.  What you want is to solve your three equations for three unknowns, as in:

solve({I__cm = m*r^2, r*T = I__cm*a/r, g*m - T = m*a}, {T, a, I__cm});

 

This ought to do it:

p := v -> R*T/(v-b) - a/v^2;
numer(p(v)) = 0;

The result is -R*T*v^2 - a*b + a*v = 0, which quadratic in v.  There is no v^3 term.

A couple of errors:

  1. In your equations you have variables named mu and mu[1].  That's bad.  One equation declares mu as a scalar, the other makes it an array.  Hence the confusion.  If you want a subscripted mu1, write it as mu__1 (note the two underscore characters!) not mu[1].  That will not conflict with the variable named mu.
  2. Your equations involve a variable T.  It needs to be assigned a numerical value.

A general adivse:  You have:

dsn := dsolve(eval({eqn1, eqn2, eqn3, eqn4, i(0) = 11437, r(0) = 1077, s(0) = 1770000, t(0) = 1087}), {i(t), r(t), s(t), t(t)}, numeric)

Aren't you interested in seeing the system of equations that you are passing to dsolve() to solve?  In general, you should be.  So define:

sys := eval({eqn1, eqn2, eqn3, eqn4, i(0) = 11437, r(0) = 1077, s(0) = 1770000, t(0) = 1087}), {i(t), r(t), s(t), t(t)};

and then examine sys to make sure that what you are passing to dsolve() is what you really mean, and only then do:

dsolve(sys, numeric);

 

Let's say you have y = f(x) for some function f.  Then dy / dx = f '(x) is a (trivial) differential equation which has y = f(x) as a solution.  You don't need Maple to tell you that.

For instance, if y = cos (x),  then dy/dx = − sin (x) meets your requirements.

I had noted earlier that it would be possible to solve your system of equations through the method of lines.  Now I have worked out the details.  See if this worksheet makes sense.

restart;

with(plots):

The PDEs

 

I have changed the notation somewhat in order to get consistency

across the board.  Here are the changes:
 
"xi -> x  tau -> t  phi -> eta  Theta -> theta   Phi -> phi  "
I solve the system in the spatial range 0 < x and x < L.  Furthermore, I have changed
the forcing term v(0, L) = cos(omega*t) to v(0, L) = sin(omega*t) so that at t = 0 it

matches the initial condition v(x, 0) = 0.  

The PDEs are given as equ1, equ2, equ3:

equ1 := diff(v(x,t),t) = phi__7*diff(v(x,t),x$2) + phi__7*diff(v(x,t),t,x$2) - phi__8*M*v(x,t) + phi__9*Gr*theta(x,t) + phi__10*Gm*phi(x,t);
equ2 := diff(theta(x,t),t) = lambda__f*diff(v(x,t),x$2)/(Pe*phi__11);
equ3 := diff(phi(x,t),t) = (1-eta)*diff(phi(x,t),x$2)/Sc;

diff(v(x, t), t) = phi__7*(diff(diff(v(x, t), x), x))+phi__7*(diff(diff(diff(v(x, t), t), x), x))-phi__8*M*v(x, t)+phi__9*Gr*theta(x, t)+phi__10*Gm*phi(x, t)

diff(theta(x, t), t) = lambda__f*(diff(diff(v(x, t), x), x))/(Pe*phi__11)

diff(phi(x, t), t) = (1-eta)*(diff(diff(phi(x, t), x), x))/Sc

We are going to solve this system on the interval 0 < x and x < L for a prescribed L 

subject to prescribed initial and boundary conditions

ic_v := v(x,0) = v__0(x);
ic_theta := theta(x,0) = theta__0(x);
ic_phi := phi(x,0) = phi__0(x);
bc_v := v(0,t) = v__left(t), v(L,t) = v__right(t);
bc_theta := theta(0,t) = theta__left(t), theta(L,t) = theta__right(t);
bc_phi := phi(0,t) = phi__left(t), phi(L,t) = phi__right(t);

v(x, 0) = v__0(x)

theta(x, 0) = theta__0(x)

phi(x, 0) = phi__0(x)

v(0, t) = v__left(t), v(L, t) = v__right(t)

theta(0, t) = theta__left(t), theta(L, t) = theta__right(t)

phi(0, t) = phi__left(t), phi(L, t) = phi__right(t)

The system is not a "standard" PDE and it requires a bit of manipulation

to put it in a manageable form.  Toward that end,

we introduce a new variable u through

pde0 := u(x,t) = v(x,t) - phi__7*diff(v(x,t),x$2);

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

or equivalently:

eq := isolate(pde0, diff(v(x,t),x$2));

diff(diff(v(x, t), x), x) = (-u(x, t)+v(x, t))/phi__7

Using the expression above to eliminate the second derivative of v from equ1.  Call the result pde1:

diff(eq, t):
subs(%, equ1):
subs(eq, %):
pde1 := isolate(%, diff(u(x,t),t));

diff(u(x, t), t) = -u(x, t)+v(x, t)-phi__8*M*v(x, t)+phi__9*Gr*theta(x, t)+phi__10*Gm*phi(x, t)

Similarly, eliminate the second derivative of v from equ2.  Call the result pde2:

pde2 := subs(eq, equ2);

diff(theta(x, t), t) = lambda__f*(-u(x, t)+v(x, t))/(phi__7*Pe*phi__11)

Keep equ3 as is.  Call it pde3:

pde3 := equ3;

diff(phi(x, t), t) = (1-eta)*(diff(diff(phi(x, t), x), x))/Sc

Equations pde0, pde1, pde2, pde3 form a system of four PDEs in the
four unknowns u, v, theta, phi.  It's not a standard PDE because pde0 has
no time derivative.

 

Let's observe that the initial condition
on u may be determined from its definition:

ic_u := subs(t=0, diff(ic_v, x$2), ic_v, pde0);

u(x, 0) = v__0(x)-phi__7*(diff(diff(v__0(x), x), x))

 

Discretization through the method of lines

 

We apply the method of lines to solve the PDEs.  Toward that end, we partition the

interval [0, L] into n+1 subintervals of equal lengths h = L/(n+1) through the n+2 
equally-spaced points x__0 = 0, x__1 = h, x__2 = 2*h, () .. (), x__n = nh, `x__n+1` = n+1 and n+1 = Lb.
We discretize the system's unknowns in space, through

"`U__j`(t)=u(`x__j`,t),  `V__j`(t)=v(`x__j`,t),  `Theta__j`(t)=theta(`x__j`,t), "

`&Phi;__j`(t) = phi(x__j, t), j = 0, 1, 2, () .. (), n+1.
Furthermore, we discretize the 2nd order derivatives through centered differences,

as in
"((&PartialD;)^2phi)/((&PartialD;)^( )x^2)(`x__j`,t)&approx;(`Phi__j-1`(t)-2 `Phi__j`(t)+`Phi__j+1`(t))/(h^(2)) ",
and similarly for "((&PartialD;)^2v)/((&PartialD;)^( )x^2)".
Here we fix the value of n and express the PDEs and the initial
and boundary conditions in terms of the discretized variables.
We choose a small n for this demonstration but n will be larger

for practical applications.

n := 8;   # change as needed

8

The initial condition on U:

convert(ic_u, D):
subs(x=h*j, %):
IC_U := seq(U[j](0) = rhs(%), j=1..n);

U[1](0) = v__0(h)-phi__7*((D@@2)(v__0))(h), U[2](0) = v__0(2*h)-phi__7*((D@@2)(v__0))(2*h), U[3](0) = v__0(3*h)-phi__7*((D@@2)(v__0))(3*h), U[4](0) = v__0(4*h)-phi__7*((D@@2)(v__0))(4*h), U[5](0) = v__0(5*h)-phi__7*((D@@2)(v__0))(5*h), U[6](0) = v__0(6*h)-phi__7*((D@@2)(v__0))(6*h), U[7](0) = v__0(7*h)-phi__7*((D@@2)(v__0))(7*h), U[8](0) = v__0(8*h)-phi__7*((D@@2)(v__0))(8*h)

 

These equations involve V__0(t) and `V__n+1`(t) which are known from the boundary conditions,

V[0](t) = subs(bc_v, v__left(t)):
V[n+1](t) = subs(bc_v, v__right(t)):
BC_V := %%, %;

V[0](t) = v__left(t), V[9](t) = v__right(t)

Shortly we will need the boundary conditions on Phi so let's calculate them now:

Phi[0](t) = subs(bc_phi, phi__left(t)):
Phi[n+1](t) = subs(bc_phi, phi__right(t)):
BC_Phi := %%, %;

Phi[0](t) = phi__left(t), Phi[9](t) = phi__right(t)

Now we turn to pde0, pde1, pde2, pde3, and express them in discretized forms:

DE0 := U[j](t) = V[j](t) - phi__7*(V[j-1](t) - 2*V[j](t) + V[j+1](t))/h^2;

U[j](t) = V[j](t)-phi__7*(V[j-1](t)-2*V[j](t)+V[j+1](t))/h^2

DE1 := diff(U[j](t),t) = -U[j](t) + V[j](t) - phi__8*M*V[j](t) + phi__9*Gr*Theta[j](t) + phi__10*Gm*Phi[j](t);

diff(U[j](t), t) = -U[j](t)+V[j](t)-phi__8*M*V[j](t)+phi__9*Gr*Theta[j](t)+phi__10*Gm*Phi[j](t)

DE2 := diff(Theta[j](t),t) = lambda__f/(phi__7*Pe*phi__11)*(-U[j](t) + V[j](t));

diff(Theta[j](t), t) = lambda__f*(-U[j](t)+V[j](t))/(phi__7*Pe*phi__11)

DE3 := diff(Phi[j](t),t) = (1 - sigma)/Sc*(Phi[j-1](t) - 2*Phi[j](t) + Phi[j+1](t))/h^2;

diff(Phi[j](t), t) = (1-sigma)*(Phi[j-1](t)-2*Phi[j](t)+Phi[j+1](t))/(Sc*h^2)

We apply each of DE0 through DE3 at the n interior nodes x__j and thus obtain a system of

4*n equations in the 4*n unknownsU__j, V__j, `&Theta;__j`, `&Phi;__j`.   The system involves the values

of V__j and `&Phi;__j` at the domain's left and right boundaries but we eliminate them through

 substituting their values from the boundary conditions BC_V and BC_Phi.

seq(DE0, j=1..n), seq(DE1, j=1..n), seq(DE2, j=1..n), seq(DE3, j=1..n):
SYS := subs(BC_V, BC_Phi, {%});

{diff(Phi[1](t), t) = (1-sigma)*(phi__left(t)-2*Phi[1](t)+Phi[2](t))/(Sc*h^2), diff(Phi[2](t), t) = (1-sigma)*(Phi[1](t)-2*Phi[2](t)+Phi[3](t))/(Sc*h^2), diff(Phi[3](t), t) = (1-sigma)*(Phi[2](t)-2*Phi[3](t)+Phi[4](t))/(Sc*h^2), diff(Phi[4](t), t) = (1-sigma)*(Phi[3](t)-2*Phi[4](t)+Phi[5](t))/(Sc*h^2), diff(Phi[5](t), t) = (1-sigma)*(Phi[4](t)-2*Phi[5](t)+Phi[6](t))/(Sc*h^2), diff(Phi[6](t), t) = (1-sigma)*(Phi[5](t)-2*Phi[6](t)+Phi[7](t))/(Sc*h^2), diff(Phi[7](t), t) = (1-sigma)*(Phi[6](t)-2*Phi[7](t)+Phi[8](t))/(Sc*h^2), diff(Phi[8](t), t) = (1-sigma)*(Phi[7](t)-2*Phi[8](t)+phi__right(t))/(Sc*h^2), diff(Theta[1](t), t) = lambda__f*(-U[1](t)+V[1](t))/(phi__7*Pe*phi__11), diff(Theta[2](t), t) = lambda__f*(-U[2](t)+V[2](t))/(phi__7*Pe*phi__11), diff(Theta[3](t), t) = lambda__f*(-U[3](t)+V[3](t))/(phi__7*Pe*phi__11), diff(Theta[4](t), t) = lambda__f*(-U[4](t)+V[4](t))/(phi__7*Pe*phi__11), diff(Theta[5](t), t) = lambda__f*(-U[5](t)+V[5](t))/(phi__7*Pe*phi__11), diff(Theta[6](t), t) = lambda__f*(-U[6](t)+V[6](t))/(phi__7*Pe*phi__11), diff(Theta[7](t), t) = lambda__f*(-U[7](t)+V[7](t))/(phi__7*Pe*phi__11), diff(Theta[8](t), t) = lambda__f*(-U[8](t)+V[8](t))/(phi__7*Pe*phi__11), diff(U[1](t), t) = -U[1](t)+V[1](t)-phi__8*M*V[1](t)+phi__9*Gr*Theta[1](t)+phi__10*Gm*Phi[1](t), diff(U[2](t), t) = -U[2](t)+V[2](t)-phi__8*M*V[2](t)+phi__9*Gr*Theta[2](t)+phi__10*Gm*Phi[2](t), diff(U[3](t), t) = -U[3](t)+V[3](t)-phi__8*M*V[3](t)+phi__9*Gr*Theta[3](t)+phi__10*Gm*Phi[3](t), diff(U[4](t), t) = -U[4](t)+V[4](t)-phi__8*M*V[4](t)+phi__9*Gr*Theta[4](t)+phi__10*Gm*Phi[4](t), diff(U[5](t), t) = -U[5](t)+V[5](t)-phi__8*M*V[5](t)+phi__9*Gr*Theta[5](t)+phi__10*Gm*Phi[5](t), diff(U[6](t), t) = -U[6](t)+V[6](t)-phi__8*M*V[6](t)+phi__9*Gr*Theta[6](t)+phi__10*Gm*Phi[6](t), diff(U[7](t), t) = -U[7](t)+V[7](t)-phi__8*M*V[7](t)+phi__9*Gr*Theta[7](t)+phi__10*Gm*Phi[7](t), diff(U[8](t), t) = -U[8](t)+V[8](t)-phi__8*M*V[8](t)+phi__9*Gr*Theta[8](t)+phi__10*Gm*Phi[8](t), U[1](t) = V[1](t)-phi__7*(v__left(t)-2*V[1](t)+V[2](t))/h^2, U[2](t) = V[2](t)-phi__7*(V[1](t)-2*V[2](t)+V[3](t))/h^2, U[3](t) = V[3](t)-phi__7*(V[2](t)-2*V[3](t)+V[4](t))/h^2, U[4](t) = V[4](t)-phi__7*(V[3](t)-2*V[4](t)+V[5](t))/h^2, U[5](t) = V[5](t)-phi__7*(V[4](t)-2*V[5](t)+V[6](t))/h^2, U[6](t) = V[6](t)-phi__7*(V[5](t)-2*V[6](t)+V[7](t))/h^2, U[7](t) = V[7](t)-phi__7*(V[6](t)-2*V[7](t)+V[8](t))/h^2, U[8](t) = V[8](t)-phi__7*(V[7](t)-2*V[8](t)+v__right(t))/h^2}

The SYS computed above is a system of linear first order DAEs (Differential-Algebraic Equations)
 in the 4*n unknowns "`U__j`, `V__j`, `Theta__j`,`Phi__j`, j=1,2,...,n."  These are DAEs because the

unknowns V__j  appear algebraically only; there are no derivatives of V__j.  

indets(SYS, function);

{diff(Phi[1](t), t), diff(Phi[2](t), t), diff(Phi[3](t), t), diff(Phi[4](t), t), diff(Phi[5](t), t), diff(Phi[6](t), t), diff(Phi[7](t), t), diff(Phi[8](t), t), diff(Theta[1](t), t), diff(Theta[2](t), t), diff(Theta[3](t), t), diff(Theta[4](t), t), diff(Theta[5](t), t), diff(Theta[6](t), t), diff(Theta[7](t), t), diff(Theta[8](t), t), diff(U[1](t), t), diff(U[2](t), t), diff(U[3](t), t), diff(U[4](t), t), diff(U[5](t), t), diff(U[6](t), t), diff(U[7](t), t), diff(U[8](t), t), v__left(t), phi__left(t), phi__right(t), v__right(t), Phi[1](t), Phi[2](t), Phi[3](t), Phi[4](t), Phi[5](t), Phi[6](t), Phi[7](t), Phi[8](t), Theta[1](t), Theta[2](t), Theta[3](t), Theta[4](t), Theta[5](t), Theta[6](t), Theta[7](t), Theta[8](t), U[1](t), U[2](t), U[3](t), U[4](t), U[5](t), U[6](t), U[7](t), U[8](t), V[1](t), V[2](t), V[3](t), V[4](t), V[5](t), V[6](t), V[7](t), V[8](t)}

The system of DAEs may be solved by applying the initial conditions IC_U
calculated earlier, and the initial conditions IC_Theta and IC_Phi which we calculate now:

subs(x=h*j, ic_theta):
IC_Theta := seq(Theta[j](0) = rhs(%), j=1..n);

Theta[1](0) = theta__0(h), Theta[2](0) = theta__0(2*h), Theta[3](0) = theta__0(3*h), Theta[4](0) = theta__0(4*h), Theta[5](0) = theta__0(5*h), Theta[6](0) = theta__0(6*h), Theta[7](0) = theta__0(7*h), Theta[8](0) = theta__0(8*h)

subs(x=h*j, ic_phi):
IC_Phi := seq(Phi[j](0) = rhs(%), j=1..n);

Phi[1](0) = phi__0(h), Phi[2](0) = phi__0(2*h), Phi[3](0) = phi__0(3*h), Phi[4](0) = phi__0(4*h), Phi[5](0) = phi__0(5*h), Phi[6](0) = phi__0(6*h), Phi[7](0) = phi__0(7*h), Phi[8](0) = phi__0(8*h)

The overall initial conditions are:

IC := { IC_U, IC_Theta, IC_Phi };

{Phi[1](0) = phi__0(h), Phi[2](0) = phi__0(2*h), Phi[3](0) = phi__0(3*h), Phi[4](0) = phi__0(4*h), Phi[5](0) = phi__0(5*h), Phi[6](0) = phi__0(6*h), Phi[7](0) = phi__0(7*h), Phi[8](0) = phi__0(8*h), Theta[1](0) = theta__0(h), Theta[2](0) = theta__0(2*h), Theta[3](0) = theta__0(3*h), Theta[4](0) = theta__0(4*h), Theta[5](0) = theta__0(5*h), Theta[6](0) = theta__0(6*h), Theta[7](0) = theta__0(7*h), Theta[8](0) = theta__0(8*h), U[1](0) = v__0(h)-phi__7*((D@@2)(v__0))(h), U[2](0) = v__0(2*h)-phi__7*((D@@2)(v__0))(2*h), U[3](0) = v__0(3*h)-phi__7*((D@@2)(v__0))(3*h), U[4](0) = v__0(4*h)-phi__7*((D@@2)(v__0))(4*h), U[5](0) = v__0(5*h)-phi__7*((D@@2)(v__0))(5*h), U[6](0) = v__0(6*h)-phi__7*((D@@2)(v__0))(6*h), U[7](0) = v__0(7*h)-phi__7*((D@@2)(v__0))(7*h), U[8](0) = v__0(8*h)-phi__7*((D@@2)(v__0))(8*h)}

 

Numerics

 

Here are the parameters/coefficients/functions that define the problem:

params :=

h = L/(n+1),
L = 10,

v__0 = (x -> 0),
theta__0 = (x -> 0),
phi__0 = (x -> 0),

v__left = (t -> 0),
theta__left = (t -> 0),
phi__left = (t -> 0),

v__right = (t -> sin(omega*t)),
theta__right = (t -> 1),
phi__right = (t -> 1),

phi__11 = 1 - eta + eta*rho__s*c__ps/(rho__f*c__pf),
phi__10 = phi__4/phi__1,
phi__9 = phi__3/phi__1,
phi__8 = phi__2/phi__1,
phi__7 = phi__6/(1 + lambda__1),
phi__6 = phi__5/(phi__1*Ra),
phi__5 = 1/(1 - eta)^2.5,
phi__4 = 1 - eta + eta*rho__s*beta__Cs/(rho__f*beta__Cf),
phi__3 = 1 - eta + eta*rho__s*beta__Ts/(rho__f*beta__Tf),
phi__2 = 1 + 3*(sigma - 1)*eta/(sigma + 2 - (sigma - 1)*eta),
phi__1 = 1 - eta + eta*rho__s/rho__f,

lambda__f = k__nf/k__f,
k__nf = (k__s + 2*k__f + 2*eta*(k__s - k__f))/(k__s + 2*k__f - eta*(k__s - k__f)),
lambda__f = k__nf/k__f,
a__0 = Pe*phi__11/lambda__f,
a__1 = Sc/(1 - eta),

M = 0.3,
Gr = 5,
Gm = 0.3,
Pe = 0.2,
Sc = 0.2,
Ra = 1,
lambda__1 = 0.5,
omega = 1,

rho__f = 5610,
rho__s = 2300,
c__pf = 0.880,
c__ps = 41.086,
beta__Tf = 0.0000125,
beta__Ts = 0.0000157,
beta__Cf = 0.0000125,
beta__Cs = 0.0000157,
eta = 0.02,
k__f = 1.046,
k__s = 1.160,
sigma = 0.2,

NULL:

Maple's dsolve() function is capable of solving DAEs.  Here is our solution:

eval(subs(params, SYS union IC)):
dsol := dsolve(%, numeric, output=operator, maxfun=0):

Let's plot a few samples:

odeplot(dsol, [t,U[3](t)], t=0..2*Pi);

odeplot(dsol, [t,V[3](t)], t=0..2*Pi);

odeplot(dsol, [t,Theta[3](t)], t=0..2*Pi);

odeplot(dsol, [t,Phi[3](t)], t=0..2*Pi);

 

 

Plotting in 3D

 

We wish to plot the solution v(x, t) over the domain

0 < x and x < L, 0 < t and t < T.  For the plotting grid, we take

the x__i = i*h, i = 0, 1, () .. (), n+1,   as we have done already,

and t__j = k*h, j = 0, 1, () .. (), m, where m is specified as desired,

and k = T/m.  Thus, the solution is represented as a grid
of points "(`x__i` , `t__j` , v(`x__i` , `t__j`))," that is, "(`x__i` , `t__j` , `V__i` (`t__j`)), "in 3D.  
The solutions  Theta(x, t) and Phi(x, t) are plotted in the same way.

 

A detail that needs toNULL be taken care of is that the solution

of the DAEs accounts for the interior nodes

i = 1, 2, () .. (), nonly.  The values of the solution corresponding to

the boundary nodes, that is, V__0(t), `V__n+1`(t), etc., are not

included in the solution of the DAE and need to be evaluated

separately through the prescribed boundary conditions.  These are:

V[0] := subs(params, v__left);
V[n+1] := subs(params, v__right);
Theta[0] := subs(params, theta__left);
Theta[n+1] := subs(params, theta__right);
Phi[0] := subs(params, phi__left);
Phi[n+1] := subs(params, phi__right);

proc (t) options operator, arrow; 0 end proc

proc (t) options operator, arrow; sin(t) end proc

proc (t) options operator, arrow; 0 end proc

proc (t) options operator, arrow; 1 end proc

proc (t) options operator, arrow; 0 end proc

proc (t) options operator, arrow; 1 end proc

Here is a proc for plotting the solution Q of the DAEs where Q is one of V, Theta, Phi.
over the domain 0 < x and x < L, 0 < t and t < T, and where m is the number of

time steps.

my_plot3d := proc(Q, T, m)
  local i, j, A, k:= T/m, L := subs(params, :-L);
  A := Array(0..n+1, 0..m, (i,j)->eval(Q[i](j*k), dsol), datatype=float[8]):
  plots:-display(GRID(0..L, 0..T, A), labels=[x,t,Q(x,t)], _rest);
end proc:

The solution v(x, t)

my_plot3d(V, 2*Pi, 20);

The solution theta(x, t):

my_plot3d(Theta, 2*Pi, 20);

The solution phi(x, t):

my_plot3d(Phi, 2*Pi, 20);

 

 

Download method-of-lines-and-DAEs.mw

 

It works if you place h(p) in quotes.  I don't know why.

plot('h(p)', p=-1..1);

Added later:

Doing

showstat(MapleTA:-Builtin:-inverf)

we see that inverf() is defined as:

inverf := proc(z::Range(0,1)) ...

and therefore it accepts only numerical arguments in the range (0,1).  In particular, inverf(p) is not accepted if p is an unassigned symbol.  That's bad.  A better-designed inverf() would have returned inverf(p) (unevaluated) for such a p, and that would have made the quotation marks in the plot() command unnecessary.

In this worksheet I show how to calculate the Christoffel symbols for a two-dimensional manifold, that is, a surface embedded in 3D.

Christoffel symbols of a parametrized surface

restart;

Receives a metric tensor gNULLas a 2*2 matrix in the variables u and v.

Returns the Christoffel tensor `&Gamma;__ij`^k which is represented as

Gamma[k][i,j] in Maple.

 

The names g, u, v, GAMMA are not hard-coded.  They can be anything.

Christoffel := proc(g::Matrix(2,2), u::assignable, v::assignable)
        local U, G, C, i, j, k, l;
        U[1], U[2] := u, v;
        G := g^(-1);
        for i from 1 to 2 do
                for j from 1 to 2 do
                        for l from 1 to 2 do
                                C[l][i,j] := 1/2*add(G[k,l]*(diff(g[i,k], U[j]) - diff(g[i,j], U[k]) + diff(g[k,j], U[i])), k=1..2);
                        end do;
                end do;
        end do;
        return C;
end proc:

 

Examples of use

 

The monkey saddle

 

S := <x, y, x^3 - 3*x*y^2 > ;

Vector(3, {(1) = x, (2) = y, (3) = x^3-3*x*y^2})

plot3d(S, x=-1..1, y=-1..1);

X[1] := diff(S, x):
X[2] := diff(S, y):
g := simplify(Matrix(2,2, (i,j) -> X[i]^+ . X[j]));

Matrix(2, 2, {(1, 1) = 9*x^4-18*x^2*y^2+9*y^4+1, (1, 2) = -18*x^3*y+18*x*y^3, (2, 1) = -18*x^3*y+18*x*y^3, (2, 2) = 36*x^2*y^2+1})

Gamma := Christoffel(g, x, y):

Here are the 8 components of `&Gamma;__ij`^k:NULL

simplify([Gamma[1][1,1], Gamma[1][1,2], Gamma[1][2,1], Gamma[1][2,2]]);
simplify([Gamma[2][1,1], Gamma[2][1,2], Gamma[2][2,1], Gamma[2][2,2]]);

[(18*x^3-18*x*y^2)/(9*x^4+18*x^2*y^2+9*y^4+1), (-18*x^2*y+18*y^3)/(9*x^4+18*x^2*y^2+9*y^4+1), (-18*x^2*y+18*y^3)/(9*x^4+18*x^2*y^2+9*y^4+1), (-18*x^3+18*x*y^2)/(9*x^4+18*x^2*y^2+9*y^4+1)]

[-36*x^2*y/(9*x^4+18*x^2*y^2+9*y^4+1), 36*x*y^2/(9*x^4+18*x^2*y^2+9*y^4+1), 36*x*y^2/(9*x^4+18*x^2*y^2+9*y^4+1), 36*x^2*y/(9*x^4+18*x^2*y^2+9*y^4+1)]

A helicoid

 

S := < s*cos(t), s*sin(t), t/4>;

Vector(3, {(1) = s*cos(t), (2) = s*sin(t), (3) = (1/4)*t})

plot3d(S, t=0..4*Pi, s=0..1, grid=[80,8]);

X[1] := diff(S,t):
X[2] := diff(S,s):
g := simplify(Matrix(2,2, (i,j) -> X[i]^+ . X[j]));

Matrix(2, 2, {(1, 1) = s^2+1/16, (1, 2) = 0, (2, 1) = 0, (2, 2) = 1})

Here we write K for the Christoffel symbols instead of the usual GAMMA to show that

the name GAMMA is not special:

K := Christoffel(g, t, s):

K[1][1,1], K[1][1,2], K[1][2,1], K[1][2,2];
K[2][1,1], K[2][1,2], K[2][2,1], K[2][2,2];

0, s/(s^2+1/16), s/(s^2+1/16), 0

-s, 0, 0, 0

A torus

 

S := < (a + b*cos(v))*cos(u), (a + b*cos(v))*sin(u), b*sin(v) >;

Vector(3, {(1) = (a+b*cos(v))*cos(u), (2) = (a+b*cos(v))*sin(u), (3) = b*sin(v)})

plot3d(subs(a=5, b=2, S), u=-Pi..Pi, v=-Pi..Pi, scaling=constrained);

X[1] := diff(S,u):
X[2] := diff(S,v):
g := simplify(Matrix(2,2, (i,j) -> X[i]^+ . X[j]));

Matrix(2, 2, {(1, 1) = (a+b*cos(v))^2, (1, 2) = 0, (2, 1) = 0, (2, 2) = b^2})

Gamma := Christoffel(g, u, v):

Gamma[1][1,1], Gamma[1][1,2], Gamma[1][2,1], Gamma[1][2,2];
Gamma[2][1,1], Gamma[2][1,2], Gamma[2][2,1], Gamma[2][2,2];

0, -b*sin(v)/(a+b*cos(v)), -b*sin(v)/(a+b*cos(v)), 0

(a+b*cos(v))*sin(v)/b, 0, 0, 0

A generic metric tensor

 

g := < a(u,v), b(u,v); b(u,v), c(u,v) >;

Matrix(2, 2, {(1, 1) = a(u, v), (1, 2) = b(u, v), (2, 1) = b(u, v), (2, 2) = c(u, v)})

Gamma := Christoffel(g, u, v):

simplify([Gamma[1][1,1], Gamma[1][1,2], Gamma[1][2,1], Gamma[1][2,2]]);
simplify([Gamma[2][1,1], Gamma[2][1,2], Gamma[2][2,1], Gamma[2][2,2]]);

[(c(u, v)*(diff(a(u, v), u))+b(u, v)*(diff(a(u, v), v)-2*(diff(b(u, v), u))))/(2*a(u, v)*c(u, v)-2*b(u, v)^2), (-b(u, v)*(diff(c(u, v), u))+c(u, v)*(diff(a(u, v), v)))/(2*a(u, v)*c(u, v)-2*b(u, v)^2), (-b(u, v)*(diff(c(u, v), u))+c(u, v)*(diff(a(u, v), v)))/(2*a(u, v)*c(u, v)-2*b(u, v)^2), (c(u, v)*(2*(diff(b(u, v), v))-(diff(c(u, v), u)))-b(u, v)*(diff(c(u, v), v)))/(2*a(u, v)*c(u, v)-2*b(u, v)^2)]

[(-b(u, v)*(diff(a(u, v), u))-a(u, v)*(diff(a(u, v), v)-2*(diff(b(u, v), u))))/(2*a(u, v)*c(u, v)-2*b(u, v)^2), (b(u, v)*(diff(a(u, v), v))-a(u, v)*(diff(c(u, v), u)))/(2*b(u, v)^2-2*a(u, v)*c(u, v)), (b(u, v)*(diff(a(u, v), v))-a(u, v)*(diff(c(u, v), u)))/(2*b(u, v)^2-2*a(u, v)*c(u, v)), ((-2*(diff(b(u, v), v))+diff(c(u, v), u))*b(u, v)+a(u, v)*(diff(c(u, v), v)))/(2*a(u, v)*c(u, v)-2*b(u, v)^2)]

A generic parametric surface

 

S := < alpha(s,t), beta(s,t), gamma(s,t) >;

Vector(3, {(1) = alpha(s, t), (2) = beta(s, t), (3) = gamma(s, t)})

X[1] := diff(S,s):
X[2] := diff(S,t):
g := simplify(Matrix(2,2, (i,j) -> X[i]^+ . X[j]));

Matrix(2, 2, {(1, 1) = (diff(alpha(s, t), s))^2+(diff(beta(s, t), s))^2, (1, 2) = (diff(alpha(s, t), s))*(diff(alpha(s, t), t))+(diff(beta(s, t), s))*(diff(beta(s, t), t)), (2, 1) = (diff(alpha(s, t), s))*(diff(alpha(s, t), t))+(diff(beta(s, t), s))*(diff(beta(s, t), t)), (2, 2) = (diff(alpha(s, t), t))^2+(diff(beta(s, t), t))^2})

Gamma := Christoffel(g, s, t):

simplify([Gamma[1][1,1], Gamma[1][1,2], Gamma[1][2,1], Gamma[1][2,2]]);
simplify([Gamma[2][1,1], Gamma[2][1,2], Gamma[2][2,1], Gamma[2][2,2]]);

[((diff(diff(alpha(s, t), s), s))*(diff(beta(s, t), t))-(diff(diff(beta(s, t), s), s))*(diff(alpha(s, t), t)))/((diff(alpha(s, t), s))*(diff(beta(s, t), t))-(diff(alpha(s, t), t))*(diff(beta(s, t), s))), ((diff(diff(alpha(s, t), s), t))*(diff(beta(s, t), t))-(diff(diff(beta(s, t), s), t))*(diff(alpha(s, t), t)))/((diff(alpha(s, t), s))*(diff(beta(s, t), t))-(diff(alpha(s, t), t))*(diff(beta(s, t), s))), ((diff(diff(alpha(s, t), s), t))*(diff(beta(s, t), t))-(diff(diff(beta(s, t), s), t))*(diff(alpha(s, t), t)))/((diff(alpha(s, t), s))*(diff(beta(s, t), t))-(diff(alpha(s, t), t))*(diff(beta(s, t), s))), ((diff(diff(alpha(s, t), t), t))*(diff(beta(s, t), t))-(diff(diff(beta(s, t), t), t))*(diff(alpha(s, t), t)))/((diff(alpha(s, t), s))*(diff(beta(s, t), t))-(diff(alpha(s, t), t))*(diff(beta(s, t), s)))]

[(-(diff(diff(alpha(s, t), s), s))*(diff(beta(s, t), s))+(diff(diff(beta(s, t), s), s))*(diff(alpha(s, t), s)))/((diff(alpha(s, t), s))*(diff(beta(s, t), t))-(diff(alpha(s, t), t))*(diff(beta(s, t), s))), (-(diff(diff(alpha(s, t), s), t))*(diff(beta(s, t), s))+(diff(diff(beta(s, t), s), t))*(diff(alpha(s, t), s)))/((diff(alpha(s, t), s))*(diff(beta(s, t), t))-(diff(alpha(s, t), t))*(diff(beta(s, t), s))), (-(diff(diff(alpha(s, t), s), t))*(diff(beta(s, t), s))+(diff(diff(beta(s, t), s), t))*(diff(alpha(s, t), s)))/((diff(alpha(s, t), s))*(diff(beta(s, t), t))-(diff(alpha(s, t), t))*(diff(beta(s, t), s))), (-(diff(diff(alpha(s, t), t), t))*(diff(beta(s, t), s))+(diff(diff(beta(s, t), t), t))*(diff(alpha(s, t), s)))/((diff(alpha(s, t), s))*(diff(beta(s, t), t))-(diff(alpha(s, t), t))*(diff(beta(s, t), s)))]

 

 

Download christoffel-symbols.mw

 

If you want your plot to appear in a separate window, do one or the other of the following options;

# plot in a separate window
plotsetup(window);
plot(x^2, x=-1..1);

# plot as a maplet
plotsetup(maplet);
plot(x^2, x=-1..1);

# restore the default (inline) plotting mode
plotsetup(default);
plot(x^2, x=-1..1);

 

 

restart;

n := 5;

5

LinearAlgebra:-BandMatrix([-1, 2, -1], 1, n);

Matrix(5, 5, {(1, 1) = 2, (1, 2) = -1, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (2, 1) = -1, (2, 2) = 2, (2, 3) = -1, (2, 4) = 0, (2, 5) = 0, (3, 1) = 0, (3, 2) = -1, (3, 3) = 2, (3, 4) = -1, (3, 5) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = -1, (4, 4) = 2, (4, 5) = -1, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = -1, (5, 5) = 2})

Download mw.mw

First 7 8 9 10 11 12 13 Last Page 9 of 58