Skip to content

Commit 0f5689e

Browse files
authored
Add files via upload
1 parent ae04c1e commit 0f5689e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: numpydemo.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import scipy.integrate
55
import scipy.optimize
66
import scipy.interpolate
7+
import matplotlib.pyplot as plt
78

89
# Numpy has its own random number generators.
910

@@ -75,7 +76,7 @@
7576
# that we will use in integration, optimization and interpolation.
7677

7778
def f(x):
78-
return np.float_power(np.e, np.sin(x))
79+
return np.float_power((np.e + np.cos(10*x)), np.sin(x - np.sqrt(x)))
7980

8081

8182
# Integration of arbitrary black box function.
@@ -97,4 +98,11 @@ def f(x):
9798
print(f"Cubic spline says that f(5.5) = {cubic_spline(5.5)}.")
9899
akima = scipy.interpolate.Akima1DInterpolator(xs, ys)
99100
print(f"Akima interpolator says that f(5.5) = {akima(5.5)}.")
100-
print(f"The exact value of f(5.5) = {f(5.5)}.")
101+
print(f"The exact value of f(5.5) = {f(5.5)}.")
102+
103+
# Finish up with flourish with some Matplotlib plotting.
104+
xxs = np.linspace(0, 10, 1001)
105+
plt.figure()
106+
# This is all just straight up Matlab.
107+
plt.plot(xs, f(xs), 'bo', xxs, f(xxs), 'k')
108+
plt.show()

0 commit comments

Comments
 (0)