フィルターのクリア

.Alternate to using for loop or symsum for the summation ∑(const)^n/(n*n!) ?

7 ビュー (過去 30 日間)
Ramaprasad Kulkarni
Ramaprasad Kulkarni 2013 年 6 月 26 日
Dear all,
Is there a more computationally efficient way compared to using for loop or symsum (from Symbolic math toolbox) to compute:
∑(const)^n/(n*n!)
const is some constant value, n is the range of limit varying from 1 to infinity (or some high value like 200 for approximating the sum).
-- Thanks, Ram.
  2 件のコメント
Sean de Wolski
Sean de Wolski 2013 年 6 月 26 日
編集済み: Sean de Wolski 2013 年 6 月 26 日
Why not symsum? You're going to need it for factorial greater than 170 anyway:
factorial(171)
Ramaprasad Kulkarni
Ramaprasad Kulkarni 2013 年 6 月 27 日
I am using symsum and it is computationally expensive. It takes a lot of time (like half an hour for my program). I am not using 'for loop' anymore which I assume would have been worse computationally.

サインインしてコメントする。

採用された回答

Roger Stafford
Roger Stafford 2013 年 6 月 26 日
Your sum is equal to the integral
int('(exp(x)-1)/x','x',0,const)
so you could do numerical integration of this rather than summing the infinite series. That integrand is actually well-behaved in the vicinity of x = 0, but computing it might give you some problems, so you could substitute a Taylor series approximation very near x = 0.
  1 件のコメント
Ramaprasad Kulkarni
Ramaprasad Kulkarni 2013 年 6 月 27 日
Well, I used symsum with 'range 1 to 200' which runs much faster without much difference in results compared to the 'range 1 to infinity' (which I was using earlier).
-- Thanks for your replies.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by