title finding the energy equivalence of mass and mass equivalence of energy by einstein s equation description einstein s massenergy equivalence is a pivotal concept in theoretical physics it asserts that energy e and mass m are directly related by the speed of light in vacuum c squared as described in the equation e mc this means that mass and energy are interchangeable a mass increase corresponds to an energy increase and vice versa this principle has profound implications in nuclear reactions explaining the release of immense energy from minuscule changes in atomic nuclei equations e mc and m ec where m is mass e is energy c is speed of light in vacuum reference https en wikipedia orgwikimasse28093energyequivalence calculates the energy equivalence of the mass using e mc in si units j from mass in kg mass float mass of body usage example energyfrommass124 56 1 11948945063458e19 energyfrommass320 2 8760165719578165e19 energyfrommass0 0 0 energyfrommass967 9 traceback most recent call last valueerror mass can t be negative calculates the mass equivalence of the energy using m ec in si units kg from energy in j energy float mass of body usage example massfromenergy124 56 1 3859169098203872e15 massfromenergy320 3 560480179371579e15 massfromenergy0 0 0 massfromenergy967 9 traceback most recent call last valueerror energy can t be negative speed of light in vacuum 299792458 m s calculates the energy equivalence of the mass using e mc² in si units j from mass in kg mass float mass of body usage example energy_from_mass 124 56 1 11948945063458e 19 energy_from_mass 320 2 8760165719578165e 19 energy_from_mass 0 0 0 energy_from_mass 967 9 traceback most recent call last valueerror mass can t be negative calculates the mass equivalence of the energy using m e c² in si units kg from energy in j energy float mass of body usage example mass_from_energy 124 56 1 3859169098203872e 15 mass_from_energy 320 3 560480179371579e 15 mass_from_energy 0 0 0 mass_from_energy 967 9 traceback most recent call last valueerror energy can t be negative
from scipy.constants import c  


def energy_from_mass(mass: float) -> float:
    
    if mass < 0:
        raise ValueError("Mass can't be negative.")
    return mass * c**2


def mass_from_energy(energy: float) -> float:
    
    if energy < 0:
        raise ValueError("Energy can't be negative.")
    return energy / c**2


if __name__ == "__main__":
    import doctest

    doctest.testmod()