Wolfram mathematica Mathematica中四变量平方根的求解,无代码响应

Wolfram mathematica Mathematica中四变量平方根的求解,无代码响应,wolfram-mathematica,Wolfram Mathematica,我试图用以下公式获得x的表达式,但没有成功 Mathematica中的代码,其中我有4个变量,x,r,a和b。有什么建议吗 Select[x, #1 \[Element] Reals &] roots = x /. Solve[ Sqrt[29991348849*x^2 - 13958305552*x + 992000000 - r + a - b] == 0, x] result1 = Select[roots, Im@# == 0 &] 为了澄清@TroyHaskin的评论

我试图用以下公式获得x的表达式,但没有成功 Mathematica中的代码,其中我有4个变量,x,r,a和b。有什么建议吗

Select[x, #1 \[Element] Reals &]
roots = x /.
Solve[
Sqrt[29991348849*x^2 - 13958305552*x + 992000000 - r + a - b] == 0,
x]
result1 = Select[roots, Im@# == 0 &]

为了澄清@TroyHaskin的评论,
Re
Im
函数将提供
复数的实部和虚部。由于符号
a
b
没有定义,
Solve
找到的根不能
复杂

还应注意,
复数
不能有零虚部:

Head[Complex[2,0]]
(*Integer*)
此表达式具有实根和复根:

根=x/。解[(x^4-1)(x^4-4)=0,x]; ({-1,-I,I,1,-Sqrt[2],-I Sqrt[2],I Sqrt[2],Sqrt[2]})

使用
FreeQ
可以找到
复合体的根

Select[roots, !FreeQ[#, _Complex] &]
(*{-I, I, -I Sqrt[2], I Sqrt[2]}*)

这是什么?这不是matlab代码这是Mathematica代码,它运行正常。
result1
为空的原因是因为您的代码没有定义
{r,a,b}
;因此,
{r,a,b}
的函数,可能有一个虚部,因此
选择
不返回任何结果。通过检查
求解
结果,如果
(r+b-a)>=-18957155412540506176/29991348849~-6 10^8
,您可以很容易地显示您有两个实根。。否则就没有真正的根。