Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

No, you cannot access the member location inside a map invocation.

The following uses seq, but I'd be surprised if you could beat it timewise:

rtable([seq(f(i,M[i]), i= 1..1000)], subtype= rtable_options(M, subtype));

If f is thread safe (see ?threadsafe ), try using Threads:-Seq instead of seq.

Please post your code where seq is slowing down the computation. I find your statement about seq surprising. Perhaps someone here can improve the code.

There are two choices: Either you have Maple cancel units when and only when you ask it to, or you have it done automatically as expressions are entered.

To implement the former, use combine(..., units):

restart:
r:= 5*Unit(m/s):
t:= 10*Unit(s):
r*t;

combine(%, units);

To have it done automatically, you need to load a Units package environment. There are two environments that I am aware of: Natural and Standard. (Note that these terms, Natural and Standard, have nothing to do with the system of units being used. Rather, they refer to the method by which the units are entered into an expression.)

restart:
with(Units:-Natural):
r:= 5*(m/s);

t:= 10*s:
r*t;

restart:
with(Units:-Standard):
r:= 5*Unit(m/s):
t:= 10*Unit(s):
r*t;

Optimization:-Maximize can get stuck on a local maximum. The DirectSearch package (which must be downloaded from the Maple Applications Center ) has global optimizers. While Optimization works fine for this simplified example, it may not for your more-general case.

Sol:= dsolve(Sys, numeric, output= listprocedure):
y2:= eval(y2(t), Sol):  y3:= eval(y3(t), Sol):
# Above two lines same as Kitonum's
DirectSearch:-Search(abs(y2(t)-y3(t)), {t= 0..100}, maximize)
;

Use command StringTools:-WrapText.

The expression (1-exp-(x-2))^2 does not make sense. You probably mean

(1-exp(-(x-2)))^2.

The equation that you pass to dsolve does not use Ep.

Did you mean phi(o) = 0 as an initial condition? I think that that should be phi(0) = 0.

You define a constant E, but you don't use it.

You never defined eq.

You mistyped with(DEtools) as xith(DEtools); however, this won't make any difference in your case because you are not using any command from DEtools.

The command restart; should appear on a line by itself.

Another way is to use simplify with side relations:

restart:
g:= y-> 80*y^8 + 68*y^6 + 12*y^4 - 4*y^2 - 1:
p:= unapply(randpoly(y), y):
h:= unapply(expand(p(y)*g(y)), y):
simplify(h(y), {g(y)=0});
                                  0

 

You do what you want by declaring (with alias) y* to be a RootOf(g(y), y):

g:= y-> 80*y^8 + 68*y^6 + 12*y^4 - 4*y^2 - 1:
alias(Y= RootOf(g(y), y)):

Now take a random p(y) and expand p(y)*g(y):

p:= unapply(randpoly(y), y):
h:= unapply(expand(p(y)*g(y)), y);

Now ordinary evaluation is not smart smart enough to know that h(Y) = 0:

h(Y);

But evaluation with evala is smart enough to do it

evala(h(Y));

                                                    0

See ?evala

I think that the only difference between the "versions" of Maple is the price. I am sure that all of those implement the algorithm via the IntegerRelations:-PSLQ command.

Your L1 is a (one-dimensional) Array of lists, each list being a pair of numbers. The same for L2. So [L1,L2] is a list of Arrays of lists. Apparently, that's too much mixing of types for plot to understand. You need to either convert everything to listlist form, or make L1 and L2 into two-dimensional Arrays (or Matrices). To do the former,

plot(map(convert, [L1,L2], listlist));

To do the latter, don't use zip to create L1 and L2. Rather, use Matrix constructors. The following assumes that groups is an Array:

L1:= < groups^%T | waitArray[..,1] >:   L2:= < groups^%T | waitArray[..,2] >:

If groups is a column vector, then omit the ^%T. If groups is a list, then

L1:= < < groups[] > | waitArray[..,1] >:  L2:= < < groups[] > | waitArray[..,2] >:

The action of the angle bracket operators is controlled by the very simple procedures `<,>` and `<|>`. In this case only the former matters. Look at showstat(`<,>`). Since lists are not scalars, and since there is more than one argument, the code branches to the line

Matrix([[args]], scan= columns);

When the left side of an assignment can only be referenced by its membership in a container, you need to use the assign command rather than the assignment operator :=. So, change your last section of code to

for i from 1 to Dimension(Q) do
     for j from 2 to nops(Q[i]) do
          assign(Q[i][j], Q[i][1])
     end do
end do:

I also changed nops(Q) to nops(Q[i]). The former makes no sense whatsoever.

You can use unassign:

unassign('a1', 'a2', 'a3', 'a4');

Note that the quotes are required.

To do it more systematically,

unassign(map(evaln, '[a||(1..4)]')[]);

The command to read .m files is simply read:

read "MyFile.m";

If you want to know the names of the new procedures defined from the file, you could do this:

before:= {anames(procedure)}:
read "MyFile.m":
newprocs:= {anames(procedure)} minus before;

The coefficient of x^k is given by

C:= (n,k)-> binomial(n,k)*2^k:

For fixed n, C(n,k) is a unimodal function of k for 0 <= k <= n. We want n such that the maximum on this range is at k=8.

fsolve({eval(diff(C(n,k),k), k=8)}, n= 8..infinity);

Since we need an integer solution, it's either n=11 or n=12, or possibly both.

seq(C(11,k), k= 7..9);

seq(C(12,k), k= 7..9);

So the answer is n = 12.

 

1. Option discont:

To correctly plot a function with discontinuities, use option discont in the plot command:

plot(tan(x), discont);

To set this permanently, include the following line in your initialization file:

local plot:= proc({discont:= true}) :-plot(args, ':-discont'= discont) end proc:

 

2. Unevaluation quotes:

To prevent the evaluation of functions, enclose the function name in single quotes, like

y = 'sin'(x - Pi/2);

 

3. Required semicolons:

I haven't been able to duplicate what you say. For me, they all require semicolons. Regardless, you should get in the habit of ending all statements with a colon or a semicolon. The colon would be used to suppress output.

 

4. MaplePrimes new users' section.

The majority of Questions on MaplePrimes are asked by new Maple users. However, most of those questions are asked by users with more mathematical experience than you.

First 300 301 302 303 304 305 306 Last Page 302 of 395