Using Solve function for polynomial

8 次查看(过去 30 天)
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
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 CenterFile Exchange 中查找有关 Polynomials 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by