blaz
blaz

Reputation: 4248

Differentiating an equation

I want to differentiate the following equation

from sympy import *
init_printing()

x, t, r, phi = symbols('x, t, r, phi')

# this is how I want to do it
eq = Eq(x(t), r*phi(t))
eq.diff(t)

enter image description here

The result is differentiated only on the left side. I would like it to be evaluated on both sides. Is that possible in a simple way?

Currently I do the following:

Eq(eq.lhs.diff(t), eq.rhs.diff(t))

Upvotes: 6

Views: 140

Answers (1)

Randy
Randy

Reputation: 14847

Borrowing some of the logic from Sympy: working with equalities manually, you can do something like this:

eq.func(*map(lambda x: diff(x, t), eq.args))

A bit ugly, but it works. Alternatively, you could just lift the .do() method from that and use it if you're going to want to do this a bunch of times.

Upvotes: 1

Related Questions