
(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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-15)
(/ -0.5 (+ (* -0.5 (/ a b)) (* 0.5 (/ b c))))
(if (<= b 2.35e+67)
(* -0.5 (/ (+ b (sqrt (fma a (* c -4.0) (* b b)))) a))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 2.35e+67) {
tmp = -0.5 * ((b + sqrt(fma(a, (c * -4.0), (b * b)))) / a);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-15) tmp = Float64(-0.5 / Float64(Float64(-0.5 * Float64(a / b)) + Float64(0.5 * Float64(b / c)))); elseif (b <= 2.35e+67) tmp = Float64(-0.5 * Float64(Float64(b + sqrt(fma(a, Float64(c * -4.0), Float64(b * b)))) / a)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-15], N[(-0.5 / N[(N[(-0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.35e+67], N[(-0.5 * N[(N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{-0.5}{-0.5 \cdot \frac{a}{b} + 0.5 \cdot \frac{b}{c}}\\
\mathbf{elif}\;b \leq 2.35 \cdot 10^{+67}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.59999999999999981e-15Initial program 11.7%
sub-neg11.7%
distribute-neg-out11.7%
neg-mul-111.7%
times-frac11.7%
metadata-eval11.7%
sub-neg11.7%
+-commutative11.7%
distribute-rgt-neg-in11.7%
distribute-rgt-neg-out11.7%
*-commutative11.7%
associate-*l*11.7%
fma-def11.7%
distribute-lft-neg-in11.7%
distribute-rgt-neg-in11.7%
metadata-eval11.7%
Simplified11.7%
clear-num11.7%
un-div-inv11.7%
pow211.7%
Applied egg-rr11.7%
Taylor expanded in b around -inf 95.1%
if -4.59999999999999981e-15 < b < 2.35000000000000009e67Initial program 76.9%
sub-neg76.9%
distribute-neg-out76.9%
neg-mul-176.9%
times-frac76.9%
metadata-eval76.9%
sub-neg76.9%
+-commutative76.9%
distribute-rgt-neg-in76.9%
distribute-rgt-neg-out76.9%
*-commutative76.9%
associate-*l*76.9%
fma-def76.9%
distribute-lft-neg-in76.9%
distribute-rgt-neg-in76.9%
metadata-eval76.9%
Simplified76.9%
if 2.35000000000000009e67 < b Initial program 66.1%
sub-neg66.1%
distribute-neg-out66.1%
neg-mul-166.1%
times-frac66.1%
metadata-eval66.1%
sub-neg66.1%
+-commutative66.1%
distribute-rgt-neg-in66.1%
distribute-rgt-neg-out66.1%
*-commutative66.1%
associate-*l*66.1%
fma-def66.2%
distribute-lft-neg-in66.2%
distribute-rgt-neg-in66.2%
metadata-eval66.2%
Simplified66.2%
Taylor expanded in b around inf 96.4%
+-commutative96.4%
mul-1-neg96.4%
unsub-neg96.4%
Simplified96.4%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-15)
(/ -0.5 (+ (* -0.5 (/ a b)) (* 0.5 (/ b c))))
(if (<= b 3e+67)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* a 2.0))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 3e+67) {
tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
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 <= (-4.6d-15)) then
tmp = (-0.5d0) / (((-0.5d0) * (a / b)) + (0.5d0 * (b / c)))
else if (b <= 3d+67) then
tmp = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (a * 2.0d0)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 3e+67) {
tmp = (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e-15: tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))) elif b <= 3e+67: tmp = (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-15) tmp = Float64(-0.5 / Float64(Float64(-0.5 * Float64(a / b)) + Float64(0.5 * Float64(b / c)))); elseif (b <= 3e+67) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(a * 2.0)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.6e-15) tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))); elseif (b <= 3e+67) tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-15], N[(-0.5 / N[(N[(-0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3e+67], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{-0.5}{-0.5 \cdot \frac{a}{b} + 0.5 \cdot \frac{b}{c}}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{+67}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.59999999999999981e-15Initial program 11.7%
sub-neg11.7%
distribute-neg-out11.7%
neg-mul-111.7%
times-frac11.7%
metadata-eval11.7%
sub-neg11.7%
+-commutative11.7%
distribute-rgt-neg-in11.7%
distribute-rgt-neg-out11.7%
*-commutative11.7%
associate-*l*11.7%
fma-def11.7%
distribute-lft-neg-in11.7%
distribute-rgt-neg-in11.7%
metadata-eval11.7%
Simplified11.7%
clear-num11.7%
un-div-inv11.7%
pow211.7%
Applied egg-rr11.7%
Taylor expanded in b around -inf 95.1%
if -4.59999999999999981e-15 < b < 3.0000000000000001e67Initial program 76.9%
if 3.0000000000000001e67 < b Initial program 66.1%
sub-neg66.1%
distribute-neg-out66.1%
neg-mul-166.1%
times-frac66.1%
metadata-eval66.1%
sub-neg66.1%
+-commutative66.1%
distribute-rgt-neg-in66.1%
distribute-rgt-neg-out66.1%
*-commutative66.1%
associate-*l*66.1%
fma-def66.2%
distribute-lft-neg-in66.2%
distribute-rgt-neg-in66.2%
metadata-eval66.2%
Simplified66.2%
Taylor expanded in b around inf 96.4%
+-commutative96.4%
mul-1-neg96.4%
unsub-neg96.4%
Simplified96.4%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-15)
(/ -0.5 (+ (* -0.5 (/ a b)) (* 0.5 (/ b c))))
(if (<= b 3.8e+67)
(/ (- (- b) (sqrt (- (* b b) (* c (* a 4.0))))) (* a 2.0))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 3.8e+67) {
tmp = (-b - sqrt(((b * b) - (c * (a * 4.0))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
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 <= (-4.6d-15)) then
tmp = (-0.5d0) / (((-0.5d0) * (a / b)) + (0.5d0 * (b / c)))
else if (b <= 3.8d+67) then
tmp = (-b - sqrt(((b * b) - (c * (a * 4.0d0))))) / (a * 2.0d0)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 3.8e+67) {
tmp = (-b - Math.sqrt(((b * b) - (c * (a * 4.0))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e-15: tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))) elif b <= 3.8e+67: tmp = (-b - math.sqrt(((b * b) - (c * (a * 4.0))))) / (a * 2.0) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-15) tmp = Float64(-0.5 / Float64(Float64(-0.5 * Float64(a / b)) + Float64(0.5 * Float64(b / c)))); elseif (b <= 3.8e+67) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0))))) / Float64(a * 2.0)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.6e-15) tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))); elseif (b <= 3.8e+67) tmp = (-b - sqrt(((b * b) - (c * (a * 4.0))))) / (a * 2.0); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-15], N[(-0.5 / N[(N[(-0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.8e+67], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{-0.5}{-0.5 \cdot \frac{a}{b} + 0.5 \cdot \frac{b}{c}}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{+67}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.59999999999999981e-15Initial program 11.7%
sub-neg11.7%
distribute-neg-out11.7%
neg-mul-111.7%
times-frac11.7%
metadata-eval11.7%
sub-neg11.7%
+-commutative11.7%
distribute-rgt-neg-in11.7%
distribute-rgt-neg-out11.7%
*-commutative11.7%
associate-*l*11.7%
fma-def11.7%
distribute-lft-neg-in11.7%
distribute-rgt-neg-in11.7%
metadata-eval11.7%
Simplified11.7%
clear-num11.7%
un-div-inv11.7%
pow211.7%
Applied egg-rr11.7%
Taylor expanded in b around -inf 95.1%
if -4.59999999999999981e-15 < b < 3.8000000000000002e67Initial program 76.9%
*-commutative76.9%
sqr-neg76.9%
*-commutative76.9%
sqr-neg76.9%
associate-*r*76.9%
*-commutative76.9%
Simplified76.9%
if 3.8000000000000002e67 < b Initial program 66.1%
sub-neg66.1%
distribute-neg-out66.1%
neg-mul-166.1%
times-frac66.1%
metadata-eval66.1%
sub-neg66.1%
+-commutative66.1%
distribute-rgt-neg-in66.1%
distribute-rgt-neg-out66.1%
*-commutative66.1%
associate-*l*66.1%
fma-def66.2%
distribute-lft-neg-in66.2%
distribute-rgt-neg-in66.2%
metadata-eval66.2%
Simplified66.2%
Taylor expanded in b around inf 96.4%
+-commutative96.4%
mul-1-neg96.4%
unsub-neg96.4%
Simplified96.4%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-15)
(/ -0.5 (+ (* -0.5 (/ a b)) (* 0.5 (/ b c))))
(if (<= b 8e-103)
(* -0.5 (* (/ 1.0 a) (+ b (sqrt (* a (* c -4.0))))))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 8e-103) {
tmp = -0.5 * ((1.0 / a) * (b + sqrt((a * (c * -4.0)))));
} else {
tmp = (c / b) - (b / a);
}
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 <= (-4.6d-15)) then
tmp = (-0.5d0) / (((-0.5d0) * (a / b)) + (0.5d0 * (b / c)))
else if (b <= 8d-103) then
tmp = (-0.5d0) * ((1.0d0 / a) * (b + sqrt((a * (c * (-4.0d0))))))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 8e-103) {
tmp = -0.5 * ((1.0 / a) * (b + Math.sqrt((a * (c * -4.0)))));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e-15: tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))) elif b <= 8e-103: tmp = -0.5 * ((1.0 / a) * (b + math.sqrt((a * (c * -4.0))))) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-15) tmp = Float64(-0.5 / Float64(Float64(-0.5 * Float64(a / b)) + Float64(0.5 * Float64(b / c)))); elseif (b <= 8e-103) tmp = Float64(-0.5 * Float64(Float64(1.0 / a) * Float64(b + sqrt(Float64(a * Float64(c * -4.0)))))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.6e-15) tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))); elseif (b <= 8e-103) tmp = -0.5 * ((1.0 / a) * (b + sqrt((a * (c * -4.0))))); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-15], N[(-0.5 / N[(N[(-0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-103], N[(-0.5 * N[(N[(1.0 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{-0.5}{-0.5 \cdot \frac{a}{b} + 0.5 \cdot \frac{b}{c}}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-103}:\\
\;\;\;\;-0.5 \cdot \left(\frac{1}{a} \cdot \left(b + \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.59999999999999981e-15Initial program 11.7%
sub-neg11.7%
distribute-neg-out11.7%
neg-mul-111.7%
times-frac11.7%
metadata-eval11.7%
sub-neg11.7%
+-commutative11.7%
distribute-rgt-neg-in11.7%
distribute-rgt-neg-out11.7%
*-commutative11.7%
associate-*l*11.7%
fma-def11.7%
distribute-lft-neg-in11.7%
distribute-rgt-neg-in11.7%
metadata-eval11.7%
Simplified11.7%
clear-num11.7%
un-div-inv11.7%
pow211.7%
Applied egg-rr11.7%
Taylor expanded in b around -inf 95.1%
if -4.59999999999999981e-15 < b < 7.99999999999999966e-103Initial program 72.0%
sub-neg72.0%
distribute-neg-out72.0%
neg-mul-172.0%
times-frac72.0%
metadata-eval72.0%
sub-neg72.0%
+-commutative72.0%
distribute-rgt-neg-in72.0%
distribute-rgt-neg-out72.0%
*-commutative72.0%
associate-*l*72.1%
fma-def72.1%
distribute-lft-neg-in72.1%
distribute-rgt-neg-in72.1%
metadata-eval72.1%
Simplified72.1%
add-sqr-sqrt71.8%
pow271.8%
pow1/271.8%
sqrt-pow172.0%
pow272.0%
metadata-eval72.0%
Applied egg-rr72.0%
Taylor expanded in b around 0 67.7%
associate-*r*67.7%
*-commutative67.7%
Simplified67.7%
clear-num67.7%
associate-/r/67.6%
pow-pow67.8%
metadata-eval67.8%
pow1/267.8%
associate-*l*67.8%
*-commutative67.8%
Applied egg-rr67.8%
if 7.99999999999999966e-103 < b Initial program 72.1%
sub-neg72.1%
distribute-neg-out72.1%
neg-mul-172.1%
times-frac72.1%
metadata-eval72.1%
sub-neg72.1%
+-commutative72.1%
distribute-rgt-neg-in72.1%
distribute-rgt-neg-out72.1%
*-commutative72.1%
associate-*l*72.1%
fma-def72.2%
distribute-lft-neg-in72.2%
distribute-rgt-neg-in72.2%
metadata-eval72.2%
Simplified72.2%
Taylor expanded in b around inf 90.0%
+-commutative90.0%
mul-1-neg90.0%
unsub-neg90.0%
Simplified90.0%
Final simplification85.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-15)
(/ -0.5 (+ (* -0.5 (/ a b)) (* 0.5 (/ b c))))
(if (<= b 7.2e-103)
(* -0.5 (/ (+ b (sqrt (* c (* a -4.0)))) a))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 7.2e-103) {
tmp = -0.5 * ((b + sqrt((c * (a * -4.0)))) / a);
} else {
tmp = (c / b) - (b / a);
}
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 <= (-4.6d-15)) then
tmp = (-0.5d0) / (((-0.5d0) * (a / b)) + (0.5d0 * (b / c)))
else if (b <= 7.2d-103) then
tmp = (-0.5d0) * ((b + sqrt((c * (a * (-4.0d0))))) / a)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 7.2e-103) {
tmp = -0.5 * ((b + Math.sqrt((c * (a * -4.0)))) / a);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e-15: tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))) elif b <= 7.2e-103: tmp = -0.5 * ((b + math.sqrt((c * (a * -4.0)))) / a) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-15) tmp = Float64(-0.5 / Float64(Float64(-0.5 * Float64(a / b)) + Float64(0.5 * Float64(b / c)))); elseif (b <= 7.2e-103) tmp = Float64(-0.5 * Float64(Float64(b + sqrt(Float64(c * Float64(a * -4.0)))) / a)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.6e-15) tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))); elseif (b <= 7.2e-103) tmp = -0.5 * ((b + sqrt((c * (a * -4.0)))) / a); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-15], N[(-0.5 / N[(N[(-0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.2e-103], N[(-0.5 * N[(N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{-0.5}{-0.5 \cdot \frac{a}{b} + 0.5 \cdot \frac{b}{c}}\\
\mathbf{elif}\;b \leq 7.2 \cdot 10^{-103}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{c \cdot \left(a \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.59999999999999981e-15Initial program 11.7%
sub-neg11.7%
distribute-neg-out11.7%
neg-mul-111.7%
times-frac11.7%
metadata-eval11.7%
sub-neg11.7%
+-commutative11.7%
distribute-rgt-neg-in11.7%
distribute-rgt-neg-out11.7%
*-commutative11.7%
associate-*l*11.7%
fma-def11.7%
distribute-lft-neg-in11.7%
distribute-rgt-neg-in11.7%
metadata-eval11.7%
Simplified11.7%
clear-num11.7%
un-div-inv11.7%
pow211.7%
Applied egg-rr11.7%
Taylor expanded in b around -inf 95.1%
if -4.59999999999999981e-15 < b < 7.1999999999999996e-103Initial program 72.0%
sub-neg72.0%
distribute-neg-out72.0%
neg-mul-172.0%
times-frac72.0%
metadata-eval72.0%
sub-neg72.0%
+-commutative72.0%
distribute-rgt-neg-in72.0%
distribute-rgt-neg-out72.0%
*-commutative72.0%
associate-*l*72.1%
fma-def72.1%
distribute-lft-neg-in72.1%
distribute-rgt-neg-in72.1%
metadata-eval72.1%
Simplified72.1%
add-sqr-sqrt71.8%
pow271.8%
pow1/271.8%
sqrt-pow172.0%
pow272.0%
metadata-eval72.0%
Applied egg-rr72.0%
Taylor expanded in b around 0 67.7%
associate-*r*67.7%
*-commutative67.7%
Simplified67.7%
Taylor expanded in a around 0 40.1%
*-commutative40.1%
log-prod63.2%
log-pow63.2%
rem-exp-log67.7%
unpow267.7%
pow-sqr67.8%
metadata-eval67.8%
unpow1/267.8%
associate-*r*67.7%
*-commutative67.7%
associate-*l*67.8%
Simplified67.8%
if 7.1999999999999996e-103 < b Initial program 72.1%
sub-neg72.1%
distribute-neg-out72.1%
neg-mul-172.1%
times-frac72.1%
metadata-eval72.1%
sub-neg72.1%
+-commutative72.1%
distribute-rgt-neg-in72.1%
distribute-rgt-neg-out72.1%
*-commutative72.1%
associate-*l*72.1%
fma-def72.2%
distribute-lft-neg-in72.2%
distribute-rgt-neg-in72.2%
metadata-eval72.2%
Simplified72.2%
Taylor expanded in b around inf 90.0%
+-commutative90.0%
mul-1-neg90.0%
unsub-neg90.0%
Simplified90.0%
Final simplification85.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-15)
(/ -0.5 (+ (* -0.5 (/ a b)) (* 0.5 (/ b c))))
(if (<= b 2.5e-103)
(* -0.5 (/ (sqrt (* a (* c -4.0))) a))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 2.5e-103) {
tmp = -0.5 * (sqrt((a * (c * -4.0))) / a);
} else {
tmp = (c / b) - (b / a);
}
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 <= (-4.6d-15)) then
tmp = (-0.5d0) / (((-0.5d0) * (a / b)) + (0.5d0 * (b / c)))
else if (b <= 2.5d-103) then
tmp = (-0.5d0) * (sqrt((a * (c * (-4.0d0)))) / a)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else if (b <= 2.5e-103) {
tmp = -0.5 * (Math.sqrt((a * (c * -4.0))) / a);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e-15: tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))) elif b <= 2.5e-103: tmp = -0.5 * (math.sqrt((a * (c * -4.0))) / a) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-15) tmp = Float64(-0.5 / Float64(Float64(-0.5 * Float64(a / b)) + Float64(0.5 * Float64(b / c)))); elseif (b <= 2.5e-103) tmp = Float64(-0.5 * Float64(sqrt(Float64(a * Float64(c * -4.0))) / a)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.6e-15) tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))); elseif (b <= 2.5e-103) tmp = -0.5 * (sqrt((a * (c * -4.0))) / a); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-15], N[(-0.5 / N[(N[(-0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-103], N[(-0.5 * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{-0.5}{-0.5 \cdot \frac{a}{b} + 0.5 \cdot \frac{b}{c}}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-103}:\\
\;\;\;\;-0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.59999999999999981e-15Initial program 11.7%
sub-neg11.7%
distribute-neg-out11.7%
neg-mul-111.7%
times-frac11.7%
metadata-eval11.7%
sub-neg11.7%
+-commutative11.7%
distribute-rgt-neg-in11.7%
distribute-rgt-neg-out11.7%
*-commutative11.7%
associate-*l*11.7%
fma-def11.7%
distribute-lft-neg-in11.7%
distribute-rgt-neg-in11.7%
metadata-eval11.7%
Simplified11.7%
clear-num11.7%
un-div-inv11.7%
pow211.7%
Applied egg-rr11.7%
Taylor expanded in b around -inf 95.1%
if -4.59999999999999981e-15 < b < 2.49999999999999983e-103Initial program 72.0%
sub-neg72.0%
distribute-neg-out72.0%
neg-mul-172.0%
times-frac72.0%
metadata-eval72.0%
sub-neg72.0%
+-commutative72.0%
distribute-rgt-neg-in72.0%
distribute-rgt-neg-out72.0%
*-commutative72.0%
associate-*l*72.1%
fma-def72.1%
distribute-lft-neg-in72.1%
distribute-rgt-neg-in72.1%
metadata-eval72.1%
Simplified72.1%
add-sqr-sqrt71.8%
pow271.8%
pow1/271.8%
sqrt-pow172.0%
pow272.0%
metadata-eval72.0%
Applied egg-rr72.0%
Taylor expanded in b around 0 67.7%
associate-*r*67.7%
*-commutative67.7%
Simplified67.7%
Taylor expanded in c around 0 34.2%
Taylor expanded in b around 0 34.3%
*-commutative34.3%
*-commutative34.3%
log-prod62.8%
exp-to-pow67.2%
unpow267.2%
pow-sqr67.3%
metadata-eval67.3%
unpow1/267.3%
associate-*r*67.3%
*-commutative67.3%
rem-square-sqrt0.0%
unpow20.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt67.3%
Simplified67.3%
if 2.49999999999999983e-103 < b Initial program 72.1%
sub-neg72.1%
distribute-neg-out72.1%
neg-mul-172.1%
times-frac72.1%
metadata-eval72.1%
sub-neg72.1%
+-commutative72.1%
distribute-rgt-neg-in72.1%
distribute-rgt-neg-out72.1%
*-commutative72.1%
associate-*l*72.1%
fma-def72.2%
distribute-lft-neg-in72.2%
distribute-rgt-neg-in72.2%
metadata-eval72.2%
Simplified72.2%
Taylor expanded in b around inf 90.0%
+-commutative90.0%
mul-1-neg90.0%
unsub-neg90.0%
Simplified90.0%
Final simplification85.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.9e-279) (/ -0.5 (+ (* -0.5 (/ a b)) (* 0.5 (/ b c)))) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.9e-279) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else {
tmp = (c / b) - (b / a);
}
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-279) then
tmp = (-0.5d0) / (((-0.5d0) * (a / b)) + (0.5d0 * (b / c)))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.9e-279) {
tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c)));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.9e-279: tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.9e-279) tmp = Float64(-0.5 / Float64(Float64(-0.5 * Float64(a / b)) + Float64(0.5 * Float64(b / c)))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.9e-279) tmp = -0.5 / ((-0.5 * (a / b)) + (0.5 * (b / c))); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.9e-279], N[(-0.5 / N[(N[(-0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.9 \cdot 10^{-279}:\\
\;\;\;\;\frac{-0.5}{-0.5 \cdot \frac{a}{b} + 0.5 \cdot \frac{b}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < 1.90000000000000016e-279Initial program 30.4%
sub-neg30.4%
distribute-neg-out30.4%
neg-mul-130.4%
times-frac30.4%
metadata-eval30.4%
sub-neg30.4%
+-commutative30.4%
distribute-rgt-neg-in30.4%
distribute-rgt-neg-out30.4%
*-commutative30.4%
associate-*l*30.4%
fma-def30.4%
distribute-lft-neg-in30.4%
distribute-rgt-neg-in30.4%
metadata-eval30.4%
Simplified30.4%
clear-num30.4%
un-div-inv30.4%
pow230.4%
Applied egg-rr30.4%
Taylor expanded in b around -inf 71.5%
if 1.90000000000000016e-279 < b Initial program 74.0%
sub-neg74.0%
distribute-neg-out74.0%
neg-mul-174.0%
times-frac74.0%
metadata-eval74.0%
sub-neg74.0%
+-commutative74.0%
distribute-rgt-neg-in74.0%
distribute-rgt-neg-out74.0%
*-commutative74.0%
associate-*l*74.0%
fma-def74.1%
distribute-lft-neg-in74.1%
distribute-rgt-neg-in74.1%
metadata-eval74.1%
Simplified74.1%
Taylor expanded in b around inf 75.3%
+-commutative75.3%
mul-1-neg75.3%
unsub-neg75.3%
Simplified75.3%
Final simplification73.4%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (- c) b) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -c / b;
} else {
tmp = (c / b) - (b / a);
}
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
else
tmp = (c / b) - (b / a)
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;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -c / b else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-c) / b); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = -c / b; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[((-c) / b), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 29.5%
sub-neg29.5%
distribute-neg-out29.5%
neg-mul-129.5%
times-frac29.5%
metadata-eval29.5%
sub-neg29.5%
+-commutative29.5%
distribute-rgt-neg-in29.5%
distribute-rgt-neg-out29.5%
*-commutative29.5%
associate-*l*29.5%
fma-def29.5%
distribute-lft-neg-in29.5%
distribute-rgt-neg-in29.5%
metadata-eval29.5%
Simplified29.5%
Taylor expanded in b around -inf 72.9%
mul-1-neg72.9%
Simplified72.9%
if -1.999999999999994e-310 < b Initial program 73.9%
sub-neg73.9%
distribute-neg-out73.9%
neg-mul-173.9%
times-frac73.9%
metadata-eval73.9%
sub-neg73.9%
+-commutative73.9%
distribute-rgt-neg-in73.9%
distribute-rgt-neg-out73.9%
*-commutative73.9%
associate-*l*73.9%
fma-def74.0%
distribute-lft-neg-in74.0%
distribute-rgt-neg-in74.0%
metadata-eval74.0%
Simplified74.0%
Taylor expanded in b around inf 73.7%
+-commutative73.7%
mul-1-neg73.7%
unsub-neg73.7%
Simplified73.7%
Final simplification73.3%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (- c) b) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -c / b;
} else {
tmp = -b / a;
}
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
else
tmp = -b / a
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;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -c / b else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-c) / b); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = -c / b; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[((-c) / b), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 29.5%
sub-neg29.5%
distribute-neg-out29.5%
neg-mul-129.5%
times-frac29.5%
metadata-eval29.5%
sub-neg29.5%
+-commutative29.5%
distribute-rgt-neg-in29.5%
distribute-rgt-neg-out29.5%
*-commutative29.5%
associate-*l*29.5%
fma-def29.5%
distribute-lft-neg-in29.5%
distribute-rgt-neg-in29.5%
metadata-eval29.5%
Simplified29.5%
Taylor expanded in b around -inf 72.9%
mul-1-neg72.9%
Simplified72.9%
if -1.999999999999994e-310 < b Initial program 73.9%
sub-neg73.9%
distribute-neg-out73.9%
neg-mul-173.9%
times-frac73.9%
metadata-eval73.9%
sub-neg73.9%
+-commutative73.9%
distribute-rgt-neg-in73.9%
distribute-rgt-neg-out73.9%
*-commutative73.9%
associate-*l*73.9%
fma-def74.0%
distribute-lft-neg-in74.0%
distribute-rgt-neg-in74.0%
metadata-eval74.0%
Simplified74.0%
Taylor expanded in b around inf 73.5%
associate-*r/73.5%
mul-1-neg73.5%
Simplified73.5%
Final simplification73.2%
(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 52.0%
sub-neg52.0%
distribute-neg-out52.0%
neg-mul-152.0%
times-frac52.0%
metadata-eval52.0%
sub-neg52.0%
+-commutative52.0%
distribute-rgt-neg-in52.0%
distribute-rgt-neg-out52.0%
*-commutative52.0%
associate-*l*52.0%
fma-def52.1%
distribute-lft-neg-in52.1%
distribute-rgt-neg-in52.1%
metadata-eval52.1%
Simplified52.1%
Taylor expanded in b around -inf 37.0%
mul-1-neg37.0%
Simplified37.0%
Final simplification37.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fabs (/ b 2.0)))
(t_1 (* (sqrt (fabs a)) (sqrt (fabs c))))
(t_2
(if (== (copysign a c) a)
(* (sqrt (- t_0 t_1)) (sqrt (+ t_0 t_1)))
(hypot (/ b 2.0) t_1))))
(if (< b 0.0) (/ c (- t_2 (/ b 2.0))) (/ (+ (/ b 2.0) t_2) (- a)))))
double code(double a, double b, double c) {
double t_0 = fabs((b / 2.0));
double t_1 = sqrt(fabs(a)) * sqrt(fabs(c));
double tmp;
if (copysign(a, c) == a) {
tmp = sqrt((t_0 - t_1)) * sqrt((t_0 + t_1));
} else {
tmp = hypot((b / 2.0), t_1);
}
double t_2 = tmp;
double tmp_1;
if (b < 0.0) {
tmp_1 = c / (t_2 - (b / 2.0));
} else {
tmp_1 = ((b / 2.0) + t_2) / -a;
}
return tmp_1;
}
public static double code(double a, double b, double c) {
double t_0 = Math.abs((b / 2.0));
double t_1 = Math.sqrt(Math.abs(a)) * Math.sqrt(Math.abs(c));
double tmp;
if (Math.copySign(a, c) == a) {
tmp = Math.sqrt((t_0 - t_1)) * Math.sqrt((t_0 + t_1));
} else {
tmp = Math.hypot((b / 2.0), t_1);
}
double t_2 = tmp;
double tmp_1;
if (b < 0.0) {
tmp_1 = c / (t_2 - (b / 2.0));
} else {
tmp_1 = ((b / 2.0) + t_2) / -a;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.fabs((b / 2.0)) t_1 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c)) tmp = 0 if math.copysign(a, c) == a: tmp = math.sqrt((t_0 - t_1)) * math.sqrt((t_0 + t_1)) else: tmp = math.hypot((b / 2.0), t_1) t_2 = tmp tmp_1 = 0 if b < 0.0: tmp_1 = c / (t_2 - (b / 2.0)) else: tmp_1 = ((b / 2.0) + t_2) / -a return tmp_1
function code(a, b, c) t_0 = abs(Float64(b / 2.0)) t_1 = Float64(sqrt(abs(a)) * sqrt(abs(c))) tmp = 0.0 if (copysign(a, c) == a) tmp = Float64(sqrt(Float64(t_0 - t_1)) * sqrt(Float64(t_0 + t_1))); else tmp = hypot(Float64(b / 2.0), t_1); end t_2 = tmp tmp_1 = 0.0 if (b < 0.0) tmp_1 = Float64(c / Float64(t_2 - Float64(b / 2.0))); else tmp_1 = Float64(Float64(Float64(b / 2.0) + t_2) / Float64(-a)); end return tmp_1 end
function tmp_3 = code(a, b, c) t_0 = abs((b / 2.0)); t_1 = sqrt(abs(a)) * sqrt(abs(c)); tmp = 0.0; if ((sign(c) * abs(a)) == a) tmp = sqrt((t_0 - t_1)) * sqrt((t_0 + t_1)); else tmp = hypot((b / 2.0), t_1); end t_2 = tmp; tmp_2 = 0.0; if (b < 0.0) tmp_2 = c / (t_2 - (b / 2.0)); else tmp_2 = ((b / 2.0) + t_2) / -a; end tmp_3 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Abs[N[(b / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[Abs[a], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Abs[c], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[Equal[N[With[{TMP1 = Abs[a], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], a], N[(N[Sqrt[N[(t$95$0 - t$95$1), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(b / 2.0), $MachinePrecision] ^ 2 + t$95$1 ^ 2], $MachinePrecision]]}, If[Less[b, 0.0], N[(c / N[(t$95$2 - N[(b / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b / 2.0), $MachinePrecision] + t$95$2), $MachinePrecision] / (-a)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{b}{2}\right|\\
t_1 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_2 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\sqrt{t_0 - t_1} \cdot \sqrt{t_0 + t_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\frac{b}{2}, t_1\right)\\
\end{array}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{c}{t_2 - \frac{b}{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{2} + t_2}{-a}\\
\end{array}
\end{array}
herbie shell --seed 2023339
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-expected 10
:herbie-target
(if (< b 0.0) (/ c (- (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c))))) (/ b 2.0))) (/ (+ (/ b 2.0) (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (- a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))