Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

substitute variable inside function

I can do

f(a,b) = a^2+b^3; f=f-f.subs(a=(a-1))
(a, b) |--> -(a - 1)^2 + a^2

I tried to write a function which does this vor arbitrary expressions and variables

def test(self, symb):          
    return (self-self.subs(symb=(symb-1)))

but

test(f,a)
(a, b) |--> 0

fails miserably. It seems self.subs(symb=(symb-1)) can not be evaluated properly. How can I achieve what I want?

substitute variable inside function

I can do

f(a,b) = a^2+b^3; f=f-f.subs(a=(a-1))
(a, b) |--> -(a - 1)^2 + a^2

I tried to write a function which does this vor for arbitrary expressions and variables

def test(self, symb):          
    return (self-self.subs(symb=(symb-1)))

but

test(f,a)
(a, b) |--> 0

fails miserably. It seems self.subs(symb=(symb-1)) can not be evaluated properly. How can I achieve what I want?