Opened 3 years ago

Last modified 3 years ago

#22850 new defect

Change specific heaviside() interface to Maxima

Reported by: rws Owned by:
Priority: major Milestone: sage-8.0
Component: calculus Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Not yet reported upstream; Will do shortly. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

Sage interfaces its Heaviside function with a Maxima function named hstep which seems to implement the same function. However, there is no documentation on it, and it is not supported in Runge-Kutta DE computations, nor in integration. This leads to mathematically wrong results when calling desolve_rk4() and integrate() with expressions containing heaviside (but it's working with unit_step).

The ticket should either replace hstep with unit_step in the Maxima interfaces, or remove it altogether with a warning. Alternatively, use substitute_function in desolve_rk4() and integrate(). Additionally, the issue with hstep should be reported upstream.

Change History (8)

comment:1 follow-up: Changed 3 years ago by mforets

i am curious about the 2nd alternative: remove it altogether with a warning. does it mean that we can write a custom integrate method that fixes integration etc and symbolics?

because if you compare with the similar problematic behaviour with the dirac delta:

sage: integrate(dirac_delta(x-1)*sin(x), x, 0, 2, algorithm='maxima')  # ??
integrate(dirac_delta(x - 1)*sin(x), x, 0, 2)
sage: integrate(dirac_delta(x-1)*sin(x), x, 0, 2, algorithm='sympy')  # ok
sin(1)

then in this other case there is no other "dirac delta" that can be used as backup, in analogy to the unit step. hence in this case i have the impression that the 2nd alternative is the only choice, isn't it?

comment:2 in reply to: ↑ 1 ; follow-up: Changed 3 years ago by rws

Replying to mforets:

i am curious about the 2nd alternative: remove it altogether with a warning. does it mean that we can write a custom integrate method that fixes integration etc and symbolics?

because if you compare with the similar problematic behaviour with the dirac delta:

sage: integrate(dirac_delta(x-1)*sin(x), x, 0, 2, algorithm='maxima')  # ??
integrate(dirac_delta(x - 1)*sin(x), x, 0, 2)
sage: integrate(dirac_delta(x-1)*sin(x), x, 0, 2, algorithm='sympy')  # ok
sin(1)

then in this other case there is no other "dirac delta" that can be used as backup, in analogy to the unit step. hence in this case i have the impression that the 2nd alternative is the only choice, isn't it?

It would be if the result (the unevaluated integral) was mathematically wrong, but it's not, so it's not a bug.

comment:3 in reply to: ↑ 2 Changed 3 years ago by rws

However, another alternative for the enhancement of dirac_delta integration would then be to always call SymPy.

comment:4 follow-up: Changed 3 years ago by mforets

However, another alternative for the enhancement of dirac_delta integration would then be to always call SymPy?.

is it possible to dispatch a particular integrator when the symbolic expression has the presence of a given function (such as dirac delta)? like a notion of "weak default"

comment:5 in reply to: ↑ 4 Changed 3 years ago by rws

Replying to mforets:

is it possible to dispatch a particular integrator when the symbolic expression has the presence of a given function (such as dirac delta)? like a notion of "weak default"

Recognition works even in Python:

sage: (1 + sin(dirac_delta(x))).has(dirac_delta(SR.wild()))
True

Changing the integrator would be done in src/sage/symbolic/integration/integral.py. Why not?

comment:6 Changed 3 years ago by mforets

ok, and this would require some decorator technology?

(just in case, in general i'm -1 to change the default integrator to other different than maxima)

think that a similar trick could be applied to laplace with heaviside for instance

comment:7 Changed 3 years ago by rws

I have no idea (I only fiddled once with changing the result after the integrators had a go). Please go ahead.

comment:8 Changed 3 years ago by mforets

we should also consider extending the available software interfaces to desolvers.py. SymPy? has dsolve. Giac has odesolve. one could be interested in choosing some of these, not only for this but for other examples.

for the integral customization, there is some initial effort in the DefiniteIntegral class, at /symbolic/integration/integral.py.

Note: See TracTickets for help on using tickets.