
(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))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+235)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(/ (- (- b) (* a (/ c d))) (- d)))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+235) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (-b - (a * (c / d))) / -d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+235) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (-b - (a * (c / d))) / -d;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a * c) + (b * d) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 1e+235: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (-b - (a * (c / d))) / -d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+235) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(Float64(-b) - Float64(a * Float64(c / d))) / Float64(-d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a * c) + (b * d); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= 1e+235) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (-b - (a * (c / d))) / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+235], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
\mathbf{if}\;\frac{t\_0}{c \cdot c + d \cdot d} \leq 10^{+235}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{-d}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.0000000000000001e235Initial program 80.1%
+-commutative80.1%
fma-udef80.1%
*-un-lft-identity80.1%
associate-*r/80.1%
add-sqr-sqrt80.1%
times-frac80.0%
fma-udef80.0%
+-commutative80.0%
hypot-def80.1%
fma-def80.0%
fma-udef80.0%
+-commutative80.0%
hypot-def97.9%
Applied egg-rr97.9%
fma-def98.0%
+-commutative98.0%
Applied egg-rr98.0%
if 1.0000000000000001e235 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 14.7%
Taylor expanded in c around 0 46.2%
associate-/l*51.9%
associate-/r/50.3%
Simplified50.3%
pow250.3%
associate-*l/46.2%
*-commutative46.2%
associate-/r*51.3%
*-commutative51.3%
Applied egg-rr51.3%
div-inv51.3%
associate-/l*64.0%
add-sqr-sqrt31.7%
sqrt-unprod33.8%
sqr-neg33.8%
sqrt-unprod19.3%
add-sqr-sqrt46.3%
distribute-frac-neg46.3%
associate-/l*43.0%
cancel-sign-sub-inv43.0%
div-inv43.0%
frac-2neg43.0%
frac-2neg43.0%
associate-/l*46.3%
distribute-frac-neg46.3%
sub-div46.3%
Applied egg-rr64.1%
associate-*l/52.9%
associate-*r/65.7%
Simplified65.7%
Final simplification89.9%
(FPCore (a b c d)
:precision binary64
(if (<= c -3.3e+81)
(* (/ c (hypot c d)) (/ a (hypot c d)))
(if (<= c -2.2e-105)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= c 7.6e-35)
(/ (- (- b) (* a (/ c d))) (- d))
(if (<= c 1.36e+101)
(/ (fma a c (* b d)) (fma d d (* c c)))
(* (/ 1.0 (hypot c d)) (+ a (* d (/ b c)))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -3.3e+81) {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
} else if (c <= -2.2e-105) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (c <= 7.6e-35) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 1.36e+101) {
tmp = fma(a, c, (b * d)) / fma(d, d, (c * c));
} else {
tmp = (1.0 / hypot(c, d)) * (a + (d * (b / c)));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -3.3e+81) tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d))); elseif (c <= -2.2e-105) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 7.6e-35) tmp = Float64(Float64(Float64(-b) - Float64(a * Float64(c / d))) / Float64(-d)); elseif (c <= 1.36e+101) tmp = Float64(fma(a, c, Float64(b * d)) / fma(d, d, Float64(c * c))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a + Float64(d * Float64(b / c)))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -3.3e+81], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.2e-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[c, 7.6e-35], N[(N[((-b) - N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision], If[LessEqual[c, 1.36e+101], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.3 \cdot 10^{+81}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -2.2 \cdot 10^{-105}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 7.6 \cdot 10^{-35}:\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{-d}\\
\mathbf{elif}\;c \leq 1.36 \cdot 10^{+101}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\end{array}
\end{array}
if c < -3.3e81Initial program 49.6%
Taylor expanded in a around inf 46.3%
*-commutative46.3%
Simplified46.3%
add-sqr-sqrt46.3%
hypot-udef46.3%
hypot-udef46.3%
times-frac86.2%
Applied egg-rr86.2%
if -3.3e81 < c < -2.20000000000000004e-105Initial program 89.6%
if -2.20000000000000004e-105 < c < 7.6000000000000002e-35Initial program 62.9%
Taylor expanded in c around 0 81.0%
associate-/l*79.7%
associate-/r/77.7%
Simplified77.7%
pow277.7%
associate-*l/81.0%
*-commutative81.0%
associate-/r*86.1%
*-commutative86.1%
Applied egg-rr86.1%
div-inv86.1%
associate-/l*86.8%
add-sqr-sqrt37.0%
sqrt-unprod62.6%
sqr-neg62.6%
sqrt-unprod36.1%
add-sqr-sqrt63.8%
distribute-frac-neg63.8%
associate-/l*63.8%
cancel-sign-sub-inv63.8%
div-inv63.8%
frac-2neg63.8%
frac-2neg63.8%
associate-/l*63.8%
distribute-frac-neg63.8%
sub-div63.8%
Applied egg-rr84.9%
associate-*l/87.2%
associate-*r/88.0%
Simplified88.0%
if 7.6000000000000002e-35 < c < 1.35999999999999998e101Initial program 80.2%
fma-def80.2%
+-commutative80.2%
fma-def80.2%
Simplified80.2%
if 1.35999999999999998e101 < c Initial program 42.7%
+-commutative42.7%
fma-udef42.7%
*-un-lft-identity42.7%
associate-*r/42.7%
add-sqr-sqrt42.7%
times-frac42.7%
fma-udef42.7%
+-commutative42.7%
hypot-def42.7%
fma-def42.7%
fma-udef42.7%
+-commutative42.7%
hypot-def71.1%
Applied egg-rr71.1%
Taylor expanded in c around inf 82.0%
associate-/l*80.4%
associate-/r/84.8%
Simplified84.8%
Final simplification86.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -8.8e+82)
(* (/ c (hypot c d)) (/ a (hypot c d)))
(if (<= c -1.15e-103)
t_0
(if (<= c 7e-35)
(/ (- (- b) (* a (/ c d))) (- d))
(if (<= c 2.8e+103)
t_0
(* (/ 1.0 (hypot c d)) (+ a (* d (/ b c))))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -8.8e+82) {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
} else if (c <= -1.15e-103) {
tmp = t_0;
} else if (c <= 7e-35) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 2.8e+103) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (a + (d * (b / c)));
}
return tmp;
}
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 (c <= -8.8e+82) {
tmp = (c / Math.hypot(c, d)) * (a / Math.hypot(c, d));
} else if (c <= -1.15e-103) {
tmp = t_0;
} else if (c <= 7e-35) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 2.8e+103) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * (a + (d * (b / c)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -8.8e+82: tmp = (c / math.hypot(c, d)) * (a / math.hypot(c, d)) elif c <= -1.15e-103: tmp = t_0 elif c <= 7e-35: tmp = (-b - (a * (c / d))) / -d elif c <= 2.8e+103: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * (a + (d * (b / c))) 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 (c <= -8.8e+82) tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d))); elseif (c <= -1.15e-103) tmp = t_0; elseif (c <= 7e-35) tmp = Float64(Float64(Float64(-b) - Float64(a * Float64(c / d))) / Float64(-d)); elseif (c <= 2.8e+103) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a + Float64(d * Float64(b / c)))); 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 (c <= -8.8e+82) tmp = (c / hypot(c, d)) * (a / hypot(c, d)); elseif (c <= -1.15e-103) tmp = t_0; elseif (c <= 7e-35) tmp = (-b - (a * (c / d))) / -d; elseif (c <= 2.8e+103) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * (a + (d * (b / c))); 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[c, -8.8e+82], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.15e-103], t$95$0, If[LessEqual[c, 7e-35], N[(N[((-b) - N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision], If[LessEqual[c, 2.8e+103], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a + N[(d * N[(b / c), $MachinePrecision]), $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}\;c \leq -8.8 \cdot 10^{+82}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -1.15 \cdot 10^{-103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 7 \cdot 10^{-35}:\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{-d}\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{+103}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\end{array}
\end{array}
if c < -8.8000000000000005e82Initial program 49.6%
Taylor expanded in a around inf 46.3%
*-commutative46.3%
Simplified46.3%
add-sqr-sqrt46.3%
hypot-udef46.3%
hypot-udef46.3%
times-frac86.2%
Applied egg-rr86.2%
if -8.8000000000000005e82 < c < -1.15e-103 or 6.99999999999999992e-35 < c < 2.80000000000000008e103Initial program 85.1%
if -1.15e-103 < c < 6.99999999999999992e-35Initial program 62.9%
Taylor expanded in c around 0 81.0%
associate-/l*79.7%
associate-/r/77.7%
Simplified77.7%
pow277.7%
associate-*l/81.0%
*-commutative81.0%
associate-/r*86.1%
*-commutative86.1%
Applied egg-rr86.1%
div-inv86.1%
associate-/l*86.8%
add-sqr-sqrt37.0%
sqrt-unprod62.6%
sqr-neg62.6%
sqrt-unprod36.1%
add-sqr-sqrt63.8%
distribute-frac-neg63.8%
associate-/l*63.8%
cancel-sign-sub-inv63.8%
div-inv63.8%
frac-2neg63.8%
frac-2neg63.8%
associate-/l*63.8%
distribute-frac-neg63.8%
sub-div63.8%
Applied egg-rr84.9%
associate-*l/87.2%
associate-*r/88.0%
Simplified88.0%
if 2.80000000000000008e103 < c Initial program 42.7%
+-commutative42.7%
fma-udef42.7%
*-un-lft-identity42.7%
associate-*r/42.7%
add-sqr-sqrt42.7%
times-frac42.7%
fma-udef42.7%
+-commutative42.7%
hypot-def42.7%
fma-def42.7%
fma-udef42.7%
+-commutative42.7%
hypot-def71.1%
Applied egg-rr71.1%
Taylor expanded in c around inf 82.0%
associate-/l*80.4%
associate-/r/84.8%
Simplified84.8%
Final simplification86.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -1.6e+83)
(+ (/ a c) (* d (/ b (pow c 2.0))))
(if (<= c -5.5e-105)
t_0
(if (<= c 1.25e-34)
(/ (- (- b) (* a (/ c d))) (- d))
(if (<= c 1.6e+104)
t_0
(* (/ 1.0 (hypot c d)) (+ a (* d (/ b c))))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -1.6e+83) {
tmp = (a / c) + (d * (b / pow(c, 2.0)));
} else if (c <= -5.5e-105) {
tmp = t_0;
} else if (c <= 1.25e-34) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 1.6e+104) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (a + (d * (b / c)));
}
return tmp;
}
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 (c <= -1.6e+83) {
tmp = (a / c) + (d * (b / Math.pow(c, 2.0)));
} else if (c <= -5.5e-105) {
tmp = t_0;
} else if (c <= 1.25e-34) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 1.6e+104) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * (a + (d * (b / c)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -1.6e+83: tmp = (a / c) + (d * (b / math.pow(c, 2.0))) elif c <= -5.5e-105: tmp = t_0 elif c <= 1.25e-34: tmp = (-b - (a * (c / d))) / -d elif c <= 1.6e+104: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * (a + (d * (b / c))) 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 (c <= -1.6e+83) tmp = Float64(Float64(a / c) + Float64(d * Float64(b / (c ^ 2.0)))); elseif (c <= -5.5e-105) tmp = t_0; elseif (c <= 1.25e-34) tmp = Float64(Float64(Float64(-b) - Float64(a * Float64(c / d))) / Float64(-d)); elseif (c <= 1.6e+104) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a + Float64(d * Float64(b / c)))); 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 (c <= -1.6e+83) tmp = (a / c) + (d * (b / (c ^ 2.0))); elseif (c <= -5.5e-105) tmp = t_0; elseif (c <= 1.25e-34) tmp = (-b - (a * (c / d))) / -d; elseif (c <= 1.6e+104) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * (a + (d * (b / c))); 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[c, -1.6e+83], N[(N[(a / c), $MachinePrecision] + N[(d * N[(b / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5.5e-105], t$95$0, If[LessEqual[c, 1.25e-34], N[(N[((-b) - N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision], If[LessEqual[c, 1.6e+104], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a + N[(d * N[(b / c), $MachinePrecision]), $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}\;c \leq -1.6 \cdot 10^{+83}:\\
\;\;\;\;\frac{a}{c} + d \cdot \frac{b}{{c}^{2}}\\
\mathbf{elif}\;c \leq -5.5 \cdot 10^{-105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{-34}:\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{-d}\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{+104}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\end{array}
\end{array}
if c < -1.5999999999999999e83Initial program 49.6%
+-commutative49.6%
fma-udef49.6%
*-un-lft-identity49.6%
associate-*r/49.6%
add-sqr-sqrt49.6%
times-frac49.5%
fma-udef49.5%
+-commutative49.5%
hypot-def49.5%
fma-def49.5%
fma-udef49.5%
+-commutative49.5%
hypot-def70.9%
Applied egg-rr70.9%
Taylor expanded in c around inf 78.5%
associate-/l*78.9%
associate-/r/82.4%
Simplified82.4%
if -1.5999999999999999e83 < c < -5.50000000000000029e-105 or 1.2500000000000001e-34 < c < 1.6e104Initial program 85.1%
if -5.50000000000000029e-105 < c < 1.2500000000000001e-34Initial program 62.9%
Taylor expanded in c around 0 81.0%
associate-/l*79.7%
associate-/r/77.7%
Simplified77.7%
pow277.7%
associate-*l/81.0%
*-commutative81.0%
associate-/r*86.1%
*-commutative86.1%
Applied egg-rr86.1%
div-inv86.1%
associate-/l*86.8%
add-sqr-sqrt37.0%
sqrt-unprod62.6%
sqr-neg62.6%
sqrt-unprod36.1%
add-sqr-sqrt63.8%
distribute-frac-neg63.8%
associate-/l*63.8%
cancel-sign-sub-inv63.8%
div-inv63.8%
frac-2neg63.8%
frac-2neg63.8%
associate-/l*63.8%
distribute-frac-neg63.8%
sub-div63.8%
Applied egg-rr84.9%
associate-*l/87.2%
associate-*r/88.0%
Simplified88.0%
if 1.6e104 < c Initial program 42.7%
+-commutative42.7%
fma-udef42.7%
*-un-lft-identity42.7%
associate-*r/42.7%
add-sqr-sqrt42.7%
times-frac42.7%
fma-udef42.7%
+-commutative42.7%
hypot-def42.7%
fma-def42.7%
fma-udef42.7%
+-commutative42.7%
hypot-def71.1%
Applied egg-rr71.1%
Taylor expanded in c around inf 82.0%
associate-/l*80.4%
associate-/r/84.8%
Simplified84.8%
Final simplification85.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (+ a (* d (/ b c)))))
(if (<= c -7.5e+82)
(* t_1 (/ -1.0 (hypot c d)))
(if (<= c -3.1e-103)
t_0
(if (<= c 1e-34)
(/ (- (- b) (* a (/ c d))) (- d))
(if (<= c 1.66e+102) t_0 (* (/ 1.0 (hypot c d)) t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = a + (d * (b / c));
double tmp;
if (c <= -7.5e+82) {
tmp = t_1 * (-1.0 / hypot(c, d));
} else if (c <= -3.1e-103) {
tmp = t_0;
} else if (c <= 1e-34) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 1.66e+102) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = a + (d * (b / c));
double tmp;
if (c <= -7.5e+82) {
tmp = t_1 * (-1.0 / Math.hypot(c, d));
} else if (c <= -3.1e-103) {
tmp = t_0;
} else if (c <= 1e-34) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 1.66e+102) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = a + (d * (b / c)) tmp = 0 if c <= -7.5e+82: tmp = t_1 * (-1.0 / math.hypot(c, d)) elif c <= -3.1e-103: tmp = t_0 elif c <= 1e-34: tmp = (-b - (a * (c / d))) / -d elif c <= 1.66e+102: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * t_1 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))) t_1 = Float64(a + Float64(d * Float64(b / c))) tmp = 0.0 if (c <= -7.5e+82) tmp = Float64(t_1 * Float64(-1.0 / hypot(c, d))); elseif (c <= -3.1e-103) tmp = t_0; elseif (c <= 1e-34) tmp = Float64(Float64(Float64(-b) - Float64(a * Float64(c / d))) / Float64(-d)); elseif (c <= 1.66e+102) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * t_1); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); t_1 = a + (d * (b / c)); tmp = 0.0; if (c <= -7.5e+82) tmp = t_1 * (-1.0 / hypot(c, d)); elseif (c <= -3.1e-103) tmp = t_0; elseif (c <= 1e-34) tmp = (-b - (a * (c / d))) / -d; elseif (c <= 1.66e+102) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * t_1; 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]}, Block[{t$95$1 = N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -7.5e+82], N[(t$95$1 * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -3.1e-103], t$95$0, If[LessEqual[c, 1e-34], N[(N[((-b) - N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision], If[LessEqual[c, 1.66e+102], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
t_1 := a + d \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -7.5 \cdot 10^{+82}:\\
\;\;\;\;t\_1 \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -3.1 \cdot 10^{-103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 10^{-34}:\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{-d}\\
\mathbf{elif}\;c \leq 1.66 \cdot 10^{+102}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t\_1\\
\end{array}
\end{array}
if c < -7.4999999999999999e82Initial program 49.6%
+-commutative49.6%
fma-udef49.6%
*-un-lft-identity49.6%
associate-*r/49.6%
add-sqr-sqrt49.6%
times-frac49.5%
fma-udef49.5%
+-commutative49.5%
hypot-def49.5%
fma-def49.5%
fma-udef49.5%
+-commutative49.5%
hypot-def70.9%
Applied egg-rr70.9%
Taylor expanded in c around -inf 78.7%
mul-1-neg78.7%
unsub-neg78.7%
neg-mul-178.7%
associate-/l*86.0%
associate-/r/86.0%
Simplified86.0%
if -7.4999999999999999e82 < c < -3.1000000000000001e-103 or 9.99999999999999928e-35 < c < 1.66e102Initial program 85.1%
if -3.1000000000000001e-103 < c < 9.99999999999999928e-35Initial program 62.9%
Taylor expanded in c around 0 81.0%
associate-/l*79.7%
associate-/r/77.7%
Simplified77.7%
pow277.7%
associate-*l/81.0%
*-commutative81.0%
associate-/r*86.1%
*-commutative86.1%
Applied egg-rr86.1%
div-inv86.1%
associate-/l*86.8%
add-sqr-sqrt37.0%
sqrt-unprod62.6%
sqr-neg62.6%
sqrt-unprod36.1%
add-sqr-sqrt63.8%
distribute-frac-neg63.8%
associate-/l*63.8%
cancel-sign-sub-inv63.8%
div-inv63.8%
frac-2neg63.8%
frac-2neg63.8%
associate-/l*63.8%
distribute-frac-neg63.8%
sub-div63.8%
Applied egg-rr84.9%
associate-*l/87.2%
associate-*r/88.0%
Simplified88.0%
if 1.66e102 < c Initial program 42.7%
+-commutative42.7%
fma-udef42.7%
*-un-lft-identity42.7%
associate-*r/42.7%
add-sqr-sqrt42.7%
times-frac42.7%
fma-udef42.7%
+-commutative42.7%
hypot-def42.7%
fma-def42.7%
fma-udef42.7%
+-commutative42.7%
hypot-def71.1%
Applied egg-rr71.1%
Taylor expanded in c around inf 82.0%
associate-/l*80.4%
associate-/r/84.8%
Simplified84.8%
Final simplification86.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (+ (/ a c) (* d (/ b (pow c 2.0))))))
(if (<= c -4.3e+82)
t_1
(if (<= c -5.5e-105)
t_0
(if (<= c 1.25e-34)
(/ (- (- b) (* a (/ c d))) (- d))
(if (<= c 4.4e+100) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (a / c) + (d * (b / pow(c, 2.0)));
double tmp;
if (c <= -4.3e+82) {
tmp = t_1;
} else if (c <= -5.5e-105) {
tmp = t_0;
} else if (c <= 1.25e-34) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 4.4e+100) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
t_1 = (a / c) + (d * (b / (c ** 2.0d0)))
if (c <= (-4.3d+82)) then
tmp = t_1
else if (c <= (-5.5d-105)) then
tmp = t_0
else if (c <= 1.25d-34) then
tmp = (-b - (a * (c / d))) / -d
else if (c <= 4.4d+100) then
tmp = t_0
else
tmp = t_1
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 t_1 = (a / c) + (d * (b / Math.pow(c, 2.0)));
double tmp;
if (c <= -4.3e+82) {
tmp = t_1;
} else if (c <= -5.5e-105) {
tmp = t_0;
} else if (c <= 1.25e-34) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 4.4e+100) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = (a / c) + (d * (b / math.pow(c, 2.0))) tmp = 0 if c <= -4.3e+82: tmp = t_1 elif c <= -5.5e-105: tmp = t_0 elif c <= 1.25e-34: tmp = (-b - (a * (c / d))) / -d elif c <= 4.4e+100: tmp = t_0 else: tmp = t_1 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))) t_1 = Float64(Float64(a / c) + Float64(d * Float64(b / (c ^ 2.0)))) tmp = 0.0 if (c <= -4.3e+82) tmp = t_1; elseif (c <= -5.5e-105) tmp = t_0; elseif (c <= 1.25e-34) tmp = Float64(Float64(Float64(-b) - Float64(a * Float64(c / d))) / Float64(-d)); elseif (c <= 4.4e+100) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); t_1 = (a / c) + (d * (b / (c ^ 2.0))); tmp = 0.0; if (c <= -4.3e+82) tmp = t_1; elseif (c <= -5.5e-105) tmp = t_0; elseif (c <= 1.25e-34) tmp = (-b - (a * (c / d))) / -d; elseif (c <= 4.4e+100) tmp = t_0; else tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(a / c), $MachinePrecision] + N[(d * N[(b / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4.3e+82], t$95$1, If[LessEqual[c, -5.5e-105], t$95$0, If[LessEqual[c, 1.25e-34], N[(N[((-b) - N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision], If[LessEqual[c, 4.4e+100], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{a}{c} + d \cdot \frac{b}{{c}^{2}}\\
\mathbf{if}\;c \leq -4.3 \cdot 10^{+82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -5.5 \cdot 10^{-105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{-34}:\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{-d}\\
\mathbf{elif}\;c \leq 4.4 \cdot 10^{+100}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -4.30000000000000015e82 or 4.4000000000000001e100 < c Initial program 46.9%
+-commutative46.9%
fma-udef46.9%
*-un-lft-identity46.9%
associate-*r/46.9%
add-sqr-sqrt46.9%
times-frac46.9%
fma-udef46.9%
+-commutative46.9%
hypot-def46.9%
fma-def46.9%
fma-udef46.9%
+-commutative46.9%
hypot-def71.0%
Applied egg-rr71.0%
Taylor expanded in c around inf 73.8%
associate-/l*73.4%
associate-/r/76.2%
Simplified76.2%
if -4.30000000000000015e82 < c < -5.50000000000000029e-105 or 1.2500000000000001e-34 < c < 4.4000000000000001e100Initial program 85.1%
if -5.50000000000000029e-105 < c < 1.2500000000000001e-34Initial program 62.9%
Taylor expanded in c around 0 81.0%
associate-/l*79.7%
associate-/r/77.7%
Simplified77.7%
pow277.7%
associate-*l/81.0%
*-commutative81.0%
associate-/r*86.1%
*-commutative86.1%
Applied egg-rr86.1%
div-inv86.1%
associate-/l*86.8%
add-sqr-sqrt37.0%
sqrt-unprod62.6%
sqr-neg62.6%
sqrt-unprod36.1%
add-sqr-sqrt63.8%
distribute-frac-neg63.8%
associate-/l*63.8%
cancel-sign-sub-inv63.8%
div-inv63.8%
frac-2neg63.8%
frac-2neg63.8%
associate-/l*63.8%
distribute-frac-neg63.8%
sub-div63.8%
Applied egg-rr84.9%
associate-*l/87.2%
associate-*r/88.0%
Simplified88.0%
Final simplification83.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -4.5e+130)
(/ a c)
(if (<= c -3.9e-103)
t_0
(if (<= c 6.8e-35)
(/ (- (- b) (* a (/ c d))) (- d))
(if (<= c 1.45e+118) t_0 (/ a (hypot c 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 (c <= -4.5e+130) {
tmp = a / c;
} else if (c <= -3.9e-103) {
tmp = t_0;
} else if (c <= 6.8e-35) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 1.45e+118) {
tmp = t_0;
} else {
tmp = a / hypot(c, d);
}
return tmp;
}
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 (c <= -4.5e+130) {
tmp = a / c;
} else if (c <= -3.9e-103) {
tmp = t_0;
} else if (c <= 6.8e-35) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 1.45e+118) {
tmp = t_0;
} else {
tmp = a / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -4.5e+130: tmp = a / c elif c <= -3.9e-103: tmp = t_0 elif c <= 6.8e-35: tmp = (-b - (a * (c / d))) / -d elif c <= 1.45e+118: tmp = t_0 else: tmp = a / math.hypot(c, 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 (c <= -4.5e+130) tmp = Float64(a / c); elseif (c <= -3.9e-103) tmp = t_0; elseif (c <= 6.8e-35) tmp = Float64(Float64(Float64(-b) - Float64(a * Float64(c / d))) / Float64(-d)); elseif (c <= 1.45e+118) tmp = t_0; else tmp = Float64(a / hypot(c, d)); 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 (c <= -4.5e+130) tmp = a / c; elseif (c <= -3.9e-103) tmp = t_0; elseif (c <= 6.8e-35) tmp = (-b - (a * (c / d))) / -d; elseif (c <= 1.45e+118) tmp = t_0; else tmp = a / hypot(c, d); 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[c, -4.5e+130], N[(a / c), $MachinePrecision], If[LessEqual[c, -3.9e-103], t$95$0, If[LessEqual[c, 6.8e-35], N[(N[((-b) - N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision], If[LessEqual[c, 1.45e+118], t$95$0, N[(a / N[Sqrt[c ^ 2 + d ^ 2], $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}\;c \leq -4.5 \cdot 10^{+130}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -3.9 \cdot 10^{-103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 6.8 \cdot 10^{-35}:\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{-d}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{+118}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -4.50000000000000039e130Initial program 39.9%
Taylor expanded in c around inf 81.9%
if -4.50000000000000039e130 < c < -3.9000000000000002e-103 or 6.8000000000000005e-35 < c < 1.45000000000000008e118Initial program 84.6%
if -3.9000000000000002e-103 < c < 6.8000000000000005e-35Initial program 62.9%
Taylor expanded in c around 0 81.0%
associate-/l*79.7%
associate-/r/77.7%
Simplified77.7%
pow277.7%
associate-*l/81.0%
*-commutative81.0%
associate-/r*86.1%
*-commutative86.1%
Applied egg-rr86.1%
div-inv86.1%
associate-/l*86.8%
add-sqr-sqrt37.0%
sqrt-unprod62.6%
sqr-neg62.6%
sqrt-unprod36.1%
add-sqr-sqrt63.8%
distribute-frac-neg63.8%
associate-/l*63.8%
cancel-sign-sub-inv63.8%
div-inv63.8%
frac-2neg63.8%
frac-2neg63.8%
associate-/l*63.8%
distribute-frac-neg63.8%
sub-div63.8%
Applied egg-rr84.9%
associate-*l/87.2%
associate-*r/88.0%
Simplified88.0%
if 1.45000000000000008e118 < c Initial program 36.4%
+-commutative36.4%
fma-udef36.4%
*-un-lft-identity36.4%
associate-*r/36.4%
add-sqr-sqrt36.4%
times-frac36.4%
fma-udef36.4%
+-commutative36.4%
hypot-def36.4%
fma-def36.4%
fma-udef36.4%
+-commutative36.4%
hypot-def69.6%
Applied egg-rr69.6%
Taylor expanded in c around -inf 23.2%
mul-1-neg23.2%
unsub-neg23.2%
neg-mul-123.2%
associate-/l*23.3%
associate-/r/23.2%
Simplified23.2%
associate-*l/23.2%
*-un-lft-identity23.2%
add-sqr-sqrt11.5%
sqrt-unprod26.7%
sqr-neg26.7%
sqrt-unprod25.2%
add-sqr-sqrt61.8%
*-commutative61.8%
clear-num61.8%
un-div-inv61.8%
Applied egg-rr61.8%
Taylor expanded in a around inf 62.4%
Final simplification82.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -1e+126)
(* a (/ -1.0 (hypot c d)))
(if (<= c -6.2e-103)
t_0
(if (<= c 6.5e-35)
(/ (- (- b) (* a (/ c d))) (- d))
(if (<= c 5e+119) t_0 (/ a (hypot c 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 (c <= -1e+126) {
tmp = a * (-1.0 / hypot(c, d));
} else if (c <= -6.2e-103) {
tmp = t_0;
} else if (c <= 6.5e-35) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 5e+119) {
tmp = t_0;
} else {
tmp = a / hypot(c, d);
}
return tmp;
}
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 (c <= -1e+126) {
tmp = a * (-1.0 / Math.hypot(c, d));
} else if (c <= -6.2e-103) {
tmp = t_0;
} else if (c <= 6.5e-35) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 5e+119) {
tmp = t_0;
} else {
tmp = a / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -1e+126: tmp = a * (-1.0 / math.hypot(c, d)) elif c <= -6.2e-103: tmp = t_0 elif c <= 6.5e-35: tmp = (-b - (a * (c / d))) / -d elif c <= 5e+119: tmp = t_0 else: tmp = a / math.hypot(c, 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 (c <= -1e+126) tmp = Float64(a * Float64(-1.0 / hypot(c, d))); elseif (c <= -6.2e-103) tmp = t_0; elseif (c <= 6.5e-35) tmp = Float64(Float64(Float64(-b) - Float64(a * Float64(c / d))) / Float64(-d)); elseif (c <= 5e+119) tmp = t_0; else tmp = Float64(a / hypot(c, d)); 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 (c <= -1e+126) tmp = a * (-1.0 / hypot(c, d)); elseif (c <= -6.2e-103) tmp = t_0; elseif (c <= 6.5e-35) tmp = (-b - (a * (c / d))) / -d; elseif (c <= 5e+119) tmp = t_0; else tmp = a / hypot(c, d); 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[c, -1e+126], N[(a * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -6.2e-103], t$95$0, If[LessEqual[c, 6.5e-35], N[(N[((-b) - N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision], If[LessEqual[c, 5e+119], t$95$0, N[(a / N[Sqrt[c ^ 2 + d ^ 2], $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}\;c \leq -1 \cdot 10^{+126}:\\
\;\;\;\;a \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -6.2 \cdot 10^{-103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{-35}:\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{-d}\\
\mathbf{elif}\;c \leq 5 \cdot 10^{+119}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -9.99999999999999925e125Initial program 39.9%
+-commutative39.9%
fma-udef39.9%
*-un-lft-identity39.9%
associate-*r/39.9%
add-sqr-sqrt39.9%
times-frac39.9%
fma-udef39.9%
+-commutative39.9%
hypot-def39.9%
fma-def39.9%
fma-udef39.9%
+-commutative39.9%
hypot-def65.1%
Applied egg-rr65.1%
Taylor expanded in c around -inf 81.9%
neg-mul-181.9%
Simplified81.9%
if -9.99999999999999925e125 < c < -6.2000000000000003e-103 or 6.4999999999999999e-35 < c < 4.9999999999999999e119Initial program 84.6%
if -6.2000000000000003e-103 < c < 6.4999999999999999e-35Initial program 62.9%
Taylor expanded in c around 0 81.0%
associate-/l*79.7%
associate-/r/77.7%
Simplified77.7%
pow277.7%
associate-*l/81.0%
*-commutative81.0%
associate-/r*86.1%
*-commutative86.1%
Applied egg-rr86.1%
div-inv86.1%
associate-/l*86.8%
add-sqr-sqrt37.0%
sqrt-unprod62.6%
sqr-neg62.6%
sqrt-unprod36.1%
add-sqr-sqrt63.8%
distribute-frac-neg63.8%
associate-/l*63.8%
cancel-sign-sub-inv63.8%
div-inv63.8%
frac-2neg63.8%
frac-2neg63.8%
associate-/l*63.8%
distribute-frac-neg63.8%
sub-div63.8%
Applied egg-rr84.9%
associate-*l/87.2%
associate-*r/88.0%
Simplified88.0%
if 4.9999999999999999e119 < c Initial program 36.4%
+-commutative36.4%
fma-udef36.4%
*-un-lft-identity36.4%
associate-*r/36.4%
add-sqr-sqrt36.4%
times-frac36.4%
fma-udef36.4%
+-commutative36.4%
hypot-def36.4%
fma-def36.4%
fma-udef36.4%
+-commutative36.4%
hypot-def69.6%
Applied egg-rr69.6%
Taylor expanded in c around -inf 23.2%
mul-1-neg23.2%
unsub-neg23.2%
neg-mul-123.2%
associate-/l*23.3%
associate-/r/23.2%
Simplified23.2%
associate-*l/23.2%
*-un-lft-identity23.2%
add-sqr-sqrt11.5%
sqrt-unprod26.7%
sqr-neg26.7%
sqrt-unprod25.2%
add-sqr-sqrt61.8%
*-commutative61.8%
clear-num61.8%
un-div-inv61.8%
Applied egg-rr61.8%
Taylor expanded in a around inf 62.4%
Final simplification82.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -1.1e+129)
(/ a c)
(if (<= c -1.25e-103)
t_0
(if (<= c 1.7e-34)
(/ (- (- b) (* a (/ c d))) (- d))
(if (<= c 1.1e+125) t_0 (/ a c)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -1.1e+129) {
tmp = a / c;
} else if (c <= -1.25e-103) {
tmp = t_0;
} else if (c <= 1.7e-34) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 1.1e+125) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
if (c <= (-1.1d+129)) then
tmp = a / c
else if (c <= (-1.25d-103)) then
tmp = t_0
else if (c <= 1.7d-34) then
tmp = (-b - (a * (c / d))) / -d
else if (c <= 1.1d+125) then
tmp = t_0
else
tmp = a / c
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 (c <= -1.1e+129) {
tmp = a / c;
} else if (c <= -1.25e-103) {
tmp = t_0;
} else if (c <= 1.7e-34) {
tmp = (-b - (a * (c / d))) / -d;
} else if (c <= 1.1e+125) {
tmp = t_0;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -1.1e+129: tmp = a / c elif c <= -1.25e-103: tmp = t_0 elif c <= 1.7e-34: tmp = (-b - (a * (c / d))) / -d elif c <= 1.1e+125: tmp = t_0 else: tmp = a / c 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 (c <= -1.1e+129) tmp = Float64(a / c); elseif (c <= -1.25e-103) tmp = t_0; elseif (c <= 1.7e-34) tmp = Float64(Float64(Float64(-b) - Float64(a * Float64(c / d))) / Float64(-d)); elseif (c <= 1.1e+125) tmp = t_0; else tmp = Float64(a / c); 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 (c <= -1.1e+129) tmp = a / c; elseif (c <= -1.25e-103) tmp = t_0; elseif (c <= 1.7e-34) tmp = (-b - (a * (c / d))) / -d; elseif (c <= 1.1e+125) tmp = t_0; else tmp = a / c; 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[c, -1.1e+129], N[(a / c), $MachinePrecision], If[LessEqual[c, -1.25e-103], t$95$0, If[LessEqual[c, 1.7e-34], N[(N[((-b) - N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision], If[LessEqual[c, 1.1e+125], t$95$0, N[(a / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -1.1 \cdot 10^{+129}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -1.25 \cdot 10^{-103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.7 \cdot 10^{-34}:\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{-d}\\
\mathbf{elif}\;c \leq 1.1 \cdot 10^{+125}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -1.1e129 or 1.09999999999999995e125 < c Initial program 38.5%
Taylor expanded in c around inf 73.8%
if -1.1e129 < c < -1.24999999999999992e-103 or 1.7e-34 < c < 1.09999999999999995e125Initial program 84.6%
if -1.24999999999999992e-103 < c < 1.7e-34Initial program 62.9%
Taylor expanded in c around 0 81.0%
associate-/l*79.7%
associate-/r/77.7%
Simplified77.7%
pow277.7%
associate-*l/81.0%
*-commutative81.0%
associate-/r*86.1%
*-commutative86.1%
Applied egg-rr86.1%
div-inv86.1%
associate-/l*86.8%
add-sqr-sqrt37.0%
sqrt-unprod62.6%
sqr-neg62.6%
sqrt-unprod36.1%
add-sqr-sqrt63.8%
distribute-frac-neg63.8%
associate-/l*63.8%
cancel-sign-sub-inv63.8%
div-inv63.8%
frac-2neg63.8%
frac-2neg63.8%
associate-/l*63.8%
distribute-frac-neg63.8%
sub-div63.8%
Applied egg-rr84.9%
associate-*l/87.2%
associate-*r/88.0%
Simplified88.0%
Final simplification82.9%
(FPCore (a b c d)
:precision binary64
(if (<= c -5e+18)
(/ a c)
(if (<= c 7.6e-35)
(+ (/ b d) (/ (/ (* a c) d) d))
(if (<= c 1.9e+104) (/ (* a c) (+ (* c c) (* d d))) (/ a c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5e+18) {
tmp = a / c;
} else if (c <= 7.6e-35) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 1.9e+104) {
tmp = (a * c) / ((c * c) + (d * 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 <= (-5d+18)) then
tmp = a / c
else if (c <= 7.6d-35) then
tmp = (b / d) + (((a * c) / d) / d)
else if (c <= 1.9d+104) then
tmp = (a * c) / ((c * c) + (d * 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 <= -5e+18) {
tmp = a / c;
} else if (c <= 7.6e-35) {
tmp = (b / d) + (((a * c) / d) / d);
} else if (c <= 1.9e+104) {
tmp = (a * c) / ((c * c) + (d * d));
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5e+18: tmp = a / c elif c <= 7.6e-35: tmp = (b / d) + (((a * c) / d) / d) elif c <= 1.9e+104: tmp = (a * c) / ((c * c) + (d * d)) else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5e+18) tmp = Float64(a / c); elseif (c <= 7.6e-35) tmp = Float64(Float64(b / d) + Float64(Float64(Float64(a * c) / d) / d)); elseif (c <= 1.9e+104) tmp = Float64(Float64(a * c) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5e+18) tmp = a / c; elseif (c <= 7.6e-35) tmp = (b / d) + (((a * c) / d) / d); elseif (c <= 1.9e+104) tmp = (a * c) / ((c * c) + (d * d)); else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5e+18], N[(a / c), $MachinePrecision], If[LessEqual[c, 7.6e-35], N[(N[(b / d), $MachinePrecision] + N[(N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.9e+104], N[(N[(a * c), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5 \cdot 10^{+18}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 7.6 \cdot 10^{-35}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a \cdot c}{d}}{d}\\
\mathbf{elif}\;c \leq 1.9 \cdot 10^{+104}:\\
\;\;\;\;\frac{a \cdot c}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -5e18 or 1.89999999999999984e104 < c Initial program 55.9%
Taylor expanded in c around inf 72.2%
if -5e18 < c < 7.6000000000000002e-35Initial program 66.0%
Taylor expanded in c around 0 76.8%
associate-/l*74.9%
associate-/r/74.1%
Simplified74.1%
pow274.1%
associate-*l/76.8%
*-commutative76.8%
associate-/r*81.9%
*-commutative81.9%
Applied egg-rr81.9%
if 7.6000000000000002e-35 < c < 1.89999999999999984e104Initial program 80.2%
Taylor expanded in a around inf 68.5%
*-commutative68.5%
Simplified68.5%
Final simplification76.0%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.3e+18) (not (<= c 1.9e-34))) (/ a c) (+ (/ b d) (/ (/ (* a c) d) d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.3e+18) || !(c <= 1.9e-34)) {
tmp = a / c;
} else {
tmp = (b / d) + (((a * c) / d) / 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 ((c <= (-2.3d+18)) .or. (.not. (c <= 1.9d-34))) then
tmp = a / c
else
tmp = (b / d) + (((a * c) / d) / d)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.3e+18) || !(c <= 1.9e-34)) {
tmp = a / c;
} else {
tmp = (b / d) + (((a * c) / d) / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.3e+18) or not (c <= 1.9e-34): tmp = a / c else: tmp = (b / d) + (((a * c) / d) / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.3e+18) || !(c <= 1.9e-34)) tmp = Float64(a / c); else tmp = Float64(Float64(b / d) + Float64(Float64(Float64(a * c) / d) / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.3e+18) || ~((c <= 1.9e-34))) tmp = a / c; else tmp = (b / d) + (((a * c) / d) / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.3e+18], N[Not[LessEqual[c, 1.9e-34]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.3 \cdot 10^{+18} \lor \neg \left(c \leq 1.9 \cdot 10^{-34}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a \cdot c}{d}}{d}\\
\end{array}
\end{array}
if c < -2.3e18 or 1.9000000000000001e-34 < c Initial program 61.9%
Taylor expanded in c around inf 67.9%
if -2.3e18 < c < 1.9000000000000001e-34Initial program 66.0%
Taylor expanded in c around 0 76.8%
associate-/l*74.9%
associate-/r/74.1%
Simplified74.1%
pow274.1%
associate-*l/76.8%
*-commutative76.8%
associate-/r*81.9%
*-commutative81.9%
Applied egg-rr81.9%
Final simplification74.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -7.5) (not (<= d 4.8e-46))) (/ (- (- b) (* a (/ c d))) (- d)) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.5) || !(d <= 4.8e-46)) {
tmp = (-b - (a * (c / d))) / -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 ((d <= (-7.5d0)) .or. (.not. (d <= 4.8d-46))) then
tmp = (-b - (a * (c / d))) / -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 ((d <= -7.5) || !(d <= 4.8e-46)) {
tmp = (-b - (a * (c / d))) / -d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7.5) or not (d <= 4.8e-46): tmp = (-b - (a * (c / d))) / -d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7.5) || !(d <= 4.8e-46)) tmp = Float64(Float64(Float64(-b) - Float64(a * Float64(c / d))) / Float64(-d)); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -7.5) || ~((d <= 4.8e-46))) tmp = (-b - (a * (c / d))) / -d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.5], N[Not[LessEqual[d, 4.8e-46]], $MachinePrecision]], N[(N[((-b) - N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.5 \lor \neg \left(d \leq 4.8 \cdot 10^{-46}\right):\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -7.5 or 4.80000000000000027e-46 < d Initial program 53.8%
Taylor expanded in c around 0 69.0%
associate-/l*68.0%
associate-/r/71.6%
Simplified71.6%
pow271.6%
associate-*l/69.0%
*-commutative69.0%
associate-/r*72.8%
*-commutative72.8%
Applied egg-rr72.8%
div-inv72.8%
associate-/l*76.7%
add-sqr-sqrt36.4%
sqrt-unprod56.7%
sqr-neg56.7%
sqrt-unprod28.5%
add-sqr-sqrt57.9%
distribute-frac-neg57.9%
associate-/l*56.3%
cancel-sign-sub-inv56.3%
div-inv56.3%
frac-2neg56.3%
frac-2neg56.3%
associate-/l*57.9%
distribute-frac-neg57.9%
sub-div57.9%
Applied egg-rr79.4%
associate-*l/72.8%
associate-*r/77.1%
Simplified77.1%
if -7.5 < d < 4.80000000000000027e-46Initial program 75.0%
Taylor expanded in c around inf 74.2%
Final simplification75.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -6.5) (not (<= d 110.0))) (/ (- (- b) (* c (/ a d))) (- d)) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -6.5) || !(d <= 110.0)) {
tmp = (-b - (c * (a / d))) / -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 ((d <= (-6.5d0)) .or. (.not. (d <= 110.0d0))) then
tmp = (-b - (c * (a / d))) / -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 ((d <= -6.5) || !(d <= 110.0)) {
tmp = (-b - (c * (a / d))) / -d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -6.5) or not (d <= 110.0): tmp = (-b - (c * (a / d))) / -d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -6.5) || !(d <= 110.0)) tmp = Float64(Float64(Float64(-b) - Float64(c * Float64(a / d))) / Float64(-d)); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -6.5) || ~((d <= 110.0))) tmp = (-b - (c * (a / d))) / -d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -6.5], N[Not[LessEqual[d, 110.0]], $MachinePrecision]], N[(N[((-b) - N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -6.5 \lor \neg \left(d \leq 110\right):\\
\;\;\;\;\frac{\left(-b\right) - c \cdot \frac{a}{d}}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -6.5 or 110 < d Initial program 52.8%
Taylor expanded in c around 0 69.3%
associate-/l*68.3%
associate-/r/72.7%
Simplified72.7%
pow272.7%
associate-*l/69.3%
*-commutative69.3%
associate-/r*73.3%
*-commutative73.3%
Applied egg-rr73.3%
div-inv73.3%
associate-/l*77.3%
add-sqr-sqrt36.3%
sqrt-unprod57.3%
sqr-neg57.3%
sqrt-unprod29.6%
add-sqr-sqrt60.1%
distribute-frac-neg60.1%
associate-/l*58.4%
cancel-sign-sub-inv58.4%
div-inv58.4%
frac-2neg58.4%
frac-2neg58.4%
associate-/l*60.1%
distribute-frac-neg60.1%
sub-div60.1%
Applied egg-rr80.8%
if -6.5 < d < 110Initial program 75.2%
Taylor expanded in c around inf 73.0%
Final simplification77.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -9e+84) (not (<= d 470.0))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -9e+84) || !(d <= 470.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 ((d <= (-9d+84)) .or. (.not. (d <= 470.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 ((d <= -9e+84) || !(d <= 470.0)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -9e+84) or not (d <= 470.0): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -9e+84) || !(d <= 470.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 ((d <= -9e+84) || ~((d <= 470.0))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -9e+84], N[Not[LessEqual[d, 470.0]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{+84} \lor \neg \left(d \leq 470\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -8.9999999999999994e84 or 470 < d Initial program 49.2%
Taylor expanded in c around 0 68.2%
if -8.9999999999999994e84 < d < 470Initial program 75.4%
Taylor expanded in c around inf 68.1%
Final simplification68.1%
(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 63.8%
Taylor expanded in c around inf 46.0%
Final simplification46.0%
(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 2024041
(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))))