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

1 次查看(过去 30 天)
  2 个评论
Dyuman Joshi
Dyuman Joshi 2024-1-6
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 = 

请先登录,再进行评论。

采纳的回答

Hassaan
Hassaan 2024-1-6
编辑:Hassaan 2024-1-6
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 个评论
Dyuman Joshi
Dyuman Joshi 2024-1-6
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.
Hassaan
Hassaan 2024-1-6
编辑:Hassaan 2024-1-6
@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));

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by