Computing the Triple Summation of the Heat Equation

1 view (last 30 days)
Hello, 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)]);
  8 Comments
uk
uk on 2 Jul 2023
Edited: uk on 2 Jul 2023
It seems that the issue was due to the fact that we added terms in the denominator but they need to be multiplied. The results are still unrealistic though.
Torsten
Torsten on 2 Jul 2023
Edited: Torsten on 2 Jul 2023
Seems to work now (see above).
Additionally to the multiplication in the denominator the line
u(it) = to + sum_val*(64*(to-tc)/pi^3);
had to be changed to
u(it) = to + sum_val*(64*(tc-to)/pi^3);
But you should check against a numerical code to see if there might be other errors.

Sign in to comment.

Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!