
(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 -2.2e+73)
(- (/ c b) (/ b a))
(if (<= b 2.75e-33)
(/ (- (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 <= -2.2e+73) {
tmp = (c / b) - (b / a);
} else if (b <= 2.75e-33) {
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 <= (-2.2d+73)) then
tmp = (c / b) - (b / a)
else if (b <= 2.75d-33) 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 <= -2.2e+73) {
tmp = (c / b) - (b / a);
} else if (b <= 2.75e-33) {
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 <= -2.2e+73: tmp = (c / b) - (b / a) elif b <= 2.75e-33: 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 <= -2.2e+73) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.75e-33) 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 <= -2.2e+73) tmp = (c / b) - (b / a); elseif (b <= 2.75e-33) 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, -2.2e+73], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.75e-33], 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 -2.2 \cdot 10^{+73}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.75 \cdot 10^{-33}:\\
\;\;\;\;\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 < -2.2e73Initial program 53.4%
*-commutative53.4%
Simplified53.4%
Taylor expanded in b around -inf 94.0%
+-commutative94.0%
mul-1-neg94.0%
unsub-neg94.0%
Simplified94.0%
if -2.2e73 < b < 2.75e-33Initial program 81.2%
if 2.75e-33 < b Initial program 8.2%
*-commutative8.2%
Simplified8.2%
Taylor expanded in b around inf 91.2%
mul-1-neg91.2%
distribute-neg-frac91.2%
Simplified91.2%
Final simplification87.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.42e-119)
(- (/ c b) (/ b a))
(if (<= b 1.22e-33)
(* (/ 0.5 a) (+ b (sqrt (* -4.0 (* c a)))))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.42e-119) {
tmp = (c / b) - (b / a);
} else if (b <= 1.22e-33) {
tmp = (0.5 / a) * (b + sqrt((-4.0 * (c * 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.42d-119)) then
tmp = (c / b) - (b / a)
else if (b <= 1.22d-33) then
tmp = (0.5d0 / a) * (b + sqrt(((-4.0d0) * (c * 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.42e-119) {
tmp = (c / b) - (b / a);
} else if (b <= 1.22e-33) {
tmp = (0.5 / a) * (b + Math.sqrt((-4.0 * (c * a))));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.42e-119: tmp = (c / b) - (b / a) elif b <= 1.22e-33: tmp = (0.5 / a) * (b + math.sqrt((-4.0 * (c * a)))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.42e-119) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.22e-33) tmp = Float64(Float64(0.5 / a) * Float64(b + sqrt(Float64(-4.0 * Float64(c * a))))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.42e-119) tmp = (c / b) - (b / a); elseif (b <= 1.22e-33) tmp = (0.5 / a) * (b + sqrt((-4.0 * (c * a)))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.42e-119], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.22e-33], N[(N[(0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.42 \cdot 10^{-119}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.22 \cdot 10^{-33}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(b + \sqrt{-4 \cdot \left(c \cdot a\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.42000000000000002e-119Initial program 70.3%
*-commutative70.3%
Simplified70.3%
Taylor expanded in b around -inf 84.2%
+-commutative84.2%
mul-1-neg84.2%
unsub-neg84.2%
Simplified84.2%
if -1.42000000000000002e-119 < b < 1.22e-33Initial program 72.3%
*-commutative72.3%
Simplified72.3%
Applied egg-rr70.3%
Taylor expanded in a around inf 71.5%
if 1.22e-33 < b Initial program 8.2%
*-commutative8.2%
Simplified8.2%
Taylor expanded in b around inf 91.2%
mul-1-neg91.2%
distribute-neg-frac91.2%
Simplified91.2%
Final simplification83.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2e-119)
(- (/ c b) (/ b a))
(if (<= b 1.75e-33)
(/ (+ b (sqrt (* c (* a -4.0)))) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-119) {
tmp = (c / b) - (b / a);
} else if (b <= 1.75e-33) {
tmp = (b + sqrt((c * (a * -4.0)))) / (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 <= (-2d-119)) then
tmp = (c / b) - (b / a)
else if (b <= 1.75d-33) then
tmp = (b + sqrt((c * (a * (-4.0d0))))) / (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 <= -2e-119) {
tmp = (c / b) - (b / a);
} else if (b <= 1.75e-33) {
tmp = (b + Math.sqrt((c * (a * -4.0)))) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-119: tmp = (c / b) - (b / a) elif b <= 1.75e-33: tmp = (b + math.sqrt((c * (a * -4.0)))) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-119) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.75e-33) tmp = Float64(Float64(b + sqrt(Float64(c * Float64(a * -4.0)))) / 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 <= -2e-119) tmp = (c / b) - (b / a); elseif (b <= 1.75e-33) tmp = (b + sqrt((c * (a * -4.0)))) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-119], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.75e-33], N[(N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-119}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.75 \cdot 10^{-33}:\\
\;\;\;\;\frac{b + \sqrt{c \cdot \left(a \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.00000000000000003e-119Initial program 70.3%
*-commutative70.3%
Simplified70.3%
Taylor expanded in b around -inf 84.2%
+-commutative84.2%
mul-1-neg84.2%
unsub-neg84.2%
Simplified84.2%
if -2.00000000000000003e-119 < b < 1.7499999999999999e-33Initial program 72.3%
*-commutative72.3%
Simplified72.3%
Taylor expanded in b around 0 72.1%
expm1-log1p-u69.3%
expm1-udef43.4%
add-sqr-sqrt14.5%
sqrt-unprod43.4%
sqr-neg43.4%
sqrt-prod28.9%
add-sqr-sqrt43.4%
Applied egg-rr43.4%
expm1-def68.9%
expm1-log1p71.7%
*-commutative71.7%
*-commutative71.7%
associate-*l*71.7%
Simplified71.7%
if 1.7499999999999999e-33 < b Initial program 8.2%
*-commutative8.2%
Simplified8.2%
Taylor expanded in b around inf 91.2%
mul-1-neg91.2%
distribute-neg-frac91.2%
Simplified91.2%
Final simplification83.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2.4e-100)
(- (/ c b) (/ b a))
(if (<= b 8.8e-34)
(/ (- (sqrt (* -4.0 (* c a))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.4e-100) {
tmp = (c / b) - (b / a);
} else if (b <= 8.8e-34) {
tmp = (sqrt((-4.0 * (c * a))) - 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 <= (-2.4d-100)) then
tmp = (c / b) - (b / a)
else if (b <= 8.8d-34) then
tmp = (sqrt(((-4.0d0) * (c * a))) - 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 <= -2.4e-100) {
tmp = (c / b) - (b / a);
} else if (b <= 8.8e-34) {
tmp = (Math.sqrt((-4.0 * (c * a))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.4e-100: tmp = (c / b) - (b / a) elif b <= 8.8e-34: tmp = (math.sqrt((-4.0 * (c * a))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.4e-100) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 8.8e-34) tmp = Float64(Float64(sqrt(Float64(-4.0 * Float64(c * a))) - 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 <= -2.4e-100) tmp = (c / b) - (b / a); elseif (b <= 8.8e-34) tmp = (sqrt((-4.0 * (c * a))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.4e-100], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.8e-34], N[(N[(N[Sqrt[N[(-4.0 * N[(c * a), $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 -2.4 \cdot 10^{-100}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 8.8 \cdot 10^{-34}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.4000000000000003e-100Initial program 70.3%
*-commutative70.3%
Simplified70.3%
Taylor expanded in b around -inf 85.5%
+-commutative85.5%
mul-1-neg85.5%
unsub-neg85.5%
Simplified85.5%
if -2.4000000000000003e-100 < b < 8.7999999999999995e-34Initial program 72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in b around 0 70.8%
if 8.7999999999999995e-34 < b Initial program 8.2%
*-commutative8.2%
Simplified8.2%
Taylor expanded in b around inf 91.2%
mul-1-neg91.2%
distribute-neg-frac91.2%
Simplified91.2%
Final simplification83.2%
(FPCore (a b c) :precision binary64 (if (<= b -2.55e-121) (- (/ c b) (/ b a)) (if (<= b 4.4e-33) (* 0.5 (/ (sqrt (* a (* c -4.0))) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.55e-121) {
tmp = (c / b) - (b / a);
} else if (b <= 4.4e-33) {
tmp = 0.5 * (sqrt((a * (c * -4.0))) / 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 <= (-2.55d-121)) then
tmp = (c / b) - (b / a)
else if (b <= 4.4d-33) then
tmp = 0.5d0 * (sqrt((a * (c * (-4.0d0)))) / 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 <= -2.55e-121) {
tmp = (c / b) - (b / a);
} else if (b <= 4.4e-33) {
tmp = 0.5 * (Math.sqrt((a * (c * -4.0))) / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.55e-121: tmp = (c / b) - (b / a) elif b <= 4.4e-33: tmp = 0.5 * (math.sqrt((a * (c * -4.0))) / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.55e-121) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 4.4e-33) tmp = Float64(0.5 * Float64(sqrt(Float64(a * Float64(c * -4.0))) / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.55e-121) tmp = (c / b) - (b / a); elseif (b <= 4.4e-33) tmp = 0.5 * (sqrt((a * (c * -4.0))) / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.55e-121], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.4e-33], N[(0.5 * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.55 \cdot 10^{-121}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{-33}:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.5499999999999999e-121Initial program 70.3%
*-commutative70.3%
Simplified70.3%
Taylor expanded in b around -inf 84.2%
+-commutative84.2%
mul-1-neg84.2%
unsub-neg84.2%
Simplified84.2%
if -2.5499999999999999e-121 < b < 4.40000000000000011e-33Initial program 72.3%
*-commutative72.3%
Simplified72.3%
prod-diff71.9%
*-commutative71.9%
fma-def71.9%
associate-+l+71.9%
pow271.9%
distribute-lft-neg-in71.9%
*-commutative71.9%
distribute-rgt-neg-in71.9%
metadata-eval71.9%
associate-*r*70.6%
*-commutative70.6%
*-commutative70.6%
fma-udef70.6%
Applied egg-rr70.5%
fma-def70.5%
fma-def70.5%
associate-*l*70.6%
Simplified70.6%
Taylor expanded in b around 0 71.1%
associate-*l/71.3%
*-lft-identity71.3%
distribute-rgt-out71.7%
metadata-eval71.7%
associate-*r*70.3%
*-commutative70.3%
Simplified70.3%
if 4.40000000000000011e-33 < b Initial program 8.2%
*-commutative8.2%
Simplified8.2%
Taylor expanded in b around inf 91.2%
mul-1-neg91.2%
distribute-neg-frac91.2%
Simplified91.2%
Final simplification82.6%
(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 69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in b around -inf 68.7%
+-commutative68.7%
mul-1-neg68.7%
unsub-neg68.7%
Simplified68.7%
if -4.999999999999985e-310 < b Initial program 30.7%
*-commutative30.7%
Simplified30.7%
Taylor expanded in b around inf 66.2%
mul-1-neg66.2%
distribute-neg-frac66.2%
Simplified66.2%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e-267) (/ (- b) a) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-267) {
tmp = -b / a;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 2.7d-267) then
tmp = -b / a
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-267) {
tmp = -b / a;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e-267: tmp = -b / a else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e-267) tmp = Float64(Float64(-b) / a); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.7e-267) tmp = -b / a; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e-267], N[((-b) / a), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-267}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < 2.69999999999999987e-267Initial program 69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in b around -inf 66.9%
associate-*r/66.9%
mul-1-neg66.9%
Simplified66.9%
if 2.69999999999999987e-267 < b Initial program 29.7%
*-commutative29.7%
Simplified29.7%
Applied egg-rr28.2%
fma-def27.7%
distribute-neg-frac27.7%
Simplified27.7%
Taylor expanded in a around 0 20.9%
distribute-rgt-out20.9%
metadata-eval20.9%
associate-*l/13.5%
mul0-rgt20.9%
Simplified20.9%
Final simplification45.9%
(FPCore (a b c) :precision binary64 (if (<= b 1.5e-287) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.5e-287) {
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.5d-287) 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.5e-287) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.5e-287: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.5e-287) 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 <= 1.5e-287) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.5e-287], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.5 \cdot 10^{-287}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 1.49999999999999996e-287Initial program 69.9%
*-commutative69.9%
Simplified69.9%
Taylor expanded in b around -inf 67.9%
associate-*r/67.9%
mul-1-neg67.9%
Simplified67.9%
if 1.49999999999999996e-287 < b Initial program 30.1%
*-commutative30.1%
Simplified30.1%
Taylor expanded in b around inf 66.8%
mul-1-neg66.8%
distribute-neg-frac66.8%
Simplified66.8%
Final simplification67.4%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 51.4%
*-commutative51.4%
Simplified51.4%
Applied egg-rr50.7%
fma-def50.5%
distribute-neg-frac50.5%
Simplified50.5%
Taylor expanded in a around 0 11.0%
distribute-rgt-out11.0%
metadata-eval11.0%
associate-*l/7.5%
mul0-rgt11.0%
Simplified11.0%
Final simplification11.0%
herbie shell --seed 2024024
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))