
(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 -1e+73)
(- (/ c b) (/ b a))
(if (<= b 6.8e-109)
(/ (- (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 <= -1e+73) {
tmp = (c / b) - (b / a);
} else if (b <= 6.8e-109) {
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 <= (-1d+73)) then
tmp = (c / b) - (b / a)
else if (b <= 6.8d-109) 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 <= -1e+73) {
tmp = (c / b) - (b / a);
} else if (b <= 6.8e-109) {
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 <= -1e+73: tmp = (c / b) - (b / a) elif b <= 6.8e-109: 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 <= -1e+73) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.8e-109) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e+73) tmp = (c / b) - (b / a); elseif (b <= 6.8e-109) 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, -1e+73], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.8e-109], 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 -1 \cdot 10^{+73}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-109}:\\
\;\;\;\;\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 < -9.99999999999999983e72Initial program 58.2%
*-commutative58.2%
Simplified58.2%
Taylor expanded in b around -inf 94.2%
+-commutative94.2%
mul-1-neg94.2%
unsub-neg94.2%
Simplified94.2%
if -9.99999999999999983e72 < b < 6.80000000000000023e-109Initial program 85.7%
if 6.80000000000000023e-109 < b Initial program 12.4%
*-commutative12.4%
Simplified12.4%
Taylor expanded in b around inf 89.6%
mul-1-neg89.6%
distribute-neg-frac89.6%
Simplified89.6%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-124)
(- (/ c b) (/ b a))
(if (<= b 6.2e-109)
(* (/ -0.5 a) (- b (sqrt (* a (* c -4.0)))))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-124) {
tmp = (c / b) - (b / a);
} else if (b <= 6.2e-109) {
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 <= (-5d-124)) then
tmp = (c / b) - (b / a)
else if (b <= 6.2d-109) 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 <= -5e-124) {
tmp = (c / b) - (b / a);
} else if (b <= 6.2e-109) {
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 <= -5e-124: tmp = (c / b) - (b / a) elif b <= 6.2e-109: 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 <= -5e-124) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.2e-109) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(a * Float64(c * -4.0))))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-124) tmp = (c / b) - (b / a); elseif (b <= 6.2e-109) 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, -5e-124], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.2e-109], 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 -5 \cdot 10^{-124}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-109}:\\
\;\;\;\;\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 < -5.0000000000000003e-124Initial program 74.7%
*-commutative74.7%
Simplified74.7%
Taylor expanded in b around -inf 84.4%
+-commutative84.4%
mul-1-neg84.4%
unsub-neg84.4%
Simplified84.4%
if -5.0000000000000003e-124 < b < 6.1999999999999999e-109Initial program 77.1%
*-commutative77.1%
Simplified77.1%
Taylor expanded in b around 0 77.0%
*-commutative77.0%
associate-*r*77.0%
Simplified77.0%
+-commutative77.0%
unsub-neg77.0%
Applied egg-rr77.0%
frac-2neg77.0%
div-inv77.0%
Applied egg-rr77.0%
*-commutative77.0%
Simplified77.0%
if 6.1999999999999999e-109 < b Initial program 12.4%
*-commutative12.4%
Simplified12.4%
Taylor expanded in b around inf 89.6%
mul-1-neg89.6%
distribute-neg-frac89.6%
Simplified89.6%
Final simplification84.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.16e-124)
(- (/ c b) (/ b a))
(if (<= b 6.6e-109)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.16e-124) {
tmp = (c / b) - (b / a);
} else if (b <= 6.6e-109) {
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 <= (-1.16d-124)) then
tmp = (c / b) - (b / a)
else if (b <= 6.6d-109) 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 <= -1.16e-124) {
tmp = (c / b) - (b / a);
} else if (b <= 6.6e-109) {
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 <= -1.16e-124: tmp = (c / b) - (b / a) elif b <= 6.6e-109: 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 <= -1.16e-124) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.6e-109) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.16e-124) tmp = (c / b) - (b / a); elseif (b <= 6.6e-109) 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, -1.16e-124], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.6e-109], 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 -1.16 \cdot 10^{-124}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-109}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.1600000000000001e-124Initial program 74.7%
*-commutative74.7%
Simplified74.7%
Taylor expanded in b around -inf 84.4%
+-commutative84.4%
mul-1-neg84.4%
unsub-neg84.4%
Simplified84.4%
if -1.1600000000000001e-124 < b < 6.59999999999999981e-109Initial program 77.1%
*-commutative77.1%
Simplified77.1%
Taylor expanded in b around 0 77.0%
*-commutative77.0%
associate-*r*77.0%
Simplified77.0%
+-commutative77.0%
unsub-neg77.0%
Applied egg-rr77.0%
if 6.59999999999999981e-109 < b Initial program 12.4%
*-commutative12.4%
Simplified12.4%
Taylor expanded in b around inf 89.6%
mul-1-neg89.6%
distribute-neg-frac89.6%
Simplified89.6%
Final simplification84.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(c / Float64(-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 77.6%
*-commutative77.6%
Simplified77.6%
Taylor expanded in b around -inf 70.7%
+-commutative70.7%
mul-1-neg70.7%
unsub-neg70.7%
Simplified70.7%
if -4.999999999999985e-310 < b Initial program 31.3%
*-commutative31.3%
Simplified31.3%
Taylor expanded in b around inf 65.6%
mul-1-neg65.6%
distribute-neg-frac65.6%
Simplified65.6%
Final simplification68.3%
(FPCore (a b c) :precision binary64 (if (<= b 1.1e+31) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.1e+31) {
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.1d+31) 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.1e+31) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.1e+31: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.1e+31) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.1e+31) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.1e+31], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.1 \cdot 10^{+31}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.10000000000000005e31Initial program 70.6%
*-commutative70.6%
Simplified70.6%
Taylor expanded in b around -inf 49.6%
associate-*r/49.6%
mul-1-neg49.6%
Simplified49.6%
if 1.10000000000000005e31 < b Initial program 8.5%
*-commutative8.5%
Simplified8.5%
Taylor expanded in b around inf 86.5%
associate-/l*88.3%
Simplified88.3%
div-inv88.2%
associate-*r*88.3%
metadata-eval88.3%
distribute-lft-neg-in88.3%
*-commutative88.3%
frac-2neg88.3%
distribute-frac-neg88.3%
add-sqr-sqrt0.0%
sqrt-unprod38.0%
sqr-neg38.0%
sqrt-prod37.5%
add-sqr-sqrt37.5%
distribute-rgt-neg-in37.5%
*-commutative37.5%
distribute-lft-neg-in37.5%
metadata-eval37.5%
associate-*r*37.5%
distribute-lft-neg-in37.5%
metadata-eval37.5%
associate-*r/37.5%
metadata-eval37.5%
div-inv37.5%
Applied egg-rr37.5%
associate-*r/37.5%
*-commutative37.5%
associate-*l*37.5%
metadata-eval37.5%
associate-/l*37.5%
Simplified37.5%
Taylor expanded in a around 0 37.3%
Final simplification46.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 77.6%
*-commutative77.6%
Simplified77.6%
Taylor expanded in b around -inf 70.6%
associate-*r/70.6%
mul-1-neg70.6%
Simplified70.6%
if -4.999999999999985e-310 < b Initial program 31.3%
*-commutative31.3%
Simplified31.3%
Taylor expanded in b around inf 65.6%
mul-1-neg65.6%
distribute-neg-frac65.6%
Simplified65.6%
Final simplification68.2%
(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 55.3%
*-commutative55.3%
Simplified55.4%
*-un-lft-identity55.4%
*-un-lft-identity55.4%
prod-diff55.4%
*-commutative55.4%
*-un-lft-identity55.4%
fma-define55.4%
*-un-lft-identity55.4%
+-commutative55.4%
add-sqr-sqrt40.3%
sqrt-unprod53.3%
sqr-neg53.3%
sqrt-prod13.0%
add-sqr-sqrt32.8%
pow232.8%
add-sqr-sqrt20.5%
sqrt-unprod32.8%
sqr-neg32.8%
sqrt-prod13.0%
add-sqr-sqrt32.4%
*-commutative32.4%
*-un-lft-identity32.4%
Applied egg-rr32.4%
+-commutative32.4%
associate-+l+32.4%
fma-undefine32.4%
*-rgt-identity32.4%
Simplified32.4%
Taylor expanded in b around -inf 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 55.3%
*-commutative55.3%
Simplified55.3%
Taylor expanded in b around inf 26.9%
associate-/l*28.8%
Simplified28.8%
div-inv28.7%
associate-*r*28.8%
metadata-eval28.8%
distribute-lft-neg-in28.8%
*-commutative28.8%
frac-2neg28.8%
distribute-frac-neg28.8%
add-sqr-sqrt1.2%
sqrt-unprod10.9%
sqr-neg10.9%
sqrt-prod9.6%
add-sqr-sqrt11.6%
distribute-rgt-neg-in11.6%
*-commutative11.6%
distribute-lft-neg-in11.6%
metadata-eval11.6%
associate-*r*11.6%
distribute-lft-neg-in11.6%
metadata-eval11.6%
associate-*r/11.6%
metadata-eval11.6%
div-inv11.6%
Applied egg-rr11.6%
associate-*r/11.6%
*-commutative11.6%
associate-*l*11.6%
metadata-eval11.6%
associate-/l*11.6%
Simplified11.6%
Taylor expanded in a around 0 11.6%
Final simplification11.6%
herbie shell --seed 2024046
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))