jet_ski.py

Created by nick-koberstein

Created on September 22, 2021

629 Bytes


from math import *
import matplotlib.pyplot as plt

def f(x):
  return 100*x+10
a = 0; b = 0.5; N = 5
n = 10 # Use n*N+1 points to plot the function smoothly
step = (b-a)/N
s = (b-a)/(n*N)


x = [0]*(N+1)
x[0]=a
for i in range(1,N+1):
  x[i]=x[i-1]+step
  
y = [0]*(N+1)
for i in range(N+1):
  y[i] = f(x[i])

X = [0]*(n*N)
X[0]=a
for i in range(1,n*N):
  X[i]=X[i-1]+s

Y = [0]*(n*N)
for i in range(n*N):
  Y[i] = f(X[i])

plt.plot(X,Y,'r')
x_left = x[:-1] # Left endpoints
y_left = y[:-1]
x_plot = [0]*(N)
for i in range (N):
  x_plot[i] = x[i]+.05

plt.bar(x_plot,y_left, 0.1,color="red")
plt.grid()

plt.show()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.