What is the difference between sum and symsum

2 次查看(过去 30 天)
could anyone tell me what is the difference between sum and symsum

回答(2 个)

KSSV
KSSV 2018-1-1
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
Walter Roberson 2018-1-1
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.

类别

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