Is there a reason you don't just use Heaviside? With the new Miejer G
algorithm in master, integrate() works fine with Heaviside functions
and expressions containing Heaviside functions.
In [101]: var("a")
Out[101]: a
In [102]: integrate(Heaviside(x - a), x)
Out[102]:
⎧ │x│
⎪ 0 for │─│ < 1
⎪ │a│
⎪
⎪ │a│
⎨ x for │─│ < 1
⎪ │x│
⎪
⎪ ╭─╮0, 2 ⎛2, 1 │ x⎞
⎪a⋅│╶┐ ⎜ │ ─⎟ otherwise
⎩ ╰─╯2, 2 ⎝ 1, 0 │ a⎠
The G-function is a result of our poor simplification of the
conditions. If you need a better value at that point, you can
substitute e.g., x = a and call simplify():
In [106]: integrate(Heaviside(x - a), x).subs(x, a).simplify()
Out[106]: 0
To answer your original question, the only way to make the Risch
heuristic work with custom functions is to define the derivative using
_eval_derivative. If that doesn't work, then that just means that the
Risch heuristic doesn't work with that kind of function.
To extend the Meijer G algorithm, you have to extend the tables. I
don't know if Tom ever wrote up a document on how to do this.
Aaron Meurer
On Mon, Mar 5, 2012 at 4:02 PM, Hansi <[email protected]> wrote:
> Is there a way to define the antiderivative of a function in order to
> be evaluated when integrating?
>
> I would like to define a function foo1(x - a) as an inherited class
> of sympy.core.function which behaves like the heaviside-function: when
> the argument of the function (x - a) is negative, foo1(x - a) is 0,
> otherwise 1.
> When integrating the function, another function foo2(x - a) should be
> returned which has the property to return 0 as long as (x - a) is
> negative, and the argument (x - a) otherwise. It is important that the
> function is not decomposed, i.e. it is not expressed as (x-a)*(sign(x-
> a) + 1)/2 because the function foo2 has to be integrated several times
> again (I already got how to solve this problem by defining the diff-
> method)
>
> The question is: Is there any way to define foo2 as the antiderivative
> of foo1?
> Overwriting foo1.integrate() does not work as integrate(foo1) does not
> deliver the result. And by defining the diff-method, I didn't get the
> result either.
>
> Thanks a lot for helping a beginner!
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.