
(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 14 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
(let* ((t_0 (* a (* 4.0 c))))
(if (<= b -6e+138)
(/ b (- a))
(if (<= b 4.6e-112)
(/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) (* a 2.0))
(if (<= b 2.05e+33)
(/
(/
(- (- (pow b 2.0) (pow b 2.0)) t_0)
(+ b (sqrt (- (pow b 2.0) t_0))))
(* a 2.0))
(/ c (- b)))))))
double code(double a, double b, double c) {
double t_0 = a * (4.0 * c);
double tmp;
if (b <= -6e+138) {
tmp = b / -a;
} else if (b <= 4.6e-112) {
tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0);
} else if (b <= 2.05e+33) {
tmp = (((pow(b, 2.0) - pow(b, 2.0)) - t_0) / (b + sqrt((pow(b, 2.0) - t_0)))) / (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) :: t_0
real(8) :: tmp
t_0 = a * (4.0d0 * c)
if (b <= (-6d+138)) then
tmp = b / -a
else if (b <= 4.6d-112) then
tmp = (sqrt(((b * b) - (4.0d0 * (a * c)))) - b) / (a * 2.0d0)
else if (b <= 2.05d+33) then
tmp = ((((b ** 2.0d0) - (b ** 2.0d0)) - t_0) / (b + sqrt(((b ** 2.0d0) - t_0)))) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = a * (4.0 * c);
double tmp;
if (b <= -6e+138) {
tmp = b / -a;
} else if (b <= 4.6e-112) {
tmp = (Math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0);
} else if (b <= 2.05e+33) {
tmp = (((Math.pow(b, 2.0) - Math.pow(b, 2.0)) - t_0) / (b + Math.sqrt((Math.pow(b, 2.0) - t_0)))) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): t_0 = a * (4.0 * c) tmp = 0 if b <= -6e+138: tmp = b / -a elif b <= 4.6e-112: tmp = (math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0) elif b <= 2.05e+33: tmp = (((math.pow(b, 2.0) - math.pow(b, 2.0)) - t_0) / (b + math.sqrt((math.pow(b, 2.0) - t_0)))) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) t_0 = Float64(a * Float64(4.0 * c)) tmp = 0.0 if (b <= -6e+138) tmp = Float64(b / Float64(-a)); elseif (b <= 4.6e-112) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) - b) / Float64(a * 2.0)); elseif (b <= 2.05e+33) tmp = Float64(Float64(Float64(Float64((b ^ 2.0) - (b ^ 2.0)) - t_0) / Float64(b + sqrt(Float64((b ^ 2.0) - t_0)))) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = a * (4.0 * c); tmp = 0.0; if (b <= -6e+138) tmp = b / -a; elseif (b <= 4.6e-112) tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0); elseif (b <= 2.05e+33) tmp = ((((b ^ 2.0) - (b ^ 2.0)) - t_0) / (b + sqrt(((b ^ 2.0) - t_0)))) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(4.0 * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -6e+138], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 4.6e-112], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.05e+33], N[(N[(N[(N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(b + N[Sqrt[N[(N[Power[b, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(4 \cdot c\right)\\
\mathbf{if}\;b \leq -6 \cdot 10^{+138}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 4.6 \cdot 10^{-112}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 2.05 \cdot 10^{+33}:\\
\;\;\;\;\frac{\frac{\left({b}^{2} - {b}^{2}\right) - t\_0}{b + \sqrt{{b}^{2} - t\_0}}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -6.0000000000000002e138Initial program 46.6%
*-commutative46.6%
Simplified46.6%
Taylor expanded in b around -inf 94.4%
associate-*r/94.4%
mul-1-neg94.4%
Simplified94.4%
if -6.0000000000000002e138 < b < 4.59999999999999981e-112Initial program 85.3%
if 4.59999999999999981e-112 < b < 2.04999999999999997e33Initial program 49.9%
*-commutative49.9%
Simplified49.9%
add-cube-cbrt49.5%
pow349.6%
*-commutative49.6%
associate-*l*49.6%
Applied egg-rr49.6%
flip-+49.3%
pow249.3%
pow249.3%
pow249.3%
add-sqr-sqrt49.4%
unpow349.5%
add-cube-cbrt49.6%
Applied egg-rr49.9%
associate--r-84.6%
unpow284.6%
sqr-neg84.6%
unpow284.6%
Simplified84.6%
if 2.04999999999999997e33 < b Initial program 8.2%
*-commutative8.2%
Simplified8.2%
Taylor expanded in b around inf 88.7%
associate-*r/88.7%
neg-mul-188.7%
Simplified88.7%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+140)
(/ b (- a))
(if (<= b 8.5e-15)
(/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+140) {
tmp = b / -a;
} else if (b <= 8.5e-15) {
tmp = (sqrt(((b * b) - (4.0 * (a * 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 <= (-1d+140)) then
tmp = b / -a
else if (b <= 8.5d-15) then
tmp = (sqrt(((b * b) - (4.0d0 * (a * 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 <= -1e+140) {
tmp = b / -a;
} else if (b <= 8.5e-15) {
tmp = (Math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e+140: tmp = b / -a elif b <= 8.5e-15: tmp = (math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e+140) tmp = Float64(b / Float64(-a)); elseif (b <= 8.5e-15) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e+140) tmp = b / -a; elseif (b <= 8.5e-15) tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e+140], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 8.5e-15], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $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 -1 \cdot 10^{+140}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-15}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.00000000000000006e140Initial program 46.6%
*-commutative46.6%
Simplified46.6%
Taylor expanded in b around -inf 94.4%
associate-*r/94.4%
mul-1-neg94.4%
Simplified94.4%
if -1.00000000000000006e140 < b < 8.50000000000000007e-15Initial program 80.6%
if 8.50000000000000007e-15 < b Initial program 10.3%
*-commutative10.3%
Simplified10.3%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
neg-mul-187.7%
Simplified87.7%
Final simplification85.2%
(FPCore (a b c)
:precision binary64
(if (<= b -8.2e-97)
(* b (+ (/ c (pow b 2.0)) (/ -1.0 a)))
(if (<= b -1.05e-241)
(sqrt (* (* -4.0 (/ c a)) 0.25))
(if (<= b 9e-163)
(* -0.5 (/ 1.0 (sqrt (* -0.25 (/ a c)))))
(/ 1.0 (- (/ a b) (/ b c)))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e-97) {
tmp = b * ((c / pow(b, 2.0)) + (-1.0 / a));
} else if (b <= -1.05e-241) {
tmp = sqrt(((-4.0 * (c / a)) * 0.25));
} else if (b <= 9e-163) {
tmp = -0.5 * (1.0 / sqrt((-0.25 * (a / c))));
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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 <= (-8.2d-97)) then
tmp = b * ((c / (b ** 2.0d0)) + ((-1.0d0) / a))
else if (b <= (-1.05d-241)) then
tmp = sqrt((((-4.0d0) * (c / a)) * 0.25d0))
else if (b <= 9d-163) then
tmp = (-0.5d0) * (1.0d0 / sqrt(((-0.25d0) * (a / c))))
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e-97) {
tmp = b * ((c / Math.pow(b, 2.0)) + (-1.0 / a));
} else if (b <= -1.05e-241) {
tmp = Math.sqrt(((-4.0 * (c / a)) * 0.25));
} else if (b <= 9e-163) {
tmp = -0.5 * (1.0 / Math.sqrt((-0.25 * (a / c))));
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.2e-97: tmp = b * ((c / math.pow(b, 2.0)) + (-1.0 / a)) elif b <= -1.05e-241: tmp = math.sqrt(((-4.0 * (c / a)) * 0.25)) elif b <= 9e-163: tmp = -0.5 * (1.0 / math.sqrt((-0.25 * (a / c)))) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.2e-97) tmp = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); elseif (b <= -1.05e-241) tmp = sqrt(Float64(Float64(-4.0 * Float64(c / a)) * 0.25)); elseif (b <= 9e-163) tmp = Float64(-0.5 * Float64(1.0 / sqrt(Float64(-0.25 * Float64(a / c))))); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.2e-97) tmp = b * ((c / (b ^ 2.0)) + (-1.0 / a)); elseif (b <= -1.05e-241) tmp = sqrt(((-4.0 * (c / a)) * 0.25)); elseif (b <= 9e-163) tmp = -0.5 * (1.0 / sqrt((-0.25 * (a / c)))); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.2e-97], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -1.05e-241], N[Sqrt[N[(N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[b, 9e-163], N[(-0.5 * N[(1.0 / N[Sqrt[N[(-0.25 * N[(a / c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.2 \cdot 10^{-97}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\mathbf{elif}\;b \leq -1.05 \cdot 10^{-241}:\\
\;\;\;\;\sqrt{\left(-4 \cdot \frac{c}{a}\right) \cdot 0.25}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-163}:\\
\;\;\;\;-0.5 \cdot \frac{1}{\sqrt{-0.25 \cdot \frac{a}{c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -8.19999999999999986e-97Initial program 70.0%
*-commutative70.0%
Simplified70.0%
Taylor expanded in b around -inf 82.9%
mul-1-neg82.9%
distribute-rgt-neg-in82.9%
+-commutative82.9%
mul-1-neg82.9%
unsub-neg82.9%
Simplified82.9%
if -8.19999999999999986e-97 < b < -1.05e-241Initial program 88.9%
*-commutative88.9%
Simplified88.9%
add-cube-cbrt88.1%
pow388.0%
*-commutative88.0%
associate-*l*88.0%
Applied egg-rr88.0%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt57.3%
rem-cube-cbrt57.7%
associate-/l*57.7%
Simplified57.7%
associate-*r/57.7%
Applied egg-rr57.7%
add-sqr-sqrt57.5%
sqrt-unprod57.7%
*-commutative57.7%
*-commutative57.7%
swap-sqr57.7%
mul-1-neg57.7%
mul-1-neg57.7%
sqr-neg57.7%
add-sqr-sqrt57.7%
*-commutative57.7%
associate-/l*57.7%
metadata-eval57.7%
Applied egg-rr57.7%
if -1.05e-241 < b < 8.9999999999999995e-163Initial program 82.8%
*-commutative82.8%
Simplified82.8%
add-cube-cbrt82.4%
pow382.4%
*-commutative82.4%
associate-*l*82.4%
Applied egg-rr82.4%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt28.0%
rem-cube-cbrt28.1%
associate-/l*28.0%
Simplified28.0%
associate-*r/28.1%
Applied egg-rr28.1%
add-sqr-sqrt0.8%
sqrt-unprod42.9%
mul-1-neg42.9%
mul-1-neg42.9%
sqr-neg42.9%
add-sqr-sqrt42.9%
clear-num42.8%
sqrt-div45.0%
metadata-eval45.0%
*-un-lft-identity45.0%
*-commutative45.0%
times-frac45.0%
metadata-eval45.0%
Applied egg-rr45.0%
if 8.9999999999999995e-163 < b Initial program 21.6%
*-commutative21.6%
Simplified21.6%
add-exp-log14.3%
frac-2neg14.3%
Applied egg-rr14.3%
rem-exp-log21.6%
clear-num21.6%
Applied egg-rr21.6%
Taylor expanded in a around 0 76.3%
+-commutative76.3%
mul-1-neg76.3%
unsub-neg76.3%
Simplified76.3%
Final simplification73.3%
(FPCore (a b c)
:precision binary64
(if (<= b -8.4e-97)
(/ b (- a))
(if (<= b -2.4e-242)
(sqrt (* (* -4.0 (/ c a)) 0.25))
(if (<= b 1.05e-162)
(* -0.5 (/ 1.0 (sqrt (* -0.25 (/ a c)))))
(/ 1.0 (- (/ a b) (/ b c)))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.4e-97) {
tmp = b / -a;
} else if (b <= -2.4e-242) {
tmp = sqrt(((-4.0 * (c / a)) * 0.25));
} else if (b <= 1.05e-162) {
tmp = -0.5 * (1.0 / sqrt((-0.25 * (a / c))));
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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 <= (-8.4d-97)) then
tmp = b / -a
else if (b <= (-2.4d-242)) then
tmp = sqrt((((-4.0d0) * (c / a)) * 0.25d0))
else if (b <= 1.05d-162) then
tmp = (-0.5d0) * (1.0d0 / sqrt(((-0.25d0) * (a / c))))
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8.4e-97) {
tmp = b / -a;
} else if (b <= -2.4e-242) {
tmp = Math.sqrt(((-4.0 * (c / a)) * 0.25));
} else if (b <= 1.05e-162) {
tmp = -0.5 * (1.0 / Math.sqrt((-0.25 * (a / c))));
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.4e-97: tmp = b / -a elif b <= -2.4e-242: tmp = math.sqrt(((-4.0 * (c / a)) * 0.25)) elif b <= 1.05e-162: tmp = -0.5 * (1.0 / math.sqrt((-0.25 * (a / c)))) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.4e-97) tmp = Float64(b / Float64(-a)); elseif (b <= -2.4e-242) tmp = sqrt(Float64(Float64(-4.0 * Float64(c / a)) * 0.25)); elseif (b <= 1.05e-162) tmp = Float64(-0.5 * Float64(1.0 / sqrt(Float64(-0.25 * Float64(a / c))))); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.4e-97) tmp = b / -a; elseif (b <= -2.4e-242) tmp = sqrt(((-4.0 * (c / a)) * 0.25)); elseif (b <= 1.05e-162) tmp = -0.5 * (1.0 / sqrt((-0.25 * (a / c)))); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.4e-97], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, -2.4e-242], N[Sqrt[N[(N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[b, 1.05e-162], N[(-0.5 * N[(1.0 / N[Sqrt[N[(-0.25 * N[(a / c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.4 \cdot 10^{-97}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq -2.4 \cdot 10^{-242}:\\
\;\;\;\;\sqrt{\left(-4 \cdot \frac{c}{a}\right) \cdot 0.25}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-162}:\\
\;\;\;\;-0.5 \cdot \frac{1}{\sqrt{-0.25 \cdot \frac{a}{c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -8.4000000000000005e-97Initial program 70.0%
*-commutative70.0%
Simplified70.0%
Taylor expanded in b around -inf 82.7%
associate-*r/82.7%
mul-1-neg82.7%
Simplified82.7%
if -8.4000000000000005e-97 < b < -2.4000000000000001e-242Initial program 88.9%
*-commutative88.9%
Simplified88.9%
add-cube-cbrt88.1%
pow388.0%
*-commutative88.0%
associate-*l*88.0%
Applied egg-rr88.0%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt57.3%
rem-cube-cbrt57.7%
associate-/l*57.7%
Simplified57.7%
associate-*r/57.7%
Applied egg-rr57.7%
add-sqr-sqrt57.5%
sqrt-unprod57.7%
*-commutative57.7%
*-commutative57.7%
swap-sqr57.7%
mul-1-neg57.7%
mul-1-neg57.7%
sqr-neg57.7%
add-sqr-sqrt57.7%
*-commutative57.7%
associate-/l*57.7%
metadata-eval57.7%
Applied egg-rr57.7%
if -2.4000000000000001e-242 < b < 1.05e-162Initial program 82.8%
*-commutative82.8%
Simplified82.8%
add-cube-cbrt82.4%
pow382.4%
*-commutative82.4%
associate-*l*82.4%
Applied egg-rr82.4%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt28.0%
rem-cube-cbrt28.1%
associate-/l*28.0%
Simplified28.0%
associate-*r/28.1%
Applied egg-rr28.1%
add-sqr-sqrt0.8%
sqrt-unprod42.9%
mul-1-neg42.9%
mul-1-neg42.9%
sqr-neg42.9%
add-sqr-sqrt42.9%
clear-num42.8%
sqrt-div45.0%
metadata-eval45.0%
*-un-lft-identity45.0%
*-commutative45.0%
times-frac45.0%
metadata-eval45.0%
Applied egg-rr45.0%
if 1.05e-162 < b Initial program 21.6%
*-commutative21.6%
Simplified21.6%
add-exp-log14.3%
frac-2neg14.3%
Applied egg-rr14.3%
rem-exp-log21.6%
clear-num21.6%
Applied egg-rr21.6%
Taylor expanded in a around 0 76.3%
+-commutative76.3%
mul-1-neg76.3%
unsub-neg76.3%
Simplified76.3%
Final simplification73.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* -4.0 (/ c a))))
(if (<= b -7.5e-97)
(/ b (- a))
(if (<= b -4.1e-241)
(sqrt (* t_0 0.25))
(if (<= b 8.2e-163) (* -0.5 (sqrt t_0)) (/ 1.0 (- (/ a b) (/ b c))))))))
double code(double a, double b, double c) {
double t_0 = -4.0 * (c / a);
double tmp;
if (b <= -7.5e-97) {
tmp = b / -a;
} else if (b <= -4.1e-241) {
tmp = sqrt((t_0 * 0.25));
} else if (b <= 8.2e-163) {
tmp = -0.5 * sqrt(t_0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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) :: tmp
t_0 = (-4.0d0) * (c / a)
if (b <= (-7.5d-97)) then
tmp = b / -a
else if (b <= (-4.1d-241)) then
tmp = sqrt((t_0 * 0.25d0))
else if (b <= 8.2d-163) then
tmp = (-0.5d0) * sqrt(t_0)
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -4.0 * (c / a);
double tmp;
if (b <= -7.5e-97) {
tmp = b / -a;
} else if (b <= -4.1e-241) {
tmp = Math.sqrt((t_0 * 0.25));
} else if (b <= 8.2e-163) {
tmp = -0.5 * Math.sqrt(t_0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): t_0 = -4.0 * (c / a) tmp = 0 if b <= -7.5e-97: tmp = b / -a elif b <= -4.1e-241: tmp = math.sqrt((t_0 * 0.25)) elif b <= 8.2e-163: tmp = -0.5 * math.sqrt(t_0) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) t_0 = Float64(-4.0 * Float64(c / a)) tmp = 0.0 if (b <= -7.5e-97) tmp = Float64(b / Float64(-a)); elseif (b <= -4.1e-241) tmp = sqrt(Float64(t_0 * 0.25)); elseif (b <= 8.2e-163) tmp = Float64(-0.5 * sqrt(t_0)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = -4.0 * (c / a); tmp = 0.0; if (b <= -7.5e-97) tmp = b / -a; elseif (b <= -4.1e-241) tmp = sqrt((t_0 * 0.25)); elseif (b <= 8.2e-163) tmp = -0.5 * sqrt(t_0); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -7.5e-97], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, -4.1e-241], N[Sqrt[N[(t$95$0 * 0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[b, 8.2e-163], N[(-0.5 * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{c}{a}\\
\mathbf{if}\;b \leq -7.5 \cdot 10^{-97}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq -4.1 \cdot 10^{-241}:\\
\;\;\;\;\sqrt{t\_0 \cdot 0.25}\\
\mathbf{elif}\;b \leq 8.2 \cdot 10^{-163}:\\
\;\;\;\;-0.5 \cdot \sqrt{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -7.5e-97Initial program 70.0%
*-commutative70.0%
Simplified70.0%
Taylor expanded in b around -inf 82.7%
associate-*r/82.7%
mul-1-neg82.7%
Simplified82.7%
if -7.5e-97 < b < -4.0999999999999999e-241Initial program 88.9%
*-commutative88.9%
Simplified88.9%
add-cube-cbrt88.1%
pow388.0%
*-commutative88.0%
associate-*l*88.0%
Applied egg-rr88.0%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt57.3%
rem-cube-cbrt57.7%
associate-/l*57.7%
Simplified57.7%
associate-*r/57.7%
Applied egg-rr57.7%
add-sqr-sqrt57.5%
sqrt-unprod57.7%
*-commutative57.7%
*-commutative57.7%
swap-sqr57.7%
mul-1-neg57.7%
mul-1-neg57.7%
sqr-neg57.7%
add-sqr-sqrt57.7%
*-commutative57.7%
associate-/l*57.7%
metadata-eval57.7%
Applied egg-rr57.7%
if -4.0999999999999999e-241 < b < 8.19999999999999965e-163Initial program 82.8%
*-commutative82.8%
Simplified82.8%
add-cube-cbrt82.4%
pow382.4%
*-commutative82.4%
associate-*l*82.4%
Applied egg-rr82.4%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt28.0%
rem-cube-cbrt28.1%
associate-/l*28.0%
Simplified28.0%
associate-*r/28.1%
Applied egg-rr28.1%
add-sqr-sqrt0.8%
sqrt-unprod42.9%
mul-1-neg42.9%
mul-1-neg42.9%
sqr-neg42.9%
add-sqr-sqrt42.9%
*-commutative42.9%
associate-/l*42.9%
Applied egg-rr42.9%
if 8.19999999999999965e-163 < b Initial program 21.6%
*-commutative21.6%
Simplified21.6%
add-exp-log14.3%
frac-2neg14.3%
Applied egg-rr14.3%
rem-exp-log21.6%
clear-num21.6%
Applied egg-rr21.6%
Taylor expanded in a around 0 76.3%
+-commutative76.3%
mul-1-neg76.3%
unsub-neg76.3%
Simplified76.3%
Final simplification73.0%
(FPCore (a b c) :precision binary64 (if (<= b -5.4e-92) (* b (+ (/ c (pow b 2.0)) (/ -1.0 a))) (if (<= b 6e-9) (/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.4e-92) {
tmp = b * ((c / pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 6e-9) {
tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.4d-92)) then
tmp = b * ((c / (b ** 2.0d0)) + ((-1.0d0) / a))
else if (b <= 6d-9) then
tmp = (sqrt((c * (a * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.4e-92) {
tmp = b * ((c / Math.pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 6e-9) {
tmp = (Math.sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.4e-92: tmp = b * ((c / math.pow(b, 2.0)) + (-1.0 / a)) elif b <= 6e-9: tmp = (math.sqrt((c * (a * -4.0))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.4e-92) tmp = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); elseif (b <= 6e-9) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.4e-92) tmp = b * ((c / (b ^ 2.0)) + (-1.0 / a)); elseif (b <= 6e-9) tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.4e-92], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6e-9], N[(N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.4 \cdot 10^{-92}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-9}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -5.3999999999999999e-92Initial program 69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in b around -inf 83.7%
mul-1-neg83.7%
distribute-rgt-neg-in83.7%
+-commutative83.7%
mul-1-neg83.7%
unsub-neg83.7%
Simplified83.7%
if -5.3999999999999999e-92 < b < 5.99999999999999996e-9Initial program 74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in b around 0 69.8%
associate-*r*69.8%
*-commutative69.8%
*-commutative69.8%
Simplified69.8%
if 5.99999999999999996e-9 < b Initial program 10.3%
*-commutative10.3%
Simplified10.3%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
neg-mul-187.7%
Simplified87.7%
Final simplification80.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e-96)
(/ b (- a))
(if (<= b 6.2e-160)
(sqrt (* (* -4.0 (/ c a)) 0.25))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-96) {
tmp = b / -a;
} else if (b <= 6.2e-160) {
tmp = sqrt(((-4.0 * (c / a)) * 0.25));
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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.15d-96)) then
tmp = b / -a
else if (b <= 6.2d-160) then
tmp = sqrt((((-4.0d0) * (c / a)) * 0.25d0))
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-96) {
tmp = b / -a;
} else if (b <= 6.2e-160) {
tmp = Math.sqrt(((-4.0 * (c / a)) * 0.25));
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e-96: tmp = b / -a elif b <= 6.2e-160: tmp = math.sqrt(((-4.0 * (c / a)) * 0.25)) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e-96) tmp = Float64(b / Float64(-a)); elseif (b <= 6.2e-160) tmp = sqrt(Float64(Float64(-4.0 * Float64(c / a)) * 0.25)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.15e-96) tmp = b / -a; elseif (b <= 6.2e-160) tmp = sqrt(((-4.0 * (c / a)) * 0.25)); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e-96], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 6.2e-160], N[Sqrt[N[(N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]], $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{-96}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-160}:\\
\;\;\;\;\sqrt{\left(-4 \cdot \frac{c}{a}\right) \cdot 0.25}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -1.15e-96Initial program 70.0%
*-commutative70.0%
Simplified70.0%
Taylor expanded in b around -inf 82.7%
associate-*r/82.7%
mul-1-neg82.7%
Simplified82.7%
if -1.15e-96 < b < 6.2000000000000001e-160Initial program 85.1%
*-commutative85.1%
Simplified85.1%
add-cube-cbrt84.6%
pow384.5%
*-commutative84.5%
associate-*l*84.5%
Applied egg-rr84.5%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt38.9%
rem-cube-cbrt39.2%
associate-/l*39.1%
Simplified39.1%
associate-*r/39.2%
Applied egg-rr39.2%
add-sqr-sqrt38.9%
sqrt-unprod39.2%
*-commutative39.2%
*-commutative39.2%
swap-sqr39.2%
mul-1-neg39.2%
mul-1-neg39.2%
sqr-neg39.2%
add-sqr-sqrt39.2%
*-commutative39.2%
associate-/l*39.2%
metadata-eval39.2%
Applied egg-rr39.2%
if 6.2000000000000001e-160 < b Initial program 20.9%
*-commutative20.9%
Simplified20.9%
add-exp-log13.6%
frac-2neg13.6%
Applied egg-rr13.6%
rem-exp-log20.9%
clear-num20.8%
Applied egg-rr20.8%
Taylor expanded in a around 0 76.9%
+-commutative76.9%
mul-1-neg76.9%
unsub-neg76.9%
Simplified76.9%
Final simplification71.4%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (/ b (- a)) (/ 1.0 (- (/ a b) (/ b c)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = b / -a;
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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 <= (-1d-310)) then
tmp = b / -a
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = b / -a;
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = b / -a else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(b / Float64(-a)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = b / -a; else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(b / (-a)), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in b around -inf 65.8%
associate-*r/65.8%
mul-1-neg65.8%
Simplified65.8%
if -9.999999999999969e-311 < b Initial program 30.9%
*-commutative30.9%
Simplified30.9%
add-exp-log18.2%
frac-2neg18.2%
Applied egg-rr18.2%
rem-exp-log30.9%
clear-num30.8%
Applied egg-rr30.8%
Taylor expanded in a around 0 65.4%
+-commutative65.4%
mul-1-neg65.4%
unsub-neg65.4%
Simplified65.4%
Final simplification65.6%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e-272) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-272) {
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.7d-272) 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.7e-272) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e-272: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e-272) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.7e-272) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e-272], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-272}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 2.69999999999999993e-272Initial program 75.7%
*-commutative75.7%
Simplified75.7%
Taylor expanded in b around -inf 63.4%
associate-*r/63.4%
mul-1-neg63.4%
Simplified63.4%
if 2.69999999999999993e-272 < b Initial program 28.3%
*-commutative28.3%
Simplified28.3%
Taylor expanded in b around inf 67.6%
associate-*r/67.6%
neg-mul-167.6%
Simplified67.6%
Final simplification65.5%
(FPCore (a b c) :precision binary64 (if (<= b 3.8e-7) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.8e-7) {
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 <= 3.8d-7) 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 <= 3.8e-7) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.8e-7: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.8e-7) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.8e-7) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.8e-7], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 3.80000000000000015e-7Initial program 72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in b around -inf 47.8%
associate-*r/47.8%
mul-1-neg47.8%
Simplified47.8%
if 3.80000000000000015e-7 < b Initial program 10.3%
*-commutative10.3%
Simplified10.3%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
neg-mul-187.7%
Simplified87.7%
add-sqr-sqrt41.8%
sqrt-unprod41.2%
sqr-neg41.2%
sqrt-unprod14.9%
add-sqr-sqrt23.4%
*-un-lft-identity23.4%
Applied egg-rr23.4%
*-lft-identity23.4%
Simplified23.4%
Final simplification39.8%
(FPCore (a b c) :precision binary64 (if (<= b 1.05e+70) (* b (- c)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.05e+70) {
tmp = b * -c;
} 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.05d+70) then
tmp = b * -c
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.05e+70) {
tmp = b * -c;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.05e+70: tmp = b * -c else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.05e+70) tmp = Float64(b * Float64(-c)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.05e+70) tmp = b * -c; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.05e+70], N[(b * (-c)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.05 \cdot 10^{+70}:\\
\;\;\;\;b \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.05000000000000004e70Initial program 66.0%
*-commutative66.0%
Simplified66.0%
Taylor expanded in b around inf 17.3%
associate-*r/17.3%
neg-mul-117.3%
Simplified17.3%
frac-2neg17.3%
div-inv17.2%
remove-double-neg17.2%
add-exp-log1.3%
metadata-eval1.3%
frac-2neg1.3%
add-sqr-sqrt0.4%
sqrt-unprod4.5%
sqr-neg4.5%
sqrt-unprod4.1%
add-sqr-sqrt4.7%
rec-exp4.7%
add-exp-log7.0%
frac-2neg7.0%
metadata-eval7.0%
remove-double-div7.0%
Applied egg-rr7.0%
if 1.05000000000000004e70 < b Initial program 7.4%
*-commutative7.4%
Simplified7.4%
Taylor expanded in b around inf 90.9%
associate-*r/90.9%
neg-mul-190.9%
Simplified90.9%
add-sqr-sqrt43.4%
sqrt-unprod48.9%
sqr-neg48.9%
sqrt-unprod19.4%
add-sqr-sqrt30.3%
*-un-lft-identity30.3%
Applied egg-rr30.3%
*-lft-identity30.3%
Simplified30.3%
Final simplification12.7%
(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 51.8%
*-commutative51.8%
Simplified51.8%
Taylor expanded in b around inf 35.1%
associate-*r/35.1%
neg-mul-135.1%
Simplified35.1%
add-sqr-sqrt17.0%
sqrt-unprod17.9%
sqr-neg17.9%
sqrt-unprod5.7%
add-sqr-sqrt9.8%
*-un-lft-identity9.8%
Applied egg-rr9.8%
*-lft-identity9.8%
Simplified9.8%
(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 51.8%
*-commutative51.8%
Simplified51.8%
Taylor expanded in b around -inf 32.9%
associate-*r/32.9%
mul-1-neg32.9%
Simplified32.9%
add-sqr-sqrt31.2%
sqrt-unprod25.0%
sqr-neg25.0%
sqrt-prod1.9%
add-sqr-sqrt2.7%
add-cbrt-cube2.3%
pow1/311.2%
pow311.2%
Applied egg-rr11.2%
Taylor expanded in b around 0 2.7%
(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}
\\
b \cdot a
\end{array}
Initial program 51.8%
*-commutative51.8%
Simplified51.8%
Taylor expanded in b around -inf 32.9%
associate-*r/32.9%
mul-1-neg32.9%
Simplified32.9%
add-sqr-sqrt31.2%
sqrt-unprod25.0%
sqr-neg25.0%
sqrt-prod1.9%
add-sqr-sqrt2.7%
add-cbrt-cube2.3%
pow1/311.2%
pow311.2%
Applied egg-rr11.2%
expm1-log1p-u5.6%
*-un-lft-identity5.6%
unpow1/32.0%
rem-cbrt-cube2.2%
div-inv2.2%
expm1-log1p-u2.7%
rem-exp-log1.4%
neg-log1.4%
add-sqr-sqrt0.5%
sqrt-unprod1.2%
sqr-neg1.2%
sqrt-unprod0.7%
add-sqr-sqrt1.3%
add-exp-log2.4%
Applied egg-rr2.4%
*-lft-identity2.4%
Simplified2.4%
(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) (/ (- t_2 (/ b 2.0)) a) (/ (- c) (+ (/ b 2.0) t_2)))))
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 = (t_2 - (b / 2.0)) / a;
} else {
tmp_1 = -c / ((b / 2.0) + t_2);
}
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 = (t_2 - (b / 2.0)) / a;
} else {
tmp_1 = -c / ((b / 2.0) + t_2);
}
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 = (t_2 - (b / 2.0)) / a else: tmp_1 = -c / ((b / 2.0) + t_2) 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(Float64(t_2 - Float64(b / 2.0)) / a); else tmp_1 = Float64(Float64(-c) / Float64(Float64(b / 2.0) + t_2)); 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 = (t_2 - (b / 2.0)) / a; else tmp_2 = -c / ((b / 2.0) + t_2); 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[(N[(t$95$2 - N[(b / 2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / N[(N[(b / 2.0), $MachinePrecision] + t$95$2), $MachinePrecision]), $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{t\_2 - \frac{b}{2}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{\frac{b}{2} + t\_2}\\
\end{array}
\end{array}
herbie shell --seed 2024133
(FPCore (a b c)
:name "quadp (p42, positive)"
:precision binary64
:herbie-expected 10
:alt
(! :herbie-platform default (let ((sqtD (let ((x (* (sqrt (fabs a)) (sqrt (fabs c))))) (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2)) x)) (sqrt (+ (fabs (/ b 2)) x))) (hypot (/ b 2) x))))) (if (< b 0) (/ (- sqtD (/ b 2)) a) (/ (- c) (+ (/ b 2) sqtD)))))
(/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))