
(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 12 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 (let* ((t_0 (/ (sin y) y))) (* z_s (if (<= z_m 2.9e-71) (/ x (/ z_m t_0)) (* t_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 t_0 = sin(y) / y;
double tmp;
if (z_m <= 2.9e-71) {
tmp = x / (z_m / t_0);
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = sin(y) / y
if (z_m <= 2.9d-71) then
tmp = x / (z_m / t_0)
else
tmp = t_0 * (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.sin(y) / y;
double tmp;
if (z_m <= 2.9e-71) {
tmp = x / (z_m / t_0);
} else {
tmp = t_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): t_0 = math.sin(y) / y tmp = 0 if z_m <= 2.9e-71: tmp = x / (z_m / t_0) else: tmp = t_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) t_0 = Float64(sin(y) / y) tmp = 0.0 if (z_m <= 2.9e-71) tmp = Float64(x / Float64(z_m / t_0)); else tmp = Float64(t_0 * Float64(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 = sin(y) / y; tmp = 0.0; if (z_m <= 2.9e-71) tmp = x / (z_m / t_0); else tmp = t_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_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, N[(z$95$s * If[LessEqual[z$95$m, 2.9e-71], N[(x / N[(z$95$m / t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(x / 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{\sin y}{y}\\
z_s \cdot \begin{array}{l}
\mathbf{if}\;z_m \leq 2.9 \cdot 10^{-71}:\\
\;\;\;\;\frac{x}{\frac{z_m}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{x}{z_m}\\
\end{array}
\end{array}
\end{array}
if z < 2.8999999999999999e-71Initial program 92.9%
associate-/l*96.9%
Simplified96.9%
if 2.8999999999999999e-71 < z Initial program 99.8%
*-commutative99.8%
associate-*r/99.8%
Simplified99.8%
Final simplification97.7%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 7e-13) (/ 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 <= 7e-13) {
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 <= 7d-13) 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 <= 7e-13) {
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 <= 7e-13: 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 <= 7e-13) 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 <= 7e-13) 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, 7e-13], 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 7 \cdot 10^{-13}:\\
\;\;\;\;\frac{x}{z_m}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sin y}{z_m \cdot y}\\
\end{array}
\end{array}
if y < 7.0000000000000005e-13Initial program 96.4%
associate-*r/97.6%
associate-/l/87.4%
*-commutative87.4%
Simplified87.4%
Taylor expanded in y around 0 66.9%
if 7.0000000000000005e-13 < y Initial program 90.9%
associate-*r/89.2%
associate-/l/88.1%
*-commutative88.1%
Simplified88.1%
Final simplification72.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 3.8e-33) (/ x z_m) (* (sin y) (/ (/ x 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 (y <= 3.8e-33) {
tmp = x / z_m;
} else {
tmp = sin(y) * ((x / 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 (y <= 3.8d-33) then
tmp = x / z_m
else
tmp = sin(y) * ((x / 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 (y <= 3.8e-33) {
tmp = x / z_m;
} else {
tmp = Math.sin(y) * ((x / 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 y <= 3.8e-33: tmp = x / z_m else: tmp = math.sin(y) * ((x / 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 (y <= 3.8e-33) tmp = Float64(x / z_m); else tmp = Float64(sin(y) * Float64(Float64(x / 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 (y <= 3.8e-33) tmp = x / z_m; else tmp = sin(y) * ((x / 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[y, 3.8e-33], N[(x / z$95$m), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(N[(x / 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 \begin{array}{l}
\mathbf{if}\;y \leq 3.8 \cdot 10^{-33}:\\
\;\;\;\;\frac{x}{z_m}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z_m}\\
\end{array}
\end{array}
if y < 3.79999999999999994e-33Initial program 96.3%
associate-*r/97.6%
associate-/l/87.3%
*-commutative87.3%
Simplified87.3%
Taylor expanded in y around 0 66.7%
if 3.79999999999999994e-33 < y Initial program 91.0%
*-lft-identity91.0%
metadata-eval91.0%
times-frac91.0%
neg-mul-191.0%
distribute-lft-neg-out91.0%
associate-*r/90.9%
associate-*l/90.9%
*-commutative90.9%
times-frac91.1%
remove-double-neg91.1%
distribute-frac-neg91.1%
sin-neg91.1%
sin-neg91.1%
neg-mul-191.1%
associate-/l*90.9%
associate-/r/91.1%
distribute-lft-neg-in91.1%
metadata-eval91.1%
metadata-eval91.1%
neg-mul-191.1%
sin-neg91.1%
*-commutative91.1%
Simplified91.1%
Final simplification73.6%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (* (/ (sin y) y) (/ 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 * ((sin(y) / y) * (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 * ((sin(y) / y) * (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 * ((Math.sin(y) / y) * (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 * ((math.sin(y) / y) * (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(Float64(sin(y) / y) * 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 * ((sin(y) / y) * (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[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / 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(\frac{\sin y}{y} \cdot \frac{x}{z_m}\right)
\end{array}
Initial program 94.8%
*-commutative94.8%
associate-*r/96.5%
Simplified96.5%
Final simplification96.5%
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.95e-7) (/ x z_m) (/ y (/ 1.0 (* x (/ -1.0 (* 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.95e-7) {
tmp = x / z_m;
} else {
tmp = y / (1.0 / (x * (-1.0 / (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.95d-7) then
tmp = x / z_m
else
tmp = y / (1.0d0 / (x * ((-1.0d0) / (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.95e-7) {
tmp = x / z_m;
} else {
tmp = y / (1.0 / (x * (-1.0 / (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.95e-7: tmp = x / z_m else: tmp = y / (1.0 / (x * (-1.0 / (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.95e-7) tmp = Float64(x / z_m); else tmp = Float64(y / Float64(1.0 / Float64(x * Float64(-1.0 / Float64(z_m * Float64(-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.95e-7) tmp = x / z_m; else tmp = y / (1.0 / (x * (-1.0 / (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.95e-7], N[(x / z$95$m), $MachinePrecision], N[(y / N[(1.0 / N[(x * N[(-1.0 / N[(z$95$m * (-y)), $MachinePrecision]), $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 1.95 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{z_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{1}{x \cdot \frac{-1}{z_m \cdot \left(-y\right)}}}\\
\end{array}
\end{array}
if y < 1.95000000000000012e-7Initial program 96.4%
associate-*r/97.6%
associate-/l/87.4%
*-commutative87.4%
Simplified87.4%
Taylor expanded in y around 0 66.9%
if 1.95000000000000012e-7 < y Initial program 90.9%
associate-*r/89.2%
associate-/l/88.1%
*-commutative88.1%
Simplified88.1%
Taylor expanded in y around 0 16.1%
*-un-lft-identity16.1%
div-inv16.1%
*-commutative16.1%
*-inverses16.1%
times-frac18.2%
*-commutative18.2%
associate-/r*15.9%
*-commutative15.9%
associate-*r/21.8%
associate-/l*27.1%
div-inv27.1%
clear-num27.1%
Applied egg-rr27.1%
associate-*r/27.2%
*-commutative27.2%
clear-num27.2%
Applied egg-rr27.2%
clear-num27.2%
frac-2neg27.2%
associate-/r/27.2%
distribute-rgt-neg-in27.2%
Applied egg-rr27.2%
Final simplification55.7%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 1e+99) (/ 1.0 (/ z_m x)) (* x (/ 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 <= 1e+99) {
tmp = 1.0 / (z_m / x);
} else {
tmp = x * (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 <= 1d+99) then
tmp = 1.0d0 / (z_m / x)
else
tmp = x * (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 <= 1e+99) {
tmp = 1.0 / (z_m / x);
} else {
tmp = x * (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 <= 1e+99: tmp = 1.0 / (z_m / x) else: tmp = x * (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 <= 1e+99) tmp = Float64(1.0 / Float64(z_m / x)); else tmp = Float64(x * Float64(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 <= 1e+99) tmp = 1.0 / (z_m / x); else tmp = x * (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, 1e+99], N[(1.0 / N[(z$95$m / x), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / 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 10^{+99}:\\
\;\;\;\;\frac{1}{\frac{z_m}{x}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z_m \cdot y}\\
\end{array}
\end{array}
if y < 9.9999999999999997e98Initial program 96.0%
associate-*r/97.4%
associate-/l/88.5%
*-commutative88.5%
Simplified88.5%
Taylor expanded in y around 0 59.9%
div-inv60.1%
clear-num60.4%
Applied egg-rr60.4%
if 9.9999999999999997e98 < y Initial program 89.0%
associate-*r/84.6%
associate-/l/82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in y around 0 23.7%
Final simplification54.1%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 8e+15) (/ x z_m) (* y (/ x (* 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 <= 8e+15) {
tmp = x / z_m;
} else {
tmp = y * (x / (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 <= 8d+15) then
tmp = x / z_m
else
tmp = y * (x / (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 <= 8e+15) {
tmp = x / z_m;
} else {
tmp = y * (x / (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 <= 8e+15: tmp = x / z_m else: tmp = y * (x / (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 <= 8e+15) tmp = Float64(x / z_m); else tmp = Float64(y * Float64(x / 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 <= 8e+15) tmp = x / z_m; else tmp = y * (x / (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, 8e+15], N[(x / z$95$m), $MachinePrecision], N[(y * N[(x / 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 8 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{z_m}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z_m \cdot y}\\
\end{array}
\end{array}
if y < 8e15Initial program 96.4%
associate-*r/97.6%
associate-/l/87.5%
*-commutative87.5%
Simplified87.5%
Taylor expanded in y around 0 66.2%
if 8e15 < y Initial program 90.6%
*-lft-identity90.6%
metadata-eval90.6%
times-frac90.6%
neg-mul-190.6%
distribute-lft-neg-out90.6%
associate-*r/90.5%
associate-*l/90.5%
*-commutative90.5%
times-frac90.7%
remove-double-neg90.7%
distribute-frac-neg90.7%
sin-neg90.7%
sin-neg90.7%
neg-mul-190.7%
associate-/l*90.6%
associate-/r/90.7%
distribute-lft-neg-in90.7%
metadata-eval90.7%
metadata-eval90.7%
neg-mul-190.7%
sin-neg90.7%
*-commutative90.7%
Simplified90.7%
Taylor expanded in y around 0 26.8%
Taylor expanded in x around 0 26.9%
*-commutative26.9%
Simplified26.9%
Final simplification55.5%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 0.12) (/ x z_m) (/ y (* 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 (y <= 0.12) {
tmp = x / z_m;
} else {
tmp = y / (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 (y <= 0.12d0) then
tmp = x / z_m
else
tmp = y / (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 (y <= 0.12) {
tmp = x / z_m;
} else {
tmp = y / (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 y <= 0.12: tmp = x / z_m else: tmp = y / (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 (y <= 0.12) tmp = Float64(x / z_m); else tmp = Float64(y / 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 (y <= 0.12) tmp = x / z_m; else tmp = y / (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[y, 0.12], N[(x / z$95$m), $MachinePrecision], N[(y / N[(y * N[(z$95$m / x), $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 0.12:\\
\;\;\;\;\frac{x}{z_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y \cdot \frac{z_m}{x}}\\
\end{array}
\end{array}
if y < 0.12Initial program 96.4%
associate-*r/97.6%
associate-/l/87.4%
*-commutative87.4%
Simplified87.4%
Taylor expanded in y around 0 66.9%
if 0.12 < y Initial program 90.9%
associate-*r/89.2%
associate-/l/88.1%
*-commutative88.1%
Simplified88.1%
Taylor expanded in y around 0 16.1%
*-un-lft-identity16.1%
div-inv16.1%
*-commutative16.1%
*-inverses16.1%
times-frac18.2%
*-commutative18.2%
associate-/r*15.9%
*-commutative15.9%
associate-*r/21.8%
associate-/l*27.1%
div-inv27.1%
clear-num27.1%
Applied egg-rr27.1%
clear-num27.1%
associate-/r/27.1%
associate-/l/26.3%
clear-num26.3%
associate-/l/26.4%
*-commutative26.4%
Applied egg-rr26.4%
clear-num27.2%
associate-*l/27.2%
*-un-lft-identity27.2%
*-un-lft-identity27.2%
times-frac26.8%
/-rgt-identity26.8%
Applied egg-rr26.8%
Final simplification55.6%
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.18e-15) (/ x z_m) (/ y (* z_m (/ y 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 (y <= 1.18e-15) {
tmp = x / z_m;
} else {
tmp = y / (z_m * (y / 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 (y <= 1.18d-15) then
tmp = x / z_m
else
tmp = y / (z_m * (y / 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 (y <= 1.18e-15) {
tmp = x / z_m;
} else {
tmp = y / (z_m * (y / 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 y <= 1.18e-15: tmp = x / z_m else: tmp = y / (z_m * (y / 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 (y <= 1.18e-15) tmp = Float64(x / z_m); else tmp = Float64(y / Float64(z_m * Float64(y / 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 (y <= 1.18e-15) tmp = x / z_m; else tmp = y / (z_m * (y / 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[y, 1.18e-15], N[(x / z$95$m), $MachinePrecision], N[(y / N[(z$95$m * N[(y / x), $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.18 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{z_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z_m \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 1.18000000000000004e-15Initial program 96.4%
associate-*r/97.6%
associate-/l/87.4%
*-commutative87.4%
Simplified87.4%
Taylor expanded in y around 0 66.9%
if 1.18000000000000004e-15 < y Initial program 90.9%
associate-*r/89.2%
associate-/l/88.1%
*-commutative88.1%
Simplified88.1%
Taylor expanded in y around 0 16.1%
*-un-lft-identity16.1%
div-inv16.1%
*-commutative16.1%
*-inverses16.1%
times-frac18.2%
*-commutative18.2%
associate-/r*15.9%
*-commutative15.9%
associate-*r/21.8%
associate-/l*27.1%
div-inv27.1%
clear-num27.1%
Applied egg-rr27.1%
Final simplification55.7%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 0.0014) (/ x z_m) (/ y (/ (* z_m y) 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 (y <= 0.0014) {
tmp = x / z_m;
} else {
tmp = y / ((z_m * y) / 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 (y <= 0.0014d0) then
tmp = x / z_m
else
tmp = y / ((z_m * y) / 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 (y <= 0.0014) {
tmp = x / z_m;
} else {
tmp = y / ((z_m * y) / 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 y <= 0.0014: tmp = x / z_m else: tmp = y / ((z_m * y) / 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 (y <= 0.0014) tmp = Float64(x / z_m); else tmp = Float64(y / Float64(Float64(z_m * y) / 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 (y <= 0.0014) tmp = x / z_m; else tmp = y / ((z_m * y) / 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[y, 0.0014], N[(x / z$95$m), $MachinePrecision], N[(y / N[(N[(z$95$m * y), $MachinePrecision] / 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}\;y \leq 0.0014:\\
\;\;\;\;\frac{x}{z_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z_m \cdot y}{x}}\\
\end{array}
\end{array}
if y < 0.00139999999999999999Initial program 96.4%
associate-*r/97.6%
associate-/l/87.4%
*-commutative87.4%
Simplified87.4%
Taylor expanded in y around 0 66.9%
if 0.00139999999999999999 < y Initial program 90.9%
associate-*r/89.2%
associate-/l/88.1%
*-commutative88.1%
Simplified88.1%
Taylor expanded in y around 0 16.1%
*-un-lft-identity16.1%
div-inv16.1%
*-commutative16.1%
*-inverses16.1%
times-frac18.2%
*-commutative18.2%
associate-/r*15.9%
*-commutative15.9%
associate-*r/21.8%
associate-/l*27.1%
div-inv27.1%
clear-num27.1%
Applied egg-rr27.1%
Taylor expanded in z around 0 27.2%
Final simplification55.7%
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 94.8%
associate-*r/95.2%
associate-/l/87.6%
*-commutative87.6%
Simplified87.6%
Taylor expanded in y around 0 52.5%
div-inv52.6%
clear-num52.9%
Applied egg-rr52.9%
Final simplification52.9%
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 94.8%
associate-*r/95.2%
associate-/l/87.6%
*-commutative87.6%
Simplified87.6%
Taylor expanded in y around 0 52.6%
Final simplification52.6%
(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 2024020
(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))