HP Forums
The diff command counts faster than ∂/∂x - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: The diff command counts faster than ∂/∂x (/thread-20955.html)



The diff command counts faster than ∂/∂x - hp-zl - 12-06-2023 06:55 AM

When I type "diff(Σ((-1)^(k+1)/k^x,k,1,20),x)" I get the result after about 4 seconds (appendix 1).
When I type "∂(Σ((-1)^(k+1)/k^x,k,1,20),x)" I get the result after about 3 minutes (sic!) (appendix 2).

CAS Mode. Firmware: 2.1.14730. HP-Prime G2.
CAS Settings. Simplify: Maximum ("Minimum" gives worse results).

The time() command probably does not take into account the formatting time of the result and its display, but the difference is apparent: 0.7 s vs. 29 s (Appendix 3).

Regards.
[attachment=12997] [attachment=12998] [attachment=12999]


RE: The diff command counts faster than ∂/∂x - Albert Chan - 12-06-2023 04:24 PM

Differentiation, unlike integration, is very mechanical, and should run very fast.
Problem is internal hard-coded simplify, that cannot be controlled by SIMPLIFY setting.

My guess is diff(f,x) is less "simplified" than ∂(f,x), thus run much faster.

OP problem, we want to stop sum from simplify f with common denominator, making a mess.
Instead of summing an expression, we sum a list, which bypass internal simpilfy code. (*)

Cas> lst := makelist(k -> (-1)^(k+1)/k^x, 1, 20)
Cas> f := sum(lst)

diff(f,x) or ∂(f,x) should now run very fast.

(*) sum(lst) = '+' operator applied to list, see https://www.hpmuseum.org/forum/thread-20389-post-176469.html#pid176469

Cas> (a+b)[1] (lst)

1 - 1/2^x + 1/3^x - 1/4^x + 1/5^x ... + 1/19^x - 1/20^x