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

Another method: Use a sparse table:

 T := table(sparse, ["green" = "gruen", "red" = "rot", "blue" = "blau"]);

Then unassigned table entries will equal 0.

I've compared the two methods timewise, and I find no significant difference when "hits" are unlikely. (The time difference is within the amount I usually atrribute to random variation.)

restart:
N:= 2^22:
for k to 3 do L||k:= RandomTools:-Generate(list(integer, N)) end do:
ct:= 0:
st:= time():
T:= table(sparse, L1=~L2):
for k in L3 do if T[k] <> 0 then ct:= ct+1 end if end do:
time()-st;
ct;

     25.641
     14

restart:
N:= 2^22:
for k to 3 do L||k:= RandomTools:-Generate(list(integer, N)) end do:
ct:= 0:
st:= time():
T:= table(L1=~L2):
for k in L3 do if assigned(T[k]) then ct:= ct+1 end if end do:
time()-st;
ct;

     25.031
     14

I also did a test where hits were likely, and in that case using assigned was significantly faster. The only difference in the code is that integer becomes integer(range= 1..N). This makes the probability of a hit 1 - exp(-1) ~ 63%.

That should be dsolve({sist, cond[i][]}, ...rather than dsolve({sist, cond[i]}, ...). Notice the extra empty square brackets. They are to convert the list cond[i] into a sequence.

There is already a command that is fairly close to what you want: numtheory:-factorset. You just need to multiply the elements:

rad:= (n::integer)-> `*`(numtheory:-factorset(n)[]);

Answering your followup question, note that the product of a list or set is `*`(L[]), not `*`(L).

You can do the same thing in Maple: Enter your expression with single forward quotes. There are certain small operations (such as arithmetic) called "automatic simplifications" that will always be done. But most operations will be suspended by the quotes. To evaluate the expression after it has been entered this way, use the ditto operator: %


'int(x, x= 0..1)';

%;

The vast majority of Maple commands use global variables (such as enviroment variables, especially Digits) to some extent. Thus they can't run multi-threaded. See ?index,threadsafe for the paltry list of exceptions.

If you are interested in a hardware floating-point answer (aka "double precision"), then the following works in parallel and should give you a processor utilization percentage in the high nineties:

Sin:= proc(x)
option threadsafe, autocompile;
     sin(x)
end proc:

Cos:= proc(x)
option threadsafe, autocompile;
     cos(x)
end proc:

SC:= Threads:-Seq([Sin(i), Cos(i)], i= 1..10^6):

Try this:

Test:= proc(j)
local x;
     plot(x^j, x= -2..2)
end proc:

for j to 3 do
     print(Test(j));
     print(`Press RETURN to continue.`);
     readline(-1);
end do:

The help at ?readline says that the -1 argument avoids the dialog box and reads from the prompt. I get a dialog box anyway.

I assume that you mean that you want the powers of t up to 3, but that the other variables can have higher powers. Use series (after correcting the syntax of your expression):

series(lhs(p1), t, 4);

I believe that evalf is giving up in some cases because it cannot control the error to within the value specified by Digits.

Twelve years ago I wrote a program for the numerical evaluation of infinite series whose summands can be symbolically integrated. Your series is certainly in that category. That program still runs fine in today's Maple. It has a parameter for the maximum absolute error. The attached worksheet includes a derivation of the formula with diagrams, a proof of the formula, the program, and many examples of its use. At the very end, I put your problem. I thought that the worksheet was too long to post inline, so you'll have to download it.

IntTest.mw

For whatever reason, the command requires a symbolic second argument. You can get around this by substituting the numeric second argument into the expanded form, like this:

eval(expand(QDifferenceEquations:-QPochhammer(-1,q,10)), q= 5);

You need to use round parentheses ( ) for all algebraic groupings, not square brackets [ ], in your eqd1 and eqd2.

I can't see exactly what is causing that error message without seeing your Phi---I can't duplicate the message---but try 

int~(Phi^%T*f, x= 0..1);

Note that ScalarMultiply is unnecessary: The operation is handled by ordinary `*` multiplication.

The tilde (~) after the int is needed to map the operation over a vector.

You could use mu[0,1] or mu[`01`] or mu[o1] or mu[O1].

Use readline to read the first line. Use ImportMatrix to read the rest. ImportMatrix has an option to skip the first n lines of the file.

My experience is that Grid operations do not work very well when the operation being replicated is trivial. In this case, the symbolic application of ln, the operation is utterly trivial, just an unevalated fuction call. My guess is that each step should take at least 1/10 second to use Grid.

Try adding the option linestyle= solid to the plot command.

First 260 261 262 263 264 265 266 Last Page 262 of 395