Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Despite what Dr Lopez said (which I agree with), you may have your own good reasons for wanting to stick with the VectorCalculus package and for wanting to represent tensors as Maple Matrices. So, I just wanted to show you that the less elegant way that you described is not so bad. Here it is:

<seq(Divergence(VectorField(M[k,..])), k= 1..3)>;

IntTutor is not designed to handle symbolic constants; however, if you hold its hand at each step, you can get an answer for this problem. But what's the point? Are you saying that you want to learn Laplace transforms, yet you don't even know how to integrate exp((a-s)*t) from 0 to infinity? For IntTutor to work, you need to replace the infinity with a finite symbolic constant. I chose gamma below. Then, in the final answer, replace gamma with infinity or a use a limit expression to that effect.

Your syntax has numerous errors: lack of parentheses, using e instead of exp, and others. Here's the corrected syntax:

f:= t-> exp(a*t):
IntTutor(Int(exp(-s*t)*f(t), t= 0..gamma);

If you use disassemble to take apart the expression, you will see that dismantle is showing a truer representation of how the expression is actually stored than ToInert is.

L1:= disassemble(addressof(3*a));

     L1 := 16, 18446744080214109662, 18446744073709551621

kernelopts(dagtag= L1[1]);

     SUM

Note that a product of variables, or a single variable to a numeric power, is a PRODUCT. It is the presence of a numeric coefficient that turns it into a SUM.

Your simplification is only valid if you assume that the parameters such as theta are real. The command evalc makes those assumptions.

simplify(evalc(Re(A)));

It looks (vaguely) like your data is stored as row Vectors. The following procedure takes as input two Vectors (row or column), Array slices, or lists (of the same length, of course) and a boolean-valued filter procedure which when passed a point (x,y) returns true iff the point should be included. It returns the filtered output as column Vectors.

Select:= proc(f, A::~Vector[column], B::~Vector[column])
local M:= convert(select(f@op, convert(<A|B>, listlist)), Matrix);
     M[..,1], M[..,2]
end proc:


Example of use: Suppose that we want to select those points whose first coordinate is even.

A:= <1|2|3|4|5>;  B:= <6|7|8|9|10>;

     A:= [1 2 3 4 5]
     B:= [6 7 8 9 10]

f:= (x,y)-> x::even:
(AA,BB):= Select(f, A, B):
% ^~ %T;

                                        [2 4], [7 9]

Download Select.mw

 

In Maple, a line break has the same syntactic significance as a space; unlike Matlab, the end of line is not considered a statement terminator. So, just find a place where you could put a space and continue on the next line. Preferably, the continuation lines will be indented farther to the right than the statement's initial line. If you are having trouble finding a place to put a space, you should probably rethink your code, and if you post it, I'll help with that.

In the case of a very long constant, string, or name---where you can't use an extra space---you can end a line with backslash \ and continue at the beginning of the next line. I consider this sloppy coding, and in 16 years of Maple usage, I've never had to use it.

It's trivial:

solve({f[k] $ k= 1..n}, {x||(1..n)}):
a||(1..n):= eval([x||(1..n)], %[1])[]:
a||(1..n);

Yes: Use eliminate instead of solve. Your situation is precisely what it's for.

 

The following paragraph is from the help page ?dsolve,details:

Integrals appearing in answers returned by dsolve are expressed using the inert Int and Intat (not int or intat). These integrals appear when int is not able to calculate them or when it appears to be convenient not to evaluate them during the solving process. You can request the evaluation of these integrals using the value command.

So, try applying the value command to dsolve's results. If you still get an integral, then Maple simply can't do the integral. If you have parameters, sometimes making assumptions on the parameters will make the integral doable. See ?assuming.

If you have further questions about this, please post your differential equation and any initial or boundary conditions.

The $ is the repetition operator (it also has a mode where it acts like seq). It is a basic operator of Maple, not something special to permute. For example, [1$4] returns [1, 1, 1, 1]. In many ways, is to seq as sum is to add and as product is to mul. For example, will take a symbolic second argument. (It's a shame that seq and are not switched: The former is more commonly used.)

To get all 2^n sequences of 0s and 1s of length n, use

combinat:-permute([1$n, 0$n], n);

While the $ does accept symbolic arguments, permute does not. To run your command, you'll need to supply a nonnegative integer for n.

Pi is not considered numeric. So, you have to do something like this

for x[2] from 15/180 to 75/180 by 5/180 do    
     a[i,j]:= Pi*x[2];
     j:= j+1
end do;

Use eliminate for a symbolic solution. For your system above, eliminate can solve for any three of the variables in terms of the fourth.

for V in combinat:-choose({x1,x2,y1,y2}, 3) do eliminate({eq||(1..3)}, V) end do;



You are mixing concatenation with indexing. If you want to consistently use indexing, then do

f_[0]:= x-> r(x):
for i to 10 do
     f_[i]:= subs(_I= i, x-> r(x)*f_[_I-1](r(x)))
end do:


(There is no need for 1 to be a special case.)

If you want to consistently use concatenation, then do

f_0:= x-> r(x):
for i to 10 do
     f_||i:= subs(_I= i, x-> r(x)*f_||(_I-1)(r(x))) 
end do:

Note that a name created by the concatenation operator || cannot be a local.

With a parameterized procedure definition (that is, a procedure created with a variable (the parameter) for which you wish to supply a value at the time the procedure is created), you need to use subs to supply the parameter's value. If you don't, the parameter remains symbolic even if it had a value at the time the procedure was created (unless the parameter is a module name (any other exceptions? Acer?)).

An alternative to subs is to use unapply to turn fully evaluated expressions into procedures. It's not really appropriate in this context (if r is complicated the procedures will be horrendously long), but it's done like this:

f_[0]:= x-> r(x):
for i to 10 do
     f_[i]:= unapply(r(x)*f_[i-1](r(x)), x)
end do:

Your procedures f_[i] (in the indexed form) can be defined as a single, simple procedure without the need for a loop or recursion. In the following, pay attention to how the index with which the procedure is called can be accessed within the procedure by using op(procname).

f_:= proc(x)
local i:= op(procname), k;
     if not procname::indexed or not i::nonnegint then
          error "This procedure needs a nonnegative integer index, e.g., f_[3](x)."
     end if;
     mul((r@@k)(x), k= 1..i+1)
end proc:

At this point, you might as well make i a declared procedure parameter rather than an index. Then the whole thing is even simpler---a one-liner---because no explicit error checking is needed:

f_:= (x, i::nonnegint)-> mul((r@@_k)(x), _k= 1..i+1):

This last form is what I would use.

Your error is in this passage:

Comet := array([1, 2]); if j = 10 then Colors := [aquamarine]; Linestyle := [longdash]; Comet[1] := spacecurve([subs(E[j] = E, x[j]), subs(E[j] = E, y[j]), subs(E[j] = E, z[j])], E = 0 .. 2*Pi, color = Colors[j], linestyle = Linestyle[j]) end if;

You redefine Color to be a list with one element, and then you ask for Colors[j] where j=10. The lists Colors and Linestyles already have 13 elements at this point in the code. There's no need for you to redefine them. The equivalent error occurs in the Oort passage immediately below the above passage. Simply remove the redefinitions of Color and Linestyle from these passages.

There's still an error after that; hopefully you will find it. If not, ask.

It would be helpful if you uploaded your work as a worksheet. If you do use plaintext, at least remove the > from the beginnings of the lines. If you don't, I have to remove every one of those by hand before I can run your code.

The LinearAlgebra:-SubMatrix command is superfluous. The same results can be obtained with indexing alone:

A:= <1,2,3,4; 5,6,7,8; 9,0,1,2>;

A[[1,2],[2,4]];

 

First 278 279 280 281 282 283 284 Last Page 280 of 395