Robert Israel

6317 Reputation

19 Badges

11 years, 48 days
University of British Columbia
Associate Professor Emeritus
Vancouver, British Columbia, Canada

MaplePrimes Activity


These are answers submitted by Robert Israel

Unfortunately, it appears that your file consists of all 0 bytes.  Whatever you had in it is lost.

I think it's somewhat more convenient to keep track of the vertices of each triangle.  If triangle #n has vertices V1, V2, V3, with V1 shared with #(n-1), then triangle n+1 is V2, V2 + P(n+1)/P(n)*(V3-V1), V2 + P(n+1)/P(n)*(V3 - V2).

This code produces the Padovan sequence:

P:=  proc(n) option remember;
  procname(n-2)+procname(n-3);
end proc:
P(1):= 1: P(2):= 1: P(3):= 1:

This produces 16 triangles.

T[1]:= [[[0,0],[1,0],[1/2,sqrt(3)/2]]:

for n from 2 to 16 do
  T[n]:= [T[n-1][2], T[n-1][2] + P(n)/P(n-1) * (T[n-1][3]-T[n-1][1]), T[n-1][2] + P(n)/P(n-1)*(T[n-1][3]-T[n-1][2])]
od:

And this displays the results.

plots:-display(seq(plots:-polygonplot(T[n], colour=`if`(n::odd, red, brown)), n=1..16), scaling=constrained, axes=none);

The assume command does not force n to be given integer values, it just causes Maple to assume the variable n is an integer for purposes of simplification. 

 

  1. You want to have a variable to represent the count.  You might as well call it count.  To set it to 0: count:= 0;To increment it:count:= count + 1;
  2. You can restrict the domain of your procedure by including a type declaration in the parameter sequence.  Thus:
    eulerphi:= proc(n::integer)

Instead of an explicit closed-form solution, you could try a numeric solution.

> ans:=pdsolve(PDE,{BC},numeric);

And then, for example,

> ans:-animate(t=0..5);

or

> ans:-plot3d(x=0..1, t=0..5);

 

 

With the code written as above (and default settings), you'll get a whole bunch of "x:= ..." output filling up the worksheet.  To avoid that, use colon ":" instead of semicolon ";" after the "end do".  All those nuisance outputs can also impact measured timing. 

Even with ":", your results will still vary slightly.  One reason is garbage collection, which takes place at unpredictable times. The more junk there already is in memory, the more often this will be needed.  On the other hand, some functions place values in remember tables, and this can reduce computation time the second time around.

Finally, typical modern computers are multi-tasking with lots of other things going on in the background, and this can have its effects on timing.

Or this:

PDEtools:-declare(y(t), prime=t);

                 y(t) will now be displayed as y
derivatives with respect to t of functions of one variable will  now be displayed with '

di;

             y'' - 4 y' + 5 y = et

 

The mathematical definition of sinc(x) is:

piecewise(x=0, 1, sin(x)/x)

The Sinc function in DynamicSystems is set up rather strangely (for someone used to ordinary Maple functions).  To get the value of sinc(0), you can use

Sinc(discrete=true,samplecount=1);

[ 1. ]

 

A really good approximation to the integrand ifor s >= 0 s obtained by using the Maclaurin series 

Thus your integral becomes

where each term can be evaluated explicitly.  Thus using terms up to k = 20:

F20:= add((-1)^k/(k+1)*int(exp(-(k+2)*s)*s^(k+1),s=0..t), k=0..20):

which will have error less than

for all t > 0.

 

 

 

This is a "feature", not a bug.  See the help page ?sum,details.

 If m > n+1 are integers, the value returned is -sum(f, k=n+1..m-1). With these conventions, the following holds for all integers l,m,n.
 

It's hard to tell without looking at your actual equation, but if h is a function of one variable and only evaluated at y^2 - k^2*x^2, you are likely to have an ordinary differential equation if you have anything at all.  Suppose your  equation is of the form
A(k,x,y)*D(h)(y^2 - k^2*x^2) + B(k,x,y)*h(y^2-k^2*x^2) + C(k,x,y) = 0.  Let t = y^2 - k^2*x^2.  In the region where y > 0, say,  we can express y in terms of t and get

a(k,x,t)*D(h)(t) + b(k,x,t)*h(t) + c(k,x,t) = 0

Fixing k and x, this is an ordinary differential equation in h(t), and can be solved by dsolve.  However, since you want h to be a function of t alone, the solution must be independent of the other variables k and x.  That may or may not be true: if there is no solution that is independent of k and x, your equation can't be solved.

There's nothing in Maple's GUI that can produce a sound, but an external program can be launched to do it.  See http://www.mapleprimes.com/questions/125062-Play-Audio-File-From-Maple

Your system corresponds to a 4 x 4 homogeneous linear first-order system X' = A X, X(0) = X0, where A is a matrix of constants.  When (as is generically the case) A has distinct eigenvalues r1,...,r4, the solution  can be written as

where vj is the eigenvector corresponding to eigenvalue rj, and cj = wj X0 where wj is a left eigenvector for rj, normalized so wj vj = 1.

Now unfortunately the "closed form" solution in radicals of a quartic polynomial is a very complicated thing, and that's where dsolve runs into time and memory problems.  If it would
use RootOf here, a manageable solution could be found.

> ode := m[r]*(diff(x[r](t), `$`(t, 2)))+c[r]*(diff(x[r](t), t)-(diff(x[g](t), t)))+
k[r]*(x[r](t)-x[g](t)) = 0,
m[g]*(diff(x[g](t), `$`(t, 2)))+c[g]*(diff(x[g](t), t))+c[r]*(diff(x[r](t), t)
-(diff(x[g](t), t)))+k[g]*x[g](t)+k[r]*(x[r](t)-x[g](t)) = 0;
subs(diff(x[g](t),t)=v[g](t),diff(x[r](t),t)=v[r](t),{ode});
solve(%,[diff(v[g](t),t),diff(v[r](t),t)]);
sys:= [op(op(%)),diff(x[g](t),t)=v[g](t),diff(x[r](t),t)=v[r](t)];

> X0:= <1,1,0,0>;
with(LinearAlgebra):
A:= GenerateMatrix(map(rhs,sys),[v[g](t),v[r](t),x[g](t),x[r](t)])[1];


> P := CharacteristicPolynomial(A,lambda);

> B:= A - lambda*IdentityMatrix(4);
V:= op(NullSpace(B[2..4,1..4]));

> W:= op(NullSpace((B^%T)[2..4,1..4]))^%T;

> a:= W . X0 /(W . V);

> sol:= Sum(a*exp(-lambda*t)*V,lambda=RootOf(P,lambda));

You might try Isolate in the RootFinding package.

Make sure under Tools, Options, General that you have Mathematical Engine set to
"Create a new engine for each document".  Then it should be possible (under any version of Windows) to have two worksheets operating independently. 

Ah: I think I see the problem.  Pressing the !!! button on one worksheet disables that button for the other worksheet.   I think that's a bug.  However, what you can do in the second worksheet is, in the Edit menu,  Select All, then Execute, Selection.

1 2 3 4 5 6 7 Last Page 1 of 138