please share matlab command please

3 comentarios

parid
parid el 7 de En. de 2023
>> syms n x
y = symsum ((1+n^2/n),n,0,100)
y = 5151
Atsushi Ueno
Atsushi Ueno el 7 de En. de 2023
Editada: Atsushi Ueno el 7 de En. de 2023
syms n x
y = symsum ((1+n^2/n),n,0,100)
y = 
5151
syms n x
y = symsum ((1+n^2)/n,n,0,100)
Error using symengine
Division by zero.

Error in sym/symsum (line 70)
rSym = mupadmex('symobj::map',fsym.s,'symobj::symsum',x.s,a.s,b.s);
You can avoid the division by 0 error.
syms n
f = (1+n^2)/n
f = 
%break the sum into two parts
part2 = symsum(f, n, 1, 100)
part2 = 
part1 = limit(f, n, 0)
part1 = 
NaN
y = part1 + part2
y = 
NaN

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 7 de En. de 2023

1 voto

You can break this up into two sums: one for n = 0 exactly, and the other one for n = 1 to 100.
You can calculate the 1 to 100 using symsum
The value for 0 exactly would normally involve a division by 0, but you can try to approach the problem using limit . Just make sure to compare the limit from the "left" with the limit from the "right"

4 comentarios

parid
parid el 7 de En. de 2023
I try in you suggest to me. please help check.
syms n x
y = symsum((1+n^2/n),n,0,100)
y =
5151
Walter Roberson
Walter Roberson el 7 de En. de 2023
You coded to calculate n^2 and divide by n, and add 1 to the result of the division. But the expression requires you to take n^2 and add 1 to the result, and divide the total by n
Mathematically except at 0 the expression is the same as (1/n)+n
parid
parid el 7 de En. de 2023
>> syms n x
y = symsum ((1+n^2/n),n,0,100)
y = 5151
Remember that / has higher priority than division, so
1+n^2/n is 1 + (n^2/n)
In turn, ^ has higher priority than / so this is 1 + ((n^2)/n)
But n^2/n is just n unless n is 0 (or unless n is so large that n^2 overflows to infinitity), so that expression is equivalent to 1 + (n)
This is different than taking n^2 and adding 1 to that value, and then dividing the whole thing by n .
Consider for example if n = 2 and n = 5
n = [2 5]
n = 1×2
2 5
result1 = (1+n.^2./n)
result1 = 1×2
3 6
result2 = 1 + ((n.^2)./n)
result2 = 1×2
3 6
temporary = n.^2 + 1; result3 = temporary ./ n
result3 = 1×2
2.5000 5.2000
result1 and result2 are the same -- they are the same calculation. result3 is different: they show what happens when you make sure to do the addition first before the division.

Iniciar sesión para comentar.

Categorías

Más información sobre Signal Processing Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 7 de En. de 2023

Comentada:

el 8 de En. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by