
(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 -4e+154)
(/ (- b) a)
(if (or (<= b 8.5e-119) (and (not (<= b 6.5e-61)) (<= b 2.9e-34)))
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+154) {
tmp = -b / a;
} else if ((b <= 8.5e-119) || (!(b <= 6.5e-61) && (b <= 2.9e-34))) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - 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 <= (-4d+154)) then
tmp = -b / a
else if ((b <= 8.5d-119) .or. (.not. (b <= 6.5d-61)) .and. (b <= 2.9d-34)) then
tmp = (sqrt(((b * b) - ((a * 4.0d0) * c))) - 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 <= -4e+154) {
tmp = -b / a;
} else if ((b <= 8.5e-119) || (!(b <= 6.5e-61) && (b <= 2.9e-34))) {
tmp = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e+154: tmp = -b / a elif (b <= 8.5e-119) or (not (b <= 6.5e-61) and (b <= 2.9e-34)): tmp = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e+154) tmp = Float64(Float64(-b) / a); elseif ((b <= 8.5e-119) || (!(b <= 6.5e-61) && (b <= 2.9e-34))) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - 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 <= -4e+154) tmp = -b / a; elseif ((b <= 8.5e-119) || (~((b <= 6.5e-61)) && (b <= 2.9e-34))) tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e+154], N[((-b) / a), $MachinePrecision], If[Or[LessEqual[b, 8.5e-119], And[N[Not[LessEqual[b, 6.5e-61]], $MachinePrecision], LessEqual[b, 2.9e-34]]], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $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 -4 \cdot 10^{+154}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-119} \lor \neg \left(b \leq 6.5 \cdot 10^{-61}\right) \land b \leq 2.9 \cdot 10^{-34}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.00000000000000015e154Initial program 41.2%
*-commutative41.2%
Simplified41.2%
Taylor expanded in b around -inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -4.00000000000000015e154 < b < 8.49999999999999977e-119 or 6.4999999999999994e-61 < b < 2.9000000000000002e-34Initial program 82.3%
if 8.49999999999999977e-119 < b < 6.4999999999999994e-61 or 2.9000000000000002e-34 < b Initial program 17.4%
*-commutative17.4%
Simplified17.4%
Taylor expanded in b around inf 86.6%
mul-1-neg86.6%
distribute-neg-frac86.6%
Simplified86.6%
Final simplification86.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.6e-82)
(/ (- b) a)
(if (<= b 4.7e-119)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.6e-82) {
tmp = -b / a;
} else if (b <= 4.7e-119) {
tmp = (sqrt((a * (c * -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.6d-82)) then
tmp = -b / a
else if (b <= 4.7d-119) then
tmp = (sqrt((a * (c * (-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.6e-82) {
tmp = -b / a;
} else if (b <= 4.7e-119) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.6e-82: tmp = -b / a elif b <= 4.7e-119: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.6e-82) tmp = Float64(Float64(-b) / a); elseif (b <= 4.7e-119) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -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.6e-82) tmp = -b / a; elseif (b <= 4.7e-119) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.6e-82], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 4.7e-119], N[(N[(N[Sqrt[N[(a * N[(c * -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 -2.6 \cdot 10^{-82}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 4.7 \cdot 10^{-119}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.6e-82Initial program 67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in b around -inf 87.4%
associate-*r/87.4%
mul-1-neg87.4%
Simplified87.4%
if -2.6e-82 < b < 4.70000000000000002e-119Initial program 73.9%
*-commutative73.9%
Simplified73.9%
add-sqr-sqrt73.5%
pow273.5%
pow1/273.5%
sqrt-pow173.5%
fma-neg73.5%
*-commutative73.5%
distribute-rgt-neg-in73.5%
*-commutative73.5%
distribute-rgt-neg-in73.5%
metadata-eval73.5%
metadata-eval73.5%
Applied egg-rr73.5%
Taylor expanded in c around inf 46.8%
Simplified71.0%
if 4.70000000000000002e-119 < b Initial program 22.1%
*-commutative22.1%
Simplified22.1%
Taylor expanded in b around inf 82.3%
mul-1-neg82.3%
distribute-neg-frac82.3%
Simplified82.3%
Final simplification81.2%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-82)
(/ (- b) a)
(if (<= b 8.5e-119)
(/ (- (sqrt (* -4.0 (* a c))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-82) {
tmp = -b / a;
} else if (b <= 8.5e-119) {
tmp = (sqrt((-4.0 * (a * c))) - 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-82)) then
tmp = -b / a
else if (b <= 8.5d-119) then
tmp = (sqrt(((-4.0d0) * (a * c))) - 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-82) {
tmp = -b / a;
} else if (b <= 8.5e-119) {
tmp = (Math.sqrt((-4.0 * (a * c))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-82: tmp = -b / a elif b <= 8.5e-119: tmp = (math.sqrt((-4.0 * (a * c))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-82) tmp = Float64(Float64(-b) / a); elseif (b <= 8.5e-119) tmp = Float64(Float64(sqrt(Float64(-4.0 * Float64(a * c))) - 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-82) tmp = -b / a; elseif (b <= 8.5e-119) tmp = (sqrt((-4.0 * (a * c))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-82], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 8.5e-119], N[(N[(N[Sqrt[N[(-4.0 * N[(a * c), $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^{-82}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-119}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.9999999999999998e-82Initial program 67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in b around -inf 87.4%
associate-*r/87.4%
mul-1-neg87.4%
Simplified87.4%
if -4.9999999999999998e-82 < b < 8.49999999999999977e-119Initial program 73.9%
*-commutative73.9%
Simplified73.9%
Taylor expanded in b around 0 71.0%
if 8.49999999999999977e-119 < b Initial program 22.1%
*-commutative22.1%
Simplified22.1%
Taylor expanded in b around inf 82.3%
mul-1-neg82.3%
distribute-neg-frac82.3%
Simplified82.3%
Final simplification81.2%
(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 71.2%
*-commutative71.2%
Simplified71.2%
Taylor expanded in b around -inf 65.6%
+-commutative65.6%
mul-1-neg65.6%
unsub-neg65.6%
Simplified65.6%
if -4.999999999999985e-310 < b Initial program 31.8%
*-commutative31.8%
Simplified31.8%
Taylor expanded in b around inf 67.1%
mul-1-neg67.1%
distribute-neg-frac67.1%
Simplified67.1%
Final simplification66.4%
(FPCore (a b c) :precision binary64 (if (<= b 4.8e+44) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.8e+44) {
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 <= 4.8d+44) 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 <= 4.8e+44) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.8e+44: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.8e+44) 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 <= 4.8e+44) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.8e+44], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.8 \cdot 10^{+44}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 4.80000000000000026e44Initial program 63.3%
*-commutative63.3%
Simplified63.3%
Taylor expanded in b around -inf 43.9%
associate-*r/43.9%
mul-1-neg43.9%
Simplified43.9%
if 4.80000000000000026e44 < b Initial program 15.9%
*-commutative15.9%
Simplified15.9%
Taylor expanded in b around -inf 2.5%
Taylor expanded in b around 0 32.3%
Final simplification40.9%
(FPCore (a b c) :precision binary64 (if (<= b 6.5e-299) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.5e-299) {
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-299) 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-299) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.5e-299: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.5e-299) 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.5e-299) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.5e-299], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5 \cdot 10^{-299}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 6.4999999999999997e-299Initial program 70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in b around -inf 64.5%
associate-*r/64.5%
mul-1-neg64.5%
Simplified64.5%
if 6.4999999999999997e-299 < b Initial program 32.2%
*-commutative32.2%
Simplified32.2%
Taylor expanded in b around inf 68.1%
mul-1-neg68.1%
distribute-neg-frac68.1%
Simplified68.1%
Final simplification66.3%
(FPCore (a b c) :precision binary64 (if (<= b 1.15e+56) (/ 0.5 a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.15e+56) {
tmp = 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 <= 1.15d+56) then
tmp = 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 <= 1.15e+56) {
tmp = 0.5 / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.15e+56: tmp = 0.5 / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.15e+56) tmp = Float64(0.5 / a); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.15e+56) tmp = 0.5 / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.15e+56], N[(0.5 / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.15 \cdot 10^{+56}:\\
\;\;\;\;\frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.15000000000000007e56Initial program 63.1%
*-commutative63.1%
Simplified63.1%
clear-num63.0%
inv-pow63.0%
Applied egg-rr44.4%
Taylor expanded in b around inf 2.7%
expm1-log1p-u2.3%
expm1-udef2.2%
unpow-12.2%
clear-num2.2%
div-inv2.2%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Simplified5.6%
if 1.15000000000000007e56 < b Initial program 14.8%
*-commutative14.8%
Simplified14.8%
Taylor expanded in b around -inf 2.5%
Taylor expanded in b around 0 33.2%
Final simplification12.6%
(FPCore (a b c) :precision binary64 (/ -0.5 a))
double code(double a, double b, double c) {
return -0.5 / a;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.5d0) / a
end function
public static double code(double a, double b, double c) {
return -0.5 / a;
}
def code(a, b, c): return -0.5 / a
function code(a, b, c) return Float64(-0.5 / a) end
function tmp = code(a, b, c) tmp = -0.5 / a; end
code[a_, b_, c_] := N[(-0.5 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5}{a}
\end{array}
Initial program 50.9%
*-commutative50.9%
Simplified50.9%
clear-num50.8%
inv-pow50.8%
Applied egg-rr34.8%
Taylor expanded in b around inf 2.7%
unpow-12.7%
frac-2neg2.7%
metadata-eval2.7%
associate-/r/2.7%
metadata-eval2.7%
distribute-neg-frac2.7%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
distribute-neg-frac0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Simplified2.3%
Final simplification2.3%
(FPCore (a b c) :precision binary64 (/ 0.5 a))
double code(double a, double b, double c) {
return 0.5 / a;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.5d0 / a
end function
public static double code(double a, double b, double c) {
return 0.5 / a;
}
def code(a, b, c): return 0.5 / a
function code(a, b, c) return Float64(0.5 / a) end
function tmp = code(a, b, c) tmp = 0.5 / a; end
code[a_, b_, c_] := N[(0.5 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{a}
\end{array}
Initial program 50.9%
*-commutative50.9%
Simplified50.9%
clear-num50.8%
inv-pow50.8%
Applied egg-rr34.8%
Taylor expanded in b around inf 2.7%
expm1-log1p-u2.1%
expm1-udef2.5%
unpow-12.5%
clear-num2.5%
div-inv2.5%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Simplified5.2%
Final simplification5.2%
herbie shell --seed 2023332
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))