How To solve this equation?
이전 댓글 표시
답변 (2개)
Hi @Alif
Here is the numerical approach.
format long g
x = 1:1000;
y = (nthroot(5*x + 2, 5))./x;
S = sum(y)
댓글 수: 4
@Alif, This is the for-loop method, but I'm unsure why the last digit (2) differs from the last digit (1) computed using the sum() command.
format long g
y = 0; % Initialize y to store the sum later
for x = 1:1000
y = y + (nthroot(5*x + 2, 5))/x;
end
disp(y)
Summing in reverse seems to be more accurate as it is sum the smallest elemenst first
format long g
y = 0; % Initialize y to store the sum later
for x = 1000:-1:1
y = y + (nthroot(5*x + 2, 5))/x;
end
disp(y)
Sam Chak
2023년 10월 7일
I guess one can obtain more digits with MATLAB too
For reference Star Strider's vpa result is 21.533035475927133
x = 1:1000;
y = (nthroot(5*x + 2, 5))./x;
S = sum(y);
fprintf('sum command = %2.15f\n', S)
y = 0; % Initialize y to store the sum later
for x = 1:1000
y = y + (nthroot(5*x + 2, 5))/x;
end
fprintf('sum forward = %2.15f\n', y)
yb = 0; % Initialize y to store the sum later
for x = 1000:-1:1
yb = yb + (nthroot(5*x + 2, 5))/x;
end
fprintf('sum backward = %2.15f\n', yb)
yvpa = 21.533035475927133;
% LSB differences
(y-yvpa)/eps(yvpa) % 8 LSB, not so good
(yb-yvpa)/eps(yvpa) % -2 LSB, not bad
(S-yvpa)/eps(yvpa) % -3 LSB, OK
One approach —
syms x
f = symsum(((5*x+2)^(1/5))/x, x, 1, 1E+3)
fvpa = vpa(f)
.
댓글 수: 3
@Star Strider, the expression you have written is incorrect -
syms x
((5*x+2)^1/5)/x
You need to put the power inside parenthesis.
Star Strider
2023년 10월 7일
Fixed. I thought that the order of precedence would take care of that. (Too early here.)
Dyuman Joshi
2023년 10월 7일
^ takes precedence over /, so it's logical that would be executed first.
카테고리
도움말 센터 및 File Exchange에서 Numbers and Precision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


