
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z): return (math.cosh(x) * (y / x)) / z
function code(x, y, z) return Float64(Float64(cosh(x) * Float64(y / x)) / z) end
function tmp = code(x, y, z) tmp = (cosh(x) * (y / x)) / z; end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z): return (math.cosh(x) * (y / x)) / z
function code(x, y, z) return Float64(Float64(cosh(x) * Float64(y / x)) / z) end
function tmp = code(x, y, z) tmp = (cosh(x) * (y / x)) / z; end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= z_m 17000000000.0)
(/ (* (/ y z_m) (cosh x)) x)
(* y (/ (/ (cosh x) x) z_m)))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 17000000000.0) {
tmp = ((y / z_m) * cosh(x)) / x;
} else {
tmp = y * ((cosh(x) / x) / z_m);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 17000000000.0d0) then
tmp = ((y / z_m) * cosh(x)) / x
else
tmp = y * ((cosh(x) / x) / z_m)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 17000000000.0) {
tmp = ((y / z_m) * Math.cosh(x)) / x;
} else {
tmp = y * ((Math.cosh(x) / x) / z_m);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if z_m <= 17000000000.0: tmp = ((y / z_m) * math.cosh(x)) / x else: tmp = y * ((math.cosh(x) / x) / z_m) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 17000000000.0) tmp = Float64(Float64(Float64(y / z_m) * cosh(x)) / x); else tmp = Float64(y * Float64(Float64(cosh(x) / x) / z_m)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (z_m <= 17000000000.0) tmp = ((y / z_m) * cosh(x)) / x; else tmp = y * ((cosh(x) / x) / z_m); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 17000000000.0], N[(N[(N[(y / z$95$m), $MachinePrecision] * N[Cosh[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(y * N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 17000000000:\\
\;\;\;\;\frac{\frac{y}{z\_m} \cdot \cosh x}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\frac{\cosh x}{x}}{z\_m}\\
\end{array}
\end{array}
if z < 1.7e10Initial program 86.6%
associate-/l*82.7%
associate-/l/81.0%
Simplified81.0%
*-commutative81.0%
associate-/r*87.2%
associate-*l/95.7%
Applied egg-rr95.7%
if 1.7e10 < z Initial program 82.3%
associate-/l*69.6%
associate-/l/72.4%
Simplified72.4%
clear-num71.8%
un-div-inv71.8%
*-commutative71.8%
associate-/l*74.0%
Applied egg-rr74.0%
associate-*r/71.8%
associate-/r/78.0%
associate-/l/99.8%
*-commutative99.8%
associate-/l/78.0%
associate-/r*99.8%
Simplified99.8%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (let* ((t_0 (* (cosh x) (/ y x)))) (* z_s (if (<= t_0 2e+276) (/ t_0 z_m) (* y (/ (/ (cosh x) x) z_m))))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double t_0 = cosh(x) * (y / x);
double tmp;
if (t_0 <= 2e+276) {
tmp = t_0 / z_m;
} else {
tmp = y * ((cosh(x) / x) / z_m);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: t_0
real(8) :: tmp
t_0 = cosh(x) * (y / x)
if (t_0 <= 2d+276) then
tmp = t_0 / z_m
else
tmp = y * ((cosh(x) / x) / z_m)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double t_0 = Math.cosh(x) * (y / x);
double tmp;
if (t_0 <= 2e+276) {
tmp = t_0 / z_m;
} else {
tmp = y * ((Math.cosh(x) / x) / z_m);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): t_0 = math.cosh(x) * (y / x) tmp = 0 if t_0 <= 2e+276: tmp = t_0 / z_m else: tmp = y * ((math.cosh(x) / x) / z_m) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) t_0 = Float64(cosh(x) * Float64(y / x)) tmp = 0.0 if (t_0 <= 2e+276) tmp = Float64(t_0 / z_m); else tmp = Float64(y * Float64(Float64(cosh(x) / x) / z_m)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) t_0 = cosh(x) * (y / x); tmp = 0.0; if (t_0 <= 2e+276) tmp = t_0 / z_m; else tmp = y * ((cosh(x) / x) / z_m); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]}, N[(z$95$s * If[LessEqual[t$95$0, 2e+276], N[(t$95$0 / z$95$m), $MachinePrecision], N[(y * N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
\begin{array}{l}
t_0 := \cosh x \cdot \frac{y}{x}\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{+276}:\\
\;\;\;\;\frac{t\_0}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\frac{\cosh x}{x}}{z\_m}\\
\end{array}
\end{array}
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 y x)) < 2.0000000000000001e276Initial program 95.9%
if 2.0000000000000001e276 < (*.f64 (cosh.f64 x) (/.f64 y x)) Initial program 66.9%
associate-/l*60.2%
associate-/l/70.0%
Simplified70.0%
clear-num70.0%
un-div-inv70.0%
*-commutative70.0%
associate-/l*74.4%
Applied egg-rr74.4%
associate-*r/70.0%
associate-/r/81.1%
associate-/l/100.0%
*-commutative100.0%
associate-/l/81.1%
associate-/r*100.0%
Simplified100.0%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (let* ((t_0 (/ (cosh x) x))) (* z_s (if (<= z_m 520000000.0) (/ (* y t_0) z_m) (* y (/ t_0 z_m))))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double t_0 = cosh(x) / x;
double tmp;
if (z_m <= 520000000.0) {
tmp = (y * t_0) / z_m;
} else {
tmp = y * (t_0 / z_m);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: t_0
real(8) :: tmp
t_0 = cosh(x) / x
if (z_m <= 520000000.0d0) then
tmp = (y * t_0) / z_m
else
tmp = y * (t_0 / z_m)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double t_0 = Math.cosh(x) / x;
double tmp;
if (z_m <= 520000000.0) {
tmp = (y * t_0) / z_m;
} else {
tmp = y * (t_0 / z_m);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): t_0 = math.cosh(x) / x tmp = 0 if z_m <= 520000000.0: tmp = (y * t_0) / z_m else: tmp = y * (t_0 / z_m) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) t_0 = Float64(cosh(x) / x) tmp = 0.0 if (z_m <= 520000000.0) tmp = Float64(Float64(y * t_0) / z_m); else tmp = Float64(y * Float64(t_0 / z_m)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) t_0 = cosh(x) / x; tmp = 0.0; if (z_m <= 520000000.0) tmp = (y * t_0) / z_m; else tmp = y * (t_0 / z_m); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision]}, N[(z$95$s * If[LessEqual[z$95$m, 520000000.0], N[(N[(y * t$95$0), $MachinePrecision] / z$95$m), $MachinePrecision], N[(y * N[(t$95$0 / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
\begin{array}{l}
t_0 := \frac{\cosh x}{x}\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 520000000:\\
\;\;\;\;\frac{y \cdot t\_0}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{t\_0}{z\_m}\\
\end{array}
\end{array}
\end{array}
if z < 5.2e8Initial program 86.4%
associate-/l*82.4%
associate-/l/80.7%
Simplified80.7%
clear-num80.7%
un-div-inv80.7%
*-commutative80.7%
associate-/l*86.5%
Applied egg-rr86.5%
associate-*r/80.7%
associate-/r/85.7%
associate-/l/93.8%
*-commutative93.8%
associate-/l/85.7%
associate-/r*93.8%
Simplified93.8%
associate-*r/98.0%
Applied egg-rr98.0%
if 5.2e8 < z Initial program 83.2%
associate-/l*71.1%
associate-/l/73.9%
Simplified73.9%
clear-num73.3%
un-div-inv73.3%
*-commutative73.3%
associate-/l*75.3%
Applied egg-rr75.3%
associate-*r/73.3%
associate-/r/79.1%
associate-/l/99.8%
*-commutative99.8%
associate-/l/79.1%
associate-/r*99.8%
Simplified99.8%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= x 1.75e-81) (/ (/ y z_m) x) (* y (/ (/ (cosh x) x) z_m)))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (x <= 1.75e-81) {
tmp = (y / z_m) / x;
} else {
tmp = y * ((cosh(x) / x) / z_m);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (x <= 1.75d-81) then
tmp = (y / z_m) / x
else
tmp = y * ((cosh(x) / x) / z_m)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (x <= 1.75e-81) {
tmp = (y / z_m) / x;
} else {
tmp = y * ((Math.cosh(x) / x) / z_m);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if x <= 1.75e-81: tmp = (y / z_m) / x else: tmp = y * ((math.cosh(x) / x) / z_m) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (x <= 1.75e-81) tmp = Float64(Float64(y / z_m) / x); else tmp = Float64(y * Float64(Float64(cosh(x) / x) / z_m)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (x <= 1.75e-81) tmp = (y / z_m) / x; else tmp = y * ((cosh(x) / x) / z_m); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[x, 1.75e-81], N[(N[(y / z$95$m), $MachinePrecision] / x), $MachinePrecision], N[(y * N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.75 \cdot 10^{-81}:\\
\;\;\;\;\frac{\frac{y}{z\_m}}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\frac{\cosh x}{x}}{z\_m}\\
\end{array}
\end{array}
if x < 1.74999999999999993e-81Initial program 85.5%
*-commutative85.5%
associate-/l*85.4%
Simplified85.4%
Taylor expanded in x around 0 62.4%
associate-*l/65.0%
un-div-inv65.1%
Applied egg-rr65.1%
if 1.74999999999999993e-81 < x Initial program 86.2%
associate-/l*72.4%
associate-/l/71.2%
Simplified71.2%
clear-num71.1%
un-div-inv71.1%
*-commutative71.1%
associate-/l*75.0%
Applied egg-rr75.0%
associate-*r/71.1%
associate-/r/81.2%
associate-/l/99.9%
*-commutative99.9%
associate-/l/81.2%
associate-/r*99.9%
Simplified99.9%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= z_m 50000000000.0) (/ (/ y z_m) x) (* y (/ (/ 1.0 x) z_m)))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 50000000000.0) {
tmp = (y / z_m) / x;
} else {
tmp = y * ((1.0 / x) / z_m);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 50000000000.0d0) then
tmp = (y / z_m) / x
else
tmp = y * ((1.0d0 / x) / z_m)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 50000000000.0) {
tmp = (y / z_m) / x;
} else {
tmp = y * ((1.0 / x) / z_m);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if z_m <= 50000000000.0: tmp = (y / z_m) / x else: tmp = y * ((1.0 / x) / z_m) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 50000000000.0) tmp = Float64(Float64(y / z_m) / x); else tmp = Float64(y * Float64(Float64(1.0 / x) / z_m)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (z_m <= 50000000000.0) tmp = (y / z_m) / x; else tmp = y * ((1.0 / x) / z_m); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 50000000000.0], N[(N[(y / z$95$m), $MachinePrecision] / x), $MachinePrecision], N[(y * N[(N[(1.0 / x), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 50000000000:\\
\;\;\;\;\frac{\frac{y}{z\_m}}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\frac{1}{x}}{z\_m}\\
\end{array}
\end{array}
if z < 5e10Initial program 86.6%
*-commutative86.6%
associate-/l*86.6%
Simplified86.6%
Taylor expanded in x around 0 53.6%
associate-*l/57.0%
un-div-inv57.0%
Applied egg-rr57.0%
if 5e10 < z Initial program 82.3%
associate-/l*69.6%
associate-/l/72.4%
Simplified72.4%
clear-num71.8%
un-div-inv71.8%
*-commutative71.8%
associate-/l*74.0%
Applied egg-rr74.0%
associate-*r/71.8%
associate-/r/78.0%
associate-/l/99.8%
*-commutative99.8%
associate-/l/78.0%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in x around 0 58.8%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= z_m 4e-47) (/ (/ y z_m) x) (/ y (* z_m x)))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 4e-47) {
tmp = (y / z_m) / x;
} else {
tmp = y / (z_m * x);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 4d-47) then
tmp = (y / z_m) / x
else
tmp = y / (z_m * x)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 4e-47) {
tmp = (y / z_m) / x;
} else {
tmp = y / (z_m * x);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if z_m <= 4e-47: tmp = (y / z_m) / x else: tmp = y / (z_m * x) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 4e-47) tmp = Float64(Float64(y / z_m) / x); else tmp = Float64(y / Float64(z_m * x)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (z_m <= 4e-47) tmp = (y / z_m) / x; else tmp = y / (z_m * x); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 4e-47], N[(N[(y / z$95$m), $MachinePrecision] / x), $MachinePrecision], N[(y / N[(z$95$m * x), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 4 \cdot 10^{-47}:\\
\;\;\;\;\frac{\frac{y}{z\_m}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z\_m \cdot x}\\
\end{array}
\end{array}
if z < 3.9999999999999999e-47Initial program 87.5%
*-commutative87.5%
associate-/l*87.4%
Simplified87.4%
Taylor expanded in x around 0 54.0%
associate-*l/57.6%
un-div-inv57.6%
Applied egg-rr57.6%
if 3.9999999999999999e-47 < z Initial program 80.7%
associate-/l*70.1%
associate-/l/72.5%
Simplified72.5%
Taylor expanded in x around 0 56.6%
Final simplification57.4%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= z_m 200000.0) (/ (/ y x) z_m) (/ y (* z_m x)))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 200000.0) {
tmp = (y / x) / z_m;
} else {
tmp = y / (z_m * x);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 200000.0d0) then
tmp = (y / x) / z_m
else
tmp = y / (z_m * x)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 200000.0) {
tmp = (y / x) / z_m;
} else {
tmp = y / (z_m * x);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if z_m <= 200000.0: tmp = (y / x) / z_m else: tmp = y / (z_m * x) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 200000.0) tmp = Float64(Float64(y / x) / z_m); else tmp = Float64(y / Float64(z_m * x)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (z_m <= 200000.0) tmp = (y / x) / z_m; else tmp = y / (z_m * x); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 200000.0], N[(N[(y / x), $MachinePrecision] / z$95$m), $MachinePrecision], N[(y / N[(z$95$m * x), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 200000:\\
\;\;\;\;\frac{\frac{y}{x}}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z\_m \cdot x}\\
\end{array}
\end{array}
if z < 2e5Initial program 86.4%
Taylor expanded in x around 0 53.5%
if 2e5 < z Initial program 83.2%
associate-/l*71.1%
associate-/l/73.9%
Simplified73.9%
Taylor expanded in x around 0 59.1%
Final simplification54.7%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (/ y (* z_m x))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
return z_s * (y / (z_m * x));
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = z_s * (y / (z_m * x))
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
return z_s * (y / (z_m * x));
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): return z_s * (y / (z_m * x))
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m) return Float64(z_s * Float64(y / Float64(z_m * x))) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp = code(z_s, x, y, z_m) tmp = z_s * (y / (z_m * x)); end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * N[(y / N[(z$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \frac{y}{z\_m \cdot x}
\end{array}
Initial program 85.7%
associate-/l*79.8%
associate-/l/79.2%
Simplified79.2%
Taylor expanded in x around 0 51.5%
Final simplification51.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (/ y z) x) (cosh x))))
(if (< y -4.618902267687042e-52)
t_0
(if (< y 1.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y / z) / x) * cosh(x);
double tmp;
if (y < -4.618902267687042e-52) {
tmp = t_0;
} else if (y < 1.038530535935153e-39) {
tmp = ((cosh(x) * y) / x) / z;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((y / z) / x) * cosh(x)
if (y < (-4.618902267687042d-52)) then
tmp = t_0
else if (y < 1.038530535935153d-39) then
tmp = ((cosh(x) * y) / x) / z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y / z) / x) * Math.cosh(x);
double tmp;
if (y < -4.618902267687042e-52) {
tmp = t_0;
} else if (y < 1.038530535935153e-39) {
tmp = ((Math.cosh(x) * y) / x) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y / z) / x) * math.cosh(x) tmp = 0 if y < -4.618902267687042e-52: tmp = t_0 elif y < 1.038530535935153e-39: tmp = ((math.cosh(x) * y) / x) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y / z) / x) * cosh(x)) tmp = 0.0 if (y < -4.618902267687042e-52) tmp = t_0; elseif (y < 1.038530535935153e-39) tmp = Float64(Float64(Float64(cosh(x) * y) / x) / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y / z) / x) * cosh(x); tmp = 0.0; if (y < -4.618902267687042e-52) tmp = t_0; elseif (y < 1.038530535935153e-39) tmp = ((cosh(x) * y) / x) / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision] * N[Cosh[x], $MachinePrecision]), $MachinePrecision]}, If[Less[y, -4.618902267687042e-52], t$95$0, If[Less[y, 1.038530535935153e-39], N[(N[(N[(N[Cosh[x], $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{y}{z}}{x} \cdot \cosh x\\
\mathbf{if}\;y < -4.618902267687042 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y < 1.038530535935153 \cdot 10^{-39}:\\
\;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024085
(FPCore (x y z)
:name "Linear.Quaternion:$ctan from linear-1.19.1.3"
:precision binary64
:alt
(if (< y -4.618902267687042e-52) (* (/ (/ y z) x) (cosh x)) (if (< y 1.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))
(/ (* (cosh x) (/ y x)) z))