
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \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) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e+121)
(- (/ c b) (/ b a))
(if (<= b 5.1e-92)
(/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e+121) {
tmp = (c / b) - (b / a);
} else if (b <= 5.1e-92) {
tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -7.5e+121) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.1e-92) tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -7.5e+121], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.1e-92], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{+121}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.1 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -7.49999999999999965e121Initial program 44.6%
*-commutative44.6%
Simplified44.6%
Taylor expanded in b around -inf 93.6%
+-commutative93.6%
mul-1-neg93.6%
unsub-neg93.6%
Simplified93.6%
if -7.49999999999999965e121 < b < 5.09999999999999972e-92Initial program 85.2%
sqr-neg85.2%
+-commutative85.2%
unsub-neg85.2%
sqr-neg85.2%
fma-neg85.2%
distribute-lft-neg-in85.2%
*-commutative85.2%
*-commutative85.2%
distribute-rgt-neg-in85.2%
metadata-eval85.2%
*-commutative85.2%
Simplified85.2%
if 5.09999999999999972e-92 < b Initial program 13.8%
*-commutative13.8%
Simplified13.8%
Taylor expanded in b around inf 85.4%
mul-1-neg85.4%
distribute-neg-frac85.4%
Simplified85.4%
Final simplification86.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e+120)
(- (/ c b) (/ b a))
(if (<= b 5.2e-92)
(/ (- (sqrt (fma a (* c -4.0) (* b b))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e+120) {
tmp = (c / b) - (b / a);
} else if (b <= 5.2e-92) {
tmp = (sqrt(fma(a, (c * -4.0), (b * b))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.6e+120) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.2e-92) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.6e+120], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.2e-92], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+120}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.59999999999999991e120Initial program 44.6%
*-commutative44.6%
Simplified44.6%
Taylor expanded in b around -inf 93.6%
+-commutative93.6%
mul-1-neg93.6%
unsub-neg93.6%
Simplified93.6%
if -1.59999999999999991e120 < b < 5.2e-92Initial program 85.2%
Simplified85.2%
if 5.2e-92 < b Initial program 13.8%
*-commutative13.8%
Simplified13.8%
Taylor expanded in b around inf 85.4%
mul-1-neg85.4%
distribute-neg-frac85.4%
Simplified85.4%
Final simplification86.8%
(FPCore (a b c)
:precision binary64
(if (<= b -7.8e+120)
(- (/ c b) (/ b a))
(if (<= b 5.8e-93)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.8e+120) {
tmp = (c / b) - (b / a);
} else if (b <= 5.8e-93) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = -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 <= (-7.8d+120)) then
tmp = (c / b) - (b / a)
else if (b <= 5.8d-93) then
tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7.8e+120) {
tmp = (c / b) - (b / a);
} else if (b <= 5.8e-93) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.8e+120: tmp = (c / b) - (b / a) elif b <= 5.8e-93: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.8e+120) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.8e-93) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.8e+120) tmp = (c / b) - (b / a); elseif (b <= 5.8e-93) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.8e+120], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.8e-93], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.8 \cdot 10^{+120}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-93}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -7.7999999999999997e120Initial program 44.6%
*-commutative44.6%
Simplified44.6%
Taylor expanded in b around -inf 93.6%
+-commutative93.6%
mul-1-neg93.6%
unsub-neg93.6%
Simplified93.6%
if -7.7999999999999997e120 < b < 5.7999999999999997e-93Initial program 85.2%
if 5.7999999999999997e-93 < b Initial program 13.8%
*-commutative13.8%
Simplified13.8%
Taylor expanded in b around inf 85.4%
mul-1-neg85.4%
distribute-neg-frac85.4%
Simplified85.4%
Final simplification86.8%
(FPCore (a b c)
:precision binary64
(if (<= b -7.6e-61)
(- (/ c b) (/ b a))
(if (<= b 1.7e-92)
(* (- b (sqrt (* c (* a -4.0)))) (/ -0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.6e-61) {
tmp = (c / b) - (b / a);
} else if (b <= 1.7e-92) {
tmp = (b - sqrt((c * (a * -4.0)))) * (-0.5 / a);
} else {
tmp = -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 <= (-7.6d-61)) then
tmp = (c / b) - (b / a)
else if (b <= 1.7d-92) then
tmp = (b - sqrt((c * (a * (-4.0d0))))) * ((-0.5d0) / a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7.6e-61) {
tmp = (c / b) - (b / a);
} else if (b <= 1.7e-92) {
tmp = (b - Math.sqrt((c * (a * -4.0)))) * (-0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.6e-61: tmp = (c / b) - (b / a) elif b <= 1.7e-92: tmp = (b - math.sqrt((c * (a * -4.0)))) * (-0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.6e-61) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.7e-92) tmp = Float64(Float64(b - sqrt(Float64(c * Float64(a * -4.0)))) * Float64(-0.5 / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.6e-61) tmp = (c / b) - (b / a); elseif (b <= 1.7e-92) tmp = (b - sqrt((c * (a * -4.0)))) * (-0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.6e-61], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.7e-92], N[(N[(b - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{-61}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.7 \cdot 10^{-92}:\\
\;\;\;\;\left(b - \sqrt{c \cdot \left(a \cdot -4\right)}\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -7.59999999999999961e-61Initial program 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in b around -inf 88.3%
+-commutative88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
if -7.59999999999999961e-61 < b < 1.7000000000000001e-92Initial program 80.1%
*-commutative80.1%
Simplified80.1%
Taylor expanded in b around 0 75.2%
*-commutative75.2%
associate-*r*75.2%
Simplified75.2%
*-commutative75.2%
sqrt-prod40.2%
Applied egg-rr40.2%
frac-2neg40.2%
div-inv40.2%
distribute-neg-in40.2%
add-sqr-sqrt23.5%
sqrt-unprod40.2%
sqr-neg40.2%
sqrt-unprod16.9%
add-sqr-sqrt39.4%
sub-neg39.4%
add-sqr-sqrt22.5%
sqrt-unprod39.5%
sqr-neg39.5%
sqrt-unprod16.7%
add-sqr-sqrt40.2%
*-commutative40.2%
sqrt-prod75.2%
distribute-rgt-neg-in75.2%
metadata-eval75.2%
Applied egg-rr75.2%
associate-*r*75.2%
*-commutative75.2%
rem-square-sqrt0.0%
unpow20.0%
associate-*l*0.0%
unpow20.0%
rem-square-sqrt75.2%
*-commutative75.2%
associate-/r*75.2%
metadata-eval75.2%
Simplified75.2%
if 1.7000000000000001e-92 < b Initial program 13.8%
*-commutative13.8%
Simplified13.8%
Taylor expanded in b around inf 85.4%
mul-1-neg85.4%
distribute-neg-frac85.4%
Simplified85.4%
Final simplification83.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.55e-63)
(- (/ c b) (/ b a))
(if (<= b 1.36e-93)
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.55e-63) {
tmp = (c / b) - (b / a);
} else if (b <= 1.36e-93) {
tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = -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.55d-63)) then
tmp = (c / b) - (b / a)
else if (b <= 1.36d-93) then
tmp = (sqrt((c * (a * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.55e-63) {
tmp = (c / b) - (b / a);
} else if (b <= 1.36e-93) {
tmp = (Math.sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.55e-63: tmp = (c / b) - (b / a) elif b <= 1.36e-93: tmp = (math.sqrt((c * (a * -4.0))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.55e-63) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.36e-93) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.55e-63) tmp = (c / b) - (b / a); elseif (b <= 1.36e-93) tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.55e-63], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.36e-93], N[(N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.55 \cdot 10^{-63}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.36 \cdot 10^{-93}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.54999999999999992e-63Initial program 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in b around -inf 88.3%
+-commutative88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
if -1.54999999999999992e-63 < b < 1.3599999999999999e-93Initial program 80.1%
*-commutative80.1%
Simplified80.1%
Taylor expanded in b around 0 75.2%
*-commutative75.2%
associate-*r*75.2%
Simplified75.2%
+-commutative75.2%
unsub-neg75.2%
Applied egg-rr75.2%
*-commutative75.2%
rem-square-sqrt0.0%
unpow20.0%
associate-*l*0.0%
unpow20.0%
rem-square-sqrt75.2%
Simplified75.2%
if 1.3599999999999999e-93 < b Initial program 13.8%
*-commutative13.8%
Simplified13.8%
Taylor expanded in b around inf 85.4%
mul-1-neg85.4%
distribute-neg-frac85.4%
Simplified85.4%
Final simplification83.6%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -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 <= (-4d-310)) then
tmp = (c / b) - (b / a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 72.7%
*-commutative72.7%
Simplified72.7%
Taylor expanded in b around -inf 70.1%
+-commutative70.1%
mul-1-neg70.1%
unsub-neg70.1%
Simplified70.1%
if -3.999999999999988e-310 < b Initial program 30.8%
*-commutative30.8%
Simplified30.8%
Taylor expanded in b around inf 65.6%
mul-1-neg65.6%
distribute-neg-frac65.6%
Simplified65.6%
Final simplification67.8%
(FPCore (a b c) :precision binary64 (if (<= b 6.5e+62) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.5e+62) {
tmp = -b / a;
} else {
tmp = 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.5d+62) then
tmp = -b / a
else
tmp = c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 6.5e+62) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.5e+62: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.5e+62) tmp = Float64(Float64(-b) / a); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.5e+62) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.5e+62], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5 \cdot 10^{+62}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 6.5000000000000003e62Initial program 67.3%
*-commutative67.3%
Simplified67.3%
Taylor expanded in b around -inf 47.9%
associate-*r/47.9%
mul-1-neg47.9%
Simplified47.9%
if 6.5000000000000003e62 < b Initial program 10.4%
*-commutative10.4%
Simplified10.4%
Applied egg-rr27.6%
unpow-127.6%
Simplified27.6%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt91.7%
metadata-eval91.7%
Simplified91.7%
expm1-log1p-u88.1%
expm1-udef40.8%
add-sqr-sqrt17.3%
sqrt-unprod40.9%
mul-1-neg40.9%
mul-1-neg40.9%
sqr-neg40.9%
sqrt-unprod23.6%
add-sqr-sqrt35.7%
clear-num35.7%
Applied egg-rr35.7%
expm1-def34.8%
expm1-log1p34.9%
Simplified34.9%
Final simplification44.3%
(FPCore (a b c) :precision binary64 (if (<= b 6.8e-306) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.8e-306) {
tmp = -b / a;
} else {
tmp = -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.8d-306) then
tmp = -b / a
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 6.8e-306) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.8e-306: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.8e-306) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.8e-306) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.8e-306], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.8 \cdot 10^{-306}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 6.7999999999999996e-306Initial program 72.9%
*-commutative72.9%
Simplified72.9%
Taylor expanded in b around -inf 68.5%
associate-*r/68.5%
mul-1-neg68.5%
Simplified68.5%
if 6.7999999999999996e-306 < b Initial program 30.3%
*-commutative30.3%
Simplified30.3%
Taylor expanded in b around inf 66.1%
mul-1-neg66.1%
distribute-neg-frac66.1%
Simplified66.1%
Final simplification67.3%
(FPCore (a b c) :precision binary64 (/ b a))
double code(double a, double b, double c) {
return b / 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 / a
end function
public static double code(double a, double b, double c) {
return b / a;
}
def code(a, b, c): return b / a
function code(a, b, c) return Float64(b / a) end
function tmp = code(a, b, c) tmp = b / a; end
code[a_, b_, c_] := N[(b / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a}
\end{array}
Initial program 51.3%
*-commutative51.3%
Simplified51.3%
+-commutative51.3%
add-sqr-sqrt49.7%
fma-def49.4%
Applied egg-rr53.7%
div-sub49.3%
sub-neg49.3%
div-inv48.0%
*-commutative48.0%
associate-/r*48.0%
metadata-eval48.0%
div-inv49.2%
*-commutative49.2%
associate-/r*49.2%
metadata-eval49.2%
Applied egg-rr49.2%
sub-neg49.2%
distribute-rgt-out--53.6%
Simplified53.6%
Taylor expanded in b around -inf 35.1%
*-commutative35.1%
Simplified35.1%
expm1-log1p-u20.3%
expm1-udef15.8%
associate-*l/15.8%
*-commutative15.8%
associate-*r*15.8%
metadata-eval15.8%
neg-mul-115.8%
add-sqr-sqrt14.2%
sqrt-unprod11.7%
sqr-neg11.7%
sqrt-unprod1.5%
add-sqr-sqrt2.2%
Applied egg-rr2.2%
expm1-def1.9%
expm1-log1p2.4%
Simplified2.4%
Final simplification2.4%
(FPCore (a b c) :precision binary64 (/ c b))
double code(double a, double b, double c) {
return 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 = c / b
end function
public static double code(double a, double b, double c) {
return c / b;
}
def code(a, b, c): return c / b
function code(a, b, c) return Float64(c / b) end
function tmp = code(a, b, c) tmp = c / b; end
code[a_, b_, c_] := N[(c / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b}
\end{array}
Initial program 51.3%
*-commutative51.3%
Simplified51.3%
Applied egg-rr53.5%
unpow-153.5%
Simplified53.5%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt34.4%
metadata-eval34.4%
Simplified34.4%
expm1-log1p-u32.1%
expm1-udef14.0%
add-sqr-sqrt6.9%
sqrt-unprod14.6%
mul-1-neg14.6%
mul-1-neg14.6%
sqr-neg14.6%
sqrt-unprod7.9%
add-sqr-sqrt11.8%
clear-num11.8%
Applied egg-rr11.8%
expm1-def11.5%
expm1-log1p12.1%
Simplified12.1%
Final simplification12.1%
herbie shell --seed 2024011
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))