I'm trying to solve the problem
where $u_n$ and $v_n$ are sequences that converge to the solution $u$ and $v$ and $\lambda$, $\sigma$, $f$ and $g$ and K_lambda are all given.
I thought of using the scipy module integrate
with a while
loop, but obviously I don't know how to implement the condition of convergence. I also don't know how to implement u_n(t) as integrand. Here's what I tried.
import numpy as np
import scipy.integrate as integrate
import scipy.special as special
import matplotlib
import matplotlib.pyplot as plt
import math
N = 30
u0 = np.ones(N)*0.2
v0 = np.ones(N)*0.15
bta = 2.1
eps = 0.1
sgm = 1.5
def K(t, s, lbda, T):
L1= np.exp(lbda*(T-s))*np.exp(lbda*t)/(1-np.exp(lbda*T))
if t>=s:
L2 = np.exp(lbda*(t-s))
else :
L2=0.0
return L1+L2
def f(s,u,v):
return np.sin(s)**2-bta*(u/(1+v))
def g(s,u,v):
return -np.cos(s)**2+sgm*(u/(1+v))+eps/(1+v)
def sigma(s):
return 1+np.sin(s)**2
def integrand_u(s, t, lbda, T,u,v):
return K(t, s, lbda, T) * (sigma(s) + lbda*u + f(s,u,v))
def integrand_v(s, t, lbda, T,u,v):
return K(t, s, lbda, T) * (sigma(s) + lbda*v + g(s,u,v))
def integral_u(t, lbda, T,u,v):
result = integrate.quad(integrand_u, 0, T, args=(t, lbda, T, u, v))[0]
return result
def integral_v(t, lbda, T,u,v):
result = integrate.quad(integrand_v, 0, T, args=(t, lbda, T, u, v))[0]
return result
# Define the parameters
lbda = 10
T = np.pi
t = np.linspace(0,T,N)
n=0
while n<N:
u = [integral_u(a, lbda, T, u0[n], v0[n]) for a in t]
v = [integral_v(a, lbda, T, u0[n], v0[n]) for a in t]
u0 = u
v0 = v
n = n+1
plt.plot(t,u)
plt.plot(t,v)
plt.show()