What is the difference between sum and symsum
Mostrar comentarios más antiguos
could anyone tell me what is the difference between sum and symsum
Respuestas (2)
KSSV
el 1 de En. de 2018
0 votos
sum works on double......it add the given numbers across specified dimension.
symsum works on symbolic variables.
You may read the documentation further.
Walter Roberson
el 1 de En. de 2018
symsum should only be used for calculating the formula for indefinite summations (or, sometimes, very large definite summations.) For example
syms k x
symsum(x^k/factorial(k), k, 1, inf)
symsum knows this is exp(x)
If you are adding up a finite list of distinct terms, you should probably be calculating the terms using vector calculations (and possibly subs() a vector of values into a symbolic expression) and then use sum() -- even if you are adding up symbolic expressions.
symsum() can never be used to index an array with a symbolic variable. You cannot use
symsum(x(k)/2^k, k, 1, length(x)) %wrong!!
for example.
Categorías
Más información sobre Mathematics 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!