Maclaurin Expansion of the Telegrapher’s Equation and Python Implementation

Kac(Kac, 1974) proved his stochastic model can express the telegrapher’s equa- tion(1). In this report, I would like to predict a function F(x, t) with using the Maclaurin ex- pansion. The expansion of F(x, t) is showed like (2). When we define the partial derivative of F(x, t) with respect to t = 0 as φ_i(3), and initial conditions are fixed as (4, 5) in this case. Then, we can regard (1) as (6). Finally, I implemented this expansion in terms of t of range between 0 and 3. Especially, in a case of F(0, 0.5), the output is 0.256581271960677.

http://projecteuclid.org/DPubS?service=UI&version=1.0&verb=Display&handle=euclid.rmjm/1250130879

[=figure1]

#-*- coding:utf-8 -*-
from __future__ import division
import numpy as np
from sympy import *
from mpmath import *
import matplotlib.pyplot as plt

def kac_Maclaurin(t):
	n_max = 52; X = 0.0; a = 2.0; v = 1.0;
	x = Symbol('x');
	phi = [];
	phi.append( (np.e**(-x**2))*(0.1+(x-0.25)**2)); phi.append(0*x); 
	F = phi[0].subs(x, X) + phi[1].subs(x, X);
	p = 1
	for n in xrange(2, n_max):
		phi.append( v**2 *phi[n-2].diff(x,2) - 2*a*phi[n-1] )
		p *= n
		F += phi[n].subs(x, X)/p * (t ** n)
	return F

def main():
	max_iter = 301;
	T = np.linspace(0, 3, max_iter);
	N = np.zeros((1, max_iter));
	for t in xrange(max_iter):
		N[0, t] =	kac_Maclaurin(T[t]);
	plt.xlabel('t');
	plt.ylabel('F(0, t)');
	plt.plot(T, N[0, :]);
	plt.show()
	
	for i in xrange(max_iter):
		print T[i], N[0, i]

if __name__ == "__main__":
	main()