Carl Love

Carl Love

28095 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Here are the very basics of logarithmic rescaling to get an even grid spacing: Let's say that your original plot is

densityplot(f(x,y), x= a..b, y= c..d);

and you want logarithmic scaling on the first axis. Then change the plot command to

densityplot(f(10^x, y), x= log10(a)..log10(b), y= c..d);

If f is a procedure, then it is trickier, but still based on the same idea.

Then you need to redo the tickmarks.

I made some corrections to your worksheet, as noted by the comments in it. I am sure about most of the corrections. I also removed the principal normal computation---I am not sure about that. I think that PathInt takes it into account automatically. If you know what final results you expect, then you can verify with what I got. If you still need the principal normal , I can work on that.

Your worksheet was in fact using exact arithmetic, and I corrected that.

(Partially?) corrected worksheet: main_screened_Poiss.mw

The problem is the quote marks that you use on ':-language'= language. I have used the correct quote marks here. The quotes that you used do not occur on the American keyboard, and I can't reproduce them here. Needless to say, they are not part of the Maple language. The correct quote mark is character number 39 in ASCII.

The command zip is like map in that it provides elementwise operation. It differs from map in that it maps a two-argument function over a pair of structures. LinearAlgebra:-Zip is just like zip, but it also has an inplace option. So, you can achieve what you want with the single command

LinearAlgebra:-Zip(eval, BB, map[2,inplace](`=`, theta, CC), inplace);

Note that I used eval instead of subs, so the above produces evaluated results. If you actually want unevaluated results (perhaps to save processor time), do

LinearAlgebra:-Zip(subs, map[2,inplace](`=`, theta, CC), BB, inplace);

Why do you need to define f at all? You can use any symbol as a function without defining it. Just type f(y). But if you have a good reason for defining it, you can do

f:= x-> 'procname'(args);

If you want to insist that f only take exactly one argument, then do

f:= proc(x,$) 'procname'(x) end proc;

Now an error message will be issued if f is invoked with other than one argument.

plots:-spacecurve([cos(t),sin(t),t], t= 0..6*Pi);

The for loop

for i from a by b to c while d do
     e
end do

is equivalent to the do loop

i:= a:
do
     if (i > c) or not d then  break  end if;
     e;
     i:= i+b
end do;

 

The problem is that your function is undefined at 0. Are you looking for a rational function that closely approximates M6? We can expand at a=1 rather than a=0:

numapprox:-pade(M6, a=1, [3,3]);

The [3,3] indicates the degree of the numerator and denominator respectively.

There are several cases to consider:

The number of indices is known at the time the program is written: In this case, use nested loops:

for i from 1 to Ni do
     for j from 1 to Nj do
         
...
             for n from 1 to Nn do
                  ...
             end do
        ...
     end do
end do;

More generally, if the index values are stored in sets or lists  Si, Sj, ..., Sn:

for i in Si do
     for j in Sj do
         ...
               for n in Sn do
                      
...
                   end do
           
... 
    end do
end do;

The next two cases involve Cartesian products of the sets or lists of indices.

The number of indices is unknown at the time the program is written: In this case, use an iterator over the Cartesian product:

Iter:= combinat:-cartprod([Si, Sj, ..., Sn]);
while not Iter[finished] do
     v:= Iter[nextvalue]();
     # Now use v[1] as i, v[2] as j, etc.
    
...
end do;

The number of indices is unknown at the time the program is written and the Cartesian product is relatively small (say, less than 10 million entries): In this case, we generate the entire Cartesian product at once, because it is faster to do so:

CartProdSeq := proc(L::seq({set,list}))
local Seq,i,j;
option `Copyright (C) 2007, Joseph Riel. All rights reserved.`;
    eval([subs(Seq=seq, foldl(Seq
                              , [cat(i,1..nargs)]
                              , seq(cat(i,j)=L[j],j=nargs..1,-1)
                             ))]);
end proc:

for v in CartProdSeq(Si, Sj, ..., Sn) do
    # Now use v[1] as i, v[2] as j, etc.
    
...
end do;

The flush: The fancifully named pigeonhole principle states that if you put p pigeons into holes then at least one hole will have at least x = ceil(p/h) pigeons. The 17 cards are the pigeons and the 4 suits are the holes: ceil(17/4) = 5. So how can we compute p = 17 knowing x = 5 and h = 4? p = (x-1)*h + 1.

The probability of a flush in a five-card draw is not as you state. It is binomial(4,1)*binomial(13,5)/binomiql(52,5). Permutations are not used because order does not matter.

The straight: Suppose that you had all the cards excepts the 5s and 10s. Then you'd have 44 cards and no straight. Add one 5 or 10 and now you have 45 cards and a straight (5*4^4 = 1280 straights in fact).

The probability of a straight in a five-card draw is 10*4^5/binomial(52,5).

You need to replace print(y) with print(eval(y)).

I don't think that I can give an adequate explanation of why. But try reading ?eval, beginning with the seventh paragraph under Description, the one beginning "The two remaining calling sequences...." The paragraphs above that apply to the two-argument version of eval, which is an unrelated command.

To make a column vector from a sequence, you enclose the sequence in angle brackets, like this

S:= 1,2,3: #a sequence
< S >;

If you end your printf statements with semicolons, then those characters will not appear.

The return value of a printf statement is NULL. When two printfs are juxtaposed in 2D input, the juxtaposition is interpreted as multiplication. NULL*NULL = NULL^2, which prints as ()^2. If there is an intervening semicolon, then they are not juxtaposed.

@John Fredsted It is not ad hoc: evalc assumes that variables are real unless otherwise specified.

In your first code, you were accidentaly assuming that the variables were real, but Maple was not. Maple could not put any variables on the diagonal in that case because they were not known to be real.

There is a three-dimensional figure called a Gomboc which was discovered with the help of Maple. See this Wikipedia page.

First 326 327 328 329 330 331 332 Last Page 328 of 395