
(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 -1.35e+118)
(/ b (- a))
(if (<= b 1.6e-141)
(/ (- (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 <= -1.35e+118) {
tmp = b / -a;
} else if (b <= 1.6e-141) {
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 <= (-1.35d+118)) then
tmp = b / -a
else if (b <= 1.6d-141) 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 <= -1.35e+118) {
tmp = b / -a;
} else if (b <= 1.6e-141) {
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 <= -1.35e+118: tmp = b / -a elif b <= 1.6e-141: 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 <= -1.35e+118) tmp = Float64(b / Float64(-a)); elseif (b <= 1.6e-141) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - 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.35e+118) tmp = b / -a; elseif (b <= 1.6e-141) 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, -1.35e+118], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.6e-141], 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 -1.35 \cdot 10^{+118}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{-141}:\\
\;\;\;\;\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 < -1.35e118Initial program 50.5%
*-commutative50.5%
Simplified50.5%
Taylor expanded in b around -inf 96.9%
mul-1-neg96.9%
distribute-neg-frac296.9%
Simplified96.9%
if -1.35e118 < b < 1.6000000000000001e-141Initial program 87.4%
if 1.6000000000000001e-141 < b Initial program 19.3%
*-commutative19.3%
Simplified19.3%
Taylor expanded in b around inf 84.3%
associate-*r/84.3%
mul-1-neg84.3%
Simplified84.3%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e-38)
(/ b (- a))
(if (<= b 1.05e-144)
(/ (- (pow (/ -0.25 (* a c)) -0.5) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-38) {
tmp = b / -a;
} else if (b <= 1.05e-144) {
tmp = (pow((-0.25 / (a * c)), -0.5) - 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 <= (-3.8d-38)) then
tmp = b / -a
else if (b <= 1.05d-144) then
tmp = ((((-0.25d0) / (a * c)) ** (-0.5d0)) - 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 <= -3.8e-38) {
tmp = b / -a;
} else if (b <= 1.05e-144) {
tmp = (Math.pow((-0.25 / (a * c)), -0.5) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.8e-38: tmp = b / -a elif b <= 1.05e-144: tmp = (math.pow((-0.25 / (a * c)), -0.5) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.8e-38) tmp = Float64(b / Float64(-a)); elseif (b <= 1.05e-144) tmp = Float64(Float64((Float64(-0.25 / Float64(a * c)) ^ -0.5) - 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 <= -3.8e-38) tmp = b / -a; elseif (b <= 1.05e-144) tmp = (((-0.25 / (a * c)) ^ -0.5) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-38], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.05e-144], N[(N[(N[Power[N[(-0.25 / N[(a * c), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-38}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-144}:\\
\;\;\;\;\frac{{\left(\frac{-0.25}{a \cdot c}\right)}^{-0.5} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -3.8e-38Initial program 70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in b around -inf 87.7%
mul-1-neg87.7%
distribute-neg-frac287.7%
Simplified87.7%
if -3.8e-38 < b < 1.0500000000000001e-144Initial program 83.9%
*-commutative83.9%
Simplified83.9%
flip--55.7%
clear-num55.8%
fma-define55.8%
*-commutative55.8%
associate-*l*55.8%
pow255.8%
pow255.8%
pow-prod-up55.8%
metadata-eval55.8%
pow255.8%
*-commutative55.8%
associate-*l*55.8%
Applied egg-rr55.8%
Taylor expanded in b around 0 73.0%
inv-pow73.0%
sqrt-pow173.1%
metadata-eval73.1%
Applied egg-rr73.1%
*-commutative73.1%
Simplified73.1%
if 1.0500000000000001e-144 < b Initial program 20.0%
*-commutative20.0%
Simplified20.0%
Taylor expanded in b around inf 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification82.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.9e-36)
(/ b (- a))
(if (<= b 1.35e-144)
(* (/ 0.5 a) (- (sqrt (* a (* c -4.0))) b))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.9e-36) {
tmp = b / -a;
} else if (b <= 1.35e-144) {
tmp = (0.5 / a) * (sqrt((a * (c * -4.0))) - b);
} 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.9d-36)) then
tmp = b / -a
else if (b <= 1.35d-144) then
tmp = (0.5d0 / a) * (sqrt((a * (c * (-4.0d0)))) - b)
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.9e-36) {
tmp = b / -a;
} else if (b <= 1.35e-144) {
tmp = (0.5 / a) * (Math.sqrt((a * (c * -4.0))) - b);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.9e-36: tmp = b / -a elif b <= 1.35e-144: tmp = (0.5 / a) * (math.sqrt((a * (c * -4.0))) - b) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.9e-36) tmp = Float64(b / Float64(-a)); elseif (b <= 1.35e-144) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(a * Float64(c * -4.0))) - b)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.9e-36) tmp = b / -a; elseif (b <= 1.35e-144) tmp = (0.5 / a) * (sqrt((a * (c * -4.0))) - b); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.9e-36], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.35e-144], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-36}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-144}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.90000000000000013e-36Initial program 70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in b around -inf 87.7%
mul-1-neg87.7%
distribute-neg-frac287.7%
Simplified87.7%
if -2.90000000000000013e-36 < b < 1.34999999999999988e-144Initial program 83.9%
*-commutative83.9%
Simplified83.9%
Applied egg-rr83.8%
sub-neg83.8%
distribute-rgt-out--83.8%
Simplified83.8%
Taylor expanded in a around inf 73.0%
*-commutative73.0%
associate-*r*73.0%
Simplified73.0%
if 1.34999999999999988e-144 < b Initial program 20.0%
*-commutative20.0%
Simplified20.0%
Taylor expanded in b around inf 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification82.3%
(FPCore (a b c)
:precision binary64
(if (<= b -3.3e-37)
(/ b (- a))
(if (<= b 1.35e-144)
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.3e-37) {
tmp = b / -a;
} else if (b <= 1.35e-144) {
tmp = (sqrt((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 <= (-3.3d-37)) then
tmp = b / -a
else if (b <= 1.35d-144) then
tmp = (sqrt((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 <= -3.3e-37) {
tmp = b / -a;
} else if (b <= 1.35e-144) {
tmp = (Math.sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.3e-37: tmp = b / -a elif b <= 1.35e-144: tmp = (math.sqrt((c * (a * -4.0))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.3e-37) tmp = Float64(b / Float64(-a)); elseif (b <= 1.35e-144) tmp = Float64(Float64(sqrt(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 <= -3.3e-37) tmp = b / -a; elseif (b <= 1.35e-144) tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.3e-37], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.35e-144], N[(N[(N[Sqrt[N[(c * N[(a * -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 -3.3 \cdot 10^{-37}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-144}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -3.29999999999999982e-37Initial program 70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in b around -inf 87.7%
mul-1-neg87.7%
distribute-neg-frac287.7%
Simplified87.7%
if -3.29999999999999982e-37 < b < 1.34999999999999988e-144Initial program 83.9%
*-commutative83.9%
Simplified83.9%
Taylor expanded in b around 0 73.0%
*-commutative73.0%
*-commutative73.0%
associate-*r*73.0%
Simplified73.0%
if 1.34999999999999988e-144 < b Initial program 20.0%
*-commutative20.0%
Simplified20.0%
Taylor expanded in b around inf 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification82.3%
(FPCore (a b c) :precision binary64 (if (<= b 8e-6) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 8e-6) {
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 <= 8d-6) 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 <= 8e-6) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8e-6: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8e-6) 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 <= 8e-6) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8e-6], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{-6}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 7.99999999999999964e-6Initial program 69.3%
*-commutative69.3%
Simplified69.3%
Taylor expanded in b around -inf 48.7%
mul-1-neg48.7%
distribute-neg-frac248.7%
Simplified48.7%
if 7.99999999999999964e-6 < b Initial program 16.9%
*-commutative16.9%
Simplified16.9%
Taylor expanded in c around 0 89.1%
fma-neg89.1%
associate-/l*91.1%
distribute-neg-frac91.1%
metadata-eval91.1%
Simplified91.1%
Taylor expanded in a around 0 91.5%
frac-2neg91.5%
metadata-eval91.5%
un-div-inv91.6%
add-sqr-sqrt0.0%
sqrt-unprod31.0%
sqr-neg31.0%
sqrt-unprod30.5%
add-sqr-sqrt30.5%
Applied egg-rr30.5%
Final simplification43.4%
(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 75.9%
*-commutative75.9%
Simplified75.9%
Taylor expanded in b around -inf 68.4%
mul-1-neg68.4%
distribute-neg-frac268.4%
Simplified68.4%
if -4.999999999999985e-310 < b Initial program 32.7%
*-commutative32.7%
Simplified32.7%
Taylor expanded in b around inf 67.4%
associate-*r/67.4%
mul-1-neg67.4%
Simplified67.4%
Final simplification67.9%
(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.2%
*-commutative54.2%
Simplified54.2%
Applied egg-rr53.4%
sub-neg53.4%
distribute-rgt-out--54.0%
Simplified54.0%
Taylor expanded in b around -inf 35.2%
*-commutative35.2%
Simplified35.2%
associate-*l/35.3%
*-commutative35.3%
associate-*r*35.3%
metadata-eval35.3%
neg-mul-135.3%
add-sqr-sqrt33.7%
sqrt-unprod27.0%
sqr-neg27.0%
sqrt-unprod1.8%
add-sqr-sqrt2.4%
Applied egg-rr2.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 54.2%
*-commutative54.2%
Simplified54.2%
Taylor expanded in c around 0 31.5%
fma-neg31.5%
associate-/l*32.2%
distribute-neg-frac32.2%
metadata-eval32.2%
Simplified32.2%
Taylor expanded in a around 0 34.8%
frac-2neg34.8%
metadata-eval34.8%
un-div-inv34.9%
add-sqr-sqrt1.0%
sqrt-unprod10.2%
sqr-neg10.2%
sqrt-unprod9.2%
add-sqr-sqrt11.2%
Applied egg-rr11.2%
Final simplification11.2%
herbie shell --seed 2024074
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))