Does anyone know how to code this summation equation that includes exponential and sine function?

2 commentaires

See - syms and symsum (requires Symbolic Math Toolbox)
I do not know if the sum converges or not and I am feeling a bit lazy to check rn.
But symsum() or vpasum() don't seem to find an explicit value -
syms m t
PI = sym('pi');
term = 180/(2*m*PI)*exp(-(2*m)^2*PI^2*t/900)*sin(2*m*PI/30);
%symsum
out1 = symsum(term, m, 1, Inf)
out1 = 
vpa(subs(out1, t, 3))
ans = 
%vpasum
out2 = vpasum(term, m, 1, Inf)
out2 = 
vpa(subs(out2, t, 3))
ans = 

Connectez-vous pour commenter.

 Réponse acceptée

Calculates the summation of the series as described:
result = compute_summation(1,100); % Computes the series for x = 1 with 100 terms
disp(result);
20.4225
function total = compute_summation(x, num_terms)
if nargin < 2
num_terms = 100; % Default number of terms
end
total = 0;
for m = 1:num_terms
exponential_part = exp(-(2*m)^2 * pi^2 / 900);
sine_part = sin(2 * m * pi / 30);
term = (180 / (2 * m * pi)) * exponential_part * sine_part;
total = total + term;
end
end
Note
Please note that computing an actual infinite series may not be possible due to computational limits, so you would typically compute a partial sum or find a closed-form if it exists.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering

2 commentaires

The series has an infinite summation, so the for loop will take too long for big values of num_terms (~1e9/1e10), nor will it give accurate results for bigger values of x.
And the exponential term is incorrect, as it is missing pi^2.
@Dyuman Joshi Thanks for pointing out I have corrected the exponential term. Also, I am not sure if MATLAB can do infinite series obviously not numerically nor symbolically dont we have to trancuate at some point?. Also I tried the syms approach.
syms m t;
% Define the general term of the series
general_term = (180/(2*m*pi)) * exp(-(2*m)^2 * pi^2 *t / 900) * sin(2*m*pi/30);
% Compute the summation
% Note: MATLAB might not be able to resolve this symbolically for an infinite series
% So we use a large number for the upper limit, say 100 terms
N = 100; % you can set N to a different value to approximate the infinite sum or inf
total_sum = symsum(general_term, m, 1, N);
% Display the symbolic sum
disp(total_sum);
% For numerical evaluation, substitute a value for x, for example x = 1
numerical_sum = subs(total_sum, m, 1);
% Display the numerical result
disp(vpa(numerical_sum));

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by