>
>
> I would most appreciate it if anyone could advise me on what to do. Thanks!
>
>
Use SymPy ! :-)

>>> binomial(i,j)
binomial(i, j)
>>> _.subs(i,5)
binomial(5, j)
>>> _.subs(j,2)
10

So your expression is written as

>>> var('lamb mu')
(lamb, mu)
>>> l, i = symbols('l i',integer=True)
>>> f=symbols('f',cls=Function)
>>> f = lamb * ( 1 + (-mu)**(l+i) ) * binomial(l+i,i)
>>> pprint(f)
     ⎛    i + l    ⎞ ⎛i + l⎞
lamb⋅⎝(-μ)      + 1⎠⋅⎜     ⎟
                     ⎝  i  ⎠
>>> f.subs(((i,5),(l,2)))
21*lamb*(-mu**7 + 1)

Please note that although you are thinking of f as a function, it is (as
you have defined it) actually an expression equal to what is on the right
hand side. If you want f to be a function of l and i (for a fixed mu and
lamb) then you might write

>>> f=lambda l,i:lamb * ( 1 + (-mu)**(l+i) ) * binomial(l+i,i)
>>> f(2, 5)
21*lamb*(-mu**7 + 1)

or write the function as

>>> def f(l, i):
...     return lamb * ( 1 + (-mu)**(l+i) ) * binomial(l+i,i)
...
>>> f(5, 2)
21*lamb*(-mu**7 + 1)
>>> f(a,b)
lamb*((-mu)**(a + b) + 1)*binomial(a + b, b)
>>> f(l,i)
lamb*((-mu)**(i + l) + 1)*binomial(i + l, i)

If you want to include an undefined function in an expression, that's the
time to use f as a function:

>>> f = Function('f')
>>> f(1,2) + 3
f(1, 2) + 3


Hope that help,
Chris

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to