[Python] How should I go about writing the time dilation equation in python?

Discussão em 'Python' iniciado por Stack, Setembro 15, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to write/plot the time dilation equation (g = 1/sqrt(1 - (v/c)^2) in python through jupyter notebook but it keeps giving me this error message:

    TypeError: pow() missing required argument 'exp' (pos 2)

    B describes v/c and is the x-axis and g described 1/sqrt(1 - (v/c)^2 and is the y-axis. I was trying to plot B over g. The variable x is supposed to represent 1 - B**2 or 1- (v/c)**2

    from pylab import *
    v = linspace(0, 50, 100)
    c = 3 * 10**8
    B = v/c
    x = 1-B**2
    g = (1)/(pow(x))
    plot(B,g,'b-')
    title("graph")
    xlabel("Beta")
    ylabel("gamma")
    show()

    Continue reading...

Compartilhe esta Página