Open GoogleCodeExporter opened 9 years ago
For example, this script solves the heat equation with homogeneous Dirichlet BC
on
[0,1] with given initial temperature distribution u0. Note that evaluation of
u1 is
very slow. Can u(x,t) be made fast and correct for arbitrarily small t, and can
it be
made to evaluate even for t = 0?
from mpmath import *
mp.dps = 5
#u0 = lambda x: sin(2*pi*x)**2
#u0 = lambda x: 1.73
u0 = lambda x: cos(x)
def theta(x,t):
return jtheta(3,pi*x/2,exp(-pi**2*t))*0.5
def u(x,t):
return quadgl(lambda r: (theta(x-r,t)-theta(x+r,t))*u0(x), [0,1])
u1 = lambda x: u(x,0.001)
u2 = lambda x: u(x,0.01)
u3 = lambda x: u(x,0.1)
u4 = lambda x: u(x,0.2)
plot([u0, u1, u2, u3, u4], [0, 1], points=100)
Original comment by fredrik....@gmail.com
on 24 Feb 2009 at 12:32
Original issue reported on code.google.com by
fredrik....@gmail.com
on 24 Feb 2009 at 12:10