Is it possible to do a summation series in Octave?
In matlab there is symsum
function for it, however I didn't found anything similar for octave.
For example, I want to find the following sum
Addendum:
Whether it's possible to sum something like this
f = @(x) nchoosek(5,x)*0.1.^x*0.9.^(5-x)
sum(f([0:5]))
Failed with error
error: called from:
error: /usr/share/octave/3.6.4/m/help/print_usage.m at line 87, column 5
error: /usr/share/octave/3.6.4/m/specfun/nchoosek.m at line 95, column 5
error: at line -1, column -1
error: evaluating argument list element number 1
If you don't need an analitical solution, then you don't need symsum
. For example if you want to calculate
the you can simply use sum
sum([1:5])
Here is another example:
f = @(x) exp(-x)
sum(f([1:5]))
And another one with factorial
function:
g = @(n) 1 ./ factorial(n)
sum(g([0:5]))
the same, but without anonymous function:
sum(1 ./ factorial([0:5]))
As for your last example, nchoosek
allows only scalar arguments. So, you'll need additional arrayfun
call:
f = @(x) nchoosek(5,x)*0.1.^x*0.9.^(5-x)
sum(arrayfun(f,[0:5]))