0
$\begingroup$

I am trying to solve coupled integral equation by iteration following the procedure that has been discussed in http://www.mathematica-journal.com/issue/v9i2/contents/IntegralEquations/IntegralEquations.pdf. Instead of using fix number of iteration, I want to stop the iteration when the difference between two consecutive iterates is less than some predetermined small value. Anybody has any idea how to do that? I am writing here a code containing fix number of iteration:

approxsoln1[x_] = 1; 
approxsoln2[x_] = 1; 
exactsoln1[x_] = E^x; 
exactsoln2[x_] = x; 
f1[x_] = 2/3 E^x - 1/4;
f2[x_] = 3/2 x - x^2; 
Kn11[x_, y_] = 1/3 E^x y ; 
Kn12[x_, y_] = y^2 ; 
Kn21[x_, y_] = x^2 E^-y ; 
Kn22[x_, y_] = -x; 
error1[x_] := exactsoln1[x] - approxsoln1[x]
error2[x_] := exactsoln2[x] - approxsoln2[x]
new[x_] := Sin[(\[Pi] x)/2]^2
dim = 100; 
<< NumericalDifferentialEquationAnalysis`;
dat = GaussianQuadratureWeights[dim, 0, 1];

iterstep := 
(fa[x_, y_] = Kn11[new[x], y] approxsoln1[y]+Kn12[new[x], y] approxsoln2[y];   
fb[x_, y_] = Kn21[new[x], y] approxsoln1[y] + Kn22[new[x], y] approxsoln2[y];   
values = Table[{new[x], 
 f1[new[x]] + Sum[fa[x, dat[[i, 1]]] dat[[i, 2]], {i, 1, dim}], 
 f2[new[x]] + Sum[fb[x, dat[[i, 1]]] dat[[i, 2]], {i, 1, dim}]}, {x, 0,1, .05}]; 
approxsoln1[x_] =    InterpolatingPolynomial[
Table[{values[[i, 1]], values[[i, 2]]}, {i, 1, 21}], x]; 
approxsoln2[x_] = InterpolatingPolynomial[
Table[{values[[i, 1]], values[[i, 3]]}, {i, 1, 21}], x]) 

Do[iterstep, {40}] // Quiet 

Plot[{error1[x]}, {x, 0, 1}] 
Plot[{error2[x]}, {x, 0, 1}]
$\endgroup$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.