Rouben Rostamian

MaplePrimes Activity


These are replies submitted by Rouben Rostamian

@janhardo That's the classic isoperimetric problem.  Here is how we solve it in Maple.

restart;

Typesetting:-Settings(typesetdot=true):

kernelopts(version);

`Maple 2024.2, X86 64 LINUX, Oct 29 2024, Build ID 1872373`

Consider a closed curve C parametrized as`<,>`(x(t), y(t)), t = 0 .. 1.

Then the curve's length is "L=(&int;)[0]^(1)sqrt(x'(t)^(2)+y'(t)^(2)) &DifferentialD;t, " and the area
enclosed by it, according to Green's theorem, is int(x(t)*(D(y))(t), t = 0 .. 1).
We wish to maximize the enclosed area subject to a given length L.

Thus we look for extrema of the functional
int(x(t)*(D(y))(t), t = 0 .. 1)+lambda*(int(sqrt((D(x))(t)^2+(D(y))(t)^2), t = 0 .. 1)),

where lambdais the Lagrange multiplier that enforces the length constraint.

 

Combining the integrals and introducing

F := x(t)*diff(y(t),t) + lambda*sqrt(diff(x(t),t)^2 + diff(y(t),t)^2);

x(t)*(diff(y(t), t))+lambda*((diff(x(t), t))^2+(diff(y(t), t))^2)^(1/2)

the functional becomes int(F(x, diff(x, x), y(x), diff(y(x), x)), t = 0 .. 1).  The corresponding

Euler-Lagrange differential equations are
"d/(dt)((&PartialD; F)/(&PartialD; x')) - (&PartialD; F)/(&PartialD; x)=0,     d/(dt)((&PartialD; F)/(&PartialD; y')) - (&PartialD; F)/(&PartialD; y)=0"

which we evaluate as:

Physics:-diff(F, diff(x(t),t)):
Physics:-diff(F, x(t)):
de1 := Diff(%%,t) - %;

Diff(lambda*(diff(x(t), t))/((diff(x(t), t))^2+(diff(y(t), t))^2)^(1/2), t)-(diff(y(t), t))

Physics:-diff(F, diff(y(t),t)):
Physics:-diff(F, y(t)):
de2 := Diff(%%,t) - %;

Diff(x(t)+lambda*(diff(y(t), t))/((diff(x(t), t))^2+(diff(y(t), t))^2)^(1/2), t)

We integrate de1 and de2 and obtain

eq1 := int(de1,t) - C[1];
eq2 := int(de2,t) - C[2];

-y(t)+lambda*(diff(x(t), t))/((diff(x(t), t))^2+(diff(y(t), t))^2)^(1/2)-C[1]

x(t)+lambda*(diff(y(t), t))/((diff(x(t), t))^2+(diff(y(t), t))^2)^(1/2)-C[2]

where C__1 and C__2 are integration constants.

 

We multiply eq1 and eq2 by (D(y))(t) and (D(x))(t), respectively,

and subtract.  We get

tmp1 := expand(eq1*diff(y(t),t) - eq2*diff(x(t),t));

-y(t)*(diff(y(t), t))-(diff(x(t), t))*x(t)+(diff(x(t), t))*C[2]-(diff(y(t), t))*C[1]

Integrate once more:

tmp2 := int(tmp1, t) = C[3];

C[2]*x(t)-(1/2)*x(t)^2-C[1]*y(t)-(1/2)*y(t)^2 = C[3]

Finally, complete the squares:

Student[Precalculus][CompleteSquare](-2*tmp2, [x(t), y(t)]);

(C[1]+y(t))^2+(x(t)-C[2])^2-C[2]^2-C[1]^2 = -2*C[3]

We see that the optimal curve C is a circle centered at `<,>`(C__2, -C__1) and radius squared equal to

"`C__1`^(2)+`C__2`^(2)-2 `C__3`."

Download isoperimetric.mw

 

@janhardo Yes, it is trivial if you recall the definition of arcsin.  That function takes an argument between -1 and 1 and returns an angle between -pi/2 and pi/2.

Thus, we define

theta = arcsin(y'/sqrt(1+y'^2))

or equivalently,

sin(theta) = y'/sqrt(1+y'^2);

where theta is between -pi/2 and pi/2.

@Alfred_F I have cleaned up my solution to the extent possible and will post it now.  There are some elements that overlap with dharr's solution, but there may be some instructive aspects in it as well.

@dharr I am glad to see that our answers have converged.  I am going to post my solution once I have cleaned it up just to provide an alternative approach.

@Alfred_F My calculation shows a teardrop-shaped domain whose value corresponding to the fence length of 100 is 15468.56. 

I will post the solution if I find some time to clean it up.

@dharr If I am reading your work correctly, you are concluding that the optimal shape is something like a teardrop with a flattened edge on the right.

That flat edge looks suspicious.  In the figure below, we remove part of the domain from the top and add it to the flat side. That does not change the fence's total length.  The removed land lies between zero and xmax, so it is only moderately priced, while the added land lies to the right of xmax, so it is highly priced.  The change, therefore increases the value of the integral.  So the original integral could not have been maximal.

 

@erik10 I don't understand what you mean by an "outline of a sphere" or its "outer reach".  See if you can clarify that.

Do you perhaps want to project the sphere onto a plane?  If so, then plottools:-transform is the right tool.  For instance, to project the sphere (or any 3d drawing) onto the xy plane, name the drawing, say call it p, and then do

plottools:-transform((x,y,z)->[x,0,z])(p);

 

@erik10 To get a smooth sphere, you may draw the sphere in the usual resolution without a grid, and then superimpose the desired grid, as in:

plot3d(1, t = -Pi .. Pi, p = 0 .. Pi, coords = spherical, style=surface);
plot3d(1.01, t = -Pi .. Pi, p = 0 .. Pi, coords = spherical, grid = [25, 19], style=line, color=black);
plots:-display(%%,%);

Note that the grid is drawn at a slightly larger radius so that it does not get blended with the surface.

PS:  The grid drawn by Maple consists of straight line segments.  If you want properly curved grid, then it can be done through plots:-spacecurve.

@aroche Thank you for prompt action on this matter!

@acer Thanks for the extra work.  Regarding the automatic coloring of different curves by display(), yes, I did see the redraw=false option noted in the help page.  I am not quite sure of its purpose, since setting the color option overrides the default colors.

Here is yet another curiousity.

My original example noted that the command

plots:-display(pic1, pic2, scaling=constrained);

plotted the diagram over an incorrect range.  Interestingly, specifying a color option fixes the issue and the curves are plotted over the correct range!

plots:-display(pic1, pic2, scaling=constrained, color=[red,green]);

So that's yet another workaround.

@acer Thanks for your comments and your offer of submitting a bug report.  Please do.

@nm Thanks for digging up that information.  In effect, the AI is providing a workaround.  It would be better if no such workaround were necessary.

@acer Also note that the right-hand side of initial condition y(Pi/2)=0 is not used anywhere.  There is no solution if the right-hand side is anything other than zero.

I cannot make sense of what you are attempting to do in your two worksheets.

In your statement you write "I define c by a 3 segment piecewise nonlinear function of H".  Perhaps that's what you intend to do, but your worksheets define c as a function of t, not H.  That's where things go wrong.

Here is a suggestion:

restart;
c := H -> piecewise(...expressions in H...);
H := t -> sin(2*Pi*t);  

Edit the above as needed, and then use c(H(t)) as the coefficient in your PDE.  Write again if problems still persist.

By the way, you have H and Ho in your worksheets.  It's not clear why there are two of them.  Need to explain that.

I can't tell what it is that is being plotted.  The code that you have supplied does not help.  To get useful help, state the objective in words.

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