Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

I strongly recommend editing in an external editor, like you suggest. Then you just need to keep a worksheet open with a read statement to load the Maple code file. But if you don't want to do that, then the GUI response time can be improved by removing any unnecessary output from your worksheet, especially plots.

You need to choose four variables to solve for including A, B, and C. Then compute B/A and C/A from what solve returns. For example:

Sol:= solve({eq||(1..4)}, {A,B,C,F}):
[B/A, C/A] =~ eval([B/A, C/A], Sol);

Or

(t-> t^2) ~ ([1,2,3]);

You do not need to close Maple and start again. Kill your mserver in Task Manager, then save your worksheet, then close your worksheet, then reopen it. That will start a new mserver.

You can put the arguments in a list. Then you can essentially have an arbitrary number of arguments.

P:= proc(P::uneval)
local p;
    if P::list then
         seq(p::eval(p), p= P)
    else
         P::eval(P)
    end if
end proc:

a:= 1:  b:= 2:
P([a,b]);

You do it by using the identical type specifier, like this:

MyPlot:= proc(f::algebraic, {color::identical(yellow,organe,red,green):= red})
     print(color)
end proc;

In the above, I made red the default. If you don't want a default, then replace the red after the := with NULL. Note that Maple's procedure ProcessOptions is now largely obsolete. Most of what it handled can now be handled in the procedure header. See chapter 6 of the Programming Guide or the help page ?parameter_classes .

How about this?

F:= [sin(x), sin(x)-x+x^2, cos(x)-sin(x), exp(x)-x, sin(x)+exp(x)]:
plot(F, x= -Pi..Pi, linestyle= [1,2,3,4,5], legend= F);

Use a try...catch statement, like this:

V:= [a,b,c]:
for k to 6 do
     try
          print(V[k/2])
     catch "invalid subscript":
          print("There was an error, but the loop continues.")
     end try
end do;

@nm Use 1 instead of NULL. Being the identity, it won't change the product.

Addressing your original problem, your evalb was subject to premature evaluation. Note:

restart:
f:= i-> evalb(i<>j):
f(3);
          true

(of course). Since product has normal evaluation rules, the evalb being inside product will not change its evaluation. But mul has special evaluation rules, the same as add and seq. Those rules delay the evaluation of i<>j until after has numeric values.

A:= 2^(k+2)*m:
for r from 2 to M+1 do
     for s to r-1 do
          F[r,s]:= `if`((r+s)::odd, A*sqrt(c[r-1]/c[s-1]), 0)
     end do
end do:


restart:

h:= r-> 2*sqrt(100-r^2):

V:= r-> Pi*r^2*h(r):

Sol:= select(r-> is(r>0 and r<10), [solve(D(V)(r), r)]);

[(10/3)*6^(1/2)]

r:= Sol[]:

Second derivative test:

evalf((D@@2)(V)(r));

-435.311847416212

It's negative, so r is a maximum. The dimensions are

[radius= r, height= h(r)];

[radius = (10/3)*6^(1/2), height = (20/3)*3^(1/2)]

evalf(%);

[radius = 8.16496580927726, height = 11.5470053837925]

P1:= plot3d([10, theta, phi], theta= 0..2*Pi, phi= 0..Pi, coords= spherical, transparency= 0.5):

P2:= plot3d([r, theta, z], theta= 0..2*Pi, z= -h(r)/2..h(r)/2, coords= cylindrical, color= yellow, style= patchnogrid):

plots:-display([P1,P2]);

 


Download cylinder_in_sphere.mw

No, ShowSolution does not make much progress with this integral. The trick for this integral is to apply a trigonometric identity for sin(a)*sin(b). The command combine applies this automatically.

J:= Int(sin(k*(t-tau))*sin(k*tau), tau= 0..t);

State the identity, for the record:

sin(a)*sin(b):  % = combine(%);

Apply it to the integral:

combine(J);

I'll assume that you know the steps to finish the integral from there. If not, let me know.

Int is the inert form of Maple's integration command. The active form is int.

expr2 := sin(k*(t-tau))*sin(k*tau);
int(simplify(expr2, symbolic), tau = 0 .. t);

If A and B are the two matrices, then do LinearAlgebra:-Equal(A,B).

Multiple plots can be made by making the first argument to plot a sequence of functions. I find this easier than using plots:-multiple.

N:= 10: #Number of plots.
plot(
     [seq(s(i), i= 0..N-1)], x= -10..10, y= -1..1,
     color= [seq(COLOR(HUE, .85*i/N), i= 0..N-1)]
);

The colors are set to proceed through the standard color spectrum, from red to violet. (The horrible staggered rendering in the plot below is the fault of MaplePrimes (this forum); the plot appears much smoother in Maple itself.)

First 285 286 287 288 289 290 291 Last Page 287 of 395