Using Solve function for polynomial

8 ビュー (過去 30 日間)
Alireza Lashgary
Alireza Lashgary 2016 年 8 月 1 日
編集済み: John D'Errico 2016 年 8 月 1 日
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
  1 件のコメント
John D'Errico
John D'Errico 2016 年 8 月 1 日
What does this have to do with a polynomial?

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

採用された回答

John D'Errico
John D'Errico 2016 年 8 月 1 日
編集済み: John D'Errico 2016 年 8 月 1 日
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 日
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.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by