
(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 -4.5e-61)
(- (/ c b) (/ b a))
(if (<= b 1.7e-92)
(* (/ 0.5 a) (+ b (sqrt (* a (* c -4.0)))))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-61) {
tmp = (c / b) - (b / a);
} else if (b <= 1.7e-92) {
tmp = (0.5 / a) * (b + sqrt((a * (c * -4.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 <= (-4.5d-61)) then
tmp = (c / b) - (b / a)
else if (b <= 1.7d-92) then
tmp = (0.5d0 / a) * (b + sqrt((a * (c * (-4.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 <= -4.5e-61) {
tmp = (c / b) - (b / a);
} else if (b <= 1.7e-92) {
tmp = (0.5 / a) * (b + Math.sqrt((a * (c * -4.0))));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.5e-61: tmp = (c / b) - (b / a) elif b <= 1.7e-92: tmp = (0.5 / a) * (b + math.sqrt((a * (c * -4.0)))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.5e-61) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.7e-92) tmp = Float64(Float64(0.5 / a) * Float64(b + sqrt(Float64(a * Float64(c * -4.0))))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.5e-61) tmp = (c / b) - (b / a); elseif (b <= 1.7e-92) tmp = (0.5 / a) * (b + sqrt((a * (c * -4.0)))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.5e-61], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.7e-92], N[(N[(0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-61}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.7 \cdot 10^{-92}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(b + \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.5e-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 -4.5e-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%
clear-num75.1%
inv-pow75.1%
+-commutative75.1%
sqrt-prod40.2%
fma-def40.2%
add-sqr-sqrt23.4%
sqrt-unprod40.2%
sqr-neg40.2%
sqrt-prod17.0%
add-sqr-sqrt39.4%
Applied egg-rr39.4%
unpow-139.4%
Simplified39.4%
associate-/r/39.4%
fma-udef39.4%
sqrt-prod73.7%
distribute-lft-in73.7%
*-commutative73.7%
associate-/r*73.7%
metadata-eval73.7%
*-commutative73.7%
*-commutative73.7%
associate-/r*73.7%
metadata-eval73.7%
Applied egg-rr73.7%
distribute-lft-out73.7%
+-commutative73.7%
*-commutative73.7%
Simplified73.7%
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.2%
(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%
Simplified80.1%
add-sqr-sqrt79.6%
pow279.6%
pow1/279.6%
sqrt-pow179.7%
pow279.7%
metadata-eval79.7%
Applied egg-rr79.7%
Taylor expanded in a around inf 37.3%
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%
Simplified10.5%
clear-num10.5%
inv-pow10.5%
*-commutative10.5%
*-un-lft-identity10.5%
times-frac10.5%
metadata-eval10.5%
sub-neg10.5%
pow210.5%
add-sqr-sqrt0.0%
sqrt-unprod4.4%
sqr-neg4.4%
sqrt-prod4.4%
add-sqr-sqrt4.4%
Applied egg-rr4.4%
unpow-14.4%
associate-*r/4.4%
*-commutative4.4%
+-commutative4.4%
Simplified4.4%
Taylor expanded in b around -inf 34.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%
Simplified51.3%
clear-num51.2%
inv-pow51.2%
*-commutative51.2%
*-un-lft-identity51.2%
times-frac51.2%
metadata-eval51.2%
sub-neg51.2%
pow251.2%
add-sqr-sqrt35.3%
sqrt-unprod49.1%
sqr-neg49.1%
sqrt-prod14.0%
add-sqr-sqrt32.2%
Applied egg-rr32.2%
unpow-132.2%
associate-*r/32.2%
*-commutative32.2%
+-commutative32.2%
Simplified32.2%
Taylor expanded in a around 0 2.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%
Simplified51.3%
clear-num51.2%
inv-pow51.2%
*-commutative51.2%
*-un-lft-identity51.2%
times-frac51.2%
metadata-eval51.2%
sub-neg51.2%
pow251.2%
add-sqr-sqrt35.3%
sqrt-unprod49.1%
sqr-neg49.1%
sqrt-prod14.0%
add-sqr-sqrt32.2%
Applied egg-rr32.2%
unpow-132.2%
associate-*r/32.2%
*-commutative32.2%
+-commutative32.2%
Simplified32.2%
Taylor expanded in b around -inf 12.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)))