
(FPCore (a b c d) :precision binary64 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= t_0 (- INFINITY))
(/ (fma b (/ d c) a) c)
(if (<= t_0 2e+237)
(/ (/ (fma a c (* b d)) (hypot c d)) (hypot c d))
(+ (/ b d) (* (/ c d) (/ a d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = fma(b, (d / c), a) / c;
} else if (t_0 <= 2e+237) {
tmp = (fma(a, c, (b * d)) / hypot(c, d)) / hypot(c, d);
} else {
tmp = (b / d) + ((c / d) * (a / d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(fma(b, Float64(d / c), a) / c); elseif (t_0 <= 2e+237) tmp = Float64(Float64(fma(a, c, Float64(b * d)) / hypot(c, d)) / hypot(c, d)); else tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$0, 2e+237], N[(N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+237}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0Initial program 44.0%
Taylor expanded in c around inf 42.9%
unpow242.9%
Simplified42.9%
+-commutative42.9%
associate-/r*71.6%
frac-add44.0%
*-commutative44.0%
Applied egg-rr44.0%
+-commutative44.0%
*-commutative44.0%
distribute-lft-out44.0%
*-commutative44.0%
*-commutative44.0%
associate-*r/44.0%
Simplified44.0%
expm1-log1p-u0.0%
expm1-udef0.0%
times-frac0.0%
pow10.0%
pow10.0%
pow-div0.0%
metadata-eval0.0%
metadata-eval0.0%
*-un-lft-identity0.0%
+-commutative0.0%
fma-def0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p83.2%
Simplified83.2%
if -inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.99999999999999988e237Initial program 81.6%
*-un-lft-identity81.6%
add-sqr-sqrt81.6%
times-frac81.5%
hypot-def81.6%
fma-def81.6%
hypot-def98.9%
Applied egg-rr98.9%
associate-*l/99.2%
*-un-lft-identity99.2%
Applied egg-rr99.2%
if 1.99999999999999988e237 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 15.2%
Taylor expanded in c around 0 55.5%
unpow255.5%
times-frac65.3%
Simplified65.3%
Final simplification89.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.65e+89)
(* (+ b (pow (/ (/ d a) c) -1.0)) (/ -1.0 (hypot c d)))
(if (<= d -7e-105)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= d 3.2e-97)
(/ (fma b (/ d c) a) c)
(if (<= d 2.9e+112)
(/ (fma a c (* b d)) (fma c c (* d d)))
(/
(+ b (fma -0.5 (* (/ b d) (* c (/ c d))) (/ c (/ d a))))
(hypot c d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.65e+89) {
tmp = (b + pow(((d / a) / c), -1.0)) * (-1.0 / hypot(c, d));
} else if (d <= -7e-105) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (d <= 3.2e-97) {
tmp = fma(b, (d / c), a) / c;
} else if (d <= 2.9e+112) {
tmp = fma(a, c, (b * d)) / fma(c, c, (d * d));
} else {
tmp = (b + fma(-0.5, ((b / d) * (c * (c / d))), (c / (d / a)))) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -1.65e+89) tmp = Float64(Float64(b + (Float64(Float64(d / a) / c) ^ -1.0)) * Float64(-1.0 / hypot(c, d))); elseif (d <= -7e-105) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 3.2e-97) tmp = Float64(fma(b, Float64(d / c), a) / c); elseif (d <= 2.9e+112) tmp = Float64(fma(a, c, Float64(b * d)) / fma(c, c, Float64(d * d))); else tmp = Float64(Float64(b + fma(-0.5, Float64(Float64(b / d) * Float64(c * Float64(c / d))), Float64(c / Float64(d / a)))) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.65e+89], N[(N[(b + N[Power[N[(N[(d / a), $MachinePrecision] / c), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7e-105], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.2e-97], N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.9e+112], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(-0.5 * N[(N[(b / d), $MachinePrecision] * N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c / N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.65 \cdot 10^{+89}:\\
\;\;\;\;\left(b + {\left(\frac{\frac{d}{a}}{c}\right)}^{-1}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -7 \cdot 10^{-105}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 3.2 \cdot 10^{-97}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
\mathbf{elif}\;d \leq 2.9 \cdot 10^{+112}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \mathsf{fma}\left(-0.5, \frac{b}{d} \cdot \left(c \cdot \frac{c}{d}\right), \frac{c}{\frac{d}{a}}\right)}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -1.64999999999999987e89Initial program 27.0%
*-un-lft-identity27.0%
add-sqr-sqrt27.0%
times-frac27.0%
hypot-def27.0%
fma-def27.0%
hypot-def41.8%
Applied egg-rr41.8%
Taylor expanded in d around -inf 85.4%
mul-1-neg85.4%
unsub-neg85.4%
mul-1-neg85.4%
associate-/l*90.3%
Simplified90.3%
clear-num90.3%
inv-pow90.3%
Applied egg-rr90.3%
if -1.64999999999999987e89 < d < -7e-105Initial program 77.1%
if -7e-105 < d < 3.1999999999999998e-97Initial program 70.7%
Taylor expanded in c around inf 81.0%
unpow281.0%
Simplified81.0%
+-commutative81.0%
associate-/r*90.7%
frac-add66.0%
*-commutative66.0%
Applied egg-rr66.0%
+-commutative66.0%
*-commutative66.0%
distribute-lft-out66.0%
*-commutative66.0%
*-commutative66.0%
associate-*r/66.1%
Simplified66.1%
expm1-log1p-u44.8%
expm1-udef25.1%
times-frac32.7%
pow132.7%
pow132.7%
pow-div32.7%
metadata-eval32.7%
metadata-eval32.7%
*-un-lft-identity32.7%
+-commutative32.7%
fma-def32.7%
Applied egg-rr32.7%
expm1-def63.1%
expm1-log1p91.9%
Simplified91.9%
if 3.1999999999999998e-97 < d < 2.9000000000000002e112Initial program 80.9%
fma-def80.9%
fma-def80.9%
Simplified80.9%
if 2.9000000000000002e112 < d Initial program 39.5%
*-un-lft-identity39.5%
add-sqr-sqrt39.5%
times-frac39.5%
hypot-def39.5%
fma-def39.5%
hypot-def65.4%
Applied egg-rr65.4%
associate-*l/65.5%
*-un-lft-identity65.5%
Applied egg-rr65.5%
Taylor expanded in c around 0 63.7%
+-commutative63.7%
fma-def63.7%
unpow263.7%
*-commutative63.7%
unpow263.7%
times-frac67.9%
associate-*r/78.0%
associate-/l*81.9%
Simplified81.9%
Final simplification85.5%
(FPCore (a b c d)
:precision binary64
(if (<= d -5.2e+82)
(* (+ b (/ c (/ d a))) (/ -1.0 (hypot c d)))
(if (<= d -3.5e-105)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= d 5.5e-87)
(/ (fma b (/ d c) a) c)
(if (<= d 2e+111)
(/ (fma a c (* b d)) (fma c c (* d d)))
(* (/ -1.0 d) (- (/ (- c) (/ d a)) b)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.2e+82) {
tmp = (b + (c / (d / a))) * (-1.0 / hypot(c, d));
} else if (d <= -3.5e-105) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (d <= 5.5e-87) {
tmp = fma(b, (d / c), a) / c;
} else if (d <= 2e+111) {
tmp = fma(a, c, (b * d)) / fma(c, c, (d * d));
} else {
tmp = (-1.0 / d) * ((-c / (d / a)) - b);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -5.2e+82) tmp = Float64(Float64(b + Float64(c / Float64(d / a))) * Float64(-1.0 / hypot(c, d))); elseif (d <= -3.5e-105) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 5.5e-87) tmp = Float64(fma(b, Float64(d / c), a) / c); elseif (d <= 2e+111) tmp = Float64(fma(a, c, Float64(b * d)) / fma(c, c, Float64(d * d))); else tmp = Float64(Float64(-1.0 / d) * Float64(Float64(Float64(-c) / Float64(d / a)) - b)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.2e+82], N[(N[(b + N[(c / N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.5e-105], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.5e-87], N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2e+111], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / d), $MachinePrecision] * N[(N[((-c) / N[(d / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.2 \cdot 10^{+82}:\\
\;\;\;\;\left(b + \frac{c}{\frac{d}{a}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -3.5 \cdot 10^{-105}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{-87}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+111}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{d} \cdot \left(\frac{-c}{\frac{d}{a}} - b\right)\\
\end{array}
\end{array}
if d < -5.1999999999999997e82Initial program 30.9%
*-un-lft-identity30.9%
add-sqr-sqrt30.9%
times-frac31.0%
hypot-def31.0%
fma-def31.0%
hypot-def45.0%
Applied egg-rr45.0%
Taylor expanded in d around -inf 86.1%
mul-1-neg86.1%
unsub-neg86.1%
mul-1-neg86.1%
associate-/l*90.8%
Simplified90.8%
if -5.1999999999999997e82 < d < -3.5e-105Initial program 76.0%
if -3.5e-105 < d < 5.5000000000000004e-87Initial program 70.7%
Taylor expanded in c around inf 81.0%
unpow281.0%
Simplified81.0%
+-commutative81.0%
associate-/r*90.7%
frac-add66.0%
*-commutative66.0%
Applied egg-rr66.0%
+-commutative66.0%
*-commutative66.0%
distribute-lft-out66.0%
*-commutative66.0%
*-commutative66.0%
associate-*r/66.1%
Simplified66.1%
expm1-log1p-u44.8%
expm1-udef25.1%
times-frac32.7%
pow132.7%
pow132.7%
pow-div32.7%
metadata-eval32.7%
metadata-eval32.7%
*-un-lft-identity32.7%
+-commutative32.7%
fma-def32.7%
Applied egg-rr32.7%
expm1-def63.1%
expm1-log1p91.9%
Simplified91.9%
if 5.5000000000000004e-87 < d < 1.99999999999999991e111Initial program 80.9%
fma-def80.9%
fma-def80.9%
Simplified80.9%
if 1.99999999999999991e111 < d Initial program 39.5%
*-un-lft-identity39.5%
add-sqr-sqrt39.5%
times-frac39.5%
hypot-def39.5%
fma-def39.5%
hypot-def65.4%
Applied egg-rr65.4%
Taylor expanded in d around -inf 22.7%
mul-1-neg22.7%
unsub-neg22.7%
mul-1-neg22.7%
associate-/l*22.8%
Simplified22.8%
Taylor expanded in d around -inf 81.3%
Final simplification85.3%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.85e+89)
(* (+ b (pow (/ (/ d a) c) -1.0)) (/ -1.0 (hypot c d)))
(if (<= d -3.3e-102)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= d 1.25e-95)
(/ (fma b (/ d c) a) c)
(if (<= d 2e+111)
(/ (fma a c (* b d)) (fma c c (* d d)))
(* (/ -1.0 d) (- (/ (- c) (/ d a)) b)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.85e+89) {
tmp = (b + pow(((d / a) / c), -1.0)) * (-1.0 / hypot(c, d));
} else if (d <= -3.3e-102) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (d <= 1.25e-95) {
tmp = fma(b, (d / c), a) / c;
} else if (d <= 2e+111) {
tmp = fma(a, c, (b * d)) / fma(c, c, (d * d));
} else {
tmp = (-1.0 / d) * ((-c / (d / a)) - b);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -2.85e+89) tmp = Float64(Float64(b + (Float64(Float64(d / a) / c) ^ -1.0)) * Float64(-1.0 / hypot(c, d))); elseif (d <= -3.3e-102) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1.25e-95) tmp = Float64(fma(b, Float64(d / c), a) / c); elseif (d <= 2e+111) tmp = Float64(fma(a, c, Float64(b * d)) / fma(c, c, Float64(d * d))); else tmp = Float64(Float64(-1.0 / d) * Float64(Float64(Float64(-c) / Float64(d / a)) - b)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.85e+89], N[(N[(b + N[Power[N[(N[(d / a), $MachinePrecision] / c), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.3e-102], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.25e-95], N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2e+111], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / d), $MachinePrecision] * N[(N[((-c) / N[(d / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.85 \cdot 10^{+89}:\\
\;\;\;\;\left(b + {\left(\frac{\frac{d}{a}}{c}\right)}^{-1}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -3.3 \cdot 10^{-102}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.25 \cdot 10^{-95}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+111}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{d} \cdot \left(\frac{-c}{\frac{d}{a}} - b\right)\\
\end{array}
\end{array}
if d < -2.84999999999999975e89Initial program 27.0%
*-un-lft-identity27.0%
add-sqr-sqrt27.0%
times-frac27.0%
hypot-def27.0%
fma-def27.0%
hypot-def41.8%
Applied egg-rr41.8%
Taylor expanded in d around -inf 85.4%
mul-1-neg85.4%
unsub-neg85.4%
mul-1-neg85.4%
associate-/l*90.3%
Simplified90.3%
clear-num90.3%
inv-pow90.3%
Applied egg-rr90.3%
if -2.84999999999999975e89 < d < -3.3e-102Initial program 77.1%
if -3.3e-102 < d < 1.2499999999999999e-95Initial program 70.7%
Taylor expanded in c around inf 81.0%
unpow281.0%
Simplified81.0%
+-commutative81.0%
associate-/r*90.7%
frac-add66.0%
*-commutative66.0%
Applied egg-rr66.0%
+-commutative66.0%
*-commutative66.0%
distribute-lft-out66.0%
*-commutative66.0%
*-commutative66.0%
associate-*r/66.1%
Simplified66.1%
expm1-log1p-u44.8%
expm1-udef25.1%
times-frac32.7%
pow132.7%
pow132.7%
pow-div32.7%
metadata-eval32.7%
metadata-eval32.7%
*-un-lft-identity32.7%
+-commutative32.7%
fma-def32.7%
Applied egg-rr32.7%
expm1-def63.1%
expm1-log1p91.9%
Simplified91.9%
if 1.2499999999999999e-95 < d < 1.99999999999999991e111Initial program 80.9%
fma-def80.9%
fma-def80.9%
Simplified80.9%
if 1.99999999999999991e111 < d Initial program 39.5%
*-un-lft-identity39.5%
add-sqr-sqrt39.5%
times-frac39.5%
hypot-def39.5%
fma-def39.5%
hypot-def65.4%
Applied egg-rr65.4%
Taylor expanded in d around -inf 22.7%
mul-1-neg22.7%
unsub-neg22.7%
mul-1-neg22.7%
associate-/l*22.8%
Simplified22.8%
Taylor expanded in d around -inf 81.3%
Final simplification85.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -4.5e+82)
(* (+ b (/ c (/ d a))) (/ -1.0 (hypot c d)))
(if (<= d -6.4e-105)
t_0
(if (<= d 5.5e-97)
(/ (fma b (/ d c) a) c)
(if (<= d 4e+111) t_0 (* (/ -1.0 d) (- (/ (- c) (/ d a)) b))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -4.5e+82) {
tmp = (b + (c / (d / a))) * (-1.0 / hypot(c, d));
} else if (d <= -6.4e-105) {
tmp = t_0;
} else if (d <= 5.5e-97) {
tmp = fma(b, (d / c), a) / c;
} else if (d <= 4e+111) {
tmp = t_0;
} else {
tmp = (-1.0 / d) * ((-c / (d / a)) - b);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -4.5e+82) tmp = Float64(Float64(b + Float64(c / Float64(d / a))) * Float64(-1.0 / hypot(c, d))); elseif (d <= -6.4e-105) tmp = t_0; elseif (d <= 5.5e-97) tmp = Float64(fma(b, Float64(d / c), a) / c); elseif (d <= 4e+111) tmp = t_0; else tmp = Float64(Float64(-1.0 / d) * Float64(Float64(Float64(-c) / Float64(d / a)) - b)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.5e+82], N[(N[(b + N[(c / N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -6.4e-105], t$95$0, If[LessEqual[d, 5.5e-97], N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4e+111], t$95$0, N[(N[(-1.0 / d), $MachinePrecision] * N[(N[((-c) / N[(d / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -4.5 \cdot 10^{+82}:\\
\;\;\;\;\left(b + \frac{c}{\frac{d}{a}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -6.4 \cdot 10^{-105}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{-97}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
\mathbf{elif}\;d \leq 4 \cdot 10^{+111}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{d} \cdot \left(\frac{-c}{\frac{d}{a}} - b\right)\\
\end{array}
\end{array}
if d < -4.4999999999999997e82Initial program 30.9%
*-un-lft-identity30.9%
add-sqr-sqrt30.9%
times-frac31.0%
hypot-def31.0%
fma-def31.0%
hypot-def45.0%
Applied egg-rr45.0%
Taylor expanded in d around -inf 86.1%
mul-1-neg86.1%
unsub-neg86.1%
mul-1-neg86.1%
associate-/l*90.8%
Simplified90.8%
if -4.4999999999999997e82 < d < -6.39999999999999962e-105 or 5.49999999999999948e-97 < d < 3.99999999999999983e111Initial program 78.4%
if -6.39999999999999962e-105 < d < 5.49999999999999948e-97Initial program 70.7%
Taylor expanded in c around inf 81.0%
unpow281.0%
Simplified81.0%
+-commutative81.0%
associate-/r*90.7%
frac-add66.0%
*-commutative66.0%
Applied egg-rr66.0%
+-commutative66.0%
*-commutative66.0%
distribute-lft-out66.0%
*-commutative66.0%
*-commutative66.0%
associate-*r/66.1%
Simplified66.1%
expm1-log1p-u44.8%
expm1-udef25.1%
times-frac32.7%
pow132.7%
pow132.7%
pow-div32.7%
metadata-eval32.7%
metadata-eval32.7%
*-un-lft-identity32.7%
+-commutative32.7%
fma-def32.7%
Applied egg-rr32.7%
expm1-def63.1%
expm1-log1p91.9%
Simplified91.9%
if 3.99999999999999983e111 < d Initial program 39.5%
*-un-lft-identity39.5%
add-sqr-sqrt39.5%
times-frac39.5%
hypot-def39.5%
fma-def39.5%
hypot-def65.4%
Applied egg-rr65.4%
Taylor expanded in d around -inf 22.7%
mul-1-neg22.7%
unsub-neg22.7%
mul-1-neg22.7%
associate-/l*22.8%
Simplified22.8%
Taylor expanded in d around -inf 81.3%
Final simplification85.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -7.4e+83)
(+ (/ b d) (* (/ c d) (/ a d)))
(if (<= d -4.2e-103)
t_0
(if (<= d 3.9e-97)
(/ (fma b (/ d c) a) c)
(if (<= d 8.2e+111) t_0 (* (/ -1.0 d) (- (/ (- c) (/ d a)) b))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -7.4e+83) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= -4.2e-103) {
tmp = t_0;
} else if (d <= 3.9e-97) {
tmp = fma(b, (d / c), a) / c;
} else if (d <= 8.2e+111) {
tmp = t_0;
} else {
tmp = (-1.0 / d) * ((-c / (d / a)) - b);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -7.4e+83) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); elseif (d <= -4.2e-103) tmp = t_0; elseif (d <= 3.9e-97) tmp = Float64(fma(b, Float64(d / c), a) / c); elseif (d <= 8.2e+111) tmp = t_0; else tmp = Float64(Float64(-1.0 / d) * Float64(Float64(Float64(-c) / Float64(d / a)) - b)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.4e+83], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.2e-103], t$95$0, If[LessEqual[d, 3.9e-97], N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 8.2e+111], t$95$0, N[(N[(-1.0 / d), $MachinePrecision] * N[(N[((-c) / N[(d / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -7.4 \cdot 10^{+83}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq -4.2 \cdot 10^{-103}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.9 \cdot 10^{-97}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
\mathbf{elif}\;d \leq 8.2 \cdot 10^{+111}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{d} \cdot \left(\frac{-c}{\frac{d}{a}} - b\right)\\
\end{array}
\end{array}
if d < -7.4000000000000005e83Initial program 30.9%
Taylor expanded in c around 0 81.0%
unpow281.0%
times-frac90.8%
Simplified90.8%
if -7.4000000000000005e83 < d < -4.20000000000000009e-103 or 3.8999999999999998e-97 < d < 8.19999999999999973e111Initial program 78.4%
if -4.20000000000000009e-103 < d < 3.8999999999999998e-97Initial program 70.7%
Taylor expanded in c around inf 81.0%
unpow281.0%
Simplified81.0%
+-commutative81.0%
associate-/r*90.7%
frac-add66.0%
*-commutative66.0%
Applied egg-rr66.0%
+-commutative66.0%
*-commutative66.0%
distribute-lft-out66.0%
*-commutative66.0%
*-commutative66.0%
associate-*r/66.1%
Simplified66.1%
expm1-log1p-u44.8%
expm1-udef25.1%
times-frac32.7%
pow132.7%
pow132.7%
pow-div32.7%
metadata-eval32.7%
metadata-eval32.7%
*-un-lft-identity32.7%
+-commutative32.7%
fma-def32.7%
Applied egg-rr32.7%
expm1-def63.1%
expm1-log1p91.9%
Simplified91.9%
if 8.19999999999999973e111 < d Initial program 39.5%
*-un-lft-identity39.5%
add-sqr-sqrt39.5%
times-frac39.5%
hypot-def39.5%
fma-def39.5%
hypot-def65.4%
Applied egg-rr65.4%
Taylor expanded in d around -inf 22.7%
mul-1-neg22.7%
unsub-neg22.7%
mul-1-neg22.7%
associate-/l*22.8%
Simplified22.8%
Taylor expanded in d around -inf 81.3%
Final simplification85.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -2.1e+83)
(+ (/ b d) (* (/ c d) (/ a d)))
(if (<= d -1.8e-104)
t_0
(if (<= d 3.5e-86)
(+ (/ a c) (/ (/ b (/ c d)) c))
(if (<= d 2e+111) t_0 (* (/ -1.0 d) (- (/ (- c) (/ d a)) b))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -2.1e+83) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= -1.8e-104) {
tmp = t_0;
} else if (d <= 3.5e-86) {
tmp = (a / c) + ((b / (c / d)) / c);
} else if (d <= 2e+111) {
tmp = t_0;
} else {
tmp = (-1.0 / d) * ((-c / (d / a)) - b);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
if (d <= (-2.1d+83)) then
tmp = (b / d) + ((c / d) * (a / d))
else if (d <= (-1.8d-104)) then
tmp = t_0
else if (d <= 3.5d-86) then
tmp = (a / c) + ((b / (c / d)) / c)
else if (d <= 2d+111) then
tmp = t_0
else
tmp = ((-1.0d0) / d) * ((-c / (d / a)) - b)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -2.1e+83) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= -1.8e-104) {
tmp = t_0;
} else if (d <= 3.5e-86) {
tmp = (a / c) + ((b / (c / d)) / c);
} else if (d <= 2e+111) {
tmp = t_0;
} else {
tmp = (-1.0 / d) * ((-c / (d / a)) - b);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -2.1e+83: tmp = (b / d) + ((c / d) * (a / d)) elif d <= -1.8e-104: tmp = t_0 elif d <= 3.5e-86: tmp = (a / c) + ((b / (c / d)) / c) elif d <= 2e+111: tmp = t_0 else: tmp = (-1.0 / d) * ((-c / (d / a)) - b) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -2.1e+83) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); elseif (d <= -1.8e-104) tmp = t_0; elseif (d <= 3.5e-86) tmp = Float64(Float64(a / c) + Float64(Float64(b / Float64(c / d)) / c)); elseif (d <= 2e+111) tmp = t_0; else tmp = Float64(Float64(-1.0 / d) * Float64(Float64(Float64(-c) / Float64(d / a)) - b)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -2.1e+83) tmp = (b / d) + ((c / d) * (a / d)); elseif (d <= -1.8e-104) tmp = t_0; elseif (d <= 3.5e-86) tmp = (a / c) + ((b / (c / d)) / c); elseif (d <= 2e+111) tmp = t_0; else tmp = (-1.0 / d) * ((-c / (d / a)) - b); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.1e+83], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.8e-104], t$95$0, If[LessEqual[d, 3.5e-86], N[(N[(a / c), $MachinePrecision] + N[(N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2e+111], t$95$0, N[(N[(-1.0 / d), $MachinePrecision] * N[(N[((-c) / N[(d / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -2.1 \cdot 10^{+83}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq -1.8 \cdot 10^{-104}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.5 \cdot 10^{-86}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+111}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{d} \cdot \left(\frac{-c}{\frac{d}{a}} - b\right)\\
\end{array}
\end{array}
if d < -2.10000000000000002e83Initial program 30.9%
Taylor expanded in c around 0 81.0%
unpow281.0%
times-frac90.8%
Simplified90.8%
if -2.10000000000000002e83 < d < -1.7999999999999999e-104 or 3.50000000000000021e-86 < d < 1.99999999999999991e111Initial program 78.4%
if -1.7999999999999999e-104 < d < 3.50000000000000021e-86Initial program 70.7%
Taylor expanded in c around inf 81.0%
unpow281.0%
Simplified81.0%
clear-num81.0%
inv-pow81.0%
*-commutative81.0%
times-frac88.6%
Applied egg-rr88.6%
unpow-188.6%
associate-*l/89.6%
Simplified89.6%
clear-num89.6%
add-cube-cbrt89.5%
times-frac90.6%
pow290.6%
Applied egg-rr90.6%
associate-*l/90.6%
associate-*r/90.6%
unpow290.6%
rem-3cbrt-lft90.7%
Simplified90.7%
if 1.99999999999999991e111 < d Initial program 39.5%
*-un-lft-identity39.5%
add-sqr-sqrt39.5%
times-frac39.5%
hypot-def39.5%
fma-def39.5%
hypot-def65.4%
Applied egg-rr65.4%
Taylor expanded in d around -inf 22.7%
mul-1-neg22.7%
unsub-neg22.7%
mul-1-neg22.7%
associate-/l*22.8%
Simplified22.8%
Taylor expanded in d around -inf 81.3%
Final simplification84.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ b d) (* (/ c d) (/ a d)))))
(if (<= d -5.4e+41)
t_0
(if (<= d 1.12e-60)
(+ (/ a c) (/ (/ b (/ c d)) c))
(if (<= d 8e+84) (/ a (+ c (* d (/ d c)))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b / d) + ((c / d) * (a / d));
double tmp;
if (d <= -5.4e+41) {
tmp = t_0;
} else if (d <= 1.12e-60) {
tmp = (a / c) + ((b / (c / d)) / c);
} else if (d <= 8e+84) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b / d) + ((c / d) * (a / d))
if (d <= (-5.4d+41)) then
tmp = t_0
else if (d <= 1.12d-60) then
tmp = (a / c) + ((b / (c / d)) / c)
else if (d <= 8d+84) then
tmp = a / (c + (d * (d / c)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b / d) + ((c / d) * (a / d));
double tmp;
if (d <= -5.4e+41) {
tmp = t_0;
} else if (d <= 1.12e-60) {
tmp = (a / c) + ((b / (c / d)) / c);
} else if (d <= 8e+84) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / d) + ((c / d) * (a / d)) tmp = 0 if d <= -5.4e+41: tmp = t_0 elif d <= 1.12e-60: tmp = (a / c) + ((b / (c / d)) / c) elif d <= 8e+84: tmp = a / (c + (d * (d / c))) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))) tmp = 0.0 if (d <= -5.4e+41) tmp = t_0; elseif (d <= 1.12e-60) tmp = Float64(Float64(a / c) + Float64(Float64(b / Float64(c / d)) / c)); elseif (d <= 8e+84) tmp = Float64(a / Float64(c + Float64(d * Float64(d / c)))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b / d) + ((c / d) * (a / d)); tmp = 0.0; if (d <= -5.4e+41) tmp = t_0; elseif (d <= 1.12e-60) tmp = (a / c) + ((b / (c / d)) / c); elseif (d <= 8e+84) tmp = a / (c + (d * (d / c))); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.4e+41], t$95$0, If[LessEqual[d, 1.12e-60], N[(N[(a / c), $MachinePrecision] + N[(N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8e+84], N[(a / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{if}\;d \leq -5.4 \cdot 10^{+41}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.12 \cdot 10^{-60}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;d \leq 8 \cdot 10^{+84}:\\
\;\;\;\;\frac{a}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -5.39999999999999999e41 or 8.00000000000000046e84 < d Initial program 43.2%
Taylor expanded in c around 0 76.6%
unpow276.6%
times-frac84.1%
Simplified84.1%
if -5.39999999999999999e41 < d < 1.12e-60Initial program 72.6%
Taylor expanded in c around inf 73.1%
unpow273.1%
Simplified73.1%
clear-num73.1%
inv-pow73.1%
*-commutative73.1%
times-frac78.2%
Applied egg-rr78.2%
unpow-178.2%
associate-*l/78.9%
Simplified78.9%
clear-num78.9%
add-cube-cbrt78.8%
times-frac79.5%
pow279.5%
Applied egg-rr79.5%
associate-*l/79.5%
associate-*r/79.5%
unpow279.5%
rem-3cbrt-lft79.6%
Simplified79.6%
if 1.12e-60 < d < 8.00000000000000046e84Initial program 74.5%
Taylor expanded in a around inf 46.1%
*-commutative46.1%
associate-/l*46.7%
unpow246.7%
unpow246.7%
+-commutative46.7%
fma-udef46.8%
Simplified46.8%
Taylor expanded in c around 0 64.4%
unpow264.4%
*-lft-identity64.4%
times-frac64.4%
/-rgt-identity64.4%
Simplified64.4%
Final simplification79.8%
(FPCore (a b c d) :precision binary64 (if (or (<= c -4e-13) (not (<= c 8.5))) (+ (/ a c) (* (/ d c) (/ b c))) (* (/ -1.0 d) (- (/ (- c) (/ d a)) b))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4e-13) || !(c <= 8.5)) {
tmp = (a / c) + ((d / c) * (b / c));
} else {
tmp = (-1.0 / d) * ((-c / (d / a)) - b);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-4d-13)) .or. (.not. (c <= 8.5d0))) then
tmp = (a / c) + ((d / c) * (b / c))
else
tmp = ((-1.0d0) / d) * ((-c / (d / a)) - b)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4e-13) || !(c <= 8.5)) {
tmp = (a / c) + ((d / c) * (b / c));
} else {
tmp = (-1.0 / d) * ((-c / (d / a)) - b);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -4e-13) or not (c <= 8.5): tmp = (a / c) + ((d / c) * (b / c)) else: tmp = (-1.0 / d) * ((-c / (d / a)) - b) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -4e-13) || !(c <= 8.5)) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); else tmp = Float64(Float64(-1.0 / d) * Float64(Float64(Float64(-c) / Float64(d / a)) - b)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -4e-13) || ~((c <= 8.5))) tmp = (a / c) + ((d / c) * (b / c)); else tmp = (-1.0 / d) * ((-c / (d / a)) - b); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -4e-13], N[Not[LessEqual[c, 8.5]], $MachinePrecision]], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / d), $MachinePrecision] * N[(N[((-c) / N[(d / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4 \cdot 10^{-13} \lor \neg \left(c \leq 8.5\right):\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{d} \cdot \left(\frac{-c}{\frac{d}{a}} - b\right)\\
\end{array}
\end{array}
if c < -4.0000000000000001e-13 or 8.5 < c Initial program 52.6%
Taylor expanded in c around inf 68.4%
unpow268.4%
times-frac73.4%
Simplified73.4%
if -4.0000000000000001e-13 < c < 8.5Initial program 70.7%
*-un-lft-identity70.7%
add-sqr-sqrt70.6%
times-frac70.6%
hypot-def70.7%
fma-def70.7%
hypot-def79.1%
Applied egg-rr79.1%
Taylor expanded in d around -inf 46.4%
mul-1-neg46.4%
unsub-neg46.4%
mul-1-neg46.4%
associate-/l*45.7%
Simplified45.7%
Taylor expanded in d around -inf 82.2%
Final simplification77.6%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.25e+43)
(/ b d)
(if (<= d 4.8e-61)
(+ (/ a c) (* d (/ b (* c c))))
(if (<= d 1.18e+85) (/ a (+ c (* d (/ d c)))) (/ b d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.25e+43) {
tmp = b / d;
} else if (d <= 4.8e-61) {
tmp = (a / c) + (d * (b / (c * c)));
} else if (d <= 1.18e+85) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-1.25d+43)) then
tmp = b / d
else if (d <= 4.8d-61) then
tmp = (a / c) + (d * (b / (c * c)))
else if (d <= 1.18d+85) then
tmp = a / (c + (d * (d / c)))
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.25e+43) {
tmp = b / d;
} else if (d <= 4.8e-61) {
tmp = (a / c) + (d * (b / (c * c)));
} else if (d <= 1.18e+85) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.25e+43: tmp = b / d elif d <= 4.8e-61: tmp = (a / c) + (d * (b / (c * c))) elif d <= 1.18e+85: tmp = a / (c + (d * (d / c))) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.25e+43) tmp = Float64(b / d); elseif (d <= 4.8e-61) tmp = Float64(Float64(a / c) + Float64(d * Float64(b / Float64(c * c)))); elseif (d <= 1.18e+85) tmp = Float64(a / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.25e+43) tmp = b / d; elseif (d <= 4.8e-61) tmp = (a / c) + (d * (b / (c * c))); elseif (d <= 1.18e+85) tmp = a / (c + (d * (d / c))); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.25e+43], N[(b / d), $MachinePrecision], If[LessEqual[d, 4.8e-61], N[(N[(a / c), $MachinePrecision] + N[(d * N[(b / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.18e+85], N[(a / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.25 \cdot 10^{+43}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 4.8 \cdot 10^{-61}:\\
\;\;\;\;\frac{a}{c} + d \cdot \frac{b}{c \cdot c}\\
\mathbf{elif}\;d \leq 1.18 \cdot 10^{+85}:\\
\;\;\;\;\frac{a}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -1.2500000000000001e43 or 1.17999999999999997e85 < d Initial program 43.2%
Taylor expanded in c around 0 72.9%
if -1.2500000000000001e43 < d < 4.8000000000000002e-61Initial program 72.6%
Taylor expanded in c around inf 73.1%
unpow273.1%
Simplified73.1%
Taylor expanded in d around 0 73.1%
unpow273.1%
associate-*r/69.8%
Simplified69.8%
if 4.8000000000000002e-61 < d < 1.17999999999999997e85Initial program 74.5%
Taylor expanded in a around inf 46.1%
*-commutative46.1%
associate-/l*46.7%
unpow246.7%
unpow246.7%
+-commutative46.7%
fma-udef46.8%
Simplified46.8%
Taylor expanded in c around 0 64.4%
unpow264.4%
*-lft-identity64.4%
times-frac64.4%
/-rgt-identity64.4%
Simplified64.4%
Final simplification70.4%
(FPCore (a b c d)
:precision binary64
(if (<= d -3.8e+43)
(/ b d)
(if (<= d 2.35e-60)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d 4.5e+85) (/ a (+ c (* d (/ d c)))) (/ b d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.8e+43) {
tmp = b / d;
} else if (d <= 2.35e-60) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= 4.5e+85) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-3.8d+43)) then
tmp = b / d
else if (d <= 2.35d-60) then
tmp = (a / c) + ((d / c) * (b / c))
else if (d <= 4.5d+85) then
tmp = a / (c + (d * (d / c)))
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -3.8e+43) {
tmp = b / d;
} else if (d <= 2.35e-60) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= 4.5e+85) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -3.8e+43: tmp = b / d elif d <= 2.35e-60: tmp = (a / c) + ((d / c) * (b / c)) elif d <= 4.5e+85: tmp = a / (c + (d * (d / c))) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -3.8e+43) tmp = Float64(b / d); elseif (d <= 2.35e-60) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= 4.5e+85) tmp = Float64(a / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -3.8e+43) tmp = b / d; elseif (d <= 2.35e-60) tmp = (a / c) + ((d / c) * (b / c)); elseif (d <= 4.5e+85) tmp = a / (c + (d * (d / c))); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.8e+43], N[(b / d), $MachinePrecision], If[LessEqual[d, 2.35e-60], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.5e+85], N[(a / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.8 \cdot 10^{+43}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 2.35 \cdot 10^{-60}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq 4.5 \cdot 10^{+85}:\\
\;\;\;\;\frac{a}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -3.80000000000000008e43 or 4.50000000000000007e85 < d Initial program 43.2%
Taylor expanded in c around 0 72.9%
if -3.80000000000000008e43 < d < 2.35e-60Initial program 72.6%
Taylor expanded in c around inf 73.1%
unpow273.1%
times-frac78.2%
Simplified78.2%
if 2.35e-60 < d < 4.50000000000000007e85Initial program 74.5%
Taylor expanded in a around inf 46.1%
*-commutative46.1%
associate-/l*46.7%
unpow246.7%
unpow246.7%
+-commutative46.7%
fma-udef46.8%
Simplified46.8%
Taylor expanded in c around 0 64.4%
unpow264.4%
*-lft-identity64.4%
times-frac64.4%
/-rgt-identity64.4%
Simplified64.4%
Final simplification74.6%
(FPCore (a b c d)
:precision binary64
(if (<= d -7e+42)
(/ b d)
(if (<= d 5e-60)
(+ (/ a c) (/ (/ b (/ c d)) c))
(if (<= d 5.2e+86) (/ a (+ c (* d (/ d c)))) (/ b d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -7e+42) {
tmp = b / d;
} else if (d <= 5e-60) {
tmp = (a / c) + ((b / (c / d)) / c);
} else if (d <= 5.2e+86) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-7d+42)) then
tmp = b / d
else if (d <= 5d-60) then
tmp = (a / c) + ((b / (c / d)) / c)
else if (d <= 5.2d+86) then
tmp = a / (c + (d * (d / c)))
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -7e+42) {
tmp = b / d;
} else if (d <= 5e-60) {
tmp = (a / c) + ((b / (c / d)) / c);
} else if (d <= 5.2e+86) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -7e+42: tmp = b / d elif d <= 5e-60: tmp = (a / c) + ((b / (c / d)) / c) elif d <= 5.2e+86: tmp = a / (c + (d * (d / c))) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -7e+42) tmp = Float64(b / d); elseif (d <= 5e-60) tmp = Float64(Float64(a / c) + Float64(Float64(b / Float64(c / d)) / c)); elseif (d <= 5.2e+86) tmp = Float64(a / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -7e+42) tmp = b / d; elseif (d <= 5e-60) tmp = (a / c) + ((b / (c / d)) / c); elseif (d <= 5.2e+86) tmp = a / (c + (d * (d / c))); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -7e+42], N[(b / d), $MachinePrecision], If[LessEqual[d, 5e-60], N[(N[(a / c), $MachinePrecision] + N[(N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.2e+86], N[(a / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7 \cdot 10^{+42}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 5 \cdot 10^{-60}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{+86}:\\
\;\;\;\;\frac{a}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -7.00000000000000047e42 or 5.1999999999999995e86 < d Initial program 43.2%
Taylor expanded in c around 0 72.9%
if -7.00000000000000047e42 < d < 5.0000000000000001e-60Initial program 72.6%
Taylor expanded in c around inf 73.1%
unpow273.1%
Simplified73.1%
clear-num73.1%
inv-pow73.1%
*-commutative73.1%
times-frac78.2%
Applied egg-rr78.2%
unpow-178.2%
associate-*l/78.9%
Simplified78.9%
clear-num78.9%
add-cube-cbrt78.8%
times-frac79.5%
pow279.5%
Applied egg-rr79.5%
associate-*l/79.5%
associate-*r/79.5%
unpow279.5%
rem-3cbrt-lft79.6%
Simplified79.6%
if 5.0000000000000001e-60 < d < 5.1999999999999995e86Initial program 74.5%
Taylor expanded in a around inf 46.1%
*-commutative46.1%
associate-/l*46.7%
unpow246.7%
unpow246.7%
+-commutative46.7%
fma-udef46.8%
Simplified46.8%
Taylor expanded in c around 0 64.4%
unpow264.4%
*-lft-identity64.4%
times-frac64.4%
/-rgt-identity64.4%
Simplified64.4%
Final simplification75.4%
(FPCore (a b c d) :precision binary64 (if (<= d -9.6e+42) (/ b d) (if (<= d 6.7e+84) (/ a (+ c (* d (/ d c)))) (/ b d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -9.6e+42) {
tmp = b / d;
} else if (d <= 6.7e+84) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-9.6d+42)) then
tmp = b / d
else if (d <= 6.7d+84) then
tmp = a / (c + (d * (d / c)))
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -9.6e+42) {
tmp = b / d;
} else if (d <= 6.7e+84) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -9.6e+42: tmp = b / d elif d <= 6.7e+84: tmp = a / (c + (d * (d / c))) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -9.6e+42) tmp = Float64(b / d); elseif (d <= 6.7e+84) tmp = Float64(a / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -9.6e+42) tmp = b / d; elseif (d <= 6.7e+84) tmp = a / (c + (d * (d / c))); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -9.6e+42], N[(b / d), $MachinePrecision], If[LessEqual[d, 6.7e+84], N[(a / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.6 \cdot 10^{+42}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 6.7 \cdot 10^{+84}:\\
\;\;\;\;\frac{a}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -9.5999999999999994e42 or 6.70000000000000041e84 < d Initial program 43.2%
Taylor expanded in c around 0 72.9%
if -9.5999999999999994e42 < d < 6.70000000000000041e84Initial program 73.0%
Taylor expanded in a around inf 44.2%
*-commutative44.2%
associate-/l*49.6%
unpow249.6%
unpow249.6%
+-commutative49.6%
fma-udef49.6%
Simplified49.6%
Taylor expanded in c around 0 65.9%
unpow265.9%
*-lft-identity65.9%
times-frac65.9%
/-rgt-identity65.9%
Simplified65.9%
Final simplification68.6%
(FPCore (a b c d) :precision binary64 (if (<= c -5.2e+104) (/ a c) (if (<= c 8.0) (/ b d) (/ a c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.2e+104) {
tmp = a / c;
} else if (c <= 8.0) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-5.2d+104)) then
tmp = a / c
else if (c <= 8.0d0) then
tmp = b / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.2e+104) {
tmp = a / c;
} else if (c <= 8.0) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.2e+104: tmp = a / c elif c <= 8.0: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.2e+104) tmp = Float64(a / c); elseif (c <= 8.0) tmp = Float64(b / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.2e+104) tmp = a / c; elseif (c <= 8.0) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.2e+104], N[(a / c), $MachinePrecision], If[LessEqual[c, 8.0], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.2 \cdot 10^{+104}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 8:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -5.20000000000000001e104 or 8 < c Initial program 46.7%
Taylor expanded in c around inf 66.7%
if -5.20000000000000001e104 < c < 8Initial program 71.5%
Taylor expanded in c around 0 61.6%
Final simplification63.7%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 61.2%
Taylor expanded in c around inf 40.2%
Final simplification40.2%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
else
tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (a + (b * (d / c))) / (c + (d * (d / c))) else: tmp = (b + (a * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (a + (b * (d / c))) / (c + (d * (d / c))); else tmp = (b + (a * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2023207
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))