Carl Love

Carl Love

28035 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

alpha__0:= x-> sqrt(d/x)/2*exp((-D__s - i)*Omega*x/V__La):
alpha__90:= x-> 3*sqrt(d/32/x)*exp((-D__s - i)*Omega*x/V__s):
alpha__theta:= (x,theta)-> alpha__0(x)*cos(theta)^2 + alpha__90(x)*sin(theta)^2:

If you intend for the i to refer to the complex unit sqrt(-1), then you'll need to change it to I.

MyArray:= (n,N)-> Array((1..N)$n, ()-> [args]);

A:= MyArray(3,3);

nilaiASCII +~ nops(nilaiASCII);

Here's how I like to solve recurrences by hand with the assistance of Maple. I start with a(n) and work backwards (towards a(0) or a(1)) with a "stunted" (i.e., partially inert) recursive procedure.

a:= n-> ''a''(n-1)/n:

Note that those quotes are two pairs of single quotes, not one pair of double quotes.

eval(a(n));

eval(%);

eval(%);

At this point, I see the pattern: a(n) = a(0)/n!

 

It may be most efficient to do it from the original integer representation. I haven't checked its speed, but here's a procedure to do it that way:

nOneBits:= proc(n::nonnegint)
local q:= n, ct:= 0;
     while q <> 0 do ct:= ct+irem(q,2,'q') end do;
     ct
end proc:
     
nOneBits(255);

     8

Is this what you're looking for?

OpList:= proc(ex)
local r:= [op(ex)], op0:= op(0,ex);
     `if`(r = [ex], ex, `if`([op0]=[], r, [op0, r]))
end proc:
 
Atomize:= proc(ex)
local r, newr:= ex;
     while r <> newr do
          r:= newr;
          newr:= subsindets[flat](r, Not({list,symbol}), OpList)
     end do
end proc:

Atomize(x*y+z-7^sin(w));

See also ?ToInert and ?dismantle.

They're both good answers so far, but I find this a little bit clearer. I'll suppose that your Vector system of equations is named Sys. Then do

X:= [u,v,w,alpha,beta,gamma]:
(M,Sys):= LinearAlgebra:-GenerateMatrix(convert(Sys, list), diff~(X(t), t$2)):
(C,Sys):= LinearAlgebra:-GenerateMatrix(convert(-Sys, list), diff~(X(t), t)):
(K,F):= LinearAlgebra:-GenerateMatrix(convert(-Sys, list), X(t)):

Do you mean this?

convert("0123456789", bytes);

convert~(%, binary);

map2(nprintf, "%08d", %);

 

Try

eval[recurse](eq, [ChgtVariables]);

You can get the leading zeros with nprintf. Here's my procedure:

myproc:= proc(p::prime, {base::And(posint, Not(identical(1))):= 10})
local n,q,r;
     if irem(base,p)=0 then return 0 end if;
     for n in numtheory:-divisors(p-1) do
          q:= iquo(base^n-1, p, 'r');
          if r=0 then return (n, nprintf("%0*d", n, q)) end if
     end do
end proc:

If you don't want the leading zeros, then return (n,q).

 

So, you want to print 200,000 3D plots? You simply need to change  plot3d to (print@plot3d).

If your goal from having a list is to recover the position numbers of items in that list, then it'd be many, many times faster to use a table whose indices are the list entries and whose entries are the positions. Both the time to create the table and the time to do the lookups are insignificant compared with the time to use a list. Here's a time comparison:

 

(L,K):= 'RandomTools:-Generate(list(posint(range= 2^17), 2^16))' $ 2:


st:= time():
for k in K do member(k,L,'p') end do:
time()-st;

19.750

#Time to create table:
st:= time():  T:= table(L=~[$1..nops(L)]):  time()-st;

0.94e-1

#Time to use table:
st:= time():
for k in K do p:= T[k] end do:
time()-st;

0.31e-1

 

 

Download table_lookup.mw

If there are multiple copies of any list entries, the table above only records one instance of that entry. The building of the table can be modified to accomodate multiple entries. This'll cause no change in the lookup time. 

 

There's no need for fea and no need for recursion. Try this:

MilRab := proc(n)
local N:= n-1, F:= FactorInteger(N), i, C:= rand(N)() &^ (N/F[1,1]^F[1,2]) mod n;
     if C = 1 or C = N then return true elif k = 1 then return false fi;
     for i to F[1,2]-1 do C:= C^2 mod n;  if C = 1 then return false elif C = N then return true fi od;
     printf("All tests exhausted.")
end proc;

I don't know whether to return true or false or FAIL if the loop completes.

Your attempt to attach a plot did not work.

One option is to use option gridlines, for example

plot(x, x= -10..10, gridlines);

However, you may consider this to be too visually intrusive.

For your second question, to sort by descending indices, you can do

ex:= a[2]+a[3]+a[1]:
sort(ex, sort([op(ex)], key= op));

First 233 234 235 236 237 238 239 Last Page 235 of 395