This is the code along with documentation

from sympy import diff, integrate, sympify, expand, Symbol
x=Symbol('x')
def Delta(expr, d = 1):
    """Takes as input function expression and returns the diffrence
between final     value(function's expression incremented to 1) and
initial value (function's  expression).

       >>>from sympy import Symbol
       >>>from sympy import sin, cos
       >>>from sympy.series.integrals import Delta
       >>>x = Symbol('x')
       >>>Delta(x**2 + 3*x -2)
       2*x + 4
       >>>Delta(sin(x))
       - sin(x) + sin(x + 1)

       If you want an increment different than 1, you can give it the
increment value as an argument to Delta
       as shown below
       >>>Delta(x**2 - 2*x + 3, 2)
       4*x
       >>>Delta(x**3 + 3*x**2 + 4*x + 5, 3)
       9*x**2 + 45*x + 66
    """

    expr=sympify(expr)
    a=diff(expr)
    b=integrate(a, (x, x, x+d))
    expand(b)
    return expand(b)



and these are the tests

from sympy import sin, cos
from sympy import pi
from sympy import Symbol
from sympy.series.kauers import Delta
x = Symbol('x', real=True)
m = Symbol('m', real=True)


def test_Delta():
    assert Delta(x**2 + 2*x + 1) == 2*x + 3
    assert Delta(x**3 + 2*x**2 + 3*x +5) == 3*x**2 + 7*x + 6
    assert Delta(x**2 - 2*x + 3) == 2*x - 1
    assert Delta(x**2 + 3*x -2) == 2*x + 4
    assert Delta(sin(x), pi/6) == -sin(x) + sin(x + pi/6)
    assert Delta(cos(x), pi/3)
    assert Delta(x**2 - 2*x + 3, 2) == 4*x
    assert Delta(x**2 - 2*x + 3, 3) == 6*x + 3




On Jul 8, 7:59 am, Aaron Meurer <[email protected]> wrote:
> It's hard to tell without seeing the code. What you wrote should work.
>
> Aaron Meurer
>
> On Jul 7, 2012, at 5:44 AM, Saurabh Jha <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> >    I implemented a Delta() function as a part of my project of
> > implementation of Kauers' algorithm
>
> >    It takes as input function expression and returns the difference
> > between final value(function's expression  incremented to 1) and
> > initial value (function's expression)
> > .
> >    I saved the changes and ran it from sympy at python IDLE as
> > follows
>
> >>>> Delta(x**2 + 2*x + 1)
> > 2*x + 3
>
> > But when I wrote the tests as
>
> > assert Delta(x**2 + 2*x + 1) == 2*x + 3
>
> > it printed assertion error
>
> > The tests diden't passed. I don't know what's the differenece between
> > the two situations, please help me figure it out
>
> > -Saurabh Jha
>
> > --
> > 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 
> > athttp://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.

Reply via email to