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

It is not a bug. Your pp has a root at cp=3220 for any value of x. You can see this by eval(pp, cp= 3220), which is identically 0. Because of floating point variation, Roots will find that root at slightly less than 3220 or exactly 3220 or slightly more than 3220. Often Roots will not find this root at all, because the curve becomes vertical (is not differentiable) at 3220. Because you asked for roots in the interval 1..3220, the root will be reported when it is less than or equal than 3220. Since you are not interested in seeing the root at 3220 on your graph, change the interval to 1..3219 and you will never see them.

Edit: Added sentence about Roots often not finding the root at 3220.

1. You seem to have some confusion as to what "leading coefficient" means. It means the coefficient of the term with the largest exponent on the main variable. What you are calling the leading coefficient is actually the "trailing coefficient."

2. Polynomials can be sorted into ascending or descending powers of their main variable with the sort command. For example:

sort(collect(expand(lhs(e4)),t), t, ascending);

3. You cannot control the order that items appear in a Maple set. If you use curly braces {}, it will be a set. If want to maintain an order, use square brackets [ ] to make it a list.

4. Why do you care about the order? Relying on a certain order is often (but not always) a sign of poor coding practice.

Use convert to convert to diff form and another convert to convert back to form. It can all be done in one line.

eq:= D[2](u)(x,t)= a^2*D[1,1](u)(x,t):
expr:= D[2,2](u)(x,t):
convert(eval[recurse](convert([expr, [eq]], diff)[]), D);

Your immediate problem is that you can't use a formal parameter, x, as the index of a for loop. I think that you meant for i to be the index.

There are other problems which don't produce syntax errors: By local top::0, you surely mean to initialize top to 0. That should be top:= 0. And by 

top =top+(((x^(2+i))*top)^(1/(n+2-i)))

you surely mean to update the value of top. So that should be 

top:= top+(x^(2+i)*top)^(1/(n+2-i))

Now the problem is that the above line can never change top from 0. So your formula is wrong, but I have no idea how to correct it because I don't recognize what this formula is supposed to do.

With all my corrections, the code becomes:

soru:= proc(n, x)
local i, top:= 0;
     for i from 2 to n do
          top:= top+(x^(2+i)*top)^(1/(n+2-i));
          print(top);
     od;
     top
end proc;

I suspect that this is a bug with the one-argument add, which is new to Maple 2015. Try replacing your add command with add(x, x= maMat[5, 1..-1]).

Initial and boundary conditions of PDEs must be specified with notation rather than diff notation. Your boundary conditions given above become

bc[1]:= -D[2](phi)(x,-d) = 0;
bc[2]:= D[1](phi)(0,z) = D[1](phi)(2*Pi,z);

where the [1] and [2] denote differentiation with respect to the first and second variable, respectively. To pass the conditions to pdsolve use

pdsolve({pde, bc[1], bc[2]}, HINT= X(x)*Z(z));

which will quickly (5 seconds or so) return a solution. I did this in Maple 18. I don't know whether Maple 13 will solve it with the boundary conditions, but I am sure that you must use notation for them.

Here are three procedures, one for each of your matrix templates:

M:= proc(i::nonnegint, alpha, N::nonnegint)
local k;
     Matrix(
          N+1, N+1,
          [seq([0$(N-k)], k= 0..i-1), [seq(1/GAMMA(k*alpha+1), k= 0..N-i)]],
          scan= band[0,i]
     )
end proc:

WF:= (w,u,f,x,lambda,N::nonnegint,m::nonnegint)->
     < < Matrix(N-m+1, N+1, (i,j)-> w[i-1,j-1]), Matrix(m, N+1, (i,j)-> u[i-1,j-1]) > |
          Vector(N+1, fill= `;`) |
         < Vector(N-m+1, i-> f(x[i-1])), Vector(m, i-> lambda[i-1]) >
     >
:

X:= (a,x,c,N::nonnegint)-> Matrix(N+1, N+1, (i,j)-> (x[i-1]-c)^((j-1)*a));

Use op. Let's say that MyProc() generates lengthy output. Then do

Result:= MyProc(): #End with a colon!
N:= nops(Results); #Number of operands
op(1..1000, Results); #Iff N > > 1000

It's very simple: D(f)

Here are the commands to numerically solve the PDE. The notation D[2] in the initial conditions refers to differentiation with respect to the second variable, t. The 0 as the third argument to each piecewise is a default value to be used when the condition (the first argument) is not satisfied.

restart:
PDE:= diff(u(x,t),t,t)-2*diff(u(x,t),x,x)+diff(u(x,t),x,t) = 0;
ICs:=
    u(x,0) = piecewise(abs(x) < 1, 1-x, 0),
    D[2](u)(x,0) = piecewise(abs(x) < 1, cos(Pi*x), 0)
;
BCs:= u(-4,t) = 0, u(4,t) = 0:
Sol:= pdsolve({PDE}, {ICs,BCs}, numeric, time= t, timestep= 0.025, spacestep= 0.1);

And here are some of the numerous plots you can generate:

Sol:-plot(x=0, t= 0..1);
Sol:-plot(t=1, x= -4..4);
Sol:-animate(x= -4..4, t= 0..3, numpoints= 100);

See ?pdsolve,numeric for more.

I believe that the memory will be freed at the first garbage collection after the restart. You can either wait for the garbage collection to come around on its own schedule, or you can force the collection with the command

gc();

 

Unknown error? I think that the error message is fairly clear for this one. You are trying to add a 3-element row Vector to a scalar.

Tr(X) and Tr(X0) are row Vectors, and H[1] is a scalar. So Tr(X).H[1]-Tr(X0).H[1] is a row Vector. Dtau1CC[1], and Tr(Dtau2) are 3x1 Matrices, and is a 3-element column Vector, so 3*(Tr(X).Dtau1.CC[i].Tr(Dtau2).U) is a scalar.

L:=[seq([i,i^2], i=1..4)]:

plots:-animate(
     plot,
     [L[1..trunc(k)]],
     k= 1..nops(L), frames= nops(L),
     style= point, symbol= circle, symbolsize= 12,
     view=[0..4,0..16]
);

Your problem is excessive calls to randomize(). Just use it once, at the top of your code.

The Maple clock has much lower resolution than your CPU clock. The Maple clock hasn't advanced between your calls to randomize() in the loop. Thus, the randomize() is setting the random sequence back to the same position.

You (or the code that you're calling) is trying to store a symbolic value, L, into a Matrix which is restricted to numeric values only. You must give a numeric value.

If that's not enough information for you to correct your code, then you'll need to post your code.

First 261 262 263 264 265 266 267 Last Page 263 of 395