python - sympy solve function as function -
i want solve f(x)
(eq(2*f(x)+f(1/x),1/x))
the expected output
f(x) = (2-x^2)/(3*x)
i try
solve((eq(2*f(x)+f(1/x),1/x)),f(x))
this answer contains f(1/x) : (-x*f(1/x) + 1)/(2*x)
how f(x) = (2-x^2)/(3*x) in sympy?
i don't think sympy solve functional equations in way want, separate particular equation two: 2y+z = 1/x , 2z+y = x y(1/x) = z(x) , let sympy solve both y , z:
in [5]: x, y, z = symbol('x'), symbol('y'), symbol('z') in [6]: solve((eq(2*y+z,1/x), eq(2*z+y,x)),y,z) out[6]: {y: (-x**2 + 2)/(3*x), z: (2*x**2 - 1)/(3*x)}
so y f(x) want here.
Comments
Post a Comment