Carl Love

Carl Love

28095 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

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).

When the prompt appears, type control-T. This removes the prompt and puts you in text mode.

Change seq(X[i],Y[i],Z[i],i=0..1000) to seq([X[i],Y[i],Z[i]], i= 0..1000).

This seems to be an oversight with the newer inert forms (the ones formed by prepending % to the function name). You can still use the older form of the inert limit, Limit. Likewise, DiffIntEval---each spelled with a capital letter---are inert forms of diffinteval.

If you want to correct this bug, it is trivial to do so. Simply define a procedure:

`print/%limit`:= ()-> Limit(args);

The command is interface(worksheetdir).

You use the command sign in your for loop. You need to change that to either signum or csgn (which one doesn't matter in this case)The command sign in Maple is something completely different and unrelated. This is a very common error in Maple. If you make the change, you'll get the answer

     sol1 := {y0 = 57.69046866}

from fsolve. See ?signum, ?csgn, and ?sign.

Yes, you convert those equations which contain integrals to differential equations by taking the derivatives with respect to t of each side. You are correct that that makes the initial conditions disappear. They are supplied separately to the dsolve command. So equation A becomes

diff(u[smooth](t), t) = - i[smooth](t)/C[smooth]

and likewise for equation C.

You made two errors: First, you must consistently refer to functions of t as functions of t. So i[komp] in equation B and i[load] in equation D need (t) appended. Second, you have u[loadt] in equation D where you intended (I presume) u[load].

The command to solve this DAE IVP system is dsolve. The specific command is

dsolve(
     {igl, u[smooth](0)=US0, u[ckomp](0) = UC0},
     {u[smooth](t), i[smooth](t), i[komp](t), i[load](t), u[ckomp](t), u[load](t)}
);

Note that I represented the initial conditions as US0 and UC0. This system can be solved symbolically by dsolve, but the solution is much too long to copy here. It's in the attached worksheet:

igl.mw

If you're writing purely numeric Maple code in double precision, it is possible to have that code automatically translated to C, compiled, and linked to your Maple. To the user, it seems just like running an ordinary Maple procedure. See ?Compiler,Compile. It is often possible to run such code in parallel using the Threads package, thereby utilizing 100% of your processor.

If you post some of your code, I may be able to quickly show you how it's done.

That error message is so weak and unhelpful that it's pathetic. What, it can't even detect that you mispelled an option name? You just need to change numerical to numeric.

About your second error, you need to change your decimal constants to exact fractions. You can do that like this:

pdsolve({convert(Selkov[1], rational), convert(Selkov[2], rational)});

I don't know if the above command will ever return an answer---I got tired of waiting---but it won't give you the "general case of floats" error.

The 3/8 rule can be derived in three steps with Maple. We take four arbitrary points with evenly spaced x-coordinates and find the interpolating polynomial. Then integrate that and simplify the result. Like this:

CurveFitting:-PolynomialInterpolation([four x-values], [four y-values], x, form= Newton);
int(%, x=
...);
factor(%);

I leave it to you to fill in the four x-values, the four y-values, and the interval of integration. The results of the first two commands will be surprisingly long and complicated. Let Maple worry about that and don't be discouraged. As you can see, the result of the third command is exactly what you're looking for.

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