Your comments

Hi again,


I can't seem to numerically stabilize my code (see below). I expect the diagonal elements in the matrix "Ortho" to be equal to L (here = 10) and the off-diagonal elements equal to zero. I'm trying to prove the orthogonality of the function f...


mp.Digits(20);

L = mp(10);
N = mp(5);
fun = @(x) cos(x)*cosh(x)-1;
B = mp(zeros(N,1));
B(1,1) = fzero(fun,[4,5]);
B(2,1) = fzero(fun,[7,8]);
for k=3:N
B(k,1) = (2*(k+1)-1)*pi/2;
end
for i=1:N
b(i,1) = B(i,1)/L;
end
ksi = mp(zeros(N,1));
for i=1:N
r = B(i,1);
ksi(i,1) = -(cos(r)-cosh(r))/(sin(r)-sinh(r));
end
Ortho = mp(zeros(N,N));
for i=1:N
p = b(i,1);
q = ksi(i,1);
for j=1:N
r = b(j,1);
s = ksi(j,1);
f = @(x)(cos(p*x)+cosh(p*x)+q*sin(p*x)+q*sinh(p*x)).*(cos(r*x)+cosh(r*x)+s*sin(r*x)+s*sinh(r*x));
[q,errbnd] = quadgk(f,mp(0),L,'RelTol',100*mp.eps(),'AbsTol',100*mp.eps(), 'MaxIntervalCount', 100000);
Ortho(j,i) = q;
end
end



Thank you for your assistance! You've been of great help!

Can I also use this to create a matrix of solutions, since I need to calculate these integrals with varying coefficients b and c?

For example, I would like to calculate the definite integral "int(sin(b*x)*cosh(c*x)" in the variable x over the interval [0,L], in which b,c and L are constant values (which I defined as mp-objects).