Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differentiating an equation

Tags:

python

sympy

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))
like image 794
blaz Avatar asked Oct 28 '15 13:10

blaz


People also ask

How do you differentiate an equation with two variables?

In implicit differentiation, we differentiate each side of an equation with two variables (usually x and y) by treating one of the variables as a function of the other. This calls for using the chain rule. Let's differentiate x 2 + y 2 = 1 x^2+y^2=1 x2+y2=1x, squared, plus, y, squared, equals, 1 for example.

How do you differentiate a function from a function?

In order to differentiate a function of a function, y = f(g(x)), that is to find dy dx , we need to do two things: 1. Substitute u = g(x). This gives us y = f(u) Next we need to use a formula that is known as the Chain Rule.

What is differentiation example?

The instantaneous rate of change of a function with respect to another quantity is called differentiation. For example, speed is the rate of change of displacement at a certain time.


1 Answers

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.

like image 139
Randy Avatar answered Sep 21 '22 02:09

Randy