I have a general solution to my heat equation as:
I have tried implementing this in MATLAB but I get inconsistent results. Do you think the issue is about my code or just the triple summation does not yield realistic outputs. Here's my code:
% Define the bounds for the summation
n = 50; % Upper limit for the first index
m = 50; % Upper limit for the second index
p = 50; % Upper limit for the third index
to = 350;
tc = 80;
Lx = 10;
Ly = 10;
Lz = 10;
k = 1;
x=5;
y=5;
z=5;
% Initialize the sum variable
sum_val = 0;
% Perform the triple summation
for a = 1:n
alpha = (2*a-1)*pi/Lx;
for b = 1:m
beta = (2*b-1)*pi/Ly;
for c = 1:p
gamma = (2*c-1)*pi/Lz;
lambda = (alpha^2 + beta^2 + gamma^2);
% Compute the term to be added to the sum
term = (sin(alpha*x) * sin(beta*y) * sin(gamma*z) * exp(-lambda*k*0)) / ...
((2*a-1) + (2*b-1) + (2*c-1));
% Add the term to the sum
sum_val = sum_val + term;
end
end
end
u = to + sum_val*(64*(to-tc)/pi^3);
% Display the result
disp(['The triple summation value is: ' num2str(u)]);
The code outputs a value of 403.4368 for x,y,z = 5. It should not be this high. I was expecting a result of 80 at most.