Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implicit differentiation with Python 3?

How can we derivate a implicit equation in Python 3?
Example x^2+y^2=25 differentiation is: dy/dx=-x/y, when try this:

from sympy import *

init_printing(use_unicode=True)

x = symbols('x')
y = Function('y')(x)

eq = x**2+y**2-25
sol = diff(eq, x)
print(sol)

But it shows:

2*x + 2*y(x)*Derivative(y(x), x)

How can get -x/y?

like image 273
Robby Avatar asked Feb 06 '23 15:02

Robby


1 Answers

SymPy has the function idiff which does what you want

In [2]: idiff(x**2+y**2-25, y, x)
Out[2]:
-x
───
 y
like image 114
asmeurer Avatar answered Feb 11 '23 17:02

asmeurer