
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
return (x * (sin(y) / y)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (sin(y) / y)) / z
end function
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
return (x * (sin(y) / y)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (sin(y) / y)) / z
end function
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= z_m 2e-51) (/ x (* y (/ z_m (sin y)))) (/ (* x (/ (sin y) y)) 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 <= 2e-51) {
tmp = x / (y * (z_m / sin(y)));
} else {
tmp = (x * (sin(y) / y)) / 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 <= 2d-51) then
tmp = x / (y * (z_m / sin(y)))
else
tmp = (x * (sin(y) / y)) / 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 <= 2e-51) {
tmp = x / (y * (z_m / Math.sin(y)));
} else {
tmp = (x * (Math.sin(y) / y)) / 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 <= 2e-51: tmp = x / (y * (z_m / math.sin(y))) else: tmp = (x * (math.sin(y) / y)) / 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 <= 2e-51) tmp = Float64(x / Float64(y * Float64(z_m / sin(y)))); else tmp = Float64(Float64(x * Float64(sin(y) / y)) / 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 <= 2e-51) tmp = x / (y * (z_m / sin(y))); else tmp = (x * (sin(y) / y)) / 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, 2e-51], N[(x / N[(y * N[(z$95$m / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z$95$m), $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 2 \cdot 10^{-51}:\\
\;\;\;\;\frac{x}{y \cdot \frac{z\_m}{\sin y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z\_m}\\
\end{array}
\end{array}
if z < 2e-51Initial program 94.3%
associate-/l*95.9%
associate-/l/88.3%
*-commutative88.3%
Simplified88.3%
associate-/r*95.9%
clear-num95.8%
un-div-inv96.0%
clear-num95.9%
associate-/r*88.2%
clear-num88.3%
associate-/l*92.4%
Applied egg-rr92.4%
if 2e-51 < z Initial program 99.9%
Final simplification94.4%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 1.25e-30) (/ x z_m) (* x (/ (sin y) (* z_m y))))))
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 (y <= 1.25e-30) {
tmp = x / z_m;
} else {
tmp = x * (sin(y) / (z_m * y));
}
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 (y <= 1.25d-30) then
tmp = x / z_m
else
tmp = x * (sin(y) / (z_m * y))
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 (y <= 1.25e-30) {
tmp = x / z_m;
} else {
tmp = x * (Math.sin(y) / (z_m * y));
}
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 y <= 1.25e-30: tmp = x / z_m else: tmp = x * (math.sin(y) / (z_m * y)) 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 (y <= 1.25e-30) tmp = Float64(x / z_m); else tmp = Float64(x * Float64(sin(y) / Float64(z_m * y))); 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 (y <= 1.25e-30) tmp = x / z_m; else tmp = x * (sin(y) / (z_m * y)); 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[y, 1.25e-30], N[(x / z$95$m), $MachinePrecision], N[(x * N[(N[Sin[y], $MachinePrecision] / N[(z$95$m * y), $MachinePrecision]), $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}\;y \leq 1.25 \cdot 10^{-30}:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sin y}{z\_m \cdot y}\\
\end{array}
\end{array}
if y < 1.24999999999999993e-30Initial program 96.3%
associate-/l*95.2%
associate-/l/87.4%
*-commutative87.4%
Simplified87.4%
Taylor expanded in y around 0 65.1%
if 1.24999999999999993e-30 < y Initial program 94.5%
associate-/l*97.9%
associate-/l/97.2%
*-commutative97.2%
Simplified97.2%
Final simplification74.2%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (* x (/ (/ (sin y) y) z_m))))
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 * (x * ((sin(y) / y) / z_m));
}
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 * (x * ((sin(y) / y) / z_m))
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 * (x * ((Math.sin(y) / y) / z_m));
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): return z_s * (x * ((math.sin(y) / y) / z_m))
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) return Float64(z_s * Float64(x * Float64(Float64(sin(y) / y) / z_m))) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp = code(z_s, x, y, z_m) tmp = z_s * (x * ((sin(y) / y) / z_m)); 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[(x * N[(N[(N[Sin[y], $MachinePrecision] / y), $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 \left(x \cdot \frac{\frac{\sin y}{y}}{z\_m}\right)
\end{array}
Initial program 95.8%
associate-/l*96.0%
Simplified96.0%
Final simplification96.0%
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= y 1.65e-16)
(/ x z_m)
(/ (/ x (+ (* (* z_m y) 0.16666666666666666) (/ z_m y))) y))))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 (y <= 1.65e-16) {
tmp = x / z_m;
} else {
tmp = (x / (((z_m * y) * 0.16666666666666666) + (z_m / y))) / y;
}
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 (y <= 1.65d-16) then
tmp = x / z_m
else
tmp = (x / (((z_m * y) * 0.16666666666666666d0) + (z_m / y))) / y
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 (y <= 1.65e-16) {
tmp = x / z_m;
} else {
tmp = (x / (((z_m * y) * 0.16666666666666666) + (z_m / y))) / y;
}
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 y <= 1.65e-16: tmp = x / z_m else: tmp = (x / (((z_m * y) * 0.16666666666666666) + (z_m / y))) / y 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 (y <= 1.65e-16) tmp = Float64(x / z_m); else tmp = Float64(Float64(x / Float64(Float64(Float64(z_m * y) * 0.16666666666666666) + Float64(z_m / y))) / y); 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 (y <= 1.65e-16) tmp = x / z_m; else tmp = (x / (((z_m * y) * 0.16666666666666666) + (z_m / y))) / y; 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[y, 1.65e-16], N[(x / z$95$m), $MachinePrecision], N[(N[(x / N[(N[(N[(z$95$m * y), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] + N[(z$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $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}\;y \leq 1.65 \cdot 10^{-16}:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\left(z\_m \cdot y\right) \cdot 0.16666666666666666 + \frac{z\_m}{y}}}{y}\\
\end{array}
\end{array}
if y < 1.64999999999999994e-16Initial program 96.3%
associate-/l*95.3%
associate-/l/87.5%
*-commutative87.5%
Simplified87.5%
Taylor expanded in y around 0 65.4%
if 1.64999999999999994e-16 < y Initial program 94.3%
*-commutative94.3%
associate-*l/94.3%
associate-/l*94.3%
associate-/l*94.3%
Simplified94.3%
associate-/r*96.9%
*-un-lft-identity96.9%
times-frac91.7%
Applied egg-rr91.7%
*-commutative91.7%
frac-times96.9%
*-un-lft-identity96.9%
associate-/r/97.0%
associate-*r/97.0%
*-commutative97.0%
associate-/r*91.8%
Applied egg-rr91.8%
Taylor expanded in y around 0 43.6%
Final simplification59.4%
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= y 2.4)
(/ x z_m)
(* (/ 1.0 y) (/ x (* y (* z_m 0.16666666666666666)))))))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 (y <= 2.4) {
tmp = x / z_m;
} else {
tmp = (1.0 / y) * (x / (y * (z_m * 0.16666666666666666)));
}
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 (y <= 2.4d0) then
tmp = x / z_m
else
tmp = (1.0d0 / y) * (x / (y * (z_m * 0.16666666666666666d0)))
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 (y <= 2.4) {
tmp = x / z_m;
} else {
tmp = (1.0 / y) * (x / (y * (z_m * 0.16666666666666666)));
}
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 y <= 2.4: tmp = x / z_m else: tmp = (1.0 / y) * (x / (y * (z_m * 0.16666666666666666))) 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 (y <= 2.4) tmp = Float64(x / z_m); else tmp = Float64(Float64(1.0 / y) * Float64(x / Float64(y * Float64(z_m * 0.16666666666666666)))); 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 (y <= 2.4) tmp = x / z_m; else tmp = (1.0 / y) * (x / (y * (z_m * 0.16666666666666666))); 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[y, 2.4], N[(x / z$95$m), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x / N[(y * N[(z$95$m * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $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}\;y \leq 2.4:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{x}{y \cdot \left(z\_m \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if y < 2.39999999999999991Initial program 96.3%
associate-/l*95.3%
associate-/l/87.7%
*-commutative87.7%
Simplified87.7%
Taylor expanded in y around 0 65.7%
if 2.39999999999999991 < y Initial program 94.1%
associate-/l*97.8%
associate-/l/97.0%
*-commutative97.0%
Simplified97.0%
associate-/r*97.8%
clear-num96.9%
un-div-inv96.9%
clear-num96.9%
associate-/r*96.9%
clear-num96.9%
associate-/l*96.9%
Applied egg-rr96.9%
Taylor expanded in y around 0 39.7%
Taylor expanded in y around inf 39.7%
*-commutative39.7%
associate-*r*39.7%
Simplified39.7%
*-un-lft-identity39.7%
times-frac41.2%
Applied egg-rr41.2%
Final simplification59.2%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 2.4) (/ x z_m) (/ x (* y (* (* z_m y) 0.16666666666666666))))))
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 (y <= 2.4) {
tmp = x / z_m;
} else {
tmp = x / (y * ((z_m * y) * 0.16666666666666666));
}
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 (y <= 2.4d0) then
tmp = x / z_m
else
tmp = x / (y * ((z_m * y) * 0.16666666666666666d0))
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 (y <= 2.4) {
tmp = x / z_m;
} else {
tmp = x / (y * ((z_m * y) * 0.16666666666666666));
}
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 y <= 2.4: tmp = x / z_m else: tmp = x / (y * ((z_m * y) * 0.16666666666666666)) 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 (y <= 2.4) tmp = Float64(x / z_m); else tmp = Float64(x / Float64(y * Float64(Float64(z_m * y) * 0.16666666666666666))); 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 (y <= 2.4) tmp = x / z_m; else tmp = x / (y * ((z_m * y) * 0.16666666666666666)); 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[y, 2.4], N[(x / z$95$m), $MachinePrecision], N[(x / N[(y * N[(N[(z$95$m * y), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $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}\;y \leq 2.4:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(\left(z\_m \cdot y\right) \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if y < 2.39999999999999991Initial program 96.3%
associate-/l*95.3%
associate-/l/87.7%
*-commutative87.7%
Simplified87.7%
Taylor expanded in y around 0 65.7%
if 2.39999999999999991 < y Initial program 94.1%
associate-/l*97.8%
associate-/l/97.0%
*-commutative97.0%
Simplified97.0%
associate-/r*97.8%
clear-num96.9%
un-div-inv96.9%
clear-num96.9%
associate-/r*96.9%
clear-num96.9%
associate-/l*96.9%
Applied egg-rr96.9%
Taylor expanded in y around 0 39.7%
Taylor expanded in y around inf 39.7%
Final simplification58.8%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 2.4) (/ x z_m) (/ (/ x y) (* y (* z_m 0.16666666666666666))))))
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 (y <= 2.4) {
tmp = x / z_m;
} else {
tmp = (x / y) / (y * (z_m * 0.16666666666666666));
}
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 (y <= 2.4d0) then
tmp = x / z_m
else
tmp = (x / y) / (y * (z_m * 0.16666666666666666d0))
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 (y <= 2.4) {
tmp = x / z_m;
} else {
tmp = (x / y) / (y * (z_m * 0.16666666666666666));
}
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 y <= 2.4: tmp = x / z_m else: tmp = (x / y) / (y * (z_m * 0.16666666666666666)) 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 (y <= 2.4) tmp = Float64(x / z_m); else tmp = Float64(Float64(x / y) / Float64(y * Float64(z_m * 0.16666666666666666))); 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 (y <= 2.4) tmp = x / z_m; else tmp = (x / y) / (y * (z_m * 0.16666666666666666)); 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[y, 2.4], N[(x / z$95$m), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y * N[(z$95$m * 0.16666666666666666), $MachinePrecision]), $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}\;y \leq 2.4:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y \cdot \left(z\_m \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if y < 2.39999999999999991Initial program 96.3%
associate-/l*95.3%
associate-/l/87.7%
*-commutative87.7%
Simplified87.7%
Taylor expanded in y around 0 65.7%
if 2.39999999999999991 < y Initial program 94.1%
associate-/l*97.8%
associate-/l/97.0%
*-commutative97.0%
Simplified97.0%
associate-/r*97.8%
clear-num96.9%
un-div-inv96.9%
clear-num96.9%
associate-/r*96.9%
clear-num96.9%
associate-/l*96.9%
Applied egg-rr96.9%
Taylor expanded in y around 0 39.7%
Taylor expanded in y around inf 39.7%
*-commutative39.7%
associate-*r*39.7%
Simplified39.7%
*-un-lft-identity39.7%
times-frac41.2%
Applied egg-rr41.2%
*-commutative41.2%
associate-*l/39.8%
associate-/l*39.8%
*-rgt-identity39.8%
Simplified39.8%
Final simplification58.8%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 50000000.0) (/ x z_m) (/ x (/ (* z_m y) y)))))
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 (y <= 50000000.0) {
tmp = x / z_m;
} else {
tmp = x / ((z_m * y) / y);
}
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 (y <= 50000000.0d0) then
tmp = x / z_m
else
tmp = x / ((z_m * y) / y)
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 (y <= 50000000.0) {
tmp = x / z_m;
} else {
tmp = x / ((z_m * y) / y);
}
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 y <= 50000000.0: tmp = x / z_m else: tmp = x / ((z_m * y) / y) 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 (y <= 50000000.0) tmp = Float64(x / z_m); else tmp = Float64(x / Float64(Float64(z_m * y) / y)); 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 (y <= 50000000.0) tmp = x / z_m; else tmp = x / ((z_m * y) / y); 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[y, 50000000.0], N[(x / z$95$m), $MachinePrecision], N[(x / N[(N[(z$95$m * y), $MachinePrecision] / y), $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}\;y \leq 50000000:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z\_m \cdot y}{y}}\\
\end{array}
\end{array}
if y < 5e7Initial program 96.3%
associate-/l*95.3%
associate-/l/87.7%
*-commutative87.7%
Simplified87.7%
Taylor expanded in y around 0 65.7%
if 5e7 < y Initial program 94.1%
associate-/l*97.8%
associate-/l/97.0%
*-commutative97.0%
Simplified97.0%
associate-/r*97.8%
clear-num96.9%
un-div-inv96.9%
clear-num96.9%
associate-/r*96.9%
clear-num96.9%
associate-/l*96.9%
Applied egg-rr96.9%
Taylor expanded in y around 0 24.6%
associate-*r/32.5%
Applied egg-rr32.5%
Final simplification56.9%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (/ 1.0 (/ 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 * (1.0 / (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 * (1.0d0 / (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 * (1.0 / (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 * (1.0 / (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(1.0 / 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 * (1.0 / (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[(1.0 / 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{1}{\frac{z\_m}{x}}
\end{array}
Initial program 95.8%
associate-/l*96.0%
associate-/l/90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in y around 0 54.7%
div-inv54.9%
clear-num55.2%
Applied egg-rr55.2%
Final simplification55.2%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (/ 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) {
return z_s * (x / z_m);
}
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 * (x / z_m)
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 * (x / z_m);
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): return z_s * (x / z_m)
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) return Float64(z_s * Float64(x / z_m)) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp = code(z_s, x, y, z_m) tmp = z_s * (x / z_m); 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[(x / z$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \frac{x}{z\_m}
\end{array}
Initial program 95.8%
associate-/l*96.0%
associate-/l/90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in y around 0 54.9%
Final simplification54.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (sin y))) (t_1 (/ (* x (/ 1.0 t_0)) z)))
(if (< z -4.2173720203427147e-29)
t_1
(if (< z 4.446702369113811e+64) (/ x (* z t_0)) t_1))))
double code(double x, double y, double z) {
double t_0 = y / sin(y);
double t_1 = (x * (1.0 / t_0)) / z;
double tmp;
if (z < -4.2173720203427147e-29) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x / (z * t_0);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = y / sin(y)
t_1 = (x * (1.0d0 / t_0)) / z
if (z < (-4.2173720203427147d-29)) then
tmp = t_1
else if (z < 4.446702369113811d+64) then
tmp = x / (z * t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / Math.sin(y);
double t_1 = (x * (1.0 / t_0)) / z;
double tmp;
if (z < -4.2173720203427147e-29) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x / (z * t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y / math.sin(y) t_1 = (x * (1.0 / t_0)) / z tmp = 0 if z < -4.2173720203427147e-29: tmp = t_1 elif z < 4.446702369113811e+64: tmp = x / (z * t_0) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y / sin(y)) t_1 = Float64(Float64(x * Float64(1.0 / t_0)) / z) tmp = 0.0 if (z < -4.2173720203427147e-29) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = Float64(x / Float64(z * t_0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / sin(y); t_1 = (x * (1.0 / t_0)) / z; tmp = 0.0; if (z < -4.2173720203427147e-29) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = x / (z * t_0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Less[z, -4.2173720203427147e-29], t$95$1, If[Less[z, 4.446702369113811e+64], N[(x / N[(z * t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{\sin y}\\
t_1 := \frac{x \cdot \frac{1}{t\_0}}{z}\\
\mathbf{if}\;z < -4.2173720203427147 \cdot 10^{-29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\
\;\;\;\;\frac{x}{z \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024040
(FPCore (x y z)
:name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< z -4.2173720203427147e-29) (/ (* x (/ 1.0 (/ y (sin y)))) z) (if (< z 4.446702369113811e+64) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1.0 (/ y (sin y)))) z)))
(/ (* x (/ (sin y) y)) z))