Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 31 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

There's a decimal point that you included somewhere in your input. Remove it.

Here's a simple solution, off the top of my head, with the dancers starting at [1,1], [1,-1], [-1,-1], [-1,1]. I leave animating this solution to you. It's really easy. The position of dancer (0 to 3) at time is [x||k(t), y||k(t)].

 

restart:

 

eqns:=
     seq(diff(x||k(t), t) = cat(x,irem(k+1,4))(t) - x||k(t), k= 0..3),
     seq(diff(y||k(t), t) = cat(y,irem(k+1,4))(t) - y||k(t), k= 0..3)
;
ics:=
     x0(0) = 1, x1(0) = 1, x2(0) = -1, x3(0) = -1,
     y0(0) = 1, y1(0) = -1, y2(0) = -1, y3(0) = 1
:
Sol:= dsolve({eqns,ics}, numeric):

diff(x0(t), t) = x1(t)-x0(t), diff(x1(t), t) = x2(t)-x1(t), diff(x2(t), t) = x3(t)-x2(t), diff(x3(t), t) = x0(t)-x3(t), diff(y0(t), t) = y1(t)-y0(t), diff(y1(t), t) = y2(t)-y1(t), diff(y2(t), t) = y3(t)-y2(t), diff(y3(t), t) = y0(t)-y3(t)

plots:-odeplot(
     Sol, [seq([x||k(t), y||k(t)], k= 0..3)], t= 0..5,
     thickness= 3, axes= none, gridlines= false
);

dsolve({eqns,ics});

{x0(t) = exp(-t)*sin(t)+exp(-t)*cos(t), x1(t) = exp(-t)*cos(t)-exp(-t)*sin(t), x2(t) = -exp(-t)*sin(t)-exp(-t)*cos(t), x3(t) = -exp(-t)*cos(t)+exp(-t)*sin(t), y0(t) = exp(-t)*cos(t)-exp(-t)*sin(t), y1(t) = -exp(-t)*sin(t)-exp(-t)*cos(t), y2(t) = -exp(-t)*cos(t)+exp(-t)*sin(t), y3(t) = exp(-t)*sin(t)+exp(-t)*cos(t)}

 

 

Download Spriral_Dance.mw

Try the old profiling commands: exprofileexcallgraphprofile. I don't have much experience with profile. I've used exprofile and excallgraph a lot, and I've never come across code that they couldn't handle.

The mathematical constant Pi is spelled with a capital in Maple. If you spell it pi, it's just another variable, which, unfortunately, prettyprints exactly the same as the mathematical constant. However, the printed forms can be distinguished using the lprint command.

A (nonconstant) function of a random variable is itself a random variable. So your is already a random variable and there's no need to apply RandomVariable to it. Skip T1, and do what you want with Y, such as 

simplify(PDF(Y,t));

or, more directly,

simplify(PDF(1/X,t));

 

restart:

 

MaxAbsWithIndex:= proc(M::Matrix(numeric), col::posint)
# Returns the entry with maximal absolute value in column col
# and its row index.
local
     Max:= -infinity, i, MaxI, v, absv, Maxv,
     Rows:= proc(M) option inline; op([1,1],M) end proc
;
     for i to Rows(M) do
          v:= M[i,col];
          absv:= abs(v);
          if absv > Max then
               Max:= absv;
               MaxI:= i;
               Maxv:= v
          end if
     end do;
     (Maxv, MaxI)
end proc:

 

Pivot:= proc(M::Matrix(numeric), row::posint, col::posint)
uses RO= LinearAlgebra:-RowOperation;
local Max,MaxI;
     (Max,MaxI):= MaxAbsWithIndex(M, col);
     RO(RO(M, [row,MaxI], _rest), row, 1/Max, _rest)
end proc:
          

A:= LinearAlgebra:-RandomMatrix(3,4);

A := Matrix(3, 4, {(1, 1) = -32, (1, 2) = 27, (1, 3) = 99, (1, 4) = 92, (2, 1) = -74, (2, 2) = 8, (2, 3) = 29, (2, 4) = -31, (3, 1) = -4, (3, 2) = 69, (3, 3) = 44, (3, 4) = 67})

A1:= Pivot(A, 1, 1);

A1 := Matrix(3, 4, {(1, 1) = 1, (1, 2) = -4/37, (1, 3) = -29/74, (1, 4) = 31/74, (2, 1) = -32, (2, 2) = 27, (2, 3) = 99, (2, 4) = 92, (3, 1) = -4, (3, 2) = 69, (3, 3) = 44, (3, 4) = 67})

A;

Matrix(3, 4, {(1, 1) = -32, (1, 2) = 27, (1, 3) = 99, (1, 4) = 92, (2, 1) = -74, (2, 2) = 8, (2, 3) = 29, (2, 4) = -31, (3, 1) = -4, (3, 2) = 69, (3, 3) = 44, (3, 4) = 67})

Pivot(A, 1, 1, inplace);

Matrix(3, 4, {(1, 1) = 1, (1, 2) = -4/37, (1, 3) = -29/74, (1, 4) = 31/74, (2, 1) = -32, (2, 2) = 27, (2, 3) = 99, (2, 4) = 92, (3, 1) = -4, (3, 2) = 69, (3, 3) = 44, (3, 4) = 67})

A;

Matrix(3, 4, {(1, 1) = 1, (1, 2) = -4/37, (1, 3) = -29/74, (1, 4) = 31/74, (2, 1) = -32, (2, 2) = 27, (2, 3) = 99, (2, 4) = 92, (3, 1) = -4, (3, 2) = 69, (3, 3) = 44, (3, 4) = 67})

 

 

Download Pivot.mw

I think that the only reason to use Join would be if you wanted to use its second argument, the separator. I did some quick tests, and cat is quicker and uses less memory. Join is externally compiled and cat is built-in, so they're both pretty efficient.

How about shifting the z-coordinates of the centers of the base circles?

p1:= plottools:-cylinder([1, 1, 1], 1, 1):
p2:= plottools:-cylinder([1, 1, 2], 2, 3):
p3:= plottools:-cylinder([1, 1, 5], 1, 4):

plots:-display([p1,p2,p3]);

Here's an example of your 1, 2, and 3. There are many ways for 2 and 3. Pay special attention to the way that prime-power fields are created in Maple because it's a little unusual.

restart:
#0. Create the matrix
p:= Randprime(3,x) mod 2;
alias(x= RootOf(p,x)):
M:= Matrix(5,7, ()-> randpoly(x, degree= 3));

#1. Get the rank.
Gausselim(M, 'rank') mod 2:
rank;
     5


#2. Row sum squared
V:= Vector(op([1,1], M), i-> expand(add(y, y= M[i,..])^2));

#3. Dividing by row sum squared
Matrix(op(1,M), (i,j)-> M[i,j]/V[i]);

 

See the commands ?sign, ?primpart, and ?content. Using those, here's a short procedure for it:

p:=x^2*y-2*y*z+3*x^2+2*y-z:

RepeatPositiveTerms:= (P::polynom(integer))->
     [seq(`if`(sign(t)=1, primpart(t) $ content(t), [][]), t= [op(expand(P))])]
:

RepeatPositiveTerms(p);

     [x^2*y, x^2, x^2, x^2, y, y]

 

Any function can be made to map over a list by appending to its name:

abs~(L);
signum~(L);

Or, getting a bit fancier, there's

(abs~, signum~)(L);

 

Your system is overspecified: You have three equations, but only two unknown functions. This can't be solved.

In general, it is a bad idea to use D and gamma as variable names because they have predefined meanings in Maple; however, your usage of them here causes no problem.

The purpose of the macro below is to simplify the typing of the function. If you don't like it, you can just as well continue to use BesselJ and HermiteH.

macro(B= BesselJ, H= HermiteH):
F:= (Pi*B(1,x)*H(0,x) + 2*B(0,x) - Pi*B(0,x)*B(1,x)*H(0,x)) *
        exp(-x^2*D*t/alpha)*B(0,x/chi)/B(1,x)^2 -
        M[0]*T[2]*gamma*exp(-T[g]/T[0]*(t-delta));
params:=
      [M[0]= 8, g= 9.8, gamma= 1.17, r= 1.15, T[g]= 1.11111,
      T[0]= 3.666667, t= 5e-9, delta= 0.002, x= 3.478505,
      alpha= 5.36, k= 1.2, r= 1.15, D= 7.46];

plot3d([chi, eval(F, params), T[2]], chi= 0.22..0.25, T[2]= 300..900, grid= [4,4]);

The purpose of grid= [4,4] is to restrict chi and T[2] to the four discrete values that you specified. You could just as well omit it and then a 50x50 grid would be used.

The general command to solve it is pdsolve:

pdsolve(diff(c(x,t),t)=diff(c(x,t),x,x)-diff(c(x,t),x)-c(x,t), c(x,t));

But unless you specify the initial and boundary conditions in the command, the solution returned is somewhat trivial. (Perhaps "trivial" is not the right word: maybe "overly general" better describes it.) If you are having trouble putting the intial and boundary conditions into the form that Maple wants, let me know.

Use the command fnormal (see ?fnormal).

First 255 256 257 258 259 260 261 Last Page 257 of 395