## Maple Questions and Posts

##### These are Posts and Questions associated with the product, Maple

Hi

I am trying to use Explore command to model the CSA  of a trough.

So I want to  be able to change the variables: length of the walls (l:, slider 0..20) and the width (w:slider 0..20) and the angle (theta: slider 0..Pi/2)

Want to be able to see the diagram change and also display the area using the formula [output (15)] on the graph

Here is my attempt.

trough.mw

## Question on solve technique...

In the attached, I had to find the required coefficient. Now this has a relatively straight forward set of equation (which apparently form a closed group), so it was easy enough tee see what to do. In a more complicated situation that may be very difficult to see. I was a wondering is there is a better approach to use here?

Prove/show the coefficient of  in  is

 (1)

 (2)

 (3)

 (4)

 (5)

 (6)

 (7)

 (8)

 (9)

 (10)

 (11)

## Is the int option continuous backward ?...

The help page says that an option for int is continuous=truefalse. The help page reads

"Specifies whether int looks for discontinuities. " I interpret that as continuous=true means look for discontinuities

and false means do not look. A simple example, however, suggests that it is the opposite.

int(3/(5-4*cos(x)),x=0..2*Pi,continuous=true)=0

int(3/(5-4*cos(x)),x=0..2*Pi,continuous=false)=2*Pi.

I interpret this as continuous=true means "I guarantee the result is continuous, so do not look"

This would be a logical opposite to discont=true in the plot command: discont=true -> continuous=false!

## Once upon a time in Maple I could get it to answer...

Consider F := Int( 1/(1+x^n), x=0..1 ).  Once upon a time in Maple ("when tigers smoked pipes") I got it to tell me that F = hypergeom( [1,1/n], [1+1/n], -1 ).  This is true, compact, and very helpful.   n is a positive integer.

I don't seem to be able to do this any more; the combinations of Int, Sum, int, sum, convert/hypergeom, etc are not working for me. I am probably forgetting just which trick I used---I don't think that Maple's capabilities have changed, except that now sometimes I get a finite sum for the integral going from k=0 to k=floor(n/2) which I don't remember seeing before.

Any ideas?

## How to Change Code Editor Font (Maple 2021)...

When I use styles to select the code font it only changes the code font within a worksheet, but not the font in the code editor. Is there any way to change font size/type in the code editor? Thanks!

## what are known limitation for running code in head...

I just spend 2 hrs trying to make this work in headless worksheet, but it does not work. I have A worksheet, which calls B worksheet. The call all go through OK and I set it all correctly. Set up the section in worksheet B and document property, etc.. as described in help.

So the call works OK and arguments are passed correctly from A to B.

The problem is that in worksheet B, I wanted to generate a plot in order to save it to postscript file.  This did not work. Nothing gets exported, even  though the plot is actually generated correctly in B.  How do I know this? Becaue B returns the plot back to A, and I can see the plot was correctly generated.  The file .ps never gets created. I look at the folder these worksheets are in, and there is no .ps file created.

But it was not saved to .ps file.  The same code works ok in standard worksheet and plot is saved correctly to .ps file using same code.

I also could not export the plot to JPEG file from worksheet B.  Only thing that worked is exporting some text to .TXT file from B.

Any one knows of limitation to calling one worksheet from another?  It seems somethings work in headless worksheet and some things do not. Which does not make it useful.

You might ask, why Am I doing this? Because I wanted to call that B worksheet later on (if it worked) from a script to do the plot exporting, as the quality is better when in a "worksheet" vs. command line).

But since this does not even work when calling the worksheet from another worksheet, then there is no point of trying it from the command line.

Attached A and B. To try it, please save both worksheets in same folder and simply open A.mw and run it. It will call B.mw

This is the first time I used documentTools package. I did not even know one can call one worksheet from another before.

I suspect it had to do with print(); call becoming inactive in headless worksheet, which causes nothing to be send to the postscript file. But I am not sure. Without print(); one can't export the plot.

I do not understand why is it so hard in Maple to export a plot to a PDF. Why is there not a simple export command to export a plot to PDF like with all the other software out there in the world?  This is the year 2021, not 1980. How many decades does Maplesoft needs to implement export to PDF?

This is on windows 10. Maple 2021.1

This is A.mw

 > restart;
 > currentdir("C:\\tmp\\TEST_MAPLE"); p:=DocumentTools[RunWorksheet]( "B.mw" , [the_function=sin(x),the_variable=x]  ): print("Back from calling worksheet B. Here is the result"); p;

 >

This is B.mw

Inputs

 > the_function:=0;
 > the_variable:=0;
 > p:=plot(the_function,the_variable=-2*Pi..2*Pi): full_file_name:=cat("C:\\tmp\\TEST_MAPLE\\tmp.ps"); plotsetup(ps,plotoutput=full_file_name): print(p); plotsetup(default): return p;

## Dutch math book, the volume of a function rotated ...

Hello, ive got another question. Im in the last chapter of this book, and i hope i can finish the book this month. So i can start with part 2 of the series of applied math for higher job education. The first book is basically the freshmans year worth of math, and im completing it within 2 months. So im happy with that. :)

Okey here is the question:
a.
Draw half a circle x^2+y^2=4, with y >= (bigger or equal to) 0.

So how do i make half a circle instead of the whole circle?

The rest of the text says:
b.
Which body is created if the area bordered by the x-axis and this half circle is revolved around the x-axis?
c.
Calculate the volume of this body.

Greetings,

The Function

 >
 >

## Simple solve on equations ...

restart;

eq1 := xdot = (xk - xk1)/dt;
eq2 := xdot2 = (xk - 2*xk1 + xk2)/dt^2;
eq3 := c*xdot + k*xk + m*xdot2 = F;
sol := solve({eq1, eq2, eq3}, xk);

What am I missing here? Ty

## Spacing between 2D Input and 2D Output cells...

How to change the distance (spacing) between 2D Input cells and 2D Output cells so that this procedure can be inserted into a style sheet and thus applied to multiple documents?

Regards

Oliveira

## Animation of motorcycle Jam...

Would you tel me why this code doesn't work : the  lenghts of BC and BD are not constant. Thank you very much.
restart;
with(plots);
with(plottools);
AB := 39;
BC := 140;
BD := 140;
local(D);
Vdot := proc(U, V) local i; add(U[i]*V[i], i = 1 .. 2); end proc;
dist := proc(M, N) sqrt(Vdot(expand(M - N), expand(M - N))); end proc;
Fig := proc(alpha)
local cir, R, BC, BD, AC, AD, lAC, A, lBC, lAB, lBD, beta, B, C, Cc, Dd, D, Aa, Bb, F1, F2, d, k, h, i, Pb, Ph, pb1, ph1, Qb, Qh, qh1, qb1, p1, P1, p2, P2, p3, P3, p4, P4, q1, Q1, q2, Q2, q3, Q3, q4, Q4, cy1, cy2, cy3, cy4, tA, tB, tC, tD;
A := [0, 0]; R := 39; d := 83; BC := 140; BD := 140;
B := [R*cos(alpha), R*sin(alpha)];
k := BC/R; h := 1/2*sqrt(2);
Ph := [h*(R + BC), h*(R + BC)];
Pb := [h*(-R + BC), h*(-R + BC)];
Qh := [-h*(R + BC), h*(R + BC)];
Qb := [-h*(-R + BC), h*(-R + BC)];
P1 := [Ph[1] - 1/2*d*h, Ph[2] + 1/2*d*h];
P2 := [Ph[1] + 1/2*d*h, Ph[2] - 1/2*d*h];
P3 := [Pb[1] - 1/2*d*h, Pb[2] + 1/2*d*h];
P4 := [Pb[1] + 1/2*d*h, Pb[2] - 1/2*d*h];
Q1 := [Qh[1] + 1/2*d*h, Qh[2] + 1/2*d*h];
Q2 := [Qh[1] - 1/2*d*h, Qh[2] - 1/2*d*h];
Q3 := [Qb[1] + 1/2*d*h, Qb[2] + 1/2*d*h];
Q4 := [Qb[1] - 1/2*d*h, Qb[2] - 1/2*d*h];
cir := circle(A, R, color = black, linestyle = longdash);
F1 := plot(x, x = -R .. R + BC, color = black, linestyle = longdash);
F2 := plot(-x, x = -R - BC .. R, color = black, linestyle = longdash);
AC := R*(cos(alpha) + sqrt(k^2 - sin(alpha)^2));
C := [h . AC, h . AC];
AD := R*(cos(Pi - alpha) + sqrt(k^2 - sin(Pi - alpha)^2));
D := [-h*AD, h*AD]; lBC := plot([B, C], color = red, thickness = 4);
lAB := plot([A, B], color = red, thickness = 4); print(evalf(dist(B, C)), evalf(dist(B, D)));
lBD := plot([B, D], color = red, thickness = 4);
pb1 := pointplot(Pb, symbol = solidcircle, symbolsize = 5, color = black);
ph1 := pointplot(Ph, symbol = solidcircle, symbolsize = 5, color = black);
qb1 := pointplot(Qb, symbol = solidcircle, symbolsize = 5, color = black);
qh1 := pointplot(Qh, symbol = solidcircle, symbolsize = 5, color = black);
p1 := pointplot(P1, symbol = solidcircle, symbolsize = 10, color = black);
p2 := pointplot(P2, symbol = solidcircle, symbolsize = 10, color = black);
p3 := pointplot(P3, symbol = solidcircle, symbolsize = 10, color = black);
p4 := pointplot(P4, symbol = solidcircle, symbolsize = 10, color = black);
q1 := pointplot(Q1, symbol = solidcircle, symbolsize = 10, color = black);
q2 := pointplot(Q2, symbol = solidcircle, symbolsize = 10, color = black);
q3 := pointplot(Q3, symbol = solidcircle, symbolsize = 10, color = black);
q4 := pointplot(Q4, symbol = solidcircle, symbolsize = 10, color = black);
Aa := pointplot(A, symbol = solidcircle, symbolsize = 12, color = blue);
Bb := pointplot(B, symbol = solidcircle, symbolsize = 12, color = blue);
Cc := pointplot(C, symbol = solidcircle, symbolsize = 12, color = blue);
Dd := pointplot(D, symbol = solidcircle, symbolsize = 12, color = blue);
cy1 := plot([P1, P3], color = black, thickness = 8); cy2 := plot([P2, P4], color = black, thickness = 8);
cy3 := plot([Q1, Q3], color = black, thickness = 8); cy4 := plot([Q2, Q4], color = black, thickness = 8);
tA := textplot([0, 0, "A"], 'align' = {'above', 'right'});
tB := textplot([B[1], B[2], "B"], 'align' = {'above', 'right'});
tC := textplot([C[1], C[2], "C"], 'align' = {'above', 'right'});
tD := textplot([D[1], D[2], "D"], 'align' = {'above', 'right'});
display([cir, F1, F2, pb1, ph1, qb1, qh1, p1, p2, p3, p4, q1, q2, q3, q4, Aa, Bb, Cc, Dd, lAB, lBC, lBD, cy1, cy2, cy3, cy4, tA, tB, tC, tD], scaling = constrained); end proc;
Fig(Pi/3);
display([seq(Fig((2*alpha*Pi)/50), alpha = 0 .. 50)], insequence = true, axes = none);

## maple code for homotopy perturbation method...

I'm trying to solve nonlinear system of equations via homotopy perturbation method. Please help with ideas to develop the code.

restart;

de1 := (1 - p)*(diff(x(t), t \$ 1) - r*x) + p*(diff(x(t), t \$ 1) - r*(1 - (x + y)/K) + al*x*v);

de2 := (1 - p)*(diff(y(t), t \$ 1) + m*y+u*y) + p*(diff(y(t), t \$ 1) - al*x*v + m*y+u*y);

de3 := (1 - p)*(diff(v(t), t \$ 1) + eta*v) + p*(diff(v(t), t \$ 1) - B*y + eta*v);

ibvc := x(0) = 0.005, y(0) = 0.0007;

v(0) = 2;

r:=0.005; al:=0.002; m:=0.0001; K:=0.0138; B:=0.2; eta:=0.006; u:=0.0001;

n := 4;

X := unapply(add(g[k](t)*p^k, k = 0 .. n), x);

Y := unapply(add(h[k](t)*p^k, k = 0 .. n), x);

V := unapply(add(i[k](t)*p^k, k = 0 .. n), x);

DE1 := series(eval(de1, x = X), p = 0, n + 1);

DE2 := series(eval(de2, y = Y), p = 0, n + 1);

DE3 := series(eval(de3, v = V), p = 0, n + 1);

C1 := map(coeffs, eval([ibvc], x = X), p);

C2 := map(coeffs, eval([ibvc], y = Y), p);

C3 := map(coeffs, eval([ibvc], v = V), p);

for k from 0 to n do

IBVC1 := select(has, C1, g[k]);

IBVC2 := select(has, C2, h[k]);

IBVC3 := select(has, C3, i[k]);

s1 := dsolve({coeff(DE1, p, k), op(IBVC1)});

s2 := dsolve({coeff(DE2, p, k), op(IBVC2)});

s3 := dsolve({coeff(DE3, p, k), op(IBVC3)});

h[k] := unapply(rhs(s1), t);

h[k] := unapply(rhs(s2), t);

i[k] := unapply(rhs(s3), t);

end do;

'X(t)' = X(t) + O(p^(n + 1));

'Y(t)' = Y(t) + O(p^(n + 1));

'V(t)' = V(t) + O(p^(n + 1));

How to make changes in the code?

## How to use smartview option in Plot?...

in my program, I need to generate plot of solution. I only know where the initial condition x value is. So I give to plot the x range as some value around that initial condition location. But this is not perfect, since the command line script will fail if Y value happend to be too large somewhere in this range due to singularity. (This fails only in the command line print driver, not in the worksheet GUI).

I can ofcource limit the y range also, using view=[....] but I do not know how to pick best Y range  automatically in the program to show what is interesting in the plot without doing lots of analysis on the expression.

There is something called smartview which is supposed to be active by default. But it does not seem to be working too well.

Here is an example. This function blows up at value near x=Pi  due to singularity. and I want the plot to automatically limit the Y range without having to specify manually the y view.

```restart;
sol:=exp(-3^(1/2)*(cos(x)-1)/sin(x)):
plot(sol,x=0..2*Pi);
```

So clearly "smartview" did not do it or I am not using it correctly. But it is supposed to be "active"?

Compare the same thing with Mathematica Plot where this  is handled automatically by Plot

```sol = Exp[-3^(1/2)*(Cos[x] - 1)/Sin[x]];
Plot[sol, {x, 0, 2*Pi}]```

Again, I know I can do the following in Maple

```plot(sol,x=0..2*Pi,view=[default,-1..20]);
```

The problem is that I am doing this in a program, which only gets an expression as function of x to plot, around some x location. So hard to decide what the right Y range is. It will best if Plot can determine the best view automatically.

How to use smartview to handle this? Or are there other alternative plot options for such cases?