
(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 -7.8e+141)
(- (/ c b) (/ b a))
(if (<= b 1.26e-182)
(/ (- (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 <= -7.8e+141) {
tmp = (c / b) - (b / a);
} else if (b <= 1.26e-182) {
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 <= (-7.8d+141)) then
tmp = (c / b) - (b / a)
else if (b <= 1.26d-182) 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 <= -7.8e+141) {
tmp = (c / b) - (b / a);
} else if (b <= 1.26e-182) {
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 <= -7.8e+141: tmp = (c / b) - (b / a) elif b <= 1.26e-182: 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 <= -7.8e+141) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.26e-182) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 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 <= -7.8e+141) tmp = (c / b) - (b / a); elseif (b <= 1.26e-182) 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, -7.8e+141], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.26e-182], 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 -7.8 \cdot 10^{+141}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.26 \cdot 10^{-182}:\\
\;\;\;\;\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 < -7.79999999999999983e141Initial program 54.3%
*-commutative54.3%
Simplified54.3%
Taylor expanded in b around -inf 96.3%
+-commutative96.3%
mul-1-neg96.3%
unsub-neg96.3%
Simplified96.3%
if -7.79999999999999983e141 < b < 1.26e-182Initial program 85.0%
if 1.26e-182 < b Initial program 20.2%
*-commutative20.2%
Simplified20.2%
Taylor expanded in b around inf 81.7%
mul-1-neg81.7%
distribute-neg-frac81.7%
Simplified81.7%
Final simplification85.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3.7e-88)
(- (/ c b) (/ b a))
(if (<= b 1.26e-182)
(* (- b (sqrt (* a (* c -4.0)))) (/ -0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.7e-88) {
tmp = (c / b) - (b / a);
} else if (b <= 1.26e-182) {
tmp = (b - sqrt((a * (c * -4.0)))) * (-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 <= (-3.7d-88)) then
tmp = (c / b) - (b / a)
else if (b <= 1.26d-182) then
tmp = (b - sqrt((a * (c * (-4.0d0))))) * ((-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 <= -3.7e-88) {
tmp = (c / b) - (b / a);
} else if (b <= 1.26e-182) {
tmp = (b - Math.sqrt((a * (c * -4.0)))) * (-0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.7e-88: tmp = (c / b) - (b / a) elif b <= 1.26e-182: tmp = (b - math.sqrt((a * (c * -4.0)))) * (-0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.7e-88) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.26e-182) tmp = Float64(Float64(b - sqrt(Float64(a * Float64(c * -4.0)))) * Float64(-0.5 / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.7e-88) tmp = (c / b) - (b / a); elseif (b <= 1.26e-182) tmp = (b - sqrt((a * (c * -4.0)))) * (-0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.7e-88], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.26e-182], N[(N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.7 \cdot 10^{-88}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.26 \cdot 10^{-182}:\\
\;\;\;\;\left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.6999999999999997e-88Initial program 74.4%
*-commutative74.4%
Simplified74.4%
Taylor expanded in b around -inf 88.5%
+-commutative88.5%
mul-1-neg88.5%
unsub-neg88.5%
Simplified88.5%
if -3.6999999999999997e-88 < b < 1.26e-182Initial program 76.0%
*-commutative76.0%
Simplified76.0%
Applied egg-rr76.0%
*-commutative76.0%
associate-/r*76.0%
metadata-eval76.0%
Simplified76.0%
Taylor expanded in a around inf 72.8%
*-commutative72.8%
associate-*r*72.8%
Simplified72.8%
if 1.26e-182 < b Initial program 20.2%
*-commutative20.2%
Simplified20.2%
Taylor expanded in b around inf 81.7%
mul-1-neg81.7%
distribute-neg-frac81.7%
Simplified81.7%
Final simplification82.6%
(FPCore (a b c)
:precision binary64
(if (<= b -5.4e-89)
(- (/ c b) (/ b a))
(if (<= b 1.26e-182)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.4e-89) {
tmp = (c / b) - (b / a);
} else if (b <= 1.26e-182) {
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 <= (-5.4d-89)) then
tmp = (c / b) - (b / a)
else if (b <= 1.26d-182) 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 <= -5.4e-89) {
tmp = (c / b) - (b / a);
} else if (b <= 1.26e-182) {
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 <= -5.4e-89: tmp = (c / b) - (b / a) elif b <= 1.26e-182: 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 <= -5.4e-89) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.26e-182) 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 <= -5.4e-89) tmp = (c / b) - (b / a); elseif (b <= 1.26e-182) 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, -5.4e-89], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.26e-182], 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 -5.4 \cdot 10^{-89}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.26 \cdot 10^{-182}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.39999999999999975e-89Initial program 74.4%
*-commutative74.4%
Simplified74.4%
Taylor expanded in b around -inf 88.5%
+-commutative88.5%
mul-1-neg88.5%
unsub-neg88.5%
Simplified88.5%
if -5.39999999999999975e-89 < b < 1.26e-182Initial program 76.0%
*-commutative76.0%
Simplified76.0%
Taylor expanded in b around 0 72.9%
*-commutative72.9%
associate-*r*72.9%
Simplified72.9%
if 1.26e-182 < b Initial program 20.2%
*-commutative20.2%
Simplified20.2%
Taylor expanded in b around inf 81.7%
mul-1-neg81.7%
distribute-neg-frac81.7%
Simplified81.7%
Final simplification82.6%
(FPCore (a b c) :precision binary64 (if (<= b -2.7e-87) (- (/ c b) (/ b a)) (if (<= b 1.26e-182) (* 0.5 (/ (sqrt (* a (* c -4.0))) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e-87) {
tmp = (c / b) - (b / a);
} else if (b <= 1.26e-182) {
tmp = 0.5 * (sqrt((a * (c * -4.0))) / 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.7d-87)) then
tmp = (c / b) - (b / a)
else if (b <= 1.26d-182) then
tmp = 0.5d0 * (sqrt((a * (c * (-4.0d0)))) / 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.7e-87) {
tmp = (c / b) - (b / a);
} else if (b <= 1.26e-182) {
tmp = 0.5 * (Math.sqrt((a * (c * -4.0))) / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.7e-87: tmp = (c / b) - (b / a) elif b <= 1.26e-182: tmp = 0.5 * (math.sqrt((a * (c * -4.0))) / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.7e-87) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.26e-182) tmp = Float64(0.5 * Float64(sqrt(Float64(a * Float64(c * -4.0))) / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.7e-87) tmp = (c / b) - (b / a); elseif (b <= 1.26e-182) tmp = 0.5 * (sqrt((a * (c * -4.0))) / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.7e-87], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.26e-182], N[(0.5 * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{-87}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.26 \cdot 10^{-182}:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.69999999999999984e-87Initial program 74.4%
*-commutative74.4%
Simplified74.4%
Taylor expanded in b around -inf 88.5%
+-commutative88.5%
mul-1-neg88.5%
unsub-neg88.5%
Simplified88.5%
if -2.69999999999999984e-87 < b < 1.26e-182Initial program 76.0%
*-commutative76.0%
Simplified76.0%
prod-diff75.4%
*-commutative75.4%
fma-def75.4%
associate-+l+75.4%
pow275.4%
distribute-lft-neg-in75.4%
*-commutative75.4%
distribute-rgt-neg-in75.4%
metadata-eval75.4%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
fma-udef75.4%
Applied egg-rr75.4%
fma-def75.4%
fma-def75.5%
associate-*l*75.5%
Simplified75.5%
Taylor expanded in b around 0 70.1%
associate-*l/70.2%
*-lft-identity70.2%
distribute-rgt-out70.8%
metadata-eval70.8%
associate-*r*70.8%
Simplified70.8%
if 1.26e-182 < b Initial program 20.2%
*-commutative20.2%
Simplified20.2%
Taylor expanded in b around inf 81.7%
mul-1-neg81.7%
distribute-neg-frac81.7%
Simplified81.7%
Final simplification82.2%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-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 <= -2e-310) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-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 -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 74.2%
*-commutative74.2%
Simplified74.2%
Taylor expanded in b around -inf 69.2%
+-commutative69.2%
mul-1-neg69.2%
unsub-neg69.2%
Simplified69.2%
if -1.999999999999994e-310 < b Initial program 28.4%
*-commutative28.4%
Simplified28.4%
Taylor expanded in b around inf 71.3%
mul-1-neg71.3%
distribute-neg-frac71.3%
Simplified71.3%
Final simplification70.2%
(FPCore (a b c) :precision binary64 (if (<= b 1.6e+77) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e+77) {
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.6d+77) 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.6e+77) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.6e+77: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.6e+77) 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 <= 1.6e+77) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.6e+77], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.6000000000000001e77Initial program 65.3%
*-commutative65.3%
Simplified65.3%
Taylor expanded in b around -inf 49.1%
associate-*r/49.1%
mul-1-neg49.1%
Simplified49.1%
if 1.6000000000000001e77 < b Initial program 13.5%
*-commutative13.5%
Simplified13.5%
Applied egg-rr13.5%
*-commutative13.5%
associate-/r*13.5%
metadata-eval13.5%
Simplified13.5%
Taylor expanded in b around -inf 2.5%
+-commutative2.5%
*-commutative2.5%
associate-*l/2.6%
fma-def2.6%
associate-*l/2.5%
associate-/l*2.6%
Simplified2.6%
Taylor expanded in b around 0 36.9%
Final simplification46.2%
(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(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 <= -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 74.2%
*-commutative74.2%
Simplified74.2%
Taylor expanded in b around -inf 68.5%
associate-*r/68.5%
mul-1-neg68.5%
Simplified68.5%
if -1.999999999999994e-310 < b Initial program 28.4%
*-commutative28.4%
Simplified28.4%
Taylor expanded in b around inf 71.3%
mul-1-neg71.3%
distribute-neg-frac71.3%
Simplified71.3%
Final simplification69.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 52.9%
*-commutative52.9%
Simplified52.9%
Applied egg-rr52.9%
*-commutative52.9%
associate-/r*52.9%
metadata-eval52.9%
Simplified52.9%
Taylor expanded in b around -inf 36.9%
+-commutative36.9%
*-commutative36.9%
associate-*l/38.0%
fma-def38.0%
associate-*l/36.9%
associate-/l*38.1%
Simplified38.1%
Taylor expanded in b around 0 11.0%
Final simplification11.0%
herbie shell --seed 2024023
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))