
(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 7 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.9e+105)
(/ (- b) a)
(if (<= b 3.4e-53)
(/ (- (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.9e+105) {
tmp = -b / a;
} else if (b <= 3.4e-53) {
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.9d+105)) then
tmp = -b / a
else if (b <= 3.4d-53) 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.9e+105) {
tmp = -b / a;
} else if (b <= 3.4e-53) {
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.9e+105: tmp = -b / a elif b <= 3.4e-53: 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.9e+105) tmp = Float64(Float64(-b) / a); elseif (b <= 3.4e-53) 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 <= -1.9e+105) tmp = -b / a; elseif (b <= 3.4e-53) 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.9e+105], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 3.4e-53], 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.9 \cdot 10^{+105}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-53}:\\
\;\;\;\;\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.9e105Initial program 49.3%
neg-sub049.3%
associate-+l-49.3%
sub0-neg49.3%
neg-mul-149.3%
associate-*l/49.3%
*-commutative49.3%
associate-/r*49.3%
/-rgt-identity49.3%
metadata-eval49.3%
Simplified49.4%
Taylor expanded in b around -inf 97.1%
associate-*r/97.1%
mul-1-neg97.1%
Simplified97.1%
if -1.9e105 < b < 3.4e-53Initial program 81.6%
if 3.4e-53 < b Initial program 17.3%
neg-sub017.3%
associate-+l-17.3%
sub0-neg17.3%
neg-mul-117.3%
associate-*l/17.2%
*-commutative17.2%
associate-/r*17.2%
/-rgt-identity17.2%
metadata-eval17.2%
Simplified17.2%
Taylor expanded in b around inf 90.4%
mul-1-neg90.4%
distribute-neg-frac90.4%
Simplified90.4%
Final simplification88.6%
(FPCore (a b c)
:precision binary64
(if (<= b -2.3e-96)
(/ (- b) a)
(if (<= b 2.65e-55)
(* (/ -0.5 a) (- b (sqrt (* a (* c -4.0)))))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e-96) {
tmp = -b / a;
} else if (b <= 2.65e-55) {
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 <= (-2.3d-96)) then
tmp = -b / a
else if (b <= 2.65d-55) 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 <= -2.3e-96) {
tmp = -b / a;
} else if (b <= 2.65e-55) {
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 <= -2.3e-96: tmp = -b / a elif b <= 2.65e-55: 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 <= -2.3e-96) tmp = Float64(Float64(-b) / a); elseif (b <= 2.65e-55) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(a * Float64(c * -4.0))))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.3e-96) tmp = -b / a; elseif (b <= 2.65e-55) 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, -2.3e-96], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.65e-55], 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 -2.3 \cdot 10^{-96}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 2.65 \cdot 10^{-55}:\\
\;\;\;\;\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 < -2.3e-96Initial program 66.3%
neg-sub066.3%
associate-+l-66.3%
sub0-neg66.3%
neg-mul-166.3%
associate-*l/66.2%
*-commutative66.2%
associate-/r*66.2%
/-rgt-identity66.2%
metadata-eval66.2%
Simplified66.2%
Taylor expanded in b around -inf 85.9%
associate-*r/85.9%
mul-1-neg85.9%
Simplified85.9%
if -2.3e-96 < b < 2.6500000000000001e-55Initial program 74.5%
neg-sub074.5%
associate-+l-74.5%
sub0-neg74.5%
neg-mul-174.5%
associate-*l/74.4%
*-commutative74.4%
associate-/r*74.4%
/-rgt-identity74.4%
metadata-eval74.4%
Simplified74.4%
associate-*r/74.5%
clear-num74.5%
Applied egg-rr74.5%
pow1/274.5%
pow-to-exp69.5%
Applied egg-rr69.5%
Taylor expanded in a around inf 35.9%
+-commutative35.9%
*-commutative35.9%
mul-1-neg35.9%
log-rec35.9%
remove-double-neg35.9%
log-prod69.5%
*-commutative69.5%
associate-*r*69.5%
*-commutative69.5%
*-commutative69.5%
associate-*r*69.5%
Simplified69.5%
expm1-log1p-u48.0%
expm1-udef20.5%
associate-/r/20.5%
*-commutative20.5%
exp-to-pow20.7%
pow1/220.7%
Applied egg-rr20.7%
expm1-def50.4%
expm1-log1p74.3%
associate-*r*74.3%
associate-*l/74.3%
metadata-eval74.3%
Simplified74.3%
if 2.6500000000000001e-55 < b Initial program 17.3%
neg-sub017.3%
associate-+l-17.3%
sub0-neg17.3%
neg-mul-117.3%
associate-*l/17.2%
*-commutative17.2%
associate-/r*17.2%
/-rgt-identity17.2%
metadata-eval17.2%
Simplified17.2%
Taylor expanded in b around inf 90.4%
mul-1-neg90.4%
distribute-neg-frac90.4%
Simplified90.4%
Final simplification85.0%
(FPCore (a b c)
:precision binary64
(if (<= b -8e-97)
(/ (- b) a)
(if (<= b 3.85e-53)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8e-97) {
tmp = -b / a;
} else if (b <= 3.85e-53) {
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 <= (-8d-97)) then
tmp = -b / a
else if (b <= 3.85d-53) 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 <= -8e-97) {
tmp = -b / a;
} else if (b <= 3.85e-53) {
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 <= -8e-97: tmp = -b / a elif b <= 3.85e-53: 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 <= -8e-97) tmp = Float64(Float64(-b) / a); elseif (b <= 3.85e-53) 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 <= -8e-97) tmp = -b / a; elseif (b <= 3.85e-53) 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, -8e-97], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 3.85e-53], 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 -8 \cdot 10^{-97}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 3.85 \cdot 10^{-53}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -8.00000000000000029e-97Initial program 66.3%
neg-sub066.3%
associate-+l-66.3%
sub0-neg66.3%
neg-mul-166.3%
associate-*l/66.2%
*-commutative66.2%
associate-/r*66.2%
/-rgt-identity66.2%
metadata-eval66.2%
Simplified66.2%
Taylor expanded in b around -inf 85.9%
associate-*r/85.9%
mul-1-neg85.9%
Simplified85.9%
if -8.00000000000000029e-97 < b < 3.84999999999999997e-53Initial program 74.5%
Taylor expanded in b around 0 74.5%
*-commutative74.5%
*-commutative74.5%
associate-*r*74.5%
Simplified74.5%
if 3.84999999999999997e-53 < b Initial program 17.3%
neg-sub017.3%
associate-+l-17.3%
sub0-neg17.3%
neg-mul-117.3%
associate-*l/17.2%
*-commutative17.2%
associate-/r*17.2%
/-rgt-identity17.2%
metadata-eval17.2%
Simplified17.2%
Taylor expanded in b around inf 90.4%
mul-1-neg90.4%
distribute-neg-frac90.4%
Simplified90.4%
Final simplification85.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-311) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-311) {
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-311)) 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-311) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-311: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-311) 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-311) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-311], 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^{-311}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.00000000000023e-311Initial program 68.6%
neg-sub068.6%
associate-+l-68.6%
sub0-neg68.6%
neg-mul-168.6%
associate-*l/68.4%
*-commutative68.4%
associate-/r*68.4%
/-rgt-identity68.4%
metadata-eval68.4%
Simplified68.5%
Taylor expanded in b around -inf 70.9%
mul-1-neg70.9%
unsub-neg70.9%
Simplified70.9%
if -5.00000000000023e-311 < b Initial program 29.7%
neg-sub029.7%
associate-+l-29.7%
sub0-neg29.7%
neg-mul-129.7%
associate-*l/29.6%
*-commutative29.6%
associate-/r*29.6%
/-rgt-identity29.6%
metadata-eval29.6%
Simplified29.6%
Taylor expanded in b around inf 74.9%
mul-1-neg74.9%
distribute-neg-frac74.9%
Simplified74.9%
Final simplification72.8%
(FPCore (a b c) :precision binary64 (if (<= b 2.3e+76) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.3e+76) {
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 <= 2.3d+76) 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 <= 2.3e+76) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.3e+76: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.3e+76) 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 <= 2.3e+76) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.3e+76], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.3 \cdot 10^{+76}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 2.30000000000000001e76Initial program 63.1%
neg-sub063.1%
associate-+l-63.1%
sub0-neg63.1%
neg-mul-163.1%
associate-*l/63.0%
*-commutative63.0%
associate-/r*63.0%
/-rgt-identity63.0%
metadata-eval63.0%
Simplified63.0%
Taylor expanded in b around -inf 50.7%
associate-*r/50.7%
mul-1-neg50.7%
Simplified50.7%
if 2.30000000000000001e76 < b Initial program 12.8%
neg-sub012.8%
associate-+l-12.8%
sub0-neg12.8%
neg-mul-112.8%
associate-*l/12.6%
*-commutative12.6%
associate-/r*12.6%
/-rgt-identity12.6%
metadata-eval12.6%
Simplified12.6%
Taylor expanded in b around -inf 2.4%
mul-1-neg2.4%
unsub-neg2.4%
Simplified2.4%
Taylor expanded in c around inf 30.7%
Final simplification45.5%
(FPCore (a b c) :precision binary64 (if (<= b 1.8e-303) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.8e-303) {
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.8d-303) 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.8e-303) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.8e-303: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.8e-303) 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.8e-303) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.8e-303], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.8 \cdot 10^{-303}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 1.7999999999999999e-303Initial program 68.6%
neg-sub068.6%
associate-+l-68.6%
sub0-neg68.6%
neg-mul-168.6%
associate-*l/68.4%
*-commutative68.4%
associate-/r*68.4%
/-rgt-identity68.4%
metadata-eval68.4%
Simplified68.5%
Taylor expanded in b around -inf 70.9%
associate-*r/70.9%
mul-1-neg70.9%
Simplified70.9%
if 1.7999999999999999e-303 < b Initial program 29.7%
neg-sub029.7%
associate-+l-29.7%
sub0-neg29.7%
neg-mul-129.7%
associate-*l/29.6%
*-commutative29.6%
associate-/r*29.6%
/-rgt-identity29.6%
metadata-eval29.6%
Simplified29.6%
Taylor expanded in b around inf 74.9%
mul-1-neg74.9%
distribute-neg-frac74.9%
Simplified74.9%
Final simplification72.8%
(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 49.9%
neg-sub049.9%
associate-+l-49.9%
sub0-neg49.9%
neg-mul-149.9%
associate-*l/49.8%
*-commutative49.8%
associate-/r*49.8%
/-rgt-identity49.8%
metadata-eval49.8%
Simplified49.8%
Taylor expanded in b around -inf 37.9%
mul-1-neg37.9%
unsub-neg37.9%
Simplified37.9%
Taylor expanded in c around inf 10.3%
Final simplification10.3%
herbie shell --seed 2023194
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))