_Maxim_

729 Reputation

12 Badges

8 years, 211 days

MaplePrimes Activity


These are questions asked by _Maxim_

It seems rather arbitrary that proc..end proc is allowed inside functions, but none of the other statements from ?index,statement are:

seq(try ln(i) catch: -infinity end try, i=0..2)
seq(proc() try ln(i) catch: -infinity end try end proc(), i=0..2)

Only the second one works, even though syntactically it doesn't seem to be different from the first one.

It would be really convenient to have any statement allowed inside a function, including assignments (as :=, not as assign()) and compound statements:

s:=0: seq(s:=s+i, i=1..10)
s:=0: seq(proc() global s:=s+i end proc(), i=1..10)

This is more compact than using a loop.

proc() local a := 0, b := 1;
  print(proc(x::uneval) x := 1 end proc(a));
  print(proc(x::uneval) x := b end proc(a))
end proc();
                               1
Error, (in unknown) illegal use of a formal parameter

Why doesn't the second nested procedure keep a unevaluated?

With Typesetting level set to Maple Standard, x->(f@g)(x) is displayed as x->f@g(x), which is wrong because composition has lower precedence than function application.

sum((-1)^k/k^(1/2), k = 2 .. infinity);
Error, (in polylog) numeric exception: division by zero

 

This remains unevaluated:

(evalf@Sum)((1-10^(-3))^k/k, k = 1 .. infinity)

This might (or might not) be related to the fact that evalf/Sum doesn't have a tolerance (epsilon) setting. If I want to evaluate the sum with 1-10^-20 instead of 1-10^-3 directly, I need to increase Digits. But then the tolerance setting will increase too to about 10^(-Digits+1), and evalf/Sum will return unevaluated again because it won't be able to attain the requested accuracy. Whereas often only a few digits are needed -- e.g., to see how the sum grows with n -- and a tolerance value of 10^-3 or so would be sufficient.

2 3 4 5 6 7 8 Last Page 4 of 14