# Revision history [back]

### Trig simplification of implicit functions fails

I'd like to use Sage to verify my solutions to Lagrangian equations of motion for a double pendulum. However, Sage seems unable to handle some basic substitutions needed to make sense of this relatively simple problem.

For example, this all works fine:

var('z')
r = cos(z)**2 + sin(z)**2
assert r.simplify_trig() == 1


However, when z is a function of time, things break down entirely:

var('x,y,t,z')
θ1 = function('θ1')(t)
θ2 = function('θ2')(t)
K = sin(θ1)**2 + cos(θ1)**2
assert K.simplify_trig() == 1


Specifically, K.simplify_trig() throws:

TypeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined.

I would also expect

assert K.substitute_function(θ1, z) == cos(z)^2 + sin(z)^2


However K.substitute_function(θ1, z) just gives me K unchanged.

Seems related, but I'm still stumped: ask.sagemath.org/question/7856/lagranian-mechanics/