Rouben Rostamian

MaplePrimes Activity


These are answers submitted by Rouben Rostamian

I assume that the first r2 in your equation is meant to be r1.

If so, then the data is inconsistent since for all x and y, the left-hand side of the equation is always greater than the right-hand side, and therefore the equality cannot hold.

You can see that in the picture below where I plot the equation's left- and right-hand sides for a range and x and y.

restart;
eq := (m1 + m2)*(x^2+y^2) + 2*m1/r1 + 2*m2/r2 = c;
EQ := subs(
  r1 = sqrt((x-d1)^2 + y^2 + z^2),
  r2 = sqrt((x-d2)^2 + y^2 + z^2),
  d1 = 0.6, d2 = 0.4,
  m1 = 10, m2 = 2, c = 20,
  z = 0,
eq);
plot3d([rhs(EQ),lhs(EQ)], x=-1..2, y=-1..1,
    numpoints=1000, view=0..300, color=[gold, cyan], style=patchcontour);

Depending on the way you want to use the indices, this alternative to Carl Love's suggestion may also be useful:

op(node[2,3,5]);

which yields 2, 3, 5.

It is possible to plot those curves through solving differential equations.but that's too much work for little gain.  Maple's contourplot function is much more effective for that purpose.  Here is how to produce the curves at the bottom of that website:

restart;
with(plots):
# Some judicious selection of contour levels:
levels1 := [ i^2 $i=0..6 ] /~ 5 +~ 1;
levels2 := i/10 $i=1..9;
levels := [levels1[], levels2[]];
display(
    contourplot(exp(y^2)*cos(x)^2, x=-Pi..Pi, y=-2..2, contours=levels),
    contourplot(y*sin(x), x=-Pi..Pi, y=-2..2, contours=11,
        filledregions=true, coloring=[red,yellow]),
    scaling=constrained, axes=none);

Download worksheet: mw.mw

restart;
with(plots):
with(LinearAlgebra):
f := x -> x^2/2 - 1;
g := x -> 2 - x^2/4;

F := <f(x), x*cos(t), x*sin(t) >;

S1 := plot3d(F, x=-2..2, t=0..2*Pi, color="Orange"):

F, 1.5*Normalize(diff(F,x), 2):
eval(%, {x=2,t=Pi}):
A1 := arrow(%, color=red):

F, 1.5*Normalize(diff(F,t), 2):
eval(%, {x=2,t=Pi}):
A2 := arrow(%, color=red):

G := < g(x), x*cos(t), x*sin(t) >;

S2 := plot3d(G, x=-2..2, t=0..2*Pi, color="Cyan"):

G, 1.5*Normalize(diff(G,x), 2):
eval(%, {x=2,t=Pi}):
A3 := arrow(%, color=red):

eval(F, t=0):
convert(%, list):
T1 := tubeplot(%, x=-2..2, radius=0.05, style=surface, color=yellow):

eval(G, t=0):
convert(%, list):
T2 := tubeplot(%, x=-2..2, radius=0.05, style=surface, color=blue):

display(S1, S2, A1, A2, A3, T1, T2, scaling=constrained,
        axes=framed, labels=[x,y,z]);

plots:-display(LH,LG);

 

plot3d(y^2, x=0..1, y=-1..1, filled, style=surface);

 

Here is the proper way of defining your Lagrangian:

L := J/2*(diff(x(t),t)/R)^2
   + m__r/2*diff(x(t),t)^2
   + m__p/2*((diff(x(t),t) + l*diff(phi(t),t)*cos(phi(t)))^2 + (l*diff(phi(t),t)*sin(phi(t)))^2)
   + m__p*g*l*cos(phi(t));

but be sure to verify that I have not introduced errors in transcribing the image that you have provided.

If you are interested in the final form of the Euler-Lagrange equations and don't care about the intermediate steps, then Maple's EulerLagrange function in the VariationalCalculus package will produce the result directly, as in Method 1 below.  Otherwise look at Method 2.

Method 1:

tmp1 := VariationalCalculus:-EulerLagrange(L, t, [x(t),phi(t)]);

tmp1 consists of a set of four expressions—two equations of the form something=K1 and something=K2, which are the integrals of motion (conservation of energy and momentum).  The other two are the differential equations of motion.  In the next step I delete the integrals of motion, and keep the differential equations:

tmp2 := remove(type, tmp1, equation);

tmp2 consists of two differential equations as I noted above.  To verify that we indeed have two items, we do:

nops(tmp2);

and indeed it returns "2".

Next, we name those equations de1 and de2:

de1 := tmp2[1] = 0;
de2 := tmp2[2] = 0;

Then you do whatever you need to do with de1 and de2

Method 2:

If you insist on doing the calculations one-step-at-a-time as you have outlined in your statement, you need to load the Physics package.  The package redefines Maple's "diff" operator which then enables you to calculate derivatives with respect to derivatives.

with(Physics):
dL_dxdot := diff(L, diff(x(t),t));         # derivative of L with respect to xdot
dL_dphidot := diff(L, diff(phi(t),t));     # derivative of L with respect to phidot
dL_dphi := diff(L, phi(t));                # derivative of L with respect to phi
diff(dL_dxdot, t);

 

p1 := plot(x^2 - 1, x = -2 .. 2, color=blue):
p2 := plots:-pointplot([3/2,5/4], symbol=solidcircle, symbolsize=20, color=white):
p3 := plots:-pointplot([3/2,5/4], symbol=     circle, symbolsize=20, color=black):
plots[display](p1, p2, p3);

In the attached worksheet I show how to generalize the definition of the pedal curve to pedal surface and calculate the equation of the pedal surface in the general case.  Then I illustrate the result by calculating the pedal surface of an ellipsoid with respect to its center.  Here is what it looks like.

Download pedal-surface.mw

No need for extra packages.  Just do this:

restart;
k := x -> piecewise(x < -6, 1/2*x + 10, x < -3, 1, x < 6*Pi, sin(1/2*x) + 2, x < 25, x - 15);
plot3d(k(x), t=0..2*Pi, x=-20..20, coords=cylindrical);

The parametrization of a surface (any surface) is not unque.  The way a surface is parametrized can have a drastic effect in how it is rendered on screen.

The standard parametrization of the oloid does not produce good computer-generated graphics as you have observed. But an oloid has a great deal of symmetries.  It is not difficult to see that it may be decomposed into four congruent patches, each of which has a quite "tame" parametrization for which Maple's default plotting grid is more than adequate.  Here I construct the oloid by putting together the four patches. 

restart;
alpha[1] := sin(t):
alpha[2] := -1/2 - cos(t):
alpha[3] := 0:
beta[1] := 0:
beta[2] := 1/2 - cos(t)/(1+cos(t)):
beta[3] := sqrt(1 + 2*cos(t))/(1+cos(t)):
x := (1-m)*alpha[1] + m*beta[1];
y := (1-m)*alpha[2] + m*beta[2];
z := (1-m)*alpha[3] + m*beta[3];
plot3d([[x,y,z], [x,y,-z], [z,-y,x], [-z,-y,x]], m=0..1, t=-Pi/2..Pi/2,
    scaling=constrained, color=[red,green,blue,yellow]);

I have colored the patches in four different colors in order to delineate them.  Change surface style and color as it suits your needs.

 

T := t -> (t+459.47) * 5/9;
seq(printf("%10d %10.2f\n", t, T(t)), t=100..110);
       100     310.82
       101     311.37
       102     311.93
       103     312.48
       104     313.04
       105     313.59
       106     314.15
       107     314.71
       108     315.26
       109     315.82
       110     316.37

 

Inversion in a sphere is much simpler than what you have in your worksheet.  Here is how I would do it.

Inversion in a sphere

Consider a sphere Sof radius R centered at the origin.  Let `#mover(mi("r"),mo("&rarr;"))` be the position vector of any

point Pin space. The inversion of P with respect to S is the point given by the position

vector `#mover(mi("&rho;",fontstyle = "normal"),mo("&rarr;"))` = R^2*`#mover(mi("r"),mo("&rarr;"))`/abs(`#mover(mi("r"),mo("&rarr;"))`)^2  provided that `#mover(mi("r"),mo("&rarr;"))` is nonzero.  We see that inversion maps the outside

of the sphere into the inside, and vise versa.  Let's note that in Cartesian coordinates
`#mover(mi("r"),mo("&rarr;"))` ="<x,y,z>     implies    (rho)=(R^(2))/(x^(2)+y^(2)+z^(2))*<x,y,z>."

 

Here we illustrate this graphically by inverting a torus in a sphere.

restart;

with(plots):

with(plottools):

The equation of a torus of radii a and b, displaced by d along the x axis in the Cartesian coordinates:

T := < d + (a + b*cos(s))*cos(t), (a + b*cos(s))*sin(t), b*sin(s) >;

Vector(3, {(1) = d+(a+b*cos(s))*cos(t), (2) = (a+b*cos(s))*sin(t), (3) = b*sin(s)})

The inversion of the torus in the sphere S

T__inverse := R^2/(T^+ . T) * T;

Vector(3, {(1) = R^2*(d+(a+b*cos(s))*cos(t))/((d+(a+b*cos(s))*cos(t))^2+(a+b*cos(s))^2*sin(t)^2+b^2*sin(s)^2), (2) = R^2*(a+b*cos(s))*sin(t)/((d+(a+b*cos(s))*cos(t))^2+(a+b*cos(s))^2*sin(t)^2+b^2*sin(s)^2), (3) = R^2*b*sin(s)/((d+(a+b*cos(s))*cos(t))^2+(a+b*cos(s))^2*sin(t)^2+b^2*sin(s)^2)})

Pick parameters for illustration:

params := { R=10, d=8, a=3, b=1 };

{R = 10, a = 3, b = 1, d = 8}

plots:-display([
        sphere(eval(R, params), style=line),
        plot3d(eval(T, params), s=0..2*Pi, t=0..2*Pi, style=surface, color="Green"),
        plot3d(eval(T__inverse, params), s=0..2*Pi, t=0..2*Pi)
], scaling=constrained, viewpoint=[circleleft, frames=100], axes=none);

 

 

Download inversion-in-sphere.mw

 

There are mnay ways of doing it, depending on what you want to do with the results.  Also it depends on how you represent quaternions.  You say that you want to represent a quaternion as a vector of length 4, but in your example your write qaa and qab as lists.  Lists and vectors are different types of objects in Maple.

Let's say you represent a quaternion as a list of length 4.  Then this will do what you want:

restart;

mult := proc(p::list,q::list)
        [
                p[1]*q[1] - p[2]*q[2] - p[3]*q[3] - p[4]*q[4],
                p[1]*q[2] + p[2]*q[1] + p[3]*q[4] - p[4]*q[3],
                p[1]*q[3] - p[2]*q[4] + p[3]*q[1] + p[4]*q[2],
                p[1]*q[4] + p[2]*q[3] - p[3]*q[2] + p[4]*q[1]
        ];
end proc:

 

mult([a,b,c,d],[e,f,g,h]);

[a*e-b*f-c*g-d*h, a*f+b*e+c*h-d*g, a*g-b*h+c*e+d*f, a*h+b*g-c*f+d*e]

mult([8,4,6,2], [2,4,6,8]);

[-52, 76, 36, 68]

That said, I much prefer the [scalar, vector] pair representation of quaternions (see the Wikipedia article) rather than lists of length 4.  But that again depends on what you want to do with them.

 

de := a*diff(y(x),x,x) + b*diff(y(x),x) + c*y(x) = 0;
dsolve(de) assuming b^2 < 4*a*c;

 

First 17 18 19 20 21 22 23 Last Page 19 of 58