MATLAB crashed when invoking symsum

조회 수: 1 (최근 30일)
Maristie
Maristie 2017년 5월 4일
댓글: Maristie 2017년 5월 9일
The minimal example:
symsum(log(nchoosek(100, x)), x, 0, 100)
I've got the sum using `for` statement just in less than 1s.
But when it comes to symsum, MATLAB just crashes.
I've tried this code both on my own machine (Debian 9.0, R2016b) and MATLAB online, but results are just the same.
Could you please help me out?
Thanks!

채택된 답변

Wilson A N
Wilson A N 2017년 5월 9일
This is probably because 'symsum' is trying to find some closed expression as an answer and it is unable to do so. If you use 'sum', it will try this out numerically and hence doesn't give an error. You can maybe try out the following command:
>>sum(subs(log(nchoosek(100, x)), x, 0:100))
  댓글 수: 2
Walter Roberson
Walter Roberson 2017년 5월 9일
Right. symsum() should only be used if you are trying to find a formula for the summation, not if you just want to add a number of terms together. To add terms together, generate the list of terms and sum() them, the way Wilson A N shows.
Maristie
Maristie 2017년 5월 9일
Thanks! It works!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 光照、透明度和着色에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!