Hi there I want to solve an equation below but i faced a problem.
i tried to solve this with following code but it did not works:
i already have Fc and m , i tried to find nc Please Help

 채택된 답변

John D'Errico
John D'Errico 2016년 8월 1일
편집: John D'Errico 2016년 8월 1일

0 개 추천

You cannot use solve to solve this because in general there is no exact solution. (And polynomials are still not involved.)
I suppose, if you want to use the extension of factorial into the real line using the special function gamma:
factorial(x) = gamma(x+1)
then you can write it as:
Fc - gamma(m+1)/(gamma(nc+1)*gamma(m-nc+1)) + nc == 0
but even here there will be no analytical solution.
syms nc
m = 5;
Fc = 8;
solve(Fc - gamma(m+1)/(gamma(nc+1)*gamma(m-nc+1))+nc,nc)
Warning: Cannot solve symbolically. Returning a numeric approximation instead.
> In solve (line 303)
ans =
2.7090797227280332212966072765956
I could have used fzero too there. Although there are many values of m for which fzero might fail due to numerical problems. Factorials get really large, really fast. But fzero will work here, using gamma:
fzero(@(nc) Fc - gamma(m+1)/(gamma(nc+1)*gamma(m-nc+1)) + nc,3)
ans =
2.70907972272803
>> fzero(@(nc) Fc - gamma(m+1)/(gamma(nc+1)*gamma(m-nc+1)) + nc,1.5)
ans =
2
It turns out, there are multiple solutions to your problem.

댓글 수: 1

John D'Errico
John D'Errico 2016년 8월 1일
편집: John D'Errico 2016년 8월 1일
Sorry, I originally misread your question. I've now fixed my response.
But no. There are at least TWO solutions to the problem.
ezplot(@(nc) Fc - gamma(m+1)./(gamma(nc+1).*gamma(m-nc+1)) + nc)
grid on
2 is one solution. But 2.709... is the second solution, as you can see from the plot.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 8월 1일

0 개 추천

syms nc
solve(Fc == factorial(m) / (factorial(nc)*factorial(m-nc)) - nc)

댓글 수: 1

Alireza Lashgary
Alireza Lashgary 2016년 8월 1일
thanks for your reply , but it did not work.
but it has a solution. Fc is 8 , m is 5 and nc must be 2 but i got that warning.

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

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by