Carl Love

Carl Love

28025 Reputation

25 Badges

12 years, 313 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

See the shell escape command ?escape.

Here's is a corrected version of your worksheet. I only corrected the errors necessary to get the combined plot. I did not deal with the singularities.

odeplot_(1).mw

The semicolons that you used in the display command should be commas:

 display(p(-1), p(-0.5), p(-0.1));

It's as simple as that.

There're only two uses of the semicolon in Maple: separating complete statements and separating the rows of a Matrix in the abbreviated angle-bracket input.

To create the side-by-side plots, you pass a row vector of plots to plots:-display. The row vector can be created by iterating (with seq) over the values of exactly like you iterated over the values of J.

 

eta:= 1+k*x+epsilon*sin(2*Pi*x):
A1:= x-> -exp(-alpha*x)*J^2*R/(2*eta^3+6*xi*J^2*eta^2):
psi0:= A1(x)*y^3:
psi:= delta*psi0:
V:= -diff(psi,x):
delta:= 0.1:
epsilon:= 0.01:
alpha:= 1:
xi:= 0.001:
k:= 0.1:
As:= [0, 2, 4]:
Rs:= [2.0, 5.0, 6.5]:
x:= 0.2:

plots:-display(
     `<|>`(seq(
          plot([seq](
               [eval(V, [J= A, R= r]), y, y= 0..eval(eta, J= A)], A= As),

               title= sprintf("velocity at R=%3.1f", r), labels= ["v", "y"],
               color= [green, red, blue],
               linestyle= [solid, dash, dot],
               legend= [seq](J = A, A= As),
               axes=boxed
          ), r= Rs
     ))
);

The three plots will superficially look alike, but note that the scaling on the horizontal axis is different. I don't know how to post side-by-side plots to MaplePrimes, so just execute the above code and you'll see what I mean.

Using the array form of points[1], give the command

surfdata(convert(points[1], list), dimension= 2, colorscheme= ["Orange","MediumBlue"])

 

@RAfossey You have invstrans, not invztrans. And why have you separated the two parts of the z expression with a comma? And why did you put y in the command? Where are you getting these wrong ideas from? The command that you need is

invztrans(z/(z-2)*5*z/(5-z)^2, z, n);

That's all that there is to it (for part a)!

For part b) use sum command. Look up ?sum. There's no need for the ztrans command.

Take the answers from parts a and b and form their quotient (as your professor suggests) and apply simplify to it. You should get 1, which shows that the expressions are equal. A more normal way to prove equality is to take the difference of expressions and try to simplify it to 0.

What you want to do can be done simply with piecewise, with no need for events. If the first derivative is 10 or greater, then the second derivative is 0. What did you try with piecewise?

m0:= 200:
m:= 32.2*(f(t)-g(t)) + 10*(diff(f(t),t)-diff(g(t),t)):

sys:=
     diff(f(t),t$2) = piecewise(diff(f(t),t) < 10, (m0-m)/5, 0),
     diff(g(t),t$2) = piecewise(diff(g(t),t) < 10, m/50, 0)
:

dsol2:= dsolve({sys, f(0)=0, g(0)=0, D(f)(0)=0, D(g)(0)=0}, numeric):

plots:-odeplot(
     dsol2, [[t,diff(f(t),t)], [t,diff(g(t),t)]], 0..10,
     color= [red, green], thickness= 2, view= [DEFAULT, 0..15]
);

 

NULL


Download piecewise_dsolve.mw

The second parameter of My is y. Inside My you have multiple subexpressions such as diff(a(y), y). This means the derivative of a(y) with respect to (wrt) y. For this to make sense, has to be a name. But in your call to My, you pass -1/2*b as the second argument. This becomes the value of y. Perhaps what you intended was not the derivative of a(y) wrt y but rather the derivative of a wrt its parameter, then evaluated at y. This would be denoted D(a)(y) rather than diff(a(y),y).

Another problem that I noticed is your use of Pi. You use it both as a constant (as in sin(m*Pi*x/a)) and as a function (as in Pi(y)). It can't be both. Preferably, you should only use it as the constant (its default meaning) and choose another symbol for the Pi in Pi(y).

A similar problem is your usage of m: It is used both as a bound variable (as in m= 1..infinity) and as a function (as in m(y))

Lastly, How can you understand or manage such a long and sloppy function? You should break it up into smaller, more-understandable chunks.

You said that "at best" you'd like to access the points by name. The following lets you do that.

 

Point:= proc(P::seq(name= [numeric,numeric]))
local r,v,p;
     for p in [P] do
          (r,v):= rhs(p)[];
          assign(
               lhs(p)=
               Record(
                    'r'= r, 'v'= v*'degrees',
                    'x'= r*cos(v*Pi/180), 'y'= r*sin(v*Pi/180)
               )
          )
     end do
end proc:

Points can be entered individually...

Point(A= [12,15]);

...sequentially...

Point(A= [12,15], B= [56,45]);

...or batch processed:

Point(([A,B,C,E]=~ zip(`[]`, [12,56,29,78], [15,45,75,102]))[]);
 

A:-x;

12*cos((1/12)*Pi)

C:-r;

29

B:-y;

28*2^(1/2)

E:-v;

102*degrees

 

 

Download Points.mw

The commands matrix, vector, transpose, linsolve, and `&*` are all very old deprecated commands, which means that they shouldn't be used anymore. They only exist in current Maple so that legacy code still works. The `&*` was used for matrix multiplication, and linsolve was used to solve a linear system. In modern Maple the above code is

a:= < a1,a2; b1,b2 >;
b:= < c1,c2 >;
c:= a^%T; #transpose
LinearAlgebra:-LinearSolve(c.a, c.b)

For example:

A_vals:= [1,2,3]:
m:= min(A_vals):  R:= max(A_vals) - m:
Sol:= dsolve(
     {diff(y(x),x$3)=y(x), y(0)=0, D(y)(0)=-0.5, (D@@2)(y)(0)=A},
     parameters= [A], numeric, range= -2..2
):
for v in A_vals do
     Sol(parameters= [v]);
     P[v]:= plots:-odeplot(
          Sol,
          [x,diff(y(x),x)],
          color= COLOR(HUE, evalf(.85*(v-m)/R)),
          legend= [A=v]
     )
end do:
plots:-display(convert(P,set));

I will assume that you have read the variable names into Maple from Excel (perhaps by using Tom Leslie's method) and that they are stored as an Array/(Vector/Matrix) of strings named LABELS, and that you have the numbers from Excel stored in an Array VALUES. Convert LABELS into an Array VARIABLES via

VARIABLES:= parse~(map2(cat, " ' ", LABELS, " ' "));

Then assign the values of the variables with

assign(convert(VARIABLES=~ VALUES, list));

If you want to reassign the values in the same session, then you need to execute only the second command again.

Note that in the first command each of the two groups of quotes is a single quote (an aposthrope) surrounded by a pair of double quotes.

 

Hello Raquel,

Construct your Matrix (or Vector) like this: Immediately after the command omega[1]:= solve(...), do

eval(<u[1,1], u[2,1], u[3,1]>, omega[1]);

Let me know if that takes care of your problem.

 

Most of what DEplot3d does can be done by sol:= dsolve(..., numeric) followed by plots:-odeplot(sol, ...). In this case, "most" is "all". The odeplot is more flexible in that it allows for functions of the dependent variables, which is what DEplot3d gave you an error about. So, replace your DEplot3d with

Sol:= dsolve(
     {eqn||(1..3), u(0)=1, v(0)=Pi, theta(0)=Pi/4},
     {theta(s), u(s), v(s)},
     numeric, range= 0..5
);
GrGline:= plots:-odeplot(Sol, [X,Y,Z], linestyle= solid, thickness= 3);

My personal aestethic opinion is that the final plot will look better if you include the option transparency= 0.1 in the display command.

(1) Your Reply has appeared, numerous times, and I am about to delete all but one copy.

(2) When you attach a worksheet to a post, you have the option of displaying the worksheet in the post as well. This is the best way. To attach a worksheet to a post, use the green uparrow tool that is the last item on the second row of the toolbar in the MaplePrimes editor.

First 263 264 265 266 267 268 269 Last Page 265 of 395