I think that your code doesn’t do what you think it does. Note for example that your declarations are self-contradicting :
Pasting code; enter '--' alone on the line to stop or use Ctrl-D. :function("xp yp zp tp f") :var("x y z t v c") :-- (xp, yp, zp, tp, f) (x, y, z, t, v, c) sage: xp.parent() <class 'sage.symbolic.function_factory.function_factory.<locals>.NewSymbolicFunction'> sage: xp = (x - v * t) / sqrt(1 - v^2 / c^2) sage: xp.parent() Symbolic Ring What you intend to do isn’t really clear… Could you try and clear your goals ? HTH, Le vendredi 22 janvier 2021 à 19:46:35 UTC+1, cseb...@gmail.com a écrit : > > I'm trying to collect all the terms in an expression with the same > second partial derivative but it doesn't seem to be working. > I can't figure out why. > > Here is my code.... > > # ============================================================ > > function("xp yp zp tp f") > var("x y z t v c") > > xp = (x - v * t) / sqrt(1 - v^2 / c^2) > yp = y > zp = z > tp = (t - v * x / c^2) / sqrt(1 - v^2 / c^2) > > e = derivative(f(xp, yp, zp, tp), x, 2) + derivative(f(xp, yp, zp, tp), y, > 2) + derivative(f(xp, yp, zp, tp), z, 2) - derivative(f(xp, yp, zp, tp), t, > 2) / c^2 > > e.collect(derivative(f(xp, yp, zp, tp), x, 2)) > > # ============================================================ > > Here is the output. I added spaces at a subtraction to make it easy to see > there are TWO of those D[0, 0](f) terms (each at the beginning of the > sections). > > (D[0, 0](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t - > v*x/c^2)/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1) - v*D[0, 3](f)(-(t*v - > x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + > 1))/(c^2*sqrt(-v^2/c^2 + 1)))/sqrt(-v^2/c^2 + 1) - v*(D[0, 3](f)(-(t*v - > x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + > 1))/sqrt(-v^2/c^2 + 1) - v*D[3, 3](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, > (t - v*x/c^2)/sqrt(-v^2/c^2 + 1))/(c^2*sqrt(-v^2/c^2 + > 1)))/(c^2*sqrt(-v^2/c^2 + 1)) > > - > > ((v*D[0, 0](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t - > v*x/c^2)/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1) - D[0, 3](f)(-(t*v - > x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + > 1))/sqrt(-v^2/c^2 + 1))*v/sqrt(-v^2/c^2 + 1) - (v*D[0, 3](f)(-(t*v - > x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + > 1))/sqrt(-v^2/c^2 + 1) - D[3, 3](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t > - v*x/c^2)/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1))/c^2 > + D[1, 1](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t - > v*x/c^2)/sqrt(-v^2/c^2 + 1)) + D[2, 2](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, > z, (t - v*x/c^2)/sqrt(-v^2/c^2 + 1)) > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/0ea1674e-c726-4a26-89d6-b851a99c8625n%40googlegroups.com.