Rouben Rostamian

MaplePrimes Activity


These are answers submitted by Rouben Rostamian

 

restart;

with(plots):

with(plottools):

The integers m and n specify a hexagon's column and row indices, and col is the color.

p := proc(m, n, col)
        local p, x, y;
        p := polygonbyname("hexagon", color=col, radius=sqrt(3)/2);
        x := 3/2*m;
        y := sqrt(3)* `if`(type(m, even), n, n+1/2);
        translate(p, x, y);
end proc:

P :=
        p(0,0,red),
        p(1,0,green),
        p(2,0,blue),
        p(0,1,yellow),
        p(1,1,cyan),
        p(2,1,magenta):

display(P, scaling=constrained, size=[600,600], axes=none);

 

 

Download mw.mw

Added later:

With the proc(m,n,col) on hand, we can generate tilings of desired size:

M, N := 10, 7:
seq(seq(p(m,n,red),   n=irem(m,2)..N, 3), m=0..M),
seq(seq(p(m,n,green), n=irem(m,2)+1..N, 3), m=0..M),
seq(seq(p(m,n,blue),  n=2*irem(m+1,2)..N, 3), m=0..M):
display(%, scaling=constrained, axes=none);

Here is yet another solution.  The logic is explained in the attached PDF.

restart;

local gamma:

Warning, A new binding for the name `gamma` has been created. The global instance of this name is still accessible using the :- prefix, :-`gamma`.  See ?protect for details.

eq1 := alpha = b/(2*a)*h^2;

alpha = (1/2)*b*h^2/a

eq2 := beta = a*b/4*( (a/2-h)/(a/2) )^2;

beta = b*((1/2)*a-h)^2/a

eq3 := gamma = a*b/4 - alpha;

gamma = (1/4)*a*b-alpha

sol := solve({eq1,eq2,eq3}, {a,b,gamma});

{a = RootOf(_Z^2-4*_Z*alpha+4*alpha^2-2*alpha*beta)*h/alpha, b = 2*RootOf(_Z^2-4*_Z*alpha+4*alpha^2-2*alpha*beta)/h, gamma = 2*RootOf(_Z^2-4*_Z*alpha+4*alpha^2-2*alpha*beta)-3*alpha+beta}

We get two choices for gamma:

gamma_choices := {allvalues(subs(sol, gamma))};

{alpha-2*2^(1/2)*(beta*alpha)^(1/2)+beta, alpha+2*2^(1/2)*(beta*alpha)^(1/2)+beta}

Let's evaluate

simplify(eval(gamma_choices, {alpha=2, beta=9}));

{-1, 23}

Area can't be negative, and therefore gamma is 23.

 

area-puzzle.pdf

Download area-puzzle.mw

The "solution" that you have obtained says that y(t)^2 = arctan(t) / t.   Letting t go to zero we get y(0)^2=1.  In what way does that satisfy the initial condition y(0)=0?

If you are looking for a way to mark a missing point on a graph by an empty circle, as it's done in textbooks, this may be of some use to you.

restart;

with(plots):

expr := (x^3-1)/(x-1);    # change as needed

(x^3-1)/(x-1)

Want to remove the point (x0,y0) from the graph

x0 := 1;

1

y0 := limit(expr, x=x0);

3

Size of the gap in the graph

h := 0.025;

0.25e-1

The symbolsize is determined by trial-and-error

display(
  plot(expr, x=0..x0-h),
  plot(expr, x=x0+h..2),
  pointplot([x0,y0], symbol=circle, symbolsize=30),
color="Green", thickness=3);

 

Download mw.mw

You have been shown several fancy approaches to solving your problem. Here is a  very basic approach, which is not much different from what you already have in your worksheet.  It's just organized in a cleaner way.

restart;

A, B, C := [0,1], [-1,4], [1,2];

[0, 1], [-1, 4], [1, 2]

f := x -> a*x^2 + b*x + c;

proc (x) options operator, arrow; a*x^2+b*x+c end proc

eqns :=
  A[2] = f(A[1]),
  B[2] = f(B[1]),
  C[2] = f(C[1]);

1 = c, 4 = a-b+c, 2 = a+b+c

sol := solve({eqns});

{a = 2, b = -1, c = 1}

subs(sol, f(x));

2*x^2-x+1

 

Download mw.mw

 

Consider using the inert form %* of multiplication:
 

v := <a,b>;

Vector(2, {(1) = a, (2) = b})

v %* cos(theta*t+phi);

`%*`(Vector(2, {(1) = a, (2) = b}), cos(t*theta+phi))

Evaluate the result when needed:

value(%);

Vector(2, {(1) = cos(t*theta+phi)*a, (2) = cos(t*theta+phi)*b})

Set the java heap size through the -j flag on the command-line, as in

maple -j 65536 -x filename.mw

The default heap size is 512.  If you need this frequently, make it an alias in your unix shell.

Here is the solution to your problem.

[inlined worksheet display adjusted by moderator]

restart;

You have prescribed three "unit vectors".  You haven't said how you came up

these vectors, but you should know that they are not exactly unit vectors.

For instance, the length of e3 is 0.9928.  I will continue with the worksheet,

ignoring that issue.

e1, e2, e3 := <-0.9, 0.375, -0.22>, <-0.95, 0, -0.33>, <-0.89, -0.44, 0>;

e1, e2, e3 := Vector(3, {(1) = -.9, (2) = .375, (3) = -.22}), Vector(3, {(1) = -.95, (2) = 0, (3) = -.33}), Vector(3, {(1) = -.89, (2) = -.44, (3) = 0})

Here are your vectors v1, v2, v3.  The lengths b and c of v2 and v3

are to be determined.

v1, v2, v3 := 3*e1, b*e2, c*e3;

v1, v2, v3 := Vector(3, {(1) = -2.70000000000000, (2) = 1.12500000000000, (3) = -.660000000000000}), Vector(3, {(1) = -.95*b, (2) = 0, (3) = -.33*b}), Vector(3, {(1) = -.89*c, (2) = -.44*c, (3) = 0})

We want v2 = v1 + v3 + v4, that is

v4 := v2 - v1 - v3;

Vector(3, {(1) = -.95*b+2.7+.89*c, (2) = -1.125+.44*c, (3) = -.33*b+.66})

Here is the square of the length of v4:

J := v4^+ . v4;

(-.95*b+HFloat(2.7)+.89*c)^2+(-HFloat(1.125)+.44*c)^2+(-.33*b+HFloat(0.66))^2

You want to mininuze J.  So set its derivatives to zero and solve the resulting system:

ans := solve( { diff(J, b) = 0, diff(J, c) = 0 });

{b = 4.005406664, c = 1.500021644}

Here are the vectors v1, v2, v3, v4 corresponding to the smallest v4:

subs(ans, [v1, v2, v3, v4]);

[Vector(3, {(1) = -2.7, (2) = 1.125, (3) = -.66}), Vector(3, {(1) = -3.805136331, (2) = 0, (3) = -1.321784199}), Vector(3, {(1) = -1.335019263, (2) = -.6600095234, (3) = 0}), Vector(3, {(1) = .2298829320000002, (2) = -.46499047660000004, (3) = -.6617841990000001})]

and here is the length of v4:

subs(ans, sqrt(J));

HFloat(0.8408451889614899)


Download mw.mw

restart;

Let a, b, c be the triangle's angles at the vertices A, B, C.
We wish to find a, b, c so that the tangents of the angles are integers.


We have a + b + c = Pi, and therefore a + b = Pi - c.

It follows that tan(a+b) = tan(Pi-c).  We rearrange

the equation as follows:

tan(a+b) = tan(Pi-c);
expand(%);
%*denom(lhs(%));
simplify(%);
expand(%);
isolate(%, tan(a)*tan(b)*tan(c));

tan(a+b) = -tan(c)

tan(c)*tan(a)*tan(b) = tan(a)+tan(b)+tan(c)

Letting U = tan(a), V=tan(b), W=tan(c), this reduces to

EQ := U*V*W = U+V+W;

U*V*W = U+V+W

Thus, the original problem reduces to finding integer solutions to EQ.

 

Without a loss of generality, suppose U < V < W.


Claim: U is less than 2.

Proof by contradiction: If  U >= 2, then V>= 2, then U*V*W >= 4*W.
On the other hand,  U + V + W <= 3*W, which according to EQ results in

U*V*W <= 3*W.  The preceding two statements are contradictory.

QED

 

Since U = tan(a) is supposed to be an integer, and U <2, our only choice

is U = 1.

 

With that choice, EQ reduces to V*W = 1 + V + W, which we rearrange

as (V-1)*(W-1) = 2.  Clearly the only integer solution is V=2, W=3.

 

We conclude that:

tan(a), tan(b), tan(c) = 1, 2, 3;

tan(a), tan(b), tan(c) = 1, 2, 3

that is,

a, b, c := arctan(1), arctan(2), arctan(3);

(1/4)*Pi, arctan(2), arctan(3)

Here are the angles in degrees:

evalf(180/Pi*[a,b,c]);

[45.00000000, 63.43494881, 71.56505113]

To plot the triangle,  let

A, B, C := [0,0], [1,0], [x,y];

[0, 0], [1, 0], [x, y]

where [x,y] needs to be calculated.

 

The parametric equations of the lines AC and BC are

AC := A + t*[cos(a), sin(a)];
BC := B + s*[-cos(b), sin(b)];

[0, 0]+t*[(1/2)*2^(1/2), (1/2)*2^(1/2)]

[1, 0]+s*[-(1/5)*5^(1/2), (2/5)*5^(1/2)]

Find the parameters s and t where the lines intersect, and then
plug the result in either of the lines AC or BC to determine C:

AC - BC;
solve(expand(%));
C := expand(subs(%, AC));

[-1, 0]+t*[(1/2)*2^(1/2), (1/2)*2^(1/2)]-s*[-(1/5)*5^(1/2), (2/5)*5^(1/2)]

{s = (1/3)*5^(1/2), t = (2/3)*2^(1/2)}

[2/3, 2/3]

Here is the triangle:

plots:-display(
    plottools:-polygon([A,B,C], color="Orange"),
    scaling=constrained);


 


 

Download integer-triangle.mw

Your worksheet is hopelessly too complicated for me to comprehend.  Consider simplifying the notation.  The tradition in mathematics is to use single letters for mathematical objects.  We write ax^2 + bx + c=0 for the quadratic equation, not a_coeff*x_unknown^2 + b_coeff*x_unknown + c_coeff = 0.

Anyway, the following does what you want, I think. Replace my vectors with yours, as needed.  Note the use of single letters.

Note: Maple vectors are displayed as quation marks on this website.
They are displayed correctly in the attached worksheet.

Given two vectors A and B, we form the cross-product N=AxB and

find the equation of the plane with the normal vector N which passes

through the tip of the prescribed vector V.  We know that the equation

of that plane is (X - V) . N = 0, where X = <x,y,z>. 

restart;

with(plots):

A, B, V := < 3,1,1>, <1,2,1>, < 0,1,2>;

Vector[column](%id = 36893623962191241692), Vector[column](%id = 36893623962191241812), Vector[column](%id = 36893623962191241932)

N := LinearAlgebra:-CrossProduct(A,B);

Vector(3, {(1) = -1, (2) = -2, (3) = 5})

N^+ . (<x,y,z> - V);
plane := isolate(%, z);

-x-2*y-8+5*z

z = (1/5)*x+(2/5)*y+8/5

p1 := display(
        plot3d(rhs(plane), x=-2..2, y=-2..2, color="Orange", transparency=0.5),
        arrow(A, color="Green"),
        arrow(B, color="Blue"),
        arrow(V, color="Red"),
        scaling=constrained, orientation=[-15,72,0]);

Next, we are given a vector Q which defines the line <x,y,z>= Q*t through the origin.

We wish to find the intersection of that line with the plane.  So we evaluate x, y, z,

substitute those in the equation of the plane, solve for t, and then substitute that t

into Q*t to find the point P of the desired intersection.

Q :=  <-1,-1,2>

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

Q*t;
x = %[1], y=%[2], z=%[3];
subs(%, plane);
isolate(%, t);
P := Q*rhs(%);

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

x = -t, y = -t, z = 2*t

2*t = -3*t*(1/5)+8/5

t = 8/13

Vector[column](%id = 36893623961797710420)

p2 := display(
        arrow(Q, color="Black"),
        pointplot3d(P, symbol=solidsphere, color="Black", symbolsize=20)
):

display(p1,p2);

Finally, we wish to find the vector R that goes from P to V:

R := V - P;

Vector(3, {(1) = 8/13, (2) = 21/13, (3) = 10/13})

 

 

Download mw.mw

There is no general agreement on the definition of Euler angles.  See the Wikipedia page Euler angles for the various possibilities.  In all cases, the rotation matrix is a product of three 3x3 elementary matrices.  As long as you stick to one of the definitions and use it consistently, you will be okay.

Well, almost okay.  Euler introduced the Euler angles in the analysis of the spinning of a top.  A top's motion is pretty tame; it doesn't go through wild somersaults and such, and Euler angles do the job quite well.  If, however, you wish to track the motion of an object that turns every which way, Euler angles are not the best choice and they can run you into trouble.  See the Wikipedia page on Gimbal lock and read (a) the paragraph on  NASA's problem with using Euler angles in the Apollo mission to the moon, and (b) the paragraph under the heading of Loss of a degree of freedom with Euler angles.

Tracking rotation through quaternions avoids the gimbal lock problem. It is the method of choice for space probes sent to the various parts of the solar system.  See Quaternions and spatial rotation for an introduction to the subject.

Do you know how to plot any of the graphs that you have mentioned?  If you know how to plot them individually, then name them p1, p2, p3, etc., as in

p1 := plot(whatever);

To display them together as one graph, do

plots:-display(p1, p2, p3);

If we take alpha=1 and v=1, then there is no singularity.  Here is what the phase space looks like.  If this is not what you have in mind, then you need to be more specific about it.

restart;

with(plots):

with(DETools):

de1 := diff(P(t),t) = W(t);
de2 := diff(W(t),t) = (P(t)-(1+a^2)*P(t)*W(t)^2)/(v+1/2*(1+a^2)*P(t)^2);

diff(P(t), t) = W(t)

diff(W(t), t) = (P(t)-(a^2+1)*P(t)*W(t)^2)/(v+(1/2)*(a^2+1)*P(t)^2)

params := a=1, v=1;

a = 1, v = 1

DEplot(subs(params,[de1,de2]), [P(t),W(t)], t=0..1, P(t)=-1..1, W(t)=-1..1, arrows=comet);


Download mw.mw

@Kitonum The statement that the locus of the centers of the circles is the parabola y=x^2/(4*R)  is immediately obvious from examining this diagram:

Here we have circles of radii R and r tangent to each other and also tangent to the line L.  The line D is at a distance R from the line L.  We see that the line segments oO and oB are of equal lengths, and therefore as the radius r varies, the point o traces a parabola with focus at O, and the directrix D; that's the geometric definition of a parabola.  We conclude that the equation of the parabola is y = x^2 / (4*R); see Parabola in Wikipedia.

A circle (actually a hoop) of radius R and mass M rolls without slipping on a horizontal line.  A circle of smaller radius r and mass m rolls without slipping inside the larger circle. The motion takes place within a vertical plane. We wish to find the equations of motion of the system, and solve and animate.

The system has two degrees of freedom, therefore we need to identify/select two generalized coordinates to describe the system's configuration.  A good choice of coordinates is essential for producing an effective solution.  I was unable to identify the generalized coordinates in your worksheet, so I started a new worksheet rolling-circles.mw from scratch.  The PDF file rolling-circles.pdf contains documentation.

There are two examples in the Maple worksheet.

In the first example, we place the small circle at the 3 o'clock position within the large circle, and start the system from rest.  The resulting motion is something that we could have intuitively anticipated:

The gold dots are markers (not weights) affixed to the rims of the two circles to help visualize their rotations.

In the second example, we position the small circle at the 6 o'clock position and give it a horizonal initial velocity (think of it as hitting it with a hammer).  I find the resulting motion quite unexpected/unintuitive.  The small circle still oscillates, but the large circle rolls, with jerks and stops, in one direction, without ever reversing.

1 2 3 4 5 6 7 Last Page 1 of 57