
(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 -2e+156)
(/ (- (fma a (* (/ c b) 2.0) (- b)) b) (* a 2.0))
(if (<= b 2e+89)
(/ (- (sqrt (fma a (* c -4.0) (* b b))) b) (* a 2.0))
(* (/ 0.5 a) (- b b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+156) {
tmp = (fma(a, ((c / b) * 2.0), -b) - b) / (a * 2.0);
} else if (b <= 2e+89) {
tmp = (sqrt(fma(a, (c * -4.0), (b * b))) - b) / (a * 2.0);
} else {
tmp = (0.5 / a) * (b - b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2e+156) tmp = Float64(Float64(fma(a, Float64(Float64(c / b) * 2.0), Float64(-b)) - b) / Float64(a * 2.0)); elseif (b <= 2e+89) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(0.5 / a) * Float64(b - b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2e+156], N[(N[(N[(a * N[(N[(c / b), $MachinePrecision] * 2.0), $MachinePrecision] + (-b)), $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e+89], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(b - b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+156}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{b} \cdot 2, -b\right) - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+89}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(b - b\right)\\
\end{array}
\end{array}
if b < -2e156Initial program 36.8%
*-commutative36.8%
Simplified36.8%
Taylor expanded in b around -inf 87.7%
+-commutative87.7%
mul-1-neg87.7%
unsub-neg87.7%
*-commutative87.7%
associate-/l*99.9%
associate-*l*99.9%
fma-neg99.9%
Simplified99.9%
if -2e156 < b < 1.99999999999999999e89Initial program 84.3%
*-commutative84.3%
Simplified84.3%
if 1.99999999999999999e89 < b Initial program 27.6%
*-commutative27.6%
Simplified27.6%
Applied egg-rr25.1%
sub-neg25.1%
distribute-rgt-out--27.6%
Simplified27.6%
Taylor expanded in a around 0 98.2%
Final simplification90.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (/ c b) (/ b a)))
(t_1 (* (/ -0.5 a) (- b (sqrt (* a (* c -4.0)))))))
(if (<= b -1.75e-34)
t_0
(if (<= b -3.7e-74)
t_1
(if (<= b -2.1e-102)
t_0
(if (<= b 1.5e-146) t_1 (* (/ 0.5 a) (- b b))))))))
double code(double a, double b, double c) {
double t_0 = (c / b) - (b / a);
double t_1 = (-0.5 / a) * (b - sqrt((a * (c * -4.0))));
double tmp;
if (b <= -1.75e-34) {
tmp = t_0;
} else if (b <= -3.7e-74) {
tmp = t_1;
} else if (b <= -2.1e-102) {
tmp = t_0;
} else if (b <= 1.5e-146) {
tmp = t_1;
} else {
tmp = (0.5 / a) * (b - 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (c / b) - (b / a)
t_1 = ((-0.5d0) / a) * (b - sqrt((a * (c * (-4.0d0)))))
if (b <= (-1.75d-34)) then
tmp = t_0
else if (b <= (-3.7d-74)) then
tmp = t_1
else if (b <= (-2.1d-102)) then
tmp = t_0
else if (b <= 1.5d-146) then
tmp = t_1
else
tmp = (0.5d0 / a) * (b - b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (c / b) - (b / a);
double t_1 = (-0.5 / a) * (b - Math.sqrt((a * (c * -4.0))));
double tmp;
if (b <= -1.75e-34) {
tmp = t_0;
} else if (b <= -3.7e-74) {
tmp = t_1;
} else if (b <= -2.1e-102) {
tmp = t_0;
} else if (b <= 1.5e-146) {
tmp = t_1;
} else {
tmp = (0.5 / a) * (b - b);
}
return tmp;
}
def code(a, b, c): t_0 = (c / b) - (b / a) t_1 = (-0.5 / a) * (b - math.sqrt((a * (c * -4.0)))) tmp = 0 if b <= -1.75e-34: tmp = t_0 elif b <= -3.7e-74: tmp = t_1 elif b <= -2.1e-102: tmp = t_0 elif b <= 1.5e-146: tmp = t_1 else: tmp = (0.5 / a) * (b - b) return tmp
function code(a, b, c) t_0 = Float64(Float64(c / b) - Float64(b / a)) t_1 = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(a * Float64(c * -4.0))))) tmp = 0.0 if (b <= -1.75e-34) tmp = t_0; elseif (b <= -3.7e-74) tmp = t_1; elseif (b <= -2.1e-102) tmp = t_0; elseif (b <= 1.5e-146) tmp = t_1; else tmp = Float64(Float64(0.5 / a) * Float64(b - b)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (c / b) - (b / a); t_1 = (-0.5 / a) * (b - sqrt((a * (c * -4.0)))); tmp = 0.0; if (b <= -1.75e-34) tmp = t_0; elseif (b <= -3.7e-74) tmp = t_1; elseif (b <= -2.1e-102) tmp = t_0; elseif (b <= 1.5e-146) tmp = t_1; else tmp = (0.5 / a) * (b - b); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.75e-34], t$95$0, If[LessEqual[b, -3.7e-74], t$95$1, If[LessEqual[b, -2.1e-102], t$95$0, If[LessEqual[b, 1.5e-146], t$95$1, N[(N[(0.5 / a), $MachinePrecision] * N[(b - b), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{b} - \frac{b}{a}\\
t_1 := \frac{-0.5}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\
\mathbf{if}\;b \leq -1.75 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq -3.7 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -2.1 \cdot 10^{-102}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-146}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(b - b\right)\\
\end{array}
\end{array}
if b < -1.75e-34 or -3.69999999999999994e-74 < b < -2.1e-102Initial program 65.2%
*-commutative65.2%
Simplified65.2%
Taylor expanded in b around -inf 90.5%
+-commutative90.5%
mul-1-neg90.5%
unsub-neg90.5%
Simplified90.5%
if -1.75e-34 < b < -3.69999999999999994e-74 or -2.1e-102 < b < 1.50000000000000009e-146Initial program 80.8%
*-commutative80.8%
Simplified80.8%
Taylor expanded in b around 0 79.3%
*-commutative79.3%
associate-*r*79.3%
Simplified79.3%
frac-2neg79.3%
div-inv79.3%
distribute-neg-in79.3%
add-sqr-sqrt56.0%
sqrt-unprod79.2%
sqr-neg79.2%
unpow279.2%
unpow279.2%
sqrt-prod23.7%
add-sqr-sqrt79.2%
sub-neg79.2%
add-sqr-sqrt55.5%
sqrt-unprod78.9%
sqr-neg78.9%
sqrt-prod23.3%
add-sqr-sqrt79.3%
distribute-neg-frac279.3%
*-commutative79.3%
associate-/r*79.3%
metadata-eval79.3%
Applied egg-rr79.3%
*-commutative79.3%
Simplified79.3%
if 1.50000000000000009e-146 < b Initial program 51.9%
*-commutative51.9%
Simplified51.9%
Applied egg-rr48.5%
sub-neg48.5%
distribute-rgt-out--51.9%
Simplified51.9%
Taylor expanded in a around 0 79.8%
Final simplification84.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+156)
(/ (- (fma a (* (/ c b) 2.0) (- b)) b) (* a 2.0))
(if (<= b 3.2e+88)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(* (/ 0.5 a) (- b b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+156) {
tmp = (fma(a, ((c / b) * 2.0), -b) - b) / (a * 2.0);
} else if (b <= 3.2e+88) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = (0.5 / a) * (b - b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2e+156) tmp = Float64(Float64(fma(a, Float64(Float64(c / b) * 2.0), Float64(-b)) - b) / Float64(a * 2.0)); elseif (b <= 3.2e+88) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(0.5 / a) * Float64(b - b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2e+156], N[(N[(N[(a * N[(N[(c / b), $MachinePrecision] * 2.0), $MachinePrecision] + (-b)), $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.2e+88], 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[(N[(0.5 / a), $MachinePrecision] * N[(b - b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+156}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{b} \cdot 2, -b\right) - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{+88}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(b - b\right)\\
\end{array}
\end{array}
if b < -2e156Initial program 36.8%
*-commutative36.8%
Simplified36.8%
Taylor expanded in b around -inf 87.7%
+-commutative87.7%
mul-1-neg87.7%
unsub-neg87.7%
*-commutative87.7%
associate-/l*99.9%
associate-*l*99.9%
fma-neg99.9%
Simplified99.9%
if -2e156 < b < 3.1999999999999999e88Initial program 84.3%
if 3.1999999999999999e88 < b Initial program 27.6%
*-commutative27.6%
Simplified27.6%
Applied egg-rr25.1%
sub-neg25.1%
distribute-rgt-out--27.6%
Simplified27.6%
Taylor expanded in a around 0 98.2%
Final simplification90.1%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ b (- a)) (* (/ 0.5 a) (- b b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = b / -a;
} else {
tmp = (0.5 / a) * (b - 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 <= (-2d-310)) then
tmp = b / -a
else
tmp = (0.5d0 / a) * (b - b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = b / -a;
} else {
tmp = (0.5 / a) * (b - b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b / -a else: tmp = (0.5 / a) * (b - b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(b / Float64(-a)); else tmp = Float64(Float64(0.5 / a) * Float64(b - b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = b / -a; else tmp = (0.5 / a) * (b - b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(b / (-a)), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(b - b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(b - b\right)\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 69.9%
*-commutative69.9%
Simplified69.9%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
mul-1-neg67.1%
Simplified67.1%
if -1.999999999999994e-310 < b Initial program 55.7%
*-commutative55.7%
Simplified55.7%
Applied egg-rr52.7%
sub-neg52.7%
distribute-rgt-out--55.7%
Simplified55.7%
Taylor expanded in a around 0 68.4%
Final simplification67.7%
(FPCore (a b c) :precision binary64 (if (<= b -2.35e-293) (- (/ c b) (/ b a)) (* (/ 0.5 a) (- b b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.35e-293) {
tmp = (c / b) - (b / a);
} else {
tmp = (0.5 / a) * (b - 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.35d-293)) then
tmp = (c / b) - (b / a)
else
tmp = (0.5d0 / a) * (b - b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.35e-293) {
tmp = (c / b) - (b / a);
} else {
tmp = (0.5 / a) * (b - b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.35e-293: tmp = (c / b) - (b / a) else: tmp = (0.5 / a) * (b - b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.35e-293) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(Float64(0.5 / a) * Float64(b - b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.35e-293) tmp = (c / b) - (b / a); else tmp = (0.5 / a) * (b - b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.35e-293], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(b - b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.35 \cdot 10^{-293}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(b - b\right)\\
\end{array}
\end{array}
if b < -2.35000000000000006e-293Initial program 69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in b around -inf 68.3%
+-commutative68.3%
mul-1-neg68.3%
unsub-neg68.3%
Simplified68.3%
if -2.35000000000000006e-293 < b Initial program 56.0%
*-commutative56.0%
Simplified56.0%
Applied egg-rr53.2%
sub-neg53.2%
distribute-rgt-out--56.0%
Simplified56.0%
Taylor expanded in a around 0 67.8%
Final simplification68.1%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ b (- a)) (- (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = b / -a;
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b / -a else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(b / Float64(-a)); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = b / -a; else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(b / (-a)), $MachinePrecision], (-N[(c / b), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 69.9%
*-commutative69.9%
Simplified69.9%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
mul-1-neg67.1%
Simplified67.1%
if -1.999999999999994e-310 < b Initial program 55.7%
*-commutative55.7%
Simplified55.7%
Taylor expanded in b around inf 29.3%
mul-1-neg29.3%
distribute-neg-frac229.3%
Simplified29.3%
Final simplification50.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(-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 63.6%
*-commutative63.6%
Simplified63.6%
Taylor expanded in b around inf 14.2%
mul-1-neg14.2%
distribute-neg-frac214.2%
Simplified14.2%
Final simplification14.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 63.6%
*-commutative63.6%
Simplified63.6%
Applied egg-rr62.3%
sub-neg62.3%
distribute-rgt-out--63.6%
Simplified63.6%
metadata-eval63.6%
associate-/r*63.6%
*-commutative63.6%
associate-*l/63.7%
*-un-lft-identity63.7%
sub-neg63.7%
+-commutative63.7%
add-sqr-sqrt39.1%
sqrt-unprod49.1%
sqr-neg49.1%
sqrt-prod10.1%
add-sqr-sqrt31.2%
fma-undefine31.1%
add-sqr-sqrt29.1%
unpow229.1%
hypot-define24.0%
Applied egg-rr24.0%
Taylor expanded in b around inf 2.3%
Final simplification2.3%
(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 63.6%
*-commutative63.6%
Simplified63.6%
Taylor expanded in b around -inf 38.8%
+-commutative38.8%
mul-1-neg38.8%
unsub-neg38.8%
Simplified38.8%
Taylor expanded in c around inf 12.7%
Final simplification12.7%
herbie shell --seed 2024052
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))