Question
There is a problem when I want to install numpy on my macbok. Antouns-MacBook-Pro:~ anton$ pip nstall numpy -bash: pip: command not found. What Can
There is a problem when I want to install numpy on my macbok.
Antouns-MacBook-Pro:~ anton$ pip nstall numpy
-bash: pip: command not found.
What Can i do? It's for this problem of the code.
import numpy as np
import matplotlib.pyplot as plt
def f(r,t):
theta = r[0]
v = r[1]
w = r[2]
return np.array([v,-(g/l)*np.sin(theta),w,(g/l)*np.cos(theta)])
a = 0.0
b = 5.0
N = 1000
h = (b-a)/N
r = np.array([np.pi/4,0.0,0.0])
tpoints = np.arange(a,b,h)
thetapoints = []
rpoints = []
for t in tpoints:
thetapoints.append(r[0])
rpoints.append(r[1])
k1 = h*f(r,t)
k2 = h*f(r+0.5*k1,t+0.5*h)
k3 = h*f(r+0.5*k2,t+0.5*h)
k4 = h*f(r+k3,t+h)
r += (k1+2*k2+2*k3+k4)/6
plt.plot(tpoints,thetapoints,label='theta(t)')
plt.plot(tpoints,rpoints,label='r(t)')
plt.legend()
plt.xlabel("t")
plt.show()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started