Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from mpl_toolkits.mplot3d import Axes3D
- from matplotlib import cm
- from sympy import *
- from math import *
- x = np.linspace(int(-8), int(8), 100)
- t = np.linspace(int(-8), int(8), 100)
- n = symbols('n', integer=True)
- X, T = np.meshgrid(x, t)
- Z = []
- y = symbols('y')
- for ix, ea in enumerate(x):
- ans = 0.
- for n in range(11): # do summation with simple for-loop
- ans = ans + (2 / 10.) * integrate(50. * sin(radians((2. * n + 1.) * pi * x[ix] / 20.)), (y, 0, 10)) * e**(2. * n + 1. / 20.)**2*pi**2*x[ix] * sin(radians((2. * n + 1.) * pi * x[ix] / 20))
- Z.append(ans)
- Z = np.array(Z, dtype=float)
- fig = plt.figure()
- ax = fig.gca(projection = '3d')
- surf = ax.plot_surface(X, T, Z,
- rstride = 3,
- cstride = 3,
- cmap = cm.coolwarm,
- linewidth = 0.5,
- antialiased = True)
- fig.colorbar(surf,
- shrink=0.8,
- aspect=16,
- orientation = 'vertical')
- ax.view_init(elev=60, azim=50)
- ax.dist=8
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement