Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to calculate Work from Potential

I'm using SageMath 8.1 on Window 10 Native with Jupyter Notebook.

This is a continuation to Potential from an exact differential form

R3 = Manifold(3, 'R3', start_index=1, latex_name=r'\mathbb{R}^3')
cartesian3d.<x,y,z> = R3.chart()
R1 = Manifold(1, 'R1', start_index=1, latex_name=r'\mathbb{R}')
cartesian1d.<t> = R1.chart()
g = R1.diff_map(R3, [e^(t^3), t^3-t^2+sin(2*pi*t^5), t^2-1])
omega = R3.diff_form(1, 'omega', latex_name=r'\omega')
omega[:] = (x^2+y*z+e^y, y^3+x*z+x*e^y+z^2, e^z+x*y+2*y*z)


aux_omega = omega
G1 = R3.diff_form(0); G1.set_expr(integral(aux_omega[1].expr(), cartesian3d[1]))
aux_omega = aux_omega - G1.differential()
G2 = R3.diff_form(0); G2.set_expr(integral(aux_omega[2].expr(), cartesian3d[2]))
aux_omega = aux_omega - G2.differential()
G3 = R3.diff_form(0); G3.set_expr(integral(aux_omega[3].expr(), cartesian3d[3]))
G = G1 + G2 + G3

Then I have to calculate G(g(1)) - G(g(0)). I came up with the following code:

A = G.expr()(x=g.expr()[0](t=1),y=g.expr()[1](t=1),z=g.expr()[2](t=1))
B = G.expr()(x=g.expr()[0](t=0),y=g.expr()[1](t=0),z=g.expr()[2](t=0))
N(A - B)

I consider this last code snippet to be brute-force, and extremely cumbersome. Is there a more elegant way to obtain the same?