Python Code that finds $U_m$ given :

$M_s-mass,\\R_s-radius,\\ B_s^{eq}-field,\\ M_p-mass,\\ R_p-radius, \\B_p^{eq}-field,\\ e-eccentricity,\\ unit-M_p, R_p\text{ is measured with respect to Earth(”e”) or Jupiter(”j”) or Sun(”s”)}$

Syntax -

$energy(M_s, R_s, B_s, M_p, R_p, B_p, e, unit)$

Default Units of M_p and R_p are with respect to earth

To run the code

Sample Inputs

Code for the energy function

https://codepen.io/vasanthkashyap/pen/OJOObjy?editors=1000

Dependence of Energy with respect to Time

https://www.desmos.com/calculator/pdvkmt2vqa