简体   繁体   English

使用fzero查找多项式的实根

[英]Finding real roots of polynomial by using fzero

I want to find only real roots of the equation which is ; 我只想找到等式的实根:

4*sqrt((1-(z^2/f1^2))*(1-z^2))-(2-z^2)^2-(m*z^4*sqrt(1-z^2/f1^2)/ ...
  sqrt(1-((z^2/f1^2)/y^2)))

I know that equation includes complex roots, but I do not want to see them. 我知道等式包含复杂的根,但我不想看到它们。 Moreover, my code fails and says that; 而且,我的代码失败并说明了这一点;

Error using fzero (line 242) Function values at interval endpoints must be finite and real. 使用fzero的错误(第242行)区间端点处的函数值必须是有限且实数。

Error in scholte (line 21) x=fzero(fun,x0) scholte错误(第21行)x = fzero(fun,x0)

Here is my code; 这是我的代码;

rho2 = 1000; %kg/m3    
rho1 = 2700; %kg/m3    
cl2 = 1481; %m/s    
cl1 = 5919; %m/s    
m = rho2/rho1;    
y = cl2/cl1;    
poi = 0.25;

f1 = (sqrt((1-2*poi)/(2*(1-poi))))^-1;

fun = @(z) 4*sqrt((1-(z^2/f1^2))*(1-z^2))-(2-z^2)^2- ...
      (m*z^4*sqrt(1-z^2/f1^2)/sqrt(1-((z^2/f1^2)/y^2)));

x0 = [1 10];

x = fzero(fun, x0)

I changed x0 interval many times, but it showed the same error. 我多次更改了x0间隔,但显示了相同的错误。 How can I fix my code? 如何修复我的代码?

Your problem, as Matlab tells you, is that Function values at interval endpoints must be finite and real , and in your case they are not real: 正如Matlab告诉您的那样,您的问题是Function values at interval endpoints must be finite and real ,而在您的情况下,它们不是实数:

fun(x0(1))

ans =

  -1.0000 + 0.1454i

Your function is probably just too complex for fzero to handle. 您的函数可能太复杂而无法处理fzero However I am not an expert, lets see if someone with more knowledge than me can point you in the correct direction for solving that equation. 但是我不是专家,让我们看看是否有人比我了解更多知识,可以为您指出解决该方程式的正确方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM