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

Mehdi,

You need to put your points into a list rather than a set to preserve their order. Just change your last line to

plot([seq([t,w[t]],t=0..0.3,h)]);

How about this? I reduced the points and frames just to avoid having to upload a huge file.

plots:-animate(
    plots:-polarplot,
    [2-2*sin(theta), theta= 0..T, filled, numpoints= 50],
    T= 0..2*Pi, frames= 50, paraminfo= false
);

First, download the OrthogonalExpansions package from the Maple Applications Center. Then


restart:

x^2 = OrthogonalExpansions:-FourierSeries(x^2, x= -Pi..Pi, infinity);

x^2 = (1/3)*Pi^2+Sum(4*(-1)^i*cos(i*x)/i^2, i = 1 .. infinity)

eval(%, x= Pi);

Pi^2 = (1/3)*Pi^2+Sum(4*(-1)^i*cos(i*Pi)/i^2, i = 1 .. infinity)

simplify(%) assuming i::posint;

Pi^2 = (1/3)*Pi^2+Sum(4/i^2, i = 1 .. infinity)

expand(%);

Pi^2 = (1/3)*Pi^2+4*(Sum(1/i^2, i = 1 .. infinity))

solve(%, indets(%, specfunc(anything, Sum)))[];

Sum(1/i^2, i = 1 .. infinity) = (1/6)*Pi^2

 


Download Fourier_Euler.mw

Frames:= 25:
plots:-animate(
     plots:-odeplot,
     [
          Trajectoire,
          [seq([x||k(t), y||k(t), t], k in [$1..9, A])],
          t= TempsInitial..T, numpoints= 10000
     ],
     T= TempsInitial+(TempsFinal-TempsInitial)/Frames .. TempsFinal,
     frames= Frames, axes= boxed, scaling= constrained
);

 

After the line defining h3, put the line

h3:= evalc(Re(evalc(simplify(evalc(h3)))));

This will cause a major simplification of h3 (which is obviously real for real parameters) and make the integration go much faster.

Here is some code that is essentially the same as the OP's original code that gave difficult-to-interpret piecewise results in Maple 17:

restart:
G:= p*(e*t+1)^r*exp(t/(e*t+1))-t;
Sol:= solve({'diff(G, [t$k])' $ k= 0..2, r > 0, p >= 0, e > 0}, {p, r, t});

To gain more understanding of this solution, I removed the inequalities from the solve and added option explicit:

Sol:= solve({'diff(G, [t$k])' $ k= 0..2}, {p, r, t}, explicit);

We see that there are two solutions, so name them individually:

Sol||(1..2):= Sol;

Now plot the p and r from each solution:

plot(eval([p,r], Sol1), e= 0.01..0.99);
plot(eval([p,r], Sol2), e= 0.01..0.99);

It is clear from the plots that only Sol1 contains the positive solutions that we're seeking. Now find the range of e that makes p >= 0 and r > 0 under Sol1:

solve({eval(p, Sol1) >= 0, eval(r, Sol1) > 0}, {e});

 

 

 

You need to get rid of all assume statements. I don't know why, but they are blocking your ability to substitute for the variables. The rest of the worksheet works fine without them.

Then, change the statement

u:= (x,y,t)->Sum(Sum(u(x,y,t),n=1..20),m=1..20);

This statement has unintended recursion. Just change the letter on the left side to capital U:

U:=(x,y,t)->Sum(Sum(u(x,y,t),n=1..20),m=1..20);

Then your plot will work. To make the animation, use this command:

plots:-animate(plot3d, [U(x,y,t), x= 0..1, y= 0..1, axes= boxed], t= 0..1);

Your main problem is that you need to change linalg[matrix] to Matrix. Also, Matrix multiplication is with `.`, not `*`. Then you need to convert the Matrices to sets before passing them to fsolve. I also made some massive simplifications to your code that was not correcting errors.

restart:
Digits:= 20:

N:= 3:
 
y11:= x-> sum(a[n]*x^n, n= 0..N):
y12:= x-> sum(b[n]*x^n, n= 0..N):
y21:= x-> sum(c[n]*x^n, n= 0..N):
y22:= x-> sum(d[n]*x^n, n= 0..N):

A:= Matrix(2, 2, [1, -1, 1, exp(x)]):
B:= Matrix(2, 2, [-3*exp(-x)-1, 2-2*exp(-x), -3*exp(-x)-2, 1-2*cosh(x)]):
Z:= Matrix(2, 2, [3,0,1,1]):

Y:= Matrix(2, 2, [y11, y12, y21, y22](x)):
YY:= diff~(Y,x):

S:= `union`(seq(convert(eval((YY-A).(Y-B), x= n/N), set), n= 1..N)):
S1:= eval(S, convert(eval(Y, x= 0)=~ Z, set)):
sol:= fsolve(S1);

alias(h=f(x,y));

I think that Joe's abbreviated code is brilliant, but it still has time complexity O(|L|*|E|). Here's a version with time complexity O(|L|+|E|) which relies on Maple's table lookups using essentially constant time.

list_minus:= proc(L::list, E::{list,set})
local R:= table(sparse), e;
     for e in E do R[e]:= R[e]+1 end do;
     remove(e-> if R[e] > 0 then R[e]:= R[e]-1; true else false end if, L)
end proc:

Test:

list_minus([1,2,4,6,2,1,3,6,2], [7,4,2,5,2]);

Make the plot's color depend on the animation parameter. For example,

plots:-animate(plot, [x+b, x= -1..1, color= COLOUR(HUE, (b+1)/2)], b= -1..1, trace= 5);

See ?Optimization and ?Optimization,NLPSolve .

This is almost identical to your last question. The answer is identical: You need to use value to force evaluation of the integrals (and hence the removal of their dummy variable _z1). Change the line

f(tau):=sum((f[j])(tau),j=0..n);

to

f(tau):= value(sum(f[j](tau), j= 0..n));

My favorite way to plot a complex expression over a real parameter range is

plot([Re,Im](-x+sqrt(-5*x)), x= -10..10);

There's also ?plots,complexplot and ?plots,complexplot3d .

That form is called prefix form. In Maple 18, this is accomplished by

InertForm:-Parse("x*(y+z)/x");

First 311 312 313 314 315 316 317 Last Page 313 of 395