Fredholm Integral Equations

First Kind

This package provides the function inteq.SolveFredholm() which approximates the solution, g(x), to the Fredholm Integral Equation of the first kind using the method described in Twomey (1963). It will return a smooth curve that is an approximate solution. However, it may not be a good approximate to the true solution.

inteq.SolveFredholm(k: Callable[[numpy.ndarray, numpy.ndarray], numpy.ndarray], f: Callable[[numpy.ndarray], numpy.ndarray] = <function <lambda>>, a: float = -1.0, b: float = 1.0, gamma: float = 0.001, num: int = 40, **kwargs) → numpy.ndarray

Approximate the solution, g(x), to the Fredholm Integral Equation of the first kind:

\[f(s) = \int_a^b K(s,y) g(y) dy\]

using the method described in Twomey (1963). It will return a smooth curve that is an approximate solution. However, it may not be a good approximate to the true solution.

Parameters
kfunction

The kernel function that takes two arguments.

ffunction

The left hand side (free) function that takes one argument.

afloat

Lower bound of the of the Fredholm definite integral, defaults to -1.

bfloat

Upper bound of the of the Fredholm definite integral, defaults to 1.

numint

Number of estimation points between zero and b.

sminfloat

Optional. Lower bound of enforcement values for s.

smaxfloat

Optional. Upper bound of enforcement values for s.

snumint

Optional. Number of enforcement points for s.

Returns
grid2-D array

Input values are in the first row and output values are in the second row.

Example

example of first kind fie

from inteq import SolveFredholm
import numpy as np
import matplotlib.pyplot as plt

# define kernel
def k(s, t):
    return (np.abs(t - s) <= 3) * (1 + np.cos(np.pi * (t - s) / 3))


# define free function
def f(s):
    sp = np.abs(s)
    sp3 = sp * np.pi / 3
    return ((6 - sp) * (2 + np.cos(sp3)) + (9 / np.pi) * np.sin(sp3)) / 2


# define true solution
def trueg(s):
    return k(0, s)


# apply the solver
s, g = SolveFredholm(k, f, a=-3, b=3, num=1000, smin=-6, smax=6)

# plot functions
figure = plt.figure()

plt.plot(s, g)
plt.plot(s, trueg(s))

plt.legend(["Estimate", "True Value"])

plt.xlabel("s")
plt.ylabel("g(s)")

figure.set_dpi(100)
figure.set_size_inches(8, 5)

figure.savefig("..\\docs\\fredholm\\fredholm-example.svg", bbox_inches="tight")

Second Kind

Implementation forthcoming.