Double asterisk

I am new to Python and am actually confused. I am reading a book and the code is working fine; I just do not understand!

T[i+1] = m*v[i+1]Ė†**/L

      

What's with the double asterisk part of this code? It was even accompanied by a forward slash. The L variable is initialized to 1.0. However, it looks like someone fell on the keyboard, but the code works fine. Is it a mathematical expression or something else? I would be grateful for your understanding. Thank you!

full code:

from pylab import *
g = 9.8 # m/sĖ†2
dt = 0.01 # s
time = 10.0 # s
v0 = 2.0 # s
D = 0.05 #
L = 1.0 # m
m = 0.5 # kg
# Numerical initialization
n = int(round(time/dt))
t = zeros(n,float)
s = zeros(n,float)
v = zeros(n,float)
T = zeros(n,float)
# Initial conditions
v[0] = v0
s[0] = 0.0
# Simulation loop
i = 0
while (i<n AND T[i]>=0.0):
    t[i+1] = t[i] + dt
    a = -D/m*v[i]*abs(v[i])-g*sin(s[i]/L)
    v[i+1] = v[i] + a*dt
    s[i+1] = s[i] + v[i+1]*dt
    T[i+1] = m*v[i+1]Ė†**/L + m*g*cos(s[i+1]/L)
    i = i + 1

      

+3


source to share


2 answers


This code is from the book Basic Mechanics Using Python: A Modern Course Combining Analytical and Numerical Methods.
According to the formula on page 255: enter image description here

So the Python line should be:



T[i+1] = m*v[i+1]**2/L + m*g*cos(s[i+1]/L)

      

+10


source


What about the double asterisk in this code?

The answer to your main questions (at least since it exists in this letter) is a double asterisk (star) - this is power - "to raise to power". Thus, there i**3

will be "cube i

".



My (cross control) source: fooobar.com/questions/109188 / ...

+6


source







All Articles