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

In Maple 2015, I tried with the default method= rkf45, and with method= rosenbrock and I had no trouble. Did you try the default method? I confirm that dverk78 and lsode don't work for this problem.

If you'd followed today's discussion in the followups to your prior Question, you would've tried is. It's the most basic command for testing the mathematical equality (over the complex numbers) of expressions. Unfortunately, testeq is very limited in the expressions that it can handle.

is(C45=C54);

     false

(I'm a bit disturbed that you ignored Kitonum's advice (in your prior Question) that you not use I as a variable. I had to substitute J for I below to get meaningful results.)

Here's an explicit proof that the two expressions are fundamentally different: We evaluate each one setting all derivatives and variables to Pi/4, then simplifying.

C45a:= subs(I= J, C45):
C45b:= evalindets(convert(C45a, rational), specfunc(diff), freeze):
C45c:= evalindets(C45b, name, ()-> Pi/4):
simplify(C45c);

C54a:= subs(I= J, C54):
C54b:= evalindets(convert(C54a, rational), specfunc(diff), freeze):
C54c:= evalindets(C54b, name, ()-> Pi/4):
simplify(C54c);

 

RootFinding:-NextZero performs a job similar to fsolve (for real functions only). It's a little trickier to use because you have to carefully adjust its options or else it'll miss roots. But, if you want all the roots in a given interval, it may be a better choice than fsolve. Here's the first 20 positive roots:

K:= N-> KummerM(1/2-sqrt(2*N)/4, 1, sqrt(2*N)):

R:= table([0=0]):
for k to 20 while R[k-1]<10000 do
     R[k]:= RootFinding:-NextZero(K, R[k-1], maxdistance= 10000, guardDigits= 3)
od:

convert(R, list)[2..];

[3.65679345776329, 22.3047305506807, 56.9605153816721, 107.620271629881, 174.282057717514, 256.945030311759, 355.608766328753, 470.273028271534, 600.937671278859, 747.602601263178, 910.267754050297, 1088.93308412430, 1283.59855815621, 1494.26415108509, 1720.92984364050, 1963.59562071823, 2222.26147028210, 2496.92738260118, 2787.59334970751, 3094.25936500266]

Another root-finding command that's supposed to find all the roots in an interval is Student:-Calculus1:-Roots. However, in this case, it only finds 4 of the first 20.

I can't tell what you're doing wrong since you didn't post your code or upload a worksheet. I'll assume that by "deriving" you mean finding the derivative. (The verb form of derivative in mathematical English is, oddly enough, differentiate rather than derive.) To differentiate L with respect to x, enter the command

diff(L, x)

 

Here's a procedure for it:

A:= M->
     <<Matrix(M) | -<seq(1/k, k= M..1, -1)> | Matrix(M, (i,j)-> `if`(i+j=M+1, 1/j, 0))>,
      Vector[row]([1$M, Pi, 1$M]),
      <Matrix(M, (i,j)-> `if`(i+j=M+1, 1/i, 0)) | <seq(1/k, k= 1..M)> | Matrix(M)>
     >/Pi:

There is a serious bug that VectorCalculus integrals consistenly ignore the sign, even in simple cases. For example:

VectorCalculus:-PathInt(x^2, [x,y]= Line(<0,0>, <1,1>));

VectorCalculus:-PathInt(x^2, [x,y]= Line(<1,1>, <0,0>));

Your ODE has a singularity at r=0. Note the 1/r factor. So you can't specify boundary or initial conditions at 0.

If your worksheet is short, please include it in your Question as well as attaching it. I think that that facilitates the discussion.

Where you have length(v), you should have numelems(v).

Making that correction, your code still produces incorrect results. But I don't understand your algorithm so I can't correct it. One thing I find surprising, and probably erroneous, is for j to 26. Why 26?

To plot the curves, do

plot([seq(<v|P[..,k]>, k= 1..10)]);

But, as it stands, the curves are constant.

The source of your problem is incorrect 2D input. To see it and correct it, select with the mouse your assignment statement that defines B[22]. Right click to bring up the context menu, then select 2-D Math -> Convert To -> 1-D Math Input. Then you will that this assignment statement is

B[22] := Q^%T . `#mi("M")` . `#mi("Q")`+`#mi("m")`[L1]*T[b]^%T . S[L1]^%T . S[L1] . T[b]+Q^%T . `#msubsup(mi("R"),mi("L1",fontstyle = "normal"),mi("b",fontstyle = "normal"))` . I__L1 . `#msubsup(mi("R"),mi("L1",fontstyle = "normal"),mi("b",fontstyle = "normal"))`^%T . Q+m[L2]*T[b]^%T . S[L2]^%T . S[L2] . T[b]+Q^%T . `#msubsup(mi("R"),mi("L2",fontstyle = "normal"),mi("b",fontstyle = "normal"))` . I__L2 . `#msubsup(mi("R"),mi("L2",fontstyle = "normal"),mi("b",fontstyle = "normal"))`^%T . Q;

The first term needs to be changed from

Q^%T . `#mi("M")` . `#mi("Q")`

to simply

Q^%T.M.Q

After making that change, the IsMatrixShape command (with the mapped expand) will instantly return true.

To avoid making mistakes like this in the future, I suggest that you switch to using 1D input.

Maple makes a distinction between pairs of expressions that are manifestly equal (identically equal) and those pairs that can be proved to be equal after some simplification. For example, sin(1)^2+cos(1)^2 is not identically equal to 1, as can be seen simply by entering the former expression and noting that it does not automatically and immediately appear as 1IsMatrixShape(..., symmetric) is checking whether the matrix's entries are manifestly equal to those of the transpose. So,

M:= <0, 1; sin(1)^2+cos(1)^2, 0>:
IsMatrixShape(M, symmetric);

     false

but

IsMatrixShape(simplify~(M), symmetric);

     true

You haven't said whether your matrices have symbolic or numeric entries. If they have symbolic or exact entries, then you need to apply expand~ to the matrix before the symmetric check, as TomLeslie noted. If your matrices have floating-point entries, then it is a little bit trickier to check for symmetry, but it can still be done. Let me know.

You should not use the same variable, i, as both the index of summation and the index of a for loop. At the end of the for loop, the value of i is 7. Thus, the subsequent sum command

sum(c[i], i= 1..6)

is interpretted as if you'd entered

sum(c[7], 7= 1..6)

Since c has only six elements, the 7 is an invalid subscript. Using a different variable for the for loop index will solve both your problem 1 and problem 2.

The evalc command is the "natural" command for evaluating complex expressions whose variables are assumed to be real. So, what first occurred to me is

convert(evalc(conjugate(exp(I*x))), exp);

Here's a solution that does return a Vector. Note that this is a procedure that returns a procedure, which was one of the stated requirements of the exercise. Neither this code nor Kitonum's returns a partition that is uniformly selected at random from the set of partitions. However, this code seems to correspond to the OP's intentions.

Partition:= proc(n::posint)
local Partition:= Vector[row](n);
     proc()
     local i, Integer, Sum:= 0;
          for i while Sum < n do
               Integer:= RandomTools:-Generate(integer(range= 1..n-Sum));
               Partition[i]:= Integer;
               Sum:= Sum+Integer
          end do;
          sort(Partition[1..i-1])
     end proc
end proc:

P:= Partition(5):
'P()' $ 20;

I think that the professor may have intended for a procedure that returned an iteratori.e., a procedure that cycles through a canonical list of partitions---something akin to combinat:-nextpart. Here's a trivial example of a procedure that returns an iterator procedure:

Partition:= proc(n::posint)
local Partition:= [n];
     proc()   Partition:= `if`(Partition=[n], [1$n], combinat:-nextpart(Partition))  end proc
end proc:

P:= Partition(5):
'P()' $ 20;

[1, 1, 1, 1, 1], [1, 1, 1, 2], [1, 2, 2], [1, 1, 3], [2, 3], [1, 4], [5], [1, 1, 1, 1, 1], [1, 1, 1, 2], [1, 2, 2], [1, 1, 3], [2, 3], [1, 4], [5], [1, 1, 1, 1, 1], [1, 1, 1, 2], [1, 2, 2], [1, 1, 3], [2, 3], [1, 4]

What is the file extension (such as .txt, .m, .mpl, .map, .dat) of the file that you are trying to open? If the extension is something other than .mw or .mws, then it's not really a Maple "document" and probably cannot be opened by Maple by simply clicking on the file. If the extension is .m, .mpl, or, .map, then you need to start Maple by clicking on its own icon. Then open a new worksheet, and use the read command by directly typing

read "filename";

At the point where you are entering this command, you are already "inside" the Maple "package"; there is no need for a with command to get further "inside" or to "load" something. You can start typing your math, such as equations. At some point, you may need to load a package, such as plots. At that point, you would use the command with(plots).

First 267 268 269 270 271 272 273 Last Page 269 of 395