We have an equation similar to the Fredholm integral equation of second kind.
To solve this equation we have been given an iterative solution that is guaranteed to converge for our specific equation. Now our only problem consists in implementing this iterative prodedure in MATLAB.
For now, the problematic part of our code looks like this:
function delta = delta(x,a,P,H,E,c,c0,w)
delt = @(x)delta_a(x,a,P,H,E,c0,w);
for i=1:500
delt = @(x)delt(x) - 1/E.*integral(@(xi)((c(1)-c(2)*delt(xi))*ms(xi,x,a,P,H,w)),0,a-0.001);
end
delta=delt;
end
delta_a
is a function of x
, and represent the initial value of the iteration. ms
is a function of x
and xi
.
As you might see we want delt
to depend on both x
(before the integral) and xi
(inside of the integral) in the iteration. Unfortunately this way of writing the code (with the function handle) does not give us a numerical value, as we wish. We can't either write delt
as two different functions, one of x
and one of xi
, since xi
is not defined (until integral
defines it). So, how can we make sure that delt
depends on xi
inside of the integral, and still get a numerical value out of the iteration?
Do any of you have any suggestions to how we might solve this?
Using numerical integration
Explanation of the input parameters: x is a vector of numerical values, all the rest are constants. A problem with my code is that the input parameter x is not being used (I guess this means that x is being treated as a symbol).
x
is the vector of grid points where your function is to be approximated....? – Jan