
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -2e+150)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.5e-28)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+150) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.5e-28) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2d+150)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.5d-28) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e+150) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.5e-28) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e+150: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.5e-28: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e+150) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.5e-28) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e+150) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.5e-28) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e+150], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e-28], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+150}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-28}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.99999999999999996e150Initial program 32.9%
Simplified32.9%
Taylor expanded in b around -inf 91.6%
*-commutative91.6%
Simplified91.6%
if -1.99999999999999996e150 < b < 1.50000000000000001e-28Initial program 81.4%
if 1.50000000000000001e-28 < b Initial program 16.8%
Simplified16.8%
Taylor expanded in b around inf 83.5%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -6e+148)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.05e-29)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e+148) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.05e-29) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-6d+148)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.05d-29) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6e+148) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.05e-29) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e+148: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.05e-29: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e+148) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.05e-29) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e+148) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.05e-29) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e+148], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-29], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{+148}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-29}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -6.00000000000000029e148Initial program 32.9%
Simplified32.9%
Taylor expanded in b around -inf 91.6%
*-commutative91.6%
Simplified91.6%
if -6.00000000000000029e148 < b < 1.04999999999999995e-29Initial program 81.4%
sqr-neg81.4%
sqr-neg81.4%
associate-*l*81.3%
Simplified81.3%
if 1.04999999999999995e-29 < b Initial program 16.8%
Simplified16.8%
Taylor expanded in b around inf 83.5%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -0.00195)
(* b (- (* 0.6666666666666666 (/ -1.0 a)) (* -0.5 (/ c (pow b 2.0)))))
(if (<= b 6.5e-27)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -0.00195) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / pow(b, 2.0))));
} else if (b <= 6.5e-27) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-0.00195d0)) then
tmp = b * ((0.6666666666666666d0 * ((-1.0d0) / a)) - ((-0.5d0) * (c / (b ** 2.0d0))))
else if (b <= 6.5d-27) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -0.00195) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / Math.pow(b, 2.0))));
} else if (b <= 6.5e-27) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -0.00195: tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / math.pow(b, 2.0)))) elif b <= 6.5e-27: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -0.00195) tmp = Float64(b * Float64(Float64(0.6666666666666666 * Float64(-1.0 / a)) - Float64(-0.5 * Float64(c / (b ^ 2.0))))); elseif (b <= 6.5e-27) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -0.00195) tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / (b ^ 2.0)))); elseif (b <= 6.5e-27) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -0.00195], N[(b * N[(N[(0.6666666666666666 * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e-27], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00195:\\
\;\;\;\;b \cdot \left(0.6666666666666666 \cdot \frac{-1}{a} - -0.5 \cdot \frac{c}{{b}^{2}}\right)\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-27}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -0.0019499999999999999Initial program 62.3%
Simplified62.3%
Taylor expanded in b around -inf 87.3%
if -0.0019499999999999999 < b < 6.50000000000000025e-27Initial program 75.3%
Simplified75.2%
Taylor expanded in b around 0 68.5%
associate-*r*68.6%
*-commutative68.6%
Simplified68.6%
if 6.50000000000000025e-27 < b Initial program 16.8%
Simplified16.8%
Taylor expanded in b around inf 83.5%
Final simplification79.6%
(FPCore (a b c)
:precision binary64
(if (<= b -0.00084)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.4e-29)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -0.00084) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.4e-29) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-0.00084d0)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.4d-29) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -0.00084) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.4e-29) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -0.00084: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.4e-29: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -0.00084) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.4e-29) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -0.00084) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.4e-29) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -0.00084], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-29], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00084:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-29}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -8.4000000000000003e-4Initial program 62.3%
Simplified62.3%
Taylor expanded in b around -inf 86.7%
*-commutative86.7%
Simplified86.7%
if -8.4000000000000003e-4 < b < 2.39999999999999992e-29Initial program 75.3%
Simplified75.2%
Taylor expanded in b around 0 68.5%
associate-*r*68.6%
*-commutative68.6%
Simplified68.6%
if 2.39999999999999992e-29 < b Initial program 16.8%
Simplified16.8%
Taylor expanded in b around inf 83.5%
Final simplification79.4%
(FPCore (a b c)
:precision binary64
(if (<= b -0.00085)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 7.6e-27)
(/ (- (sqrt (* (* a c) -3.0)) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -0.00085) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.6e-27) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-0.00085d0)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 7.6d-27) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -0.00085) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.6e-27) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -0.00085: tmp = (b * -2.0) / (3.0 * a) elif b <= 7.6e-27: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -0.00085) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 7.6e-27) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -0.00085) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 7.6e-27) tmp = (sqrt(((a * c) * -3.0)) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -0.00085], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-27], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00085:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-27}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -8.49999999999999953e-4Initial program 62.3%
Simplified62.3%
Taylor expanded in b around -inf 86.7%
*-commutative86.7%
Simplified86.7%
if -8.49999999999999953e-4 < b < 7.60000000000000001e-27Initial program 75.3%
Simplified75.2%
Taylor expanded in b around 0 68.5%
if 7.60000000000000001e-27 < b Initial program 16.8%
Simplified16.8%
Taylor expanded in b around inf 83.5%
Final simplification79.4%
(FPCore (a b c) :precision binary64 (if (<= b -0.102) (/ (* b -2.0) (* 3.0 a)) (if (<= b 7.3e-31) (/ (sqrt (* a (* c -3.0))) (* 3.0 a)) (* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -0.102) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.3e-31) {
tmp = sqrt((a * (c * -3.0))) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-0.102d0)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 7.3d-31) then
tmp = sqrt((a * (c * (-3.0d0)))) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -0.102) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.3e-31) {
tmp = Math.sqrt((a * (c * -3.0))) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -0.102: tmp = (b * -2.0) / (3.0 * a) elif b <= 7.3e-31: tmp = math.sqrt((a * (c * -3.0))) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -0.102) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 7.3e-31) tmp = Float64(sqrt(Float64(a * Float64(c * -3.0))) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -0.102) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 7.3e-31) tmp = sqrt((a * (c * -3.0))) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -0.102], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.3e-31], N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.102:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 7.3 \cdot 10^{-31}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -0.101999999999999993Initial program 62.3%
Simplified62.3%
Taylor expanded in b around -inf 86.7%
*-commutative86.7%
Simplified86.7%
if -0.101999999999999993 < b < 7.3000000000000003e-31Initial program 75.3%
add-cube-cbrt74.5%
pow374.5%
Applied egg-rr74.5%
Taylor expanded in a around -inf 0.0%
mul-1-neg0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt66.4%
distribute-lft-neg-in66.4%
metadata-eval66.4%
rem-cube-cbrt66.6%
Simplified66.6%
if 7.3000000000000003e-31 < b Initial program 16.8%
Simplified16.8%
Taylor expanded in b around inf 83.5%
Final simplification78.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.06e-104)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 7.3e-45)
(* (sqrt (* c (/ -3.0 a))) (- -0.3333333333333333))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.06e-104) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.3e-45) {
tmp = sqrt((c * (-3.0 / a))) * -(-0.3333333333333333);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.06d-104)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 7.3d-45) then
tmp = sqrt((c * ((-3.0d0) / a))) * -(-0.3333333333333333d0)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.06e-104) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.3e-45) {
tmp = Math.sqrt((c * (-3.0 / a))) * -(-0.3333333333333333);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.06e-104: tmp = (b * -2.0) / (3.0 * a) elif b <= 7.3e-45: tmp = math.sqrt((c * (-3.0 / a))) * -(-0.3333333333333333) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.06e-104) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 7.3e-45) tmp = Float64(sqrt(Float64(c * Float64(-3.0 / a))) * Float64(-(-0.3333333333333333))); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.06e-104) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 7.3e-45) tmp = sqrt((c * (-3.0 / a))) * -(-0.3333333333333333); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.06e-104], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.3e-45], N[(N[Sqrt[N[(c * N[(-3.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (--0.3333333333333333)), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.06 \cdot 10^{-104}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 7.3 \cdot 10^{-45}:\\
\;\;\;\;\sqrt{c \cdot \frac{-3}{a}} \cdot \left(--0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.06e-104Initial program 67.6%
Simplified67.6%
Taylor expanded in b around -inf 78.9%
*-commutative78.9%
Simplified78.9%
if -1.06e-104 < b < 7.30000000000000062e-45Initial program 71.0%
sqr-neg71.0%
sqr-neg71.0%
associate-*l*70.9%
Simplified70.9%
add-cube-cbrt70.3%
pow370.3%
Applied egg-rr70.3%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt32.3%
rem-cube-cbrt32.3%
associate-/l*32.4%
Simplified32.4%
if 7.30000000000000062e-45 < b Initial program 18.6%
Simplified18.5%
Taylor expanded in b around inf 82.0%
Final simplification67.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (* b -2.0) (* 3.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b * -2.0) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b * -2.0) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.3%
Simplified67.3%
Taylor expanded in b around -inf 65.2%
*-commutative65.2%
Simplified65.2%
if -4.999999999999985e-310 < b Initial program 36.8%
Simplified36.8%
Taylor expanded in b around inf 60.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (* b -0.6666666666666666) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (b * (-0.6666666666666666d0)) / a
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b * -0.6666666666666666) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b * -0.6666666666666666) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.3%
Simplified67.3%
Taylor expanded in b around 0 67.3%
*-commutative67.3%
fma-define67.3%
Simplified67.3%
Taylor expanded in b around -inf 64.6%
associate-*r/65.2%
Simplified65.2%
if -4.999999999999985e-310 < b Initial program 36.8%
Simplified36.8%
Taylor expanded in b around inf 60.1%
Final simplification62.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.3%
Simplified67.3%
Taylor expanded in b around -inf 64.6%
*-commutative64.6%
Simplified64.6%
if -4.999999999999985e-310 < b Initial program 36.8%
Simplified36.8%
Taylor expanded in b around inf 60.1%
Final simplification62.3%
(FPCore (a b c) :precision binary64 (if (<= b -2.45e+87) (/ c 0.0) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.45e+87) {
tmp = c / 0.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.45d+87)) then
tmp = c / 0.0d0
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.45e+87) {
tmp = c / 0.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.45e+87: tmp = c / 0.0 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.45e+87) tmp = Float64(c / 0.0); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.45e+87) tmp = c / 0.0; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.45e+87], N[(c / 0.0), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.45 \cdot 10^{+87}:\\
\;\;\;\;\frac{c}{0}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.44999999999999986e87Initial program 52.3%
Simplified52.3%
Taylor expanded in b around inf 2.5%
clear-num2.5%
un-div-inv2.5%
Applied egg-rr2.5%
associate-/r/2.5%
Simplified2.5%
frac-2neg2.5%
metadata-eval2.5%
div-inv2.5%
add-sqr-sqrt2.5%
sqrt-unprod2.5%
sqr-neg2.5%
sqrt-prod0.0%
add-sqr-sqrt3.2%
Applied egg-rr3.2%
associate-*r/3.2%
metadata-eval3.2%
Simplified3.2%
*-commutative3.2%
clear-num3.2%
un-div-inv3.2%
div-inv3.2%
metadata-eval3.2%
metadata-eval3.2%
distribute-rgt-out3.2%
*-un-lft-identity3.2%
*-un-lft-identity3.2%
flip-+0.0%
unpow20.0%
unpow20.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified17.8%
if -2.44999999999999986e87 < b Initial program 51.7%
Simplified51.7%
Taylor expanded in b around inf 41.0%
(FPCore (a b c) :precision binary64 (if (<= b -5.4e+86) (/ c 0.0) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.4e+86) {
tmp = c / 0.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.4d+86)) then
tmp = c / 0.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.4e+86) {
tmp = c / 0.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.4e+86: tmp = c / 0.0 else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.4e+86) tmp = Float64(c / 0.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.4e+86) tmp = c / 0.0; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.4e+86], N[(c / 0.0), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.4 \cdot 10^{+86}:\\
\;\;\;\;\frac{c}{0}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -5.40000000000000036e86Initial program 52.3%
Simplified52.3%
Taylor expanded in b around inf 2.5%
clear-num2.5%
un-div-inv2.5%
Applied egg-rr2.5%
associate-/r/2.5%
Simplified2.5%
frac-2neg2.5%
metadata-eval2.5%
div-inv2.5%
add-sqr-sqrt2.5%
sqrt-unprod2.5%
sqr-neg2.5%
sqrt-prod0.0%
add-sqr-sqrt3.2%
Applied egg-rr3.2%
associate-*r/3.2%
metadata-eval3.2%
Simplified3.2%
*-commutative3.2%
clear-num3.2%
un-div-inv3.2%
div-inv3.2%
metadata-eval3.2%
metadata-eval3.2%
distribute-rgt-out3.2%
*-un-lft-identity3.2%
*-un-lft-identity3.2%
flip-+0.0%
unpow20.0%
unpow20.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified17.8%
if -5.40000000000000036e86 < b Initial program 51.7%
Simplified51.7%
Taylor expanded in b around inf 13.4%
Taylor expanded in b around 0 13.4%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 51.8%
Simplified51.8%
Taylor expanded in b around inf 10.8%
Taylor expanded in b around 0 10.8%
herbie shell --seed 2024169
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))