729 Reputation

12 Badges

8 years, 189 days

MaplePrimes Activity

These are replies submitted by _Maxim_


Interesting. So in fact this is a bug in simplify, not in sum:

simplify(polylog(1/2, -1)+1);
Error, (in polylog) numeric exception: division by zero


@Robert Israel

At least for trigs of Pi*rational there is a method that usually works:


(evala@convert)(ee, RootOf);
M := Matrix(5, 5,  (i, j) -> (10*i+j)*sin((1/180)*Pi*(10*i+j))):

timed := proc(e::uneval) local f, t, ans := NULL;
  if procname::indexed and [op](procname) = [real] then f := time[real] else f := time end if;
  t := f(proc() try assign('ans', eval(e)) catch: WARNING(lastexception[2 .. -1]) end try end proc());
  [t, ans] end proc:

Normalizer := evala:

M2 := (evala@convert)~(M, RootOf):
M3 := subs((evala@Algfield)(M2)[1], M2): # M2 will do as well, but will be slower

Warning, singular matrix

                           [1.625, 0]

        [2.531, Vector[row](5, [0, 0, 0, 0, 0])]

Normalizer:=normal is in fact something like Normalizer:=automatic, invoking LinearAlgebra:-DeduceNormalizer, which has a custom setting for algebraics. But Determinant apparently doesn't call DeduceNormalizer, so Normalizer := evala is needed.


For the same reason why it's needed for evalf/Int. Like the example from point #3 here: it doesn't work with higher settings of digits, because the tolerance setting also increases and is not attainable. But setting the tolerance (epsilon) to a more reasonable value works like a charm.

For evalf/Sum we cannot do a direct test, but, as some indirect evidence, at Digits:=19, evalf/Sum of 1/(k^2+ln(k)) takes about 40 seconds; for Digits:=20, it takes 110 seconds. The difference seems to be due mostly to the increase in the requested tolerance. But the point is that often one does not need the extra accuracy, only the extra digits to work with numerically unstable summands.

If Maple had a summation method based on the Euler–Maclaurin formula, the evalf/Int example would be directly relevant. Perhaps the issue is that Maple seems to have exactly one summation method. So it fails even for rather simple summands, like 1/(k^2*ln(k)) or sin(Pi*k/3)/k.

@Axel Vogt

The question is about computing a sum numerically when no closed form is available.


That's debatable. Take the sum of (1-10^(-20))^k/k and consider how many terms you need to add to get one correct digit. While for an appropriate summation method the example is easy (just evaluating the integral already gets you in the right ballpark).

Your example is just another illustration that evalf/Sum needs more user-controllable options like epsilon. Specifically, for your example, an option to control how many terms to take at the beginning.


foldl(seq, i, i = 1 .. 2);
                              i, i

Unlike in the example with apply, here i doesn't get properly localized.

ee := foldl(%seq, 0, i = 1 .. 2, j = 1 .. 2)

value(ee) # fails

eval(ee, %seq = seq) # fails

eval(subs(%seq = seq, ee)) # works

This one is less of an issue (it's safer to use [%seq]), but it looks like an accident of the implementation that the last one works and the other two don't.


That works, thanks. ?plot/tickmarks could have been clearer, I guess, because it says "Restricted forms of the tickmarks and gridlines option may also be given directly to a plotting command" and then "The tickmark specification for all axes may be given through a single tickmarks=[s1, s2]", giving an impression that tickmarks=[xspec, yspec] should work as a suboption to axis as well, since it works as a top-level option.



Might be system-dependent? Because on Windows I'm seeing this: https://i.imgur.com/4b6pcoP.jpg. The details are definitely missing.


Impressive. One possible catch is that 'background' isn't pixel-perfect. In Embed(abs(fft2unmasked)^(1/4)) there's a prominent vertical midline, and nine dots visible (the ninth one is in the center), five of them really as tiny dots rather than crosses. In Preview2D, there's a much dimmer vertical midline, and only the four crosses visible. So I'd say this should be used in conjunction with Embed.

@Mariusz Iwaniuk

Well, there's nothing wrong with the antiderivative, it's even continuous. The problem seems to occur when int computes the limit of the antiderivative at infinity.


Indeed. So for S1 it's the other way around, :-asympt fails, but MultiSeries:-asympt knows how to deal with those elliptics:

MultiSeries:-asympt(subs(S(a, t) = int(s(tau), tau = a .. t), E(a, t)[2]), t);
    sqrt(6)*a+4*sqrt(9)*sqrt(1-(3*I)*a^2)*sqrt(1+(3*I)*a^2)*EllipticF((1/2+1/2*I)*a*sqrt(6), I)+

evalf(subs(a = 1, %));

But this is the position of the asymptote at -infinity. So as the asymptotic expansion of E(a, t) at +infinity, this is wrong.


I'm probably missing something here. This works:

:-asympt~(subs(S(a, t) = S__h, E(a, t)), t)

but not MultiSeries:-asympt. What are you applying MultiSeries:-asympt to?

@Carl Love

Then, if an expression with the head `seq` can be constructed using eval and suchlike, why not using composition?

apply works:

(f@curry(apply, seq))(i, i = 1 .. 2);
                            f(1, 2)

And composition works for time:


It's like you say, the argument is evaluated before the special evaluation rules kick in.

(To digress, it also means that (`[]`@time)(e) is not the same as [time](e).)

In all fairness, there is this page: ?spec_eval_rules, and it does list evalf. But it only says about evalf that "it ensures that its second argument (if provided) is evaluated before its first argument".


Adding two other examples of the code crashing or not working correctly when several commands are put in the same cell. Both examples work fine if each input line is in a separate 2D Input cell.

An mserver crash.

f := proc (t) options operator, arrow; t end proc; `diff/S` := proc (e, x) options operator, arrow; 0 end proc; E := proc (t) options operator, arrow; S(t) end proc; `assuming`([simplify(eval(diff(E(t), t), t = a))], [a > 0])

gc() works only when put in a separate cell.

f := proc (t) options operator, arrow; t end proc; `diff/S` := proc (e, x) options operator, arrow; f(e)*(diff(e, x)) end proc; diff(S(t), t)



f := proc (t) options operator, arrow; t^2 end proc; `diff/S` := proc (e, x) options operator, arrow; f(e)*(diff(e, x)) end proc; gc(); diff(S(t), t)




diff(S(t), t)



Download 2d2.mw


2 3 4 5 6 7 8 Page 4 of 9