Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Perhaps you don't realize that Psi is an already-defined special function? See ?Psi. If this is the case, then you should use a different name than Psi. But if you really have a good reason for wanting to use the name Psi, then first execute

local Psi;

Since subs works, you should use it.

The set of cases where algsubs works is not a superset of the set of cases where subs works. Thus, "It is a generalization of the subs command" should perhaps be removed from its help. Rather, think of algsubs as something that will sometimes work for cases where subs fails. Please read carefully the paragraph of ?algsubs that deals with how negative powers of the substitution target are handled. That is what is happening in the case that you present.

Algsubs is a high-level command, written in Maple. It consists of 194 lines (*footnote 1) of highly recursive (*footnote 2) code split over 11 procedures. On the other hand, subs is a low-level builtin command, and it is easy to fully understand what it does, even though you can't read the code. The job of replacing one name with another is clearly a job for subs.

(*footnote 1): Lines are as counted by showstat, which doesn't count proc, local, elif, else, end, blank lines, or comments as separate lines.

(*footnote 2): On a quick read through, I counted 13 points where the code calls itself recursively.

If A is the array, and it has n elements, then the animation can be produced by

plots:-display([seq(A[k], k= 1..n)], insequence);

It is not your fault. This is a bug. The issue is that there are two ways to enter an inert double integral (using 1D input), but only one of those ways is understood by dchange. The two ways are

Int(Int(f(x,y), x= a..b), y= c..d);

That's the old way, which is still 100% acceptable. The newer way is

Int(f(x,y), [x= a..b, y= c..d]);

but this isn't understood by dchange and some other commands.

The workaround is to use value(UP) instead of simply UP in the dchange command.

The entries of a Maple matrix can be any type of Maple data structure, including other matrices, expression sequeneces, NULL. For example:

M:= Matrix((2,2), (i,j)-> Matrix((j,i), (m,n)-> m*n));

A semicolon or colon after your first end do is required. The colons after your second and third print statements are optional.

After you fix that syntax, you'll have an infinite loop, but I think that you already know that. What you may not know is that it's very difficult to stop an infinite loop that's displaying output to the screen. You usually need to kill your entire Maple session, including all open worksheets.

1. I don't understand what "if G(r) = 0, then r = z" means.

2. I don't understand the boundary condition Psi(z) = 1. Do you mean Psi(0) = 1?

3. I don't know if one can "shoot" for infinity (although this may be a well-known technique with which I am simply unfamiliar).

4. Does r represent the distance from the origin in the complex plane?

For efficiency, it'd be better to use a custom procedure for this purpose rather than constructing a lengthy expression of ands and ors using seq. This is because in the vast majority of cases the evaluation can be terminated early without examining every (or even most) of the elements. Here's the procedure:

LexicographicOrder:= proc(a, b)
local k, na, nb;
   (na,nb):= (numelems(a), numelems(b));
   for k to min(na,nb) do
      if a[k] < b[k] then return true 
      elif a[k] > b[k] then return false
      end if
   end do;
   evalb(na < nb)
end proc:

If you're comparing lists of length 100, the procedure should be thousands of times faster for the average case than the construction with seqs. Constructing sequences of numerous subsequences is a relatively expensive operation in Maple.

Your second form and displayed form, both of which show the series as externally multiplied, are mathematical nonsense. But your first form, which has the series nested, makes sense. You said that it gives wrong answers. Note that the results below differ from your desired results by a factor of exactly 3. You must be missing a 3 somewhere.

restart:


SS:= sum(F[k-m]*sum(F[m-L]*sum(F[L-j]*F[j], j= 0..L), L= 0..m), m= 0..k):
eq:= (-1/(k+1))*(F[k] + sum((k-m+1)*F[k-m+1]*F[m], m= 0..k)/2+SS/20):
n:= 8:
F:= table():
for K from 0 to n do
   F[K+1]:= solve(eval(eq, k= K), F[K+1])
end do;

-(1/10)*F[0]^3-2

(3/200)*F[0]^2*(F[0]^3+20)

-(1/400)*F[0]*(F[0]^6+28*F[0]^3+160)

(7/16000)*F[0]^9+(63/4000)*F[0]^6+(3/20)*F[0]^3+1/5

-(9/800000)*F[0]^2*(7*F[0]^9+308*F[0]^6+4160*F[0]^3+16000)

(3/16000000)*F[0]*(77*F[0]^12+4004*F[0]^9+70080*F[0]^6+448000*F[0]^3+640000)

-(429/160000000)*F[0]^15-(1287/8000000)*F[0]^12-(3459/1000000)*F[0]^9-(777/25000)*F[0]^6-(171/1750)*F[0]^3-6/175

(9/17920000000)*F[0]^2*(1001*F[0]^15+68068*F[0]^12+1735776*F[0]^9+20137600*F[0]^6+100121600*F[0]^3+145920000)

-(1/179200000000)*F[0]*(17017*F[0]^18+1293292*F[0]^15+38152576*F[0]^12+542971520*F[0]^9+3722624000*F[0]^6+10304000000*F[0]^3+5836800000)

 

Download Solve_series.mw

Note that the -1/(k+1) coefficient in front of eq is superfluous. It couldn't possibly change the results because eq is equated to 0.

The polynomial equation is sixth degree in v. It's mathematically impossible to solve it. This is not a limitation of Maple.

The package linalg, and the commands evalm and crossprod had been superceded long before Maple 13. Also, you can reduce the repetition in your code by using elementwise operators:

restart:
ly:= 9.4607e15:
M0:= 1.99e30:

M:= M0*[2.20, 2.00, 1.50, 3.00]:

r:= [<-3, 3, 0>, <0, -2, 0>, <1, 2, 0>, <6, 4, 0>]*ly:
v:= [<25, 15, 0>, <20, -20, 0>, <-5, -25, 0>, <15, 0, 0>]*1e3:

Mtot:= `+`(M[]):

rcm:= `+`((M*~r)[])/Mtot:
vcm:= `+`((M*~v)[])/Mtot:

with(LinearAlgebra): 
add(r[i] &x (M[i]*v[i]), i= 1..nops(v)) - rcm &x (Mtot*vcm);

Other than the names, there is no similarity between eval and evalf. The command for evaluating an expression with free variables at values for those variables (a "point") is eval. The command for converting expressions with no free variables into complex decimal approximations is evalf. If you use evalf on an expression with free variables, then it is simply applied to the subparts that don't. It's not possible to use one command in place of the other.

You'll need to post the series problem that you're talking about to get further advice.

Induction is a proof technique. The corresponding programming technique is called recursion. This means that the procedure calls itself.

(A half a line of code omitted.)

That's all there is to it.

 

 

The error message says that it wants an indication of the dependent variables. So, change the pdsolve command to

pdsolve([pde, bc], u(x,t))

Diff(int(value(z), t), t);

First 192 193 194 195 196 197 198 Last Page 194 of 395