
(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 8 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 -5e+110)
(- (/ c b) (/ b a))
(if (<= b 5e-119)
(/ (- (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 <= -5e+110) {
tmp = (c / b) - (b / a);
} else if (b <= 5e-119) {
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 <= (-5d+110)) then
tmp = (c / b) - (b / a)
else if (b <= 5d-119) 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 <= -5e+110) {
tmp = (c / b) - (b / a);
} else if (b <= 5e-119) {
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 <= -5e+110: tmp = (c / b) - (b / a) elif b <= 5e-119: 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 <= -5e+110) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5e-119) 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 <= -5e+110) tmp = (c / b) - (b / a); elseif (b <= 5e-119) 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, -5e+110], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e-119], 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 -5 \cdot 10^{+110}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{-119}:\\
\;\;\;\;\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 < -4.99999999999999978e110Initial program 44.8%
neg-sub044.8%
associate-+l-44.8%
sub0-neg44.8%
neg-mul-144.8%
associate-*l/44.7%
*-commutative44.7%
associate-/r*44.7%
/-rgt-identity44.7%
metadata-eval44.7%
Simplified44.8%
Taylor expanded in b around -inf 96.7%
mul-1-neg96.7%
unsub-neg96.7%
Simplified96.7%
if -4.99999999999999978e110 < b < 4.99999999999999993e-119Initial program 92.2%
if 4.99999999999999993e-119 < b Initial program 13.9%
neg-sub013.9%
associate-+l-13.9%
sub0-neg13.9%
neg-mul-113.9%
associate-*l/14.0%
*-commutative14.0%
associate-/r*14.0%
/-rgt-identity14.0%
metadata-eval14.0%
Simplified14.0%
Taylor expanded in b around inf 86.6%
mul-1-neg86.6%
distribute-neg-frac86.6%
Simplified86.6%
Final simplification91.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4.9e+48)
(- (/ c b) (/ b a))
(if (<= b 1.12e-120)
(* (- b (sqrt (- (* b b) (* a (* c 4.0))))) (/ -0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.9e+48) {
tmp = (c / b) - (b / a);
} else if (b <= 1.12e-120) {
tmp = (b - sqrt(((b * b) - (a * (c * 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 <= (-4.9d+48)) then
tmp = (c / b) - (b / a)
else if (b <= 1.12d-120) then
tmp = (b - sqrt(((b * b) - (a * (c * 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 <= -4.9e+48) {
tmp = (c / b) - (b / a);
} else if (b <= 1.12e-120) {
tmp = (b - Math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.9e+48: tmp = (c / b) - (b / a) elif b <= 1.12e-120: tmp = (b - math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.9e+48) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.12e-120) tmp = Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 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 <= -4.9e+48) tmp = (c / b) - (b / a); elseif (b <= 1.12e-120) tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.9e+48], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.12e-120], N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.9 \cdot 10^{+48}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.12 \cdot 10^{-120}:\\
\;\;\;\;\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.9000000000000003e48Initial program 59.1%
neg-sub059.1%
associate-+l-59.1%
sub0-neg59.1%
neg-mul-159.1%
associate-*l/59.0%
*-commutative59.0%
associate-/r*59.0%
/-rgt-identity59.0%
metadata-eval59.0%
Simplified57.8%
Taylor expanded in b around -inf 97.6%
mul-1-neg97.6%
unsub-neg97.6%
Simplified97.6%
if -4.9000000000000003e48 < b < 1.12e-120Initial program 90.5%
neg-sub090.5%
associate-+l-90.5%
sub0-neg90.5%
neg-mul-190.5%
associate-*l/90.2%
*-commutative90.2%
associate-/r*90.2%
/-rgt-identity90.2%
metadata-eval90.2%
Simplified90.2%
fma-udef90.2%
*-commutative90.2%
associate-*r*90.2%
metadata-eval90.2%
distribute-rgt-neg-in90.2%
*-commutative90.2%
distribute-lft-neg-in90.2%
+-commutative90.2%
sub-neg90.2%
*-commutative90.2%
associate-*l*90.2%
Applied egg-rr90.2%
*-commutative90.2%
Simplified90.2%
if 1.12e-120 < b Initial program 13.9%
neg-sub013.9%
associate-+l-13.9%
sub0-neg13.9%
neg-mul-113.9%
associate-*l/14.0%
*-commutative14.0%
associate-/r*14.0%
/-rgt-identity14.0%
metadata-eval14.0%
Simplified14.0%
Taylor expanded in b around inf 86.6%
mul-1-neg86.6%
distribute-neg-frac86.6%
Simplified86.6%
Final simplification91.1%
(FPCore (a b c)
:precision binary64
(if (<= b -5.3e-24)
(- (/ c b) (/ b a))
(if (<= b 4.9e-119)
(* -0.5 (/ (- b (sqrt (* c (/ a -0.25)))) a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.3e-24) {
tmp = (c / b) - (b / a);
} else if (b <= 4.9e-119) {
tmp = -0.5 * ((b - sqrt((c * (a / -0.25)))) / 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 <= (-5.3d-24)) then
tmp = (c / b) - (b / a)
else if (b <= 4.9d-119) then
tmp = (-0.5d0) * ((b - sqrt((c * (a / (-0.25d0))))) / 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 <= -5.3e-24) {
tmp = (c / b) - (b / a);
} else if (b <= 4.9e-119) {
tmp = -0.5 * ((b - Math.sqrt((c * (a / -0.25)))) / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.3e-24: tmp = (c / b) - (b / a) elif b <= 4.9e-119: tmp = -0.5 * ((b - math.sqrt((c * (a / -0.25)))) / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.3e-24) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 4.9e-119) tmp = Float64(-0.5 * Float64(Float64(b - sqrt(Float64(c * Float64(a / -0.25)))) / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.3e-24) tmp = (c / b) - (b / a); elseif (b <= 4.9e-119) tmp = -0.5 * ((b - sqrt((c * (a / -0.25)))) / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.3e-24], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.9e-119], N[(-0.5 * N[(N[(b - N[Sqrt[N[(c * N[(a / -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.3 \cdot 10^{-24}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 4.9 \cdot 10^{-119}:\\
\;\;\;\;-0.5 \cdot \frac{b - \sqrt{c \cdot \frac{a}{-0.25}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.29999999999999969e-24Initial program 65.8%
neg-sub065.8%
associate-+l-65.8%
sub0-neg65.8%
neg-mul-165.8%
associate-*l/65.6%
*-commutative65.6%
associate-/r*65.6%
/-rgt-identity65.6%
metadata-eval65.6%
Simplified64.6%
Taylor expanded in b around -inf 93.1%
mul-1-neg93.1%
unsub-neg93.1%
Simplified93.1%
if -5.29999999999999969e-24 < b < 4.9e-119Initial program 89.5%
neg-sub089.5%
associate-+l-89.5%
sub0-neg89.5%
neg-mul-189.5%
associate-*l/89.2%
*-commutative89.2%
associate-/r*89.2%
/-rgt-identity89.2%
metadata-eval89.2%
Simplified89.2%
pow1/289.2%
pow-to-exp83.6%
Applied egg-rr83.6%
Taylor expanded in c around -inf 39.8%
mul-1-neg39.8%
unsub-neg39.8%
*-commutative39.8%
Simplified39.8%
Taylor expanded in a around 0 39.8%
+-commutative39.8%
log-prod39.8%
unsub-neg39.8%
*-commutative39.8%
sub-neg39.8%
Simplified79.5%
if 4.9e-119 < b Initial program 13.9%
neg-sub013.9%
associate-+l-13.9%
sub0-neg13.9%
neg-mul-113.9%
associate-*l/14.0%
*-commutative14.0%
associate-/r*14.0%
/-rgt-identity14.0%
metadata-eval14.0%
Simplified14.0%
Taylor expanded in b around inf 86.6%
mul-1-neg86.6%
distribute-neg-frac86.6%
Simplified86.6%
Final simplification87.1%
(FPCore (a b c) :precision binary64 (if (<= b -1.15e-100) (- (/ c b) (/ b a)) (if (<= b 1.05e-120) (* 0.5 (/ (sqrt (* c (/ a -0.25))) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-100) {
tmp = (c / b) - (b / a);
} else if (b <= 1.05e-120) {
tmp = 0.5 * (sqrt((c * (a / -0.25))) / 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.15d-100)) then
tmp = (c / b) - (b / a)
else if (b <= 1.05d-120) then
tmp = 0.5d0 * (sqrt((c * (a / (-0.25d0)))) / 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.15e-100) {
tmp = (c / b) - (b / a);
} else if (b <= 1.05e-120) {
tmp = 0.5 * (Math.sqrt((c * (a / -0.25))) / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e-100: tmp = (c / b) - (b / a) elif b <= 1.05e-120: tmp = 0.5 * (math.sqrt((c * (a / -0.25))) / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e-100) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.05e-120) tmp = Float64(0.5 * Float64(sqrt(Float64(c * Float64(a / -0.25))) / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.15e-100) tmp = (c / b) - (b / a); elseif (b <= 1.05e-120) tmp = 0.5 * (sqrt((c * (a / -0.25))) / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e-100], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-120], N[(0.5 * N[(N[Sqrt[N[(c * N[(a / -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{-100}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-120}:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{c \cdot \frac{a}{-0.25}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.14999999999999997e-100Initial program 69.6%
neg-sub069.6%
associate-+l-69.6%
sub0-neg69.6%
neg-mul-169.6%
associate-*l/69.4%
*-commutative69.4%
associate-/r*69.4%
/-rgt-identity69.4%
metadata-eval69.4%
Simplified68.5%
Taylor expanded in b around -inf 88.6%
mul-1-neg88.6%
unsub-neg88.6%
Simplified88.6%
if -1.14999999999999997e-100 < b < 1.05e-120Initial program 87.4%
neg-sub087.4%
associate-+l-87.4%
sub0-neg87.4%
neg-mul-187.4%
associate-*l/87.1%
*-commutative87.1%
associate-/r*87.1%
/-rgt-identity87.1%
metadata-eval87.1%
Simplified87.1%
pow1/287.1%
pow-to-exp81.7%
Applied egg-rr81.7%
Taylor expanded in c around -inf 43.0%
mul-1-neg43.0%
unsub-neg43.0%
*-commutative43.0%
Simplified43.0%
Taylor expanded in b around 0 42.7%
*-commutative42.7%
*-commutative42.7%
log-div77.8%
exp-to-pow83.0%
unpow1/283.0%
associate-/r/83.1%
*-commutative83.1%
associate-/l*83.1%
metadata-eval83.1%
Simplified83.1%
if 1.05e-120 < b Initial program 13.9%
neg-sub013.9%
associate-+l-13.9%
sub0-neg13.9%
neg-mul-113.9%
associate-*l/14.0%
*-commutative14.0%
associate-/r*14.0%
/-rgt-identity14.0%
metadata-eval14.0%
Simplified14.0%
Taylor expanded in b around inf 86.6%
mul-1-neg86.6%
distribute-neg-frac86.6%
Simplified86.6%
Final simplification86.6%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-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 <= (-1d-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 <= -1e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-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 <= -1e-310) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-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 -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 73.4%
neg-sub073.4%
associate-+l-73.4%
sub0-neg73.4%
neg-mul-173.4%
associate-*l/73.1%
*-commutative73.1%
associate-/r*73.1%
/-rgt-identity73.1%
metadata-eval73.1%
Simplified72.4%
Taylor expanded in b around -inf 70.8%
mul-1-neg70.8%
unsub-neg70.8%
Simplified70.8%
if -9.999999999999969e-311 < b Initial program 32.0%
neg-sub032.0%
associate-+l-32.0%
sub0-neg32.0%
neg-mul-132.0%
associate-*l/32.0%
*-commutative32.0%
associate-/r*32.0%
/-rgt-identity32.0%
metadata-eval32.0%
Simplified32.0%
Taylor expanded in b around inf 69.2%
mul-1-neg69.2%
distribute-neg-frac69.2%
Simplified69.2%
Final simplification70.1%
(FPCore (a b c) :precision binary64 (if (<= b 6.9e-282) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.9e-282) {
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.9d-282) 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.9e-282) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.9e-282: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.9e-282) 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.9e-282) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.9e-282], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.9 \cdot 10^{-282}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 6.89999999999999967e-282Initial program 73.8%
neg-sub073.8%
associate-+l-73.8%
sub0-neg73.8%
neg-mul-173.8%
associate-*l/73.5%
*-commutative73.5%
associate-/r*73.5%
/-rgt-identity73.5%
metadata-eval73.5%
Simplified72.8%
Taylor expanded in b around -inf 69.1%
associate-*r/69.1%
mul-1-neg69.1%
Simplified69.1%
if 6.89999999999999967e-282 < b Initial program 30.8%
neg-sub030.8%
associate-+l-30.8%
sub0-neg30.8%
neg-mul-130.8%
associate-*l/30.8%
*-commutative30.8%
associate-/r*30.8%
/-rgt-identity30.8%
metadata-eval30.8%
Simplified30.8%
Taylor expanded in b around inf 70.4%
mul-1-neg70.4%
distribute-neg-frac70.4%
Simplified70.4%
Final simplification69.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(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 54.1%
neg-sub054.1%
associate-+l-54.1%
sub0-neg54.1%
neg-mul-154.1%
associate-*l/54.0%
*-commutative54.0%
associate-/r*54.0%
/-rgt-identity54.0%
metadata-eval54.0%
Simplified53.6%
Taylor expanded in b around -inf 38.8%
associate-*r/38.8%
mul-1-neg38.8%
Simplified38.8%
Final simplification38.8%
(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 54.1%
neg-sub054.1%
associate-+l-54.1%
sub0-neg54.1%
neg-mul-154.1%
associate-*l/54.0%
*-commutative54.0%
associate-/r*54.0%
/-rgt-identity54.0%
metadata-eval54.0%
Simplified53.6%
associate-*r/53.8%
clear-num53.7%
Applied egg-rr53.7%
Taylor expanded in a around 0 33.4%
mul-1-neg33.4%
unsub-neg33.4%
Simplified33.4%
Taylor expanded in a around inf 2.4%
Final simplification2.4%
herbie shell --seed 2023174
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))