
(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 10 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 -5e+150)
(/ b (* a -1.5))
(if (<= b 3.7e-25)
(/ (- (sqrt (fma b b (* a (* c -3.0)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+150) {
tmp = b / (a * -1.5);
} else if (b <= 3.7e-25) {
tmp = (sqrt(fma(b, b, (a * (c * -3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+150) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 3.7e-25) tmp = Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(c * -3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+150], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.7e-25], N[(N[(N[Sqrt[N[(b * b + N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+150}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 3.7 \cdot 10^{-25}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.00000000000000009e150Initial program 44.5%
neg-sub044.5%
sqr-neg44.5%
associate-+l-44.5%
sub0-neg44.5%
sub-neg44.5%
distribute-neg-in44.5%
remove-double-neg44.5%
sqr-neg44.5%
associate-*l*44.5%
Simplified44.5%
Applied egg-rr53.7%
Taylor expanded in b around -inf 97.5%
*-commutative97.5%
associate-*l/97.5%
associate-/l*97.5%
Simplified97.5%
clear-num97.5%
un-div-inv97.6%
div-inv97.6%
metadata-eval97.6%
Applied egg-rr97.6%
if -5.00000000000000009e150 < b < 3.70000000000000009e-25Initial program 77.3%
/-rgt-identity77.3%
metadata-eval77.3%
Simplified77.3%
if 3.70000000000000009e-25 < b Initial program 13.1%
neg-sub013.1%
sqr-neg13.1%
associate-+l-13.1%
sub0-neg13.1%
sub-neg13.1%
distribute-neg-in13.1%
remove-double-neg13.1%
sqr-neg13.1%
associate-*l*13.1%
Simplified13.1%
Taylor expanded in b around inf 95.0%
*-commutative95.0%
Simplified95.0%
Final simplification86.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e+148)
(/ b (* a -1.5))
(if (<= b 4.2e-22)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e+148) {
tmp = b / (a * -1.5);
} else if (b <= 4.2e-22) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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.25d+148)) then
tmp = b / (a * (-1.5d0))
else if (b <= 4.2d-22) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e+148) {
tmp = b / (a * -1.5);
} else if (b <= 4.2e-22) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e+148: tmp = b / (a * -1.5) elif b <= 4.2e-22: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e+148) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 4.2e-22) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.25e+148) tmp = b / (a * -1.5); elseif (b <= 4.2e-22) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e+148], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.2e-22], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{+148}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 4.2 \cdot 10^{-22}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.25000000000000006e148Initial program 44.5%
neg-sub044.5%
sqr-neg44.5%
associate-+l-44.5%
sub0-neg44.5%
sub-neg44.5%
distribute-neg-in44.5%
remove-double-neg44.5%
sqr-neg44.5%
associate-*l*44.5%
Simplified44.5%
Applied egg-rr53.7%
Taylor expanded in b around -inf 97.5%
*-commutative97.5%
associate-*l/97.5%
associate-/l*97.5%
Simplified97.5%
clear-num97.5%
un-div-inv97.6%
div-inv97.6%
metadata-eval97.6%
Applied egg-rr97.6%
if -1.25000000000000006e148 < b < 4.20000000000000016e-22Initial program 77.3%
neg-sub077.3%
sqr-neg77.3%
associate-+l-77.3%
sub0-neg77.3%
sub-neg77.3%
distribute-neg-in77.3%
remove-double-neg77.3%
sqr-neg77.3%
associate-*l*77.3%
Simplified77.3%
if 4.20000000000000016e-22 < b Initial program 13.1%
neg-sub013.1%
sqr-neg13.1%
associate-+l-13.1%
sub0-neg13.1%
sub-neg13.1%
distribute-neg-in13.1%
remove-double-neg13.1%
sqr-neg13.1%
associate-*l*13.1%
Simplified13.1%
Taylor expanded in b around inf 95.0%
*-commutative95.0%
Simplified95.0%
Final simplification86.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.35e-31)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 2.4e-25)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e-31) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 2.4e-25) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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.35d-31)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 2.4d-25) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e-31) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 2.4e-25) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.35e-31: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 2.4e-25: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.35e-31) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 2.4e-25) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.35e-31) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 2.4e-25) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.35e-31], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-25], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \cdot 10^{-31}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-25}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.35000000000000007e-31Initial program 68.7%
neg-sub068.7%
sqr-neg68.7%
associate-+l-68.7%
sub0-neg68.7%
sub-neg68.7%
distribute-neg-in68.7%
remove-double-neg68.7%
sqr-neg68.7%
associate-*l*68.7%
Simplified68.7%
Taylor expanded in b around -inf 93.9%
Taylor expanded in c around 0 94.0%
if -1.35000000000000007e-31 < b < 2.40000000000000009e-25Initial program 69.5%
neg-sub069.5%
sqr-neg69.5%
associate-+l-69.5%
sub0-neg69.5%
sub-neg69.5%
distribute-neg-in69.5%
remove-double-neg69.5%
sqr-neg69.5%
associate-*l*69.5%
Simplified69.5%
Taylor expanded in b around 0 61.3%
*-commutative61.3%
associate-*r*61.3%
Simplified61.3%
if 2.40000000000000009e-25 < b Initial program 13.1%
neg-sub013.1%
sqr-neg13.1%
associate-+l-13.1%
sub0-neg13.1%
sub-neg13.1%
distribute-neg-in13.1%
remove-double-neg13.1%
sqr-neg13.1%
associate-*l*13.1%
Simplified13.1%
Taylor expanded in b around inf 95.0%
*-commutative95.0%
Simplified95.0%
Final simplification83.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.75e-31)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 2.4e-25)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e-31) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 2.4e-25) {
tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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.75d-31)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 2.4d-25) then
tmp = (sqrt(((-3.0d0) * (a * c))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e-31) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 2.4e-25) {
tmp = (Math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.75e-31: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 2.4e-25: tmp = (math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.75e-31) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 2.4e-25) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.75e-31) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 2.4e-25) tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.75e-31], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-25], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.75 \cdot 10^{-31}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-25}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.74999999999999993e-31Initial program 68.7%
neg-sub068.7%
sqr-neg68.7%
associate-+l-68.7%
sub0-neg68.7%
sub-neg68.7%
distribute-neg-in68.7%
remove-double-neg68.7%
sqr-neg68.7%
associate-*l*68.7%
Simplified68.7%
Taylor expanded in b around -inf 93.9%
Taylor expanded in c around 0 94.0%
if -1.74999999999999993e-31 < b < 2.40000000000000009e-25Initial program 69.5%
neg-sub069.5%
sqr-neg69.5%
associate-+l-69.5%
sub0-neg69.5%
sub-neg69.5%
distribute-neg-in69.5%
remove-double-neg69.5%
sqr-neg69.5%
associate-*l*69.5%
Simplified69.5%
Taylor expanded in b around 0 61.3%
if 2.40000000000000009e-25 < b Initial program 13.1%
neg-sub013.1%
sqr-neg13.1%
associate-+l-13.1%
sub0-neg13.1%
sub-neg13.1%
distribute-neg-in13.1%
remove-double-neg13.1%
sqr-neg13.1%
associate-*l*13.1%
Simplified13.1%
Taylor expanded in b around inf 95.0%
*-commutative95.0%
Simplified95.0%
Final simplification82.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else {
tmp = (c / b) * -0.5;
}
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)) + ((c / b) * 0.5d0)
else
tmp = (c / b) * (-0.5d0)
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)) + ((c / b) * 0.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 73.0%
neg-sub073.0%
sqr-neg73.0%
associate-+l-73.0%
sub0-neg73.0%
sub-neg73.0%
distribute-neg-in73.0%
remove-double-neg73.0%
sqr-neg73.0%
associate-*l*73.0%
Simplified73.0%
Taylor expanded in b around -inf 68.4%
Taylor expanded in c around 0 69.7%
if -4.999999999999985e-310 < b Initial program 28.5%
neg-sub028.5%
sqr-neg28.5%
associate-+l-28.5%
sub0-neg28.5%
sub-neg28.5%
distribute-neg-in28.5%
remove-double-neg28.5%
sqr-neg28.5%
associate-*l*28.5%
Simplified28.5%
Taylor expanded in b around inf 71.4%
*-commutative71.4%
Simplified71.4%
Final simplification70.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ 1.0 (* a (/ -1.5 b))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = 1.0 / (a * (-1.5 / b));
} else {
tmp = (c / b) * -0.5;
}
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 = 1.0d0 / (a * ((-1.5d0) / b))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = 1.0 / (a * (-1.5 / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = 1.0 / (a * (-1.5 / b)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(1.0 / Float64(a * Float64(-1.5 / b))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = 1.0 / (a * (-1.5 / b)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(1.0 / N[(a * N[(-1.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{1}{a \cdot \frac{-1.5}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 73.0%
neg-sub073.0%
sqr-neg73.0%
associate-+l-73.0%
sub0-neg73.0%
sub-neg73.0%
distribute-neg-in73.0%
remove-double-neg73.0%
sqr-neg73.0%
associate-*l*73.0%
Simplified73.0%
Applied egg-rr66.7%
associate-*r/66.7%
sub-div66.6%
div-inv66.6%
metadata-eval66.6%
Applied egg-rr66.6%
clear-num66.6%
inv-pow66.6%
*-un-lft-identity66.6%
distribute-rgt-out--66.6%
times-frac66.5%
metadata-eval66.5%
Applied egg-rr66.5%
unpow-166.5%
associate-*r/66.7%
*-commutative66.7%
Simplified66.7%
Taylor expanded in b around -inf 69.3%
metadata-eval69.3%
times-frac69.4%
*-commutative69.4%
times-frac69.4%
/-rgt-identity69.4%
Simplified69.4%
if -4.999999999999985e-310 < b Initial program 28.5%
neg-sub028.5%
sqr-neg28.5%
associate-+l-28.5%
sub0-neg28.5%
sub-neg28.5%
distribute-neg-in28.5%
remove-double-neg28.5%
sqr-neg28.5%
associate-*l*28.5%
Simplified28.5%
Taylor expanded in b around inf 71.4%
*-commutative71.4%
Simplified71.4%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* a -1.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
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 / (a * (-1.5d0))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (a * -1.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b / (a * -1.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 73.0%
neg-sub073.0%
sqr-neg73.0%
associate-+l-73.0%
sub0-neg73.0%
sub-neg73.0%
distribute-neg-in73.0%
remove-double-neg73.0%
sqr-neg73.0%
associate-*l*73.0%
Simplified73.0%
Applied egg-rr66.6%
Taylor expanded in b around -inf 69.3%
*-commutative69.3%
associate-*l/69.3%
associate-/l*69.3%
Simplified69.3%
clear-num69.3%
un-div-inv69.4%
div-inv69.4%
metadata-eval69.4%
Applied egg-rr69.4%
if -4.999999999999985e-310 < b Initial program 28.5%
neg-sub028.5%
sqr-neg28.5%
associate-+l-28.5%
sub0-neg28.5%
sub-neg28.5%
distribute-neg-in28.5%
remove-double-neg28.5%
sqr-neg28.5%
associate-*l*28.5%
Simplified28.5%
Taylor expanded in b around inf 71.4%
*-commutative71.4%
Simplified71.4%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
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 = (c / b) * (-0.5d0)
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 = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(Float64(c / b) * -0.5); 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 = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 73.0%
neg-sub073.0%
sqr-neg73.0%
associate-+l-73.0%
sub0-neg73.0%
sub-neg73.0%
distribute-neg-in73.0%
remove-double-neg73.0%
sqr-neg73.0%
associate-*l*73.0%
Simplified73.0%
Applied egg-rr66.6%
Taylor expanded in b around -inf 69.3%
*-commutative69.3%
associate-*l/69.3%
associate-/l*69.3%
Simplified69.3%
if -4.999999999999985e-310 < b Initial program 28.5%
neg-sub028.5%
sqr-neg28.5%
associate-+l-28.5%
sub0-neg28.5%
sub-neg28.5%
distribute-neg-in28.5%
remove-double-neg28.5%
sqr-neg28.5%
associate-*l*28.5%
Simplified28.5%
Taylor expanded in b around inf 71.4%
*-commutative71.4%
Simplified71.4%
(FPCore (a b c) :precision binary64 (if (<= b 0.000125) (* b (/ -0.6666666666666666 a)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.000125) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
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.000125d0) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = (c / b) * 0.5d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 0.000125) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 0.000125: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 0.000125) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(Float64(c / b) * 0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 0.000125) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 0.000125], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.000125:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 1.25e-4Initial program 67.8%
neg-sub067.8%
sqr-neg67.8%
associate-+l-67.8%
sub0-neg67.8%
sub-neg67.8%
distribute-neg-in67.8%
remove-double-neg67.8%
sqr-neg67.8%
associate-*l*67.8%
Simplified67.8%
Applied egg-rr63.1%
Taylor expanded in b around -inf 51.0%
*-commutative51.0%
associate-*l/51.0%
associate-/l*51.0%
Simplified51.0%
if 1.25e-4 < b Initial program 12.5%
neg-sub012.5%
sqr-neg12.5%
associate-+l-12.5%
sub0-neg12.5%
sub-neg12.5%
distribute-neg-in12.5%
remove-double-neg12.5%
sqr-neg12.5%
associate-*l*12.5%
Simplified12.5%
Taylor expanded in b around -inf 2.6%
Taylor expanded in b around 0 34.6%
Final simplification46.0%
(FPCore (a b c) :precision binary64 (* (/ c b) 0.5))
double code(double a, double b, double c) {
return (c / b) * 0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * 0.5d0
end function
public static double code(double a, double b, double c) {
return (c / b) * 0.5;
}
def code(a, b, c): return (c / b) * 0.5
function code(a, b, c) return Float64(Float64(c / b) * 0.5) end
function tmp = code(a, b, c) tmp = (c / b) * 0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot 0.5
\end{array}
Initial program 50.7%
neg-sub050.7%
sqr-neg50.7%
associate-+l-50.7%
sub0-neg50.7%
sub-neg50.7%
distribute-neg-in50.7%
remove-double-neg50.7%
sqr-neg50.7%
associate-*l*50.7%
Simplified50.7%
Taylor expanded in b around -inf 35.4%
Taylor expanded in b around 0 12.9%
Final simplification12.9%
herbie shell --seed 2024113
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))