Buckets:
| from numpy import * | |
| from matplotlib.pyplot import * | |
| A = 1 | |
| a = 2 | |
| T = 4 | |
| dt = 0.2 | |
| N = int(round(T/dt)) | |
| y = zeros(N+1) | |
| t = linspace(0, T, N+1) | |
| theta = 1 | |
| y[0] = A | |
| for n in range(0, N): | |
| y[n+1] = (1 - (1-theta)*a*dt)/(1 + theta*dt*a)*y[n] | |
| y_e = A*exp(-a*t) - y | |
| error = y_e - y | |
| E = sqrt(dt*sum(error**2)) | |
| print 'Norm of the error: %.3E' % E | |
| plot(t, y, 'r--o') | |
| t_e = linspace(0, T, 1001) | |
| y_e = A*exp(-a*t_e) | |
| plot(t_e, y_e, 'b-') | |
| legend(['numerical, theta=%g' % theta, 'exact']) | |
| xlabel('t') | |
| ylabel('y') | |
| show() | |
Xet Storage Details
- Size:
- 506 Bytes
- Xet hash:
- ac8d70088cbc353cbad4dfb33e62565590866ad1d1c04a1870aea4f2a1da3b42
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.