How To solve this equation?
Mostrar comentarios más antiguos
Respuestas (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 comentarios
@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
el 7 de Oct. de 2023
Bruno Luong
el 7 de Oct. de 2023
Editada: Bruno Luong
el 7 de Oct. de 2023
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
Star Strider
el 7 de Oct. de 2023
Editada: Star Strider
el 7 de Oct. de 2023
One approach —
syms x
f = symsum(((5*x+2)^(1/5))/x, x, 1, 1E+3)
fvpa = vpa(f)
.
3 comentarios
@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
el 7 de Oct. de 2023
Fixed. I thought that the order of precedence would take care of that. (Too early here.)
Dyuman Joshi
el 7 de Oct. de 2023
^ takes precedence over /, so it's logical that would be executed first.
Categorías
Más información sobre Numbers and Precision en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


