
(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 9 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 -7.2e+124)
(* (fma 0.5 (* c (/ a b)) (* b -0.6666666666666666)) (/ 1.0 a))
(if (<= b 1.08e-10)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.2e+124) {
tmp = fma(0.5, (c * (a / b)), (b * -0.6666666666666666)) * (1.0 / a);
} else if (b <= 1.08e-10) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -7.2e+124) tmp = Float64(fma(0.5, Float64(c * Float64(a / b)), Float64(b * -0.6666666666666666)) * Float64(1.0 / a)); elseif (b <= 1.08e-10) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -7.2e+124], N[(N[(0.5 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(b * -0.6666666666666666), $MachinePrecision]), $MachinePrecision] * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.08e-10], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.2 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(0.5, c \cdot \frac{a}{b}, b \cdot -0.6666666666666666\right) \cdot \frac{1}{a}\\
\mathbf{elif}\;b \leq 1.08 \cdot 10^{-10}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -7.19999999999999972e124Initial program 46.8%
/-rgt-identity46.8%
metadata-eval46.8%
associate-/r/46.8%
metadata-eval46.8%
metadata-eval46.8%
times-frac46.8%
*-commutative46.8%
times-frac46.9%
*-commutative46.9%
associate-/r*46.9%
associate-*l/46.9%
Simplified46.9%
Taylor expanded in b around -inf 82.4%
fma-def82.4%
associate-/l*93.4%
*-commutative93.4%
Simplified93.4%
div-inv93.5%
div-inv93.5%
clear-num93.5%
Applied egg-rr93.5%
if -7.19999999999999972e124 < b < 1.08000000000000002e-10Initial program 81.7%
if 1.08000000000000002e-10 < b Initial program 18.9%
Taylor expanded in b around inf 95.6%
Final simplification87.6%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+126)
(* (fma 0.5 (* c (/ a b)) (* b -0.6666666666666666)) (/ 1.0 a))
(if (<= b 1.25e-10)
(/ (- (sqrt (- (* b b) (* 3.0 (* c a)))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+126) {
tmp = fma(0.5, (c * (a / b)), (b * -0.6666666666666666)) * (1.0 / a);
} else if (b <= 1.25e-10) {
tmp = (sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+126) tmp = Float64(fma(0.5, Float64(c * Float64(a / b)), Float64(b * -0.6666666666666666)) * Float64(1.0 / a)); elseif (b <= 1.25e-10) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(c * a)))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+126], N[(N[(0.5 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(b * -0.6666666666666666), $MachinePrecision]), $MachinePrecision] * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.25e-10], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+126}:\\
\;\;\;\;\mathsf{fma}\left(0.5, c \cdot \frac{a}{b}, b \cdot -0.6666666666666666\right) \cdot \frac{1}{a}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-10}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.99999999999999977e126Initial program 46.8%
/-rgt-identity46.8%
metadata-eval46.8%
associate-/r/46.8%
metadata-eval46.8%
metadata-eval46.8%
times-frac46.8%
*-commutative46.8%
times-frac46.9%
*-commutative46.9%
associate-/r*46.9%
associate-*l/46.9%
Simplified46.9%
Taylor expanded in b around -inf 82.4%
fma-def82.4%
associate-/l*93.4%
*-commutative93.4%
Simplified93.4%
div-inv93.5%
div-inv93.5%
clear-num93.5%
Applied egg-rr93.5%
if -4.99999999999999977e126 < b < 1.25000000000000008e-10Initial program 81.7%
neg-sub081.7%
associate-+l-81.7%
sub0-neg81.7%
neg-mul-181.7%
associate-*r/81.7%
metadata-eval81.7%
metadata-eval81.7%
times-frac81.7%
*-commutative81.7%
times-frac81.6%
associate-*l/81.7%
Simplified81.6%
if 1.25000000000000008e-10 < b Initial program 18.9%
Taylor expanded in b around inf 95.6%
Final simplification87.6%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (fma (/ -3.0 (/ b c)) -0.16666666666666666 (/ b (/ a -0.6666666666666666))) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
tmp = fma((-3.0 / (b / c)), -0.16666666666666666, (b / (a / -0.6666666666666666)));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) tmp = fma(Float64(-3.0 / Float64(b / c)), -0.16666666666666666, Float64(b / Float64(a / -0.6666666666666666))); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], N[(N[(-3.0 / N[(b / c), $MachinePrecision]), $MachinePrecision] * -0.16666666666666666 + N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-3}{\frac{b}{c}}, -0.16666666666666666, \frac{b}{\frac{a}{-0.6666666666666666}}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 73.3%
/-rgt-identity73.3%
metadata-eval73.3%
associate-/r/73.3%
metadata-eval73.3%
metadata-eval73.3%
times-frac73.3%
*-commutative73.3%
times-frac73.2%
*-commutative73.2%
associate-/r*73.2%
associate-*l/73.3%
Simplified73.2%
expm1-log1p-u70.8%
expm1-udef51.9%
*-commutative51.9%
fma-udef51.9%
associate-*r*51.9%
add-sqr-sqrt36.6%
hypot-def40.9%
Applied egg-rr40.9%
expm1-def56.4%
expm1-log1p59.0%
*-commutative59.0%
*-commutative59.0%
associate-*l*59.0%
Simplified59.0%
Taylor expanded in b around -inf 0.0%
+-commutative0.0%
*-commutative0.0%
fma-def0.0%
*-commutative0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt65.9%
associate-*r/65.9%
*-commutative65.9%
associate-/l*65.9%
Simplified65.9%
if -1.000000000000002e-309 < b Initial program 41.8%
Taylor expanded in b around inf 65.7%
Final simplification65.8%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} 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 <= (-1d-309)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
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 <= -1e-309) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-309) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 73.3%
Taylor expanded in b around -inf 65.9%
if -1.000000000000002e-309 < b Initial program 41.8%
Taylor expanded in b around inf 65.7%
Final simplification65.8%
(FPCore (a b c) :precision binary64 (if (<= b 2.6e-286) (/ (* b -2.0) (* a 3.0)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.6e-286) {
tmp = (b * -2.0) / (a * 3.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.6d-286) then
tmp = (b * (-2.0d0)) / (a * 3.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.6e-286) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.6e-286: tmp = (b * -2.0) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.6e-286) tmp = Float64(Float64(b * -2.0) / Float64(a * 3.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.6e-286) tmp = (b * -2.0) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.6e-286], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{-286}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.6e-286Initial program 73.7%
Taylor expanded in b around -inf 64.6%
*-commutative64.6%
Simplified64.6%
if 2.6e-286 < b Initial program 40.8%
Taylor expanded in b around inf 66.8%
Final simplification65.6%
(FPCore (a b c) :precision binary64 (if (<= b 6.3e-285) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.3e-285) {
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 <= 6.3d-285) 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 <= 6.3e-285) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.3e-285: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.3e-285) 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 <= 6.3e-285) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.3e-285], 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 6.3 \cdot 10^{-285}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.29999999999999989e-285Initial program 73.7%
Taylor expanded in b around -inf 64.5%
*-commutative64.5%
Simplified64.5%
if 6.29999999999999989e-285 < b Initial program 40.8%
Taylor expanded in b around inf 66.8%
Final simplification65.6%
(FPCore (a b c) :precision binary64 (if (<= b 2.6e-286) (/ b (/ a -0.6666666666666666)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.6e-286) {
tmp = b / (a / -0.6666666666666666);
} 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.6d-286) then
tmp = b / (a / (-0.6666666666666666d0))
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.6e-286) {
tmp = b / (a / -0.6666666666666666);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.6e-286: tmp = b / (a / -0.6666666666666666) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.6e-286) tmp = Float64(b / Float64(a / -0.6666666666666666)); 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.6e-286) tmp = b / (a / -0.6666666666666666); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.6e-286], N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{-286}:\\
\;\;\;\;\frac{b}{\frac{a}{-0.6666666666666666}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.6e-286Initial program 73.7%
/-rgt-identity73.7%
metadata-eval73.7%
associate-/r/73.7%
metadata-eval73.7%
metadata-eval73.7%
times-frac73.7%
*-commutative73.7%
times-frac73.6%
*-commutative73.6%
associate-/r*73.6%
associate-*l/73.6%
Simplified73.6%
expm1-log1p-u71.1%
expm1-udef52.6%
*-commutative52.6%
fma-udef52.6%
associate-*r*52.6%
add-sqr-sqrt37.4%
hypot-def41.7%
Applied egg-rr41.7%
expm1-def57.0%
expm1-log1p59.5%
*-commutative59.5%
*-commutative59.5%
associate-*l*59.6%
Simplified59.6%
Taylor expanded in b around -inf 64.5%
associate-*r/64.5%
*-commutative64.5%
associate-/l*64.5%
Simplified64.5%
if 2.6e-286 < b Initial program 40.8%
Taylor expanded in b around inf 66.8%
Final simplification65.6%
(FPCore (a b c) :precision binary64 (if (<= b 6.2e-285) (/ (/ b -1.5) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.2e-285) {
tmp = (b / -1.5) / 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 <= 6.2d-285) then
tmp = (b / (-1.5d0)) / 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 <= 6.2e-285) {
tmp = (b / -1.5) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.2e-285: tmp = (b / -1.5) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.2e-285) tmp = Float64(Float64(b / -1.5) / 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 <= 6.2e-285) tmp = (b / -1.5) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.2e-285], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.2 \cdot 10^{-285}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.2000000000000002e-285Initial program 73.7%
Taylor expanded in b around -inf 64.6%
*-commutative64.6%
Simplified64.6%
expm1-log1p-u37.3%
expm1-udef25.1%
times-frac25.1%
Applied egg-rr25.1%
expm1-def37.3%
expm1-log1p64.6%
associate-*r/64.6%
associate-*l/64.6%
associate-/l*64.6%
metadata-eval64.6%
Simplified64.6%
if 6.2000000000000002e-285 < b Initial program 40.8%
Taylor expanded in b around inf 66.8%
Final simplification65.6%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 58.1%
Taylor expanded in b around inf 32.9%
Final simplification32.9%
herbie shell --seed 2023193
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))