The standard cubic polynomial is: $ax^3+bx^2+cx + d$.
And when I used my function:
piecewiseForm[equation_,solvingVariable_,domain_]:=
Module[{solutions,radicalSolutions,piecewiseList},
solutions = Solve[equation, solvingVariable, domain];
radicalSolutions = ToRadicals[Normal @ x /. solutions];
piecewiseList = Piecewise[Table[
{First[radicalSolutions[[i]]], Last[radicalSolutions[[i]]]},
{i, 1, Length[radicalSolutions]}
]];
piecewiseList//TraditionalForm
]
with:
piecewiseForm[a*x^3+b*x^2+c*x+d==0,x,Reals]
I got:
$$\begin{cases} -\frac{b}{3 a}+\frac{\sqrt[3]{-2 b^3+9 a c b-27 a^2 d+\sqrt{4 \left(3 a c-b^2\right)^3+\left(-2 b^3+9 a c b-27 a^2 d\right)^2}}}{3 \sqrt[3]{2} a}-\frac{\sqrt[3]{2} \left(3 a c-b^2\right)}{3 a \sqrt[3]{-2 b^3+9 a c b-27 a^2 d+\sqrt{4 \left(3 a c-b^2\right)^3+\left(-2 b^3+9 a c b-27 a^2 d\right)^2}}} & \left(3 a-\frac{b^2}{c}>0\land c>0\right)\lor \left(3 a-\frac{b^2}{c}>0\land c<0\land \frac{2 b^3}{a^2}-\frac{9 c b}{a}+27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}>0\land -\frac{2 b^3}{a^2}+\frac{9 c b}{a}-27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}>0\right)\lor \left(3 a-\frac{b^2}{c}>0\land c<0\land \frac{2 b^3}{a^2}-\frac{9 c b}{a}+27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}<0\right)\lor \left(3 a-\frac{b^2}{c}>0\land c<0\land -\frac{2 b^3}{a^2}+\frac{9 c b}{a}-27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}<0\right)\lor \left(3 a-\frac{b^2}{c}<0\land c>0\land \frac{2 b^3}{a^2}-\frac{9 c b}{a}+27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}>0\land -\frac{2 b^3}{a^2}+\frac{9 c b}{a}-27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}>0\right)\lor \left(3 a-\frac{b^2}{c}<0\land c>0\land \frac{2 b^3}{a^2}-\frac{9 c b}{a}+27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}<0\right)\lor \left(3 a-\frac{b^2}{c}<0\land c>0\land -\frac{2 b^3}{a^2}+\frac{9 c b}{a}-27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}<0\right)\lor \left(3 a-\frac{b^2}{c}<0\land c<0\right) \\ -\frac{b}{3 a}-\frac{\left(1-i \sqrt{3}\right) \sqrt[3]{-2 b^3+9 a c b-27 a^2 d+\sqrt{4 \left(3 a c-b^2\right)^3+\left(-2 b^3+9 a c b-27 a^2 d\right)^2}}}{6 \sqrt[3]{2} a}+\frac{\left(1+i \sqrt{3}\right) \left(3 a c-b^2\right)}{3\ 2^{2/3} a \sqrt[3]{-2 b^3+9 a c b-27 a^2 d+\sqrt{4 \left(3 a c-b^2\right)^3+\left(-2 b^3+9 a c b-27 a^2 d\right)^2}}} & \left(3 a-\frac{b^2}{c}>0\land \frac{2 b^3}{a^2}-\frac{9 c b}{a}+27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}>0\land -\frac{2 b^3}{a^2}+\frac{9 c b}{a}-27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}>0\land c<0\right)\lor \left(3 a-\frac{b^2}{c}<0\land \frac{2 b^3}{a^2}-\frac{9 c b}{a}+27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}>0\land -\frac{2 b^3}{a^2}+\frac{9 c b}{a}-27 d+2 \sqrt{\frac{\left(b^2-3 a c\right)^3}{a^4}}>0\land c>0\right) \end{cases}$$
but when I try:
piecewiseForm[a*x^3+b*x^2+c*x+d==0,x,NonNegativeReals]
I just get $0$ and even:
Solve[a*x^3+b*x^2+c*x+d==0,x,NonNegativeReals]
gives: $\{\}$
but I know there are obviously non-negative solutions for the general cubic polynomial. How do I find this formula using Mathematica?
solutions = equation, solvingVariable, domain]
is wrong syntax. $\endgroup$LogicalExpand[Reduce[a*x^3+b*x^2+c*x+d==0&&x>=0,x,Reals]]
andLogicalExpand[Simplify[Reduce[a*x^3+b*x^2+c*x+d==0&&x>=0,x,Reals]]]
reduces the size by 25% at the cost making the result less explicit for x in some cases. Maybe you can eliminate some cases that you consider not interesting and find the solution you are looking for in that. $\endgroup$