
(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 9 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 -6.2e+108)
(- (/ c b) (/ b a))
(if (<= b 1.4e-48)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.2e+108) {
tmp = (c / b) - (b / a);
} else if (b <= 1.4e-48) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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+108)) then
tmp = (c / b) - (b / a)
else if (b <= 1.4d-48) then
tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.2e+108) {
tmp = (c / b) - (b / a);
} else if (b <= 1.4e-48) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.2e+108: tmp = (c / b) - (b / a) elif b <= 1.4e-48: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.2e+108) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.4e-48) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.2e+108) tmp = (c / b) - (b / a); elseif (b <= 1.4e-48) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.2e+108], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e-48], 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[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.2 \cdot 10^{+108}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-48}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -6.2000000000000003e108Initial program 37.8%
*-commutative37.8%
Simplified37.8%
Taylor expanded in b around -inf 93.4%
+-commutative93.4%
mul-1-neg93.4%
unsub-neg93.4%
Simplified93.4%
if -6.2000000000000003e108 < b < 1.40000000000000002e-48Initial program 81.2%
if 1.40000000000000002e-48 < b Initial program 14.9%
*-commutative14.9%
Simplified14.9%
frac-2neg14.9%
div-inv14.9%
Applied egg-rr14.9%
un-div-inv14.9%
clear-num14.9%
fma-udef14.9%
add-sqr-sqrt12.1%
hypot-def23.1%
Applied egg-rr23.1%
*-un-lft-identity23.1%
times-frac23.1%
Applied egg-rr23.1%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt87.9%
metadata-eval87.9%
Simplified87.9%
Final simplification85.9%
(FPCore (a b c)
:precision binary64
(if (<= b -5.5e-80)
(- (/ c b) (/ b a))
(if (<= b 9e-47)
(* (/ 0.5 a) (+ b (sqrt (* c (* a -4.0)))))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-80) {
tmp = (c / b) - (b / a);
} else if (b <= 9e-47) {
tmp = (0.5 / a) * (b + sqrt((c * (a * -4.0))));
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.5d-80)) then
tmp = (c / b) - (b / a)
else if (b <= 9d-47) then
tmp = (0.5d0 / a) * (b + sqrt((c * (a * (-4.0d0)))))
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-80) {
tmp = (c / b) - (b / a);
} else if (b <= 9e-47) {
tmp = (0.5 / a) * (b + Math.sqrt((c * (a * -4.0))));
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e-80: tmp = (c / b) - (b / a) elif b <= 9e-47: tmp = (0.5 / a) * (b + math.sqrt((c * (a * -4.0)))) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e-80) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 9e-47) tmp = Float64(Float64(0.5 / a) * Float64(b + sqrt(Float64(c * Float64(a * -4.0))))); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e-80) tmp = (c / b) - (b / a); elseif (b <= 9e-47) tmp = (0.5 / a) * (b + sqrt((c * (a * -4.0)))); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e-80], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9e-47], N[(N[(0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-80}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-47}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(b + \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -5.4999999999999997e-80Initial program 59.7%
*-commutative59.7%
Simplified59.7%
Taylor expanded in b around -inf 84.5%
+-commutative84.5%
mul-1-neg84.5%
unsub-neg84.5%
Simplified84.5%
if -5.4999999999999997e-80 < b < 9e-47Initial program 77.3%
*-commutative77.3%
Simplified77.3%
clear-num77.2%
associate-/r/77.2%
*-commutative77.2%
associate-/r*77.2%
metadata-eval77.2%
add-sqr-sqrt44.7%
sqrt-unprod76.2%
sqr-neg76.2%
sqrt-prod31.6%
add-sqr-sqrt67.9%
fma-neg67.9%
*-commutative67.9%
distribute-rgt-neg-in67.9%
*-commutative67.9%
distribute-rgt-neg-in67.9%
metadata-eval67.9%
Applied egg-rr67.9%
Taylor expanded in b around 0 67.6%
associate-*r*67.6%
*-commutative67.6%
*-commutative67.6%
Simplified67.6%
if 9e-47 < b Initial program 14.9%
*-commutative14.9%
Simplified14.9%
frac-2neg14.9%
div-inv14.9%
Applied egg-rr14.9%
un-div-inv14.9%
clear-num14.9%
fma-udef14.9%
add-sqr-sqrt12.1%
hypot-def23.1%
Applied egg-rr23.1%
*-un-lft-identity23.1%
times-frac23.1%
Applied egg-rr23.1%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt87.9%
metadata-eval87.9%
Simplified87.9%
Final simplification80.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.4e-29)
(- (/ c b) (/ b a))
(if (<= b 7.6e-48)
(/ (- (sqrt (* -4.0 (* c a))) b) (* a 2.0))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.4e-29) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-48) {
tmp = (sqrt((-4.0 * (c * a))) - b) / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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.4d-29)) then
tmp = (c / b) - (b / a)
else if (b <= 7.6d-48) then
tmp = (sqrt(((-4.0d0) * (c * a))) - b) / (a * 2.0d0)
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.4e-29) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-48) {
tmp = (Math.sqrt((-4.0 * (c * a))) - b) / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.4e-29: tmp = (c / b) - (b / a) elif b <= 7.6e-48: tmp = (math.sqrt((-4.0 * (c * a))) - b) / (a * 2.0) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.4e-29) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 7.6e-48) tmp = Float64(Float64(sqrt(Float64(-4.0 * Float64(c * a))) - b) / Float64(a * 2.0)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.4e-29) tmp = (c / b) - (b / a); elseif (b <= 7.6e-48) tmp = (sqrt((-4.0 * (c * a))) - b) / (a * 2.0); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.4e-29], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-48], N[(N[(N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4 \cdot 10^{-29}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-48}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -1.4000000000000001e-29Initial program 57.3%
*-commutative57.3%
Simplified57.3%
Taylor expanded in b around -inf 89.3%
+-commutative89.3%
mul-1-neg89.3%
unsub-neg89.3%
Simplified89.3%
if -1.4000000000000001e-29 < b < 7.60000000000000005e-48Initial program 77.7%
*-commutative77.7%
Simplified77.7%
add-sqr-sqrt77.4%
pow277.4%
pow1/277.4%
sqrt-pow177.5%
fma-neg77.5%
*-commutative77.5%
distribute-rgt-neg-in77.5%
*-commutative77.5%
distribute-rgt-neg-in77.5%
metadata-eval77.5%
metadata-eval77.5%
Applied egg-rr77.5%
Taylor expanded in c around inf 37.3%
Simplified66.9%
if 7.60000000000000005e-48 < b Initial program 14.9%
*-commutative14.9%
Simplified14.9%
frac-2neg14.9%
div-inv14.9%
Applied egg-rr14.9%
un-div-inv14.9%
clear-num14.9%
fma-udef14.9%
add-sqr-sqrt12.1%
hypot-def23.1%
Applied egg-rr23.1%
*-un-lft-identity23.1%
times-frac23.1%
Applied egg-rr23.1%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt87.9%
metadata-eval87.9%
Simplified87.9%
Final simplification81.2%
(FPCore (a b c) :precision binary64 (if (<= b -7.5e-305) (- (/ c b) (/ b a)) (/ 1.0 (- (/ a b) (/ b c)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-305) {
tmp = (c / b) - (b / a);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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.5d-305)) then
tmp = (c / b) - (b / a)
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-305) {
tmp = (c / b) - (b / a);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e-305: tmp = (c / b) - (b / a) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e-305) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.5e-305) tmp = (c / b) - (b / a); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e-305], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{-305}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -7.5000000000000003e-305Initial program 67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in b around -inf 66.6%
+-commutative66.6%
mul-1-neg66.6%
unsub-neg66.6%
Simplified66.6%
if -7.5000000000000003e-305 < b Initial program 32.1%
*-commutative32.1%
Simplified32.1%
frac-2neg32.1%
div-inv32.1%
Applied egg-rr32.1%
un-div-inv32.1%
clear-num32.0%
fma-udef32.0%
add-sqr-sqrt30.1%
hypot-def37.5%
Applied egg-rr37.5%
*-un-lft-identity37.5%
times-frac37.5%
Applied egg-rr37.5%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt65.6%
metadata-eval65.6%
Simplified65.6%
Final simplification66.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-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 <= (-5d-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 <= -5e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-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 <= -5e-310) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.8%
*-commutative67.8%
Simplified67.8%
Taylor expanded in b around -inf 66.2%
+-commutative66.2%
mul-1-neg66.2%
unsub-neg66.2%
Simplified66.2%
if -4.999999999999985e-310 < b Initial program 31.5%
*-commutative31.5%
Simplified31.5%
Taylor expanded in b around inf 65.5%
mul-1-neg65.5%
distribute-neg-frac65.5%
Simplified65.5%
Final simplification65.8%
(FPCore (a b c) :precision binary64 (if (<= b 1.85e+26) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.85e+26) {
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 <= 1.85d+26) 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 <= 1.85e+26) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.85e+26: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.85e+26) 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 <= 1.85e+26) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.85e+26], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.85 \cdot 10^{+26}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.84999999999999994e26Initial program 66.2%
*-commutative66.2%
Simplified66.2%
Taylor expanded in b around -inf 50.1%
associate-*r/50.1%
mul-1-neg50.1%
Simplified50.1%
if 1.84999999999999994e26 < b Initial program 12.6%
*-commutative12.6%
Simplified12.6%
Taylor expanded in b around -inf 2.4%
Taylor expanded in b around 0 28.2%
Final simplification43.8%
(FPCore (a b c) :precision binary64 (if (<= b 3.6e-270) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.6e-270) {
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 <= 3.6d-270) 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 <= 3.6e-270) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.6e-270: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.6e-270) 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 <= 3.6e-270) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.6e-270], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.6 \cdot 10^{-270}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 3.5999999999999998e-270Initial program 68.4%
*-commutative68.4%
Simplified68.4%
Taylor expanded in b around -inf 63.2%
associate-*r/63.2%
mul-1-neg63.2%
Simplified63.2%
if 3.5999999999999998e-270 < b Initial program 28.8%
*-commutative28.8%
Simplified28.8%
Taylor expanded in b around inf 68.8%
mul-1-neg68.8%
distribute-neg-frac68.8%
Simplified68.8%
Final simplification65.7%
(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 50.9%
*-commutative50.9%
Simplified50.9%
clear-num50.8%
associate-/r/50.8%
*-commutative50.8%
associate-/r*50.8%
metadata-eval50.8%
add-sqr-sqrt36.2%
sqrt-unprod48.1%
sqr-neg48.1%
sqrt-prod11.9%
add-sqr-sqrt31.8%
fma-neg31.8%
*-commutative31.8%
distribute-rgt-neg-in31.8%
*-commutative31.8%
distribute-rgt-neg-in31.8%
metadata-eval31.8%
Applied egg-rr31.8%
Taylor expanded in a around 0 2.6%
Final simplification2.6%
(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 50.9%
*-commutative50.9%
Simplified50.9%
Taylor expanded in b around -inf 33.9%
Taylor expanded in b around 0 10.4%
Final simplification10.4%
herbie shell --seed 2023309
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))