Joe Riel

9660 Reputation

23 Badges

20 years, 16 days

MaplePrimes Activity


These are replies submitted by Joe Riel

I'm curious why you use and assign to f(t) (viz. particle(t), aysmptote(t), etc).  While it is valid Maple, it is strange in that (1) it suggests an actual function when it is not, and (2) it suggests that the quantites are functions of time, when, in fact, they are expressions equal to time (functions of x).  I might have chosen t_particle, t_asymptote, and t_photon.  Notation aside, I prefer your approach.

By default, Maple doesn't install a maple.ini file.  It is a Maple script file, that is, it contains standard Maple language constructs.  It is read when Maple starts (and reread when it is restarted). 

By default, Maple doesn't install a maple.ini file.  It is a Maple script file, that is, it contains standard Maple language constructs.  It is read when Maple starts (and reread when it is restarted). 

This particular procedure, pointplot3d, can take either a set or a list.  While it doesn't matter here, because all points are distinct, it is conceivable that a set could be an advantage because it would eliminate redundant points. However, I suspect pointplot3d converts to a set anyway.

While the $ operator is more compact, the seq function is generally preferred.  It is more efficient (doesn't matter here).  Actually, there isn't any reason to use the $ in your example, since you already call seq (see below).  The reason, I assume, that John proposed a separate call to seq was to explicitly assign/show the generation of the domain.

plots[pointplot3d]([seq([x,sin(x),cos(x)],x=1..5000)]);

This particular procedure, pointplot3d, can take either a set or a list.  While it doesn't matter here, because all points are distinct, it is conceivable that a set could be an advantage because it would eliminate redundant points. However, I suspect pointplot3d converts to a set anyway.

While the $ operator is more compact, the seq function is generally preferred.  It is more efficient (doesn't matter here).  Actually, there isn't any reason to use the $ in your example, since you already call seq (see below).  The reason, I assume, that John proposed a separate call to seq was to explicitly assign/show the generation of the domain.

plots[pointplot3d]([seq([x,sin(x),cos(x)],x=1..5000)]);

Hi John.  A minor "improvement" is to use the one-argument form of seq:

  s := {seq(1..5000)};

It is unfortunate that Maple does not have a builtin identity function (I've lobbied for `()`, as it is analagous to `[]` and `{}`).   If it did you could do

  plots[pointplot3d](map([`()`,sin,cos], s);

This can be done with the user-defined one-argument identity

  plots[pointplot3d](map([x->x,sin,cos], s)

but I prefer the look of an argumentless operator.  By the way, here is the first assignment using `{}`:

  s := `{}`(seq)(1..5000);

 

Hi John.  A minor "improvement" is to use the one-argument form of seq:

  s := {seq(1..5000)};

It is unfortunate that Maple does not have a builtin identity function (I've lobbied for `()`, as it is analagous to `[]` and `{}`).   If it did you could do

  plots[pointplot3d](map([`()`,sin,cos], s);

This can be done with the user-defined one-argument identity

  plots[pointplot3d](map([x->x,sin,cos], s)

but I prefer the look of an argumentless operator.  By the way, here is the first assignment using `{}`:

  s := `{}`(seq)(1..5000);

 

My only suggestion would be to use a string rather than a name for the path directory. While the likelihood is remote, it is possible for a name (`c:/tmp/Maple/Gravitation`) to be reassigned.  A string ("c:/tmp/Maple/Gravitation") avoids that issue. Note that forward slashes are being used here.  Generally that will work, though technically the backslash is the directory separator on a Windows OS.  If you do use backslashes (in either a string or a name) be sure to double them.

My only suggestion would be to use a string rather than a name for the path directory. While the likelihood is remote, it is possible for a name (`c:/tmp/Maple/Gravitation`) to be reassigned.  A string ("c:/tmp/Maple/Gravitation") avoids that issue. Note that forward slashes are being used here.  Generally that will work, though technically the backslash is the directory separator on a Windows OS.  If you do use backslashes (in either a string or a name) be sure to double them.

Which approaches sqrt(Pi/a)/2 for a large.  How do enter the math expressions here? The Maple icon didn't do anything.

Which approaches sqrt(Pi/a)/2 for a large.  How do enter the math expressions here? The Maple icon didn't do anything.

The mistake I was made not increasing Digits for identify; I had merely computed the floating point to 30 digits, identify will revert to using the assigned value of Digits.  I should have done

guess := proc(a)
local y,id;
    Digits := 20;
    y := evalf(J2(a));
    id := identify(y);
    if not id::float then
        'J2'(a) = identify(y);
    end if;
end proc:

for a in [0,1,2,sqrt(Pi)] do
    guess(a);
end do;
                         J2(0) = 2

I wondered why the Inverse Symbolic Calculator didn't come up with the same result.

The mistake I was made not increasing Digits for identify; I had merely computed the floating point to 30 digits, identify will revert to using the assigned value of Digits.  I should have done

guess := proc(a)
local y,id;
    Digits := 20;
    y := evalf(J2(a));
    id := identify(y);
    if not id::float then
        'J2'(a) = identify(y);
    end if;
end proc:

for a in [0,1,2,sqrt(Pi)] do
    guess(a);
end do;
                         J2(0) = 2

I wondered why the Inverse Symbolic Calculator didn't come up with the same result.

While probably not of immediate interest to the original poster, the reason the loop can be much slower is not so much because it is an external loop, but rather because it is being used to build up a sequence term by term.  Each intermediate term is stored in Maple's simplification table, so, after n loops, it looks like

term1
term1, term2
term1, term2, term3, ..., termn

This is an O(n2) process.  By inserting the terms into a table in the loop, and then converting to a list at the end, this becomes O(n).  Conceptually,

term := table()
for i to n do
   term[i] := (compute the term);
end do;
convert(term, 'list');

Of course, if one can generate the list with one call to seq, that is usually better, however, sometimes it is more convenient to use the imperative style and write a loop.

While probably not of immediate interest to the original poster, the reason the loop can be much slower is not so much because it is an external loop, but rather because it is being used to build up a sequence term by term.  Each intermediate term is stored in Maple's simplification table, so, after n loops, it looks like

term1
term1, term2
term1, term2, term3, ..., termn

This is an O(n2) process.  By inserting the terms into a table in the loop, and then converting to a list at the end, this becomes O(n).  Conceptually,

term := table()
for i to n do
   term[i] := (compute the term);
end do;
convert(term, 'list');

Of course, if one can generate the list with one call to seq, that is usually better, however, sometimes it is more convenient to use the imperative style and write a loop.

First 150 151 152 153 154 155 156 Last Page 152 of 195