Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

My method, similar to Acer's, takes 23 seconds. Note that I selected a different NAG integration routine, appropriate for infinite intervals, and set the upper limit to infinity (because I assumed that that was your original intention). Note the capital-I Int. That's the key to getting numeric integration.

with(plots):
z:= 2*Int((sin(2*y)-sin(y))*cos(y*x)*exp(-y^2*t)/y, y = 0 .. infinity, method= _d01amc)/Pi;
animate(plot, [z, x = 0 .. 10, y= -.1..2, gridlines= false], t = 0 .. 1, frames = 100);

 

I see numerous syntax errors, and I don't know why you can't find them yourself at this point.

  1. There should be a semicolon, not a comma, after local bb
  2. i also should be declared local
  3. There should be no = after in the for clause
  4. You need a space before end if
  5. You have an extra colon in y::= x[i]^2

Fix those, then I'll help you with the rest.

 

You can't use the word error as a name in Maple code. (Well, you can't do it directly at least.) Use err instead.

You're making this unnecessarily complicated. Just use dsolve and plot the function that it gives you for each value of b:

restart:
ODE:= b-> 2*diff(y(t),t$2) + b*diff(y(t),t) + 9*y(t) = 0:
ICs:= y(0)=0, D(y)(0) = -3:
Y:= b-> rhs(dsolve({ODE(b), ICs})):
b||(1..3):= 1, sqrt(72), 9:
plot(['Y(b||k)' $ k= 1..3], t= 0..2*Pi, legend= ['b = b||k' $ k= 1..3]);

Your syntax for a Matrix constructor in HomRot is completely wrong. It should be

HomRot:= theta->
     < < cos(theta)  | sin(theta) | 0 >,
       < -sin(theta)  | cos(theta) | 0 >,
       < 0               | 0              | 1 >
     >;

There are a few other syntaxes available also. Without seeing your code for Trans and HomSquare, I can't help you further.

Do you intend for the function to be zero outside the ranges that you defined in the piecewise? One thing that you can do is simply add a plot range:

plot(piecewise(0 <= t and t < 2, 2-t, 2 <= t and t <= 3, 2*t-4), t= 0..6, axes= boxed);

You can select individual curves in a plot with the mouse. Then right click for the context menu. Then select the Line submenu.

Programmatically, you can do something like this:

plot([x, x^2], x= 0..2, linestyle= [solid, dash]);

 

In your second worksheet there is a procedure FiveSpeedGearBox_R which contains the two lines

eq:= piecewise(ig=1,i[1],ig=2, i[2],ig=3,i[3],ig=4,i[4],ig=5,i[5],1);
return eq(ig);

The expression eq(ig) is gibberish. Unfortunately, Maple does not recognize it as such and lets you run with it. A piecewise expression is not a procedure---it does not take an argument. Replace these two lines with the single line

return piecewise(ig=1,i[1],ig=2, i[2],ig=3,i[3],ig=4,i[4],ig=5,i[5],1);

After making that change, the solve runs for about 90 minutes and returns a solution without error or warning. That solution is five screens "wide" by 56 screens "tall". Here is the executed worksheet:

withGB.mw

 

You can use a recursive procedure.

X:= proc(Xo,Ro,n)
option remember;
     if not n::nonnegint then return 'procname'(args) end if;
     if n=0 then return Xo end if;
     Ro*thisproc(Xo,Ro,n-1)/(1+thisproc(Xo,Ro,n-1))^4
end proc:

BTW, I corrected your spelling of Hassell.

You must use N:= floor(a/h) or trunc(a/h). If you use round(a/h) then there's a risk that your x's will get larger than a. Note that trunc is semantically equivalent to floor for nonnegative numeric arguments, but trunc is simpler and faster.

test:=module()
uses DT = DocumentTools;
export abcd,tt,vv;
abcd:=proc()
    tt:=2000;
    vv:=DT:-GetProperty('Slider0', 'value');
    DT:-SetProperty('Label0', 'caption', vv);
end proc;

end module;

Your module test, which I've copied above, contains a procedure abcd which sets the values of some of the exports of the module. However, abcd is merely defined; it is never executed. So, right above the end module put the line abcd().

LinearAlgebra:-GramSchmidt({< 22,11,5 >, < 13,6,3 >, < -5,-2,1 >});

The imaginary parts are due to round-off error. Note that they are quite small. Their exact value is zero. It is impossible to avoid these imaginary parts if you solve a cubic by the cubic formula and and then substitute floating-point values for the coefficients. A plot shows that the cubic polynomial has three real roots. So, just throw away the imaginary parts. You can apply the Re command to each solution.

You want to use an Array of Records. See ?record .

I suggest that you enter your graph the normal way, by using the command GraphTheory:-Graph. GRAPHLN is intended for internal use. If you entered it the normal way, then the error pointed out by Kitonum would not have happened.

First 313 314 315 316 317 318 319 Last Page 315 of 395