
(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}
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 2.4e+118) (/ x (/ z (/ (sin y) y))) (* (/ (sin y) z) (/ x y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2.4e+118) {
tmp = x / (z / (sin(y) / y));
} else {
tmp = (sin(y) / z) * (x / y);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 2.4d+118) then
tmp = x / (z / (sin(y) / y))
else
tmp = (sin(y) / z) * (x / y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.4e+118) {
tmp = x / (z / (Math.sin(y) / y));
} else {
tmp = (Math.sin(y) / z) * (x / y);
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 2.4e+118: tmp = x / (z / (math.sin(y) / y)) else: tmp = (math.sin(y) / z) * (x / y) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 2.4e+118) tmp = Float64(x / Float64(z / Float64(sin(y) / y))); else tmp = Float64(Float64(sin(y) / z) * Float64(x / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.4e+118) tmp = x / (z / (sin(y) / y)); else tmp = (sin(y) / z) * (x / y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 2.4e+118], N[(x / N[(z / N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4 \cdot 10^{+118}:\\
\;\;\;\;\frac{x}{\frac{z}{\frac{\sin y}{y}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin y}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 2.4e118Initial program 97.1%
associate-/l*97.8%
Simplified97.8%
if 2.4e118 < y Initial program 97.9%
associate-*r/97.6%
associate-/l/76.0%
*-commutative76.0%
times-frac97.8%
Simplified97.8%
Final simplification97.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 0.0001) (/ (* x (+ 1.0 (* -0.16666666666666666 (* y y)))) z) (* (/ (sin y) z) (/ x y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 0.0001) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = (sin(y) / z) * (x / y);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 0.0001d0) then
tmp = (x * (1.0d0 + ((-0.16666666666666666d0) * (y * y)))) / z
else
tmp = (sin(y) / z) * (x / y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 0.0001) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = (Math.sin(y) / z) * (x / y);
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 0.0001: tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z else: tmp = (math.sin(y) / z) * (x / y) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 0.0001) tmp = Float64(Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y)))) / z); else tmp = Float64(Float64(sin(y) / z) * Float64(x / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.0001) tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z; else tmp = (sin(y) / z) * (x / y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 0.0001], N[(N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.0001:\\
\;\;\;\;\frac{x \cdot \left(1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin y}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 1.00000000000000005e-4Initial program 97.4%
Taylor expanded in y around 0 61.6%
unpow261.6%
Simplified61.6%
if 1.00000000000000005e-4 < y Initial program 96.6%
associate-*r/96.4%
associate-/l/84.5%
*-commutative84.5%
times-frac96.6%
Simplified96.6%
Final simplification70.0%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
y = abs(y);
double code(double x, double y, double z) {
return (x * (sin(y) / y)) / z;
}
NOTE: y should be positive before calling this function
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
y = Math.abs(y);
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
y = abs(y) def code(x, y, z): return (x * (math.sin(y) / y)) / z
y = abs(y) function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
y = abs(y) function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
Initial program 97.2%
Final simplification97.2%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 18.5) (/ (* x (+ 1.0 (* -0.16666666666666666 (* y y)))) z) (/ y (/ (* y z) x))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 18.5) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = y / ((y * z) / x);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 18.5d0) then
tmp = (x * (1.0d0 + ((-0.16666666666666666d0) * (y * y)))) / z
else
tmp = y / ((y * z) / x)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 18.5) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = y / ((y * z) / x);
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 18.5: tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z else: tmp = y / ((y * z) / x) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 18.5) tmp = Float64(Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y)))) / z); else tmp = Float64(y / Float64(Float64(y * z) / x)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 18.5) tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z; else tmp = y / ((y * z) / x); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 18.5], N[(N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y / N[(N[(y * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 18.5:\\
\;\;\;\;\frac{x \cdot \left(1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{y \cdot z}{x}}\\
\end{array}
\end{array}
if y < 18.5Initial program 97.4%
Taylor expanded in y around 0 61.8%
unpow261.8%
Simplified61.8%
if 18.5 < y Initial program 96.5%
associate-*r/96.3%
associate-/l/84.2%
*-commutative84.2%
times-frac96.5%
Simplified96.5%
Taylor expanded in y around 0 26.3%
frac-times30.5%
*-commutative30.5%
associate-/l*38.1%
Applied egg-rr38.1%
Final simplification56.3%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 8e-13) (/ x z) (/ y (/ 1.0 (/ x (* y z))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 8e-13) {
tmp = x / z;
} else {
tmp = y / (1.0 / (x / (y * z)));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 8d-13) then
tmp = x / z
else
tmp = y / (1.0d0 / (x / (y * z)))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 8e-13) {
tmp = x / z;
} else {
tmp = y / (1.0 / (x / (y * z)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 8e-13: tmp = x / z else: tmp = y / (1.0 / (x / (y * z))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 8e-13) tmp = Float64(x / z); else tmp = Float64(y / Float64(1.0 / Float64(x / Float64(y * z)))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 8e-13) tmp = x / z; else tmp = y / (1.0 / (x / (y * z))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 8e-13], N[(x / z), $MachinePrecision], N[(y / N[(1.0 / N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-13}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{1}{\frac{x}{y \cdot z}}}\\
\end{array}
\end{array}
if y < 8.0000000000000002e-13Initial program 97.4%
associate-*r/91.6%
associate-/l/87.3%
*-commutative87.3%
times-frac82.3%
Simplified82.3%
Taylor expanded in y around 0 68.3%
if 8.0000000000000002e-13 < y Initial program 96.6%
associate-*r/96.5%
associate-/l/84.7%
*-commutative84.7%
times-frac96.6%
Simplified96.6%
Taylor expanded in y around 0 27.7%
*-commutative27.7%
clear-num27.7%
frac-times38.7%
*-un-lft-identity38.7%
Applied egg-rr38.7%
associate-*l/39.1%
clear-num39.1%
Applied egg-rr39.1%
Final simplification61.3%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 4e+47) (/ x z) (* y (/ x (* y z)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 4e+47) {
tmp = x / z;
} else {
tmp = y * (x / (y * z));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 4d+47) then
tmp = x / z
else
tmp = y * (x / (y * z))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4e+47) {
tmp = x / z;
} else {
tmp = y * (x / (y * z));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 4e+47: tmp = x / z else: tmp = y * (x / (y * z)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 4e+47) tmp = Float64(x / z); else tmp = Float64(y * Float64(x / Float64(y * z))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4e+47) tmp = x / z; else tmp = y * (x / (y * z)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 4e+47], N[(x / z), $MachinePrecision], N[(y * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+47}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 4.0000000000000002e47Initial program 97.5%
associate-*r/92.1%
associate-/l/87.6%
*-commutative87.6%
times-frac83.4%
Simplified83.4%
Taylor expanded in y around 0 65.9%
if 4.0000000000000002e47 < y Initial program 95.8%
associate-*r/95.6%
associate-/l/82.7%
*-commutative82.7%
times-frac95.9%
Simplified95.9%
Taylor expanded in y around 0 27.3%
*-commutative27.3%
clear-num27.3%
frac-times41.2%
*-un-lft-identity41.2%
Applied egg-rr41.2%
associate-*l/41.8%
associate-/l*32.5%
*-un-lft-identity32.5%
times-frac39.4%
/-rgt-identity39.4%
Applied egg-rr39.4%
Final simplification60.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 4.5e-17) (/ x z) (/ y (* y (/ z x)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 4.5e-17) {
tmp = x / z;
} else {
tmp = y / (y * (z / x));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 4.5d-17) then
tmp = x / z
else
tmp = y / (y * (z / x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.5e-17) {
tmp = x / z;
} else {
tmp = y / (y * (z / x));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 4.5e-17: tmp = x / z else: tmp = y / (y * (z / x)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 4.5e-17) tmp = Float64(x / z); else tmp = Float64(y / Float64(y * Float64(z / x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.5e-17) tmp = x / z; else tmp = y / (y * (z / x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 4.5e-17], N[(x / z), $MachinePrecision], N[(y / N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.5 \cdot 10^{-17}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y \cdot \frac{z}{x}}\\
\end{array}
\end{array}
if y < 4.49999999999999978e-17Initial program 97.3%
associate-*r/91.5%
associate-/l/87.1%
*-commutative87.1%
times-frac82.1%
Simplified82.1%
Taylor expanded in y around 0 68.0%
if 4.49999999999999978e-17 < y Initial program 96.7%
associate-*r/96.6%
associate-/l/85.2%
*-commutative85.2%
times-frac96.7%
Simplified96.7%
Taylor expanded in y around 0 30.0%
*-commutative30.0%
clear-num30.0%
frac-times40.6%
*-un-lft-identity40.6%
Applied egg-rr40.6%
Taylor expanded in y around 0 41.0%
associate-*r/40.6%
Simplified40.6%
Final simplification61.2%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 6e-14) (/ x z) (/ y (* z (/ y x)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 6e-14) {
tmp = x / z;
} else {
tmp = y / (z * (y / x));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 6d-14) then
tmp = x / z
else
tmp = y / (z * (y / x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 6e-14) {
tmp = x / z;
} else {
tmp = y / (z * (y / x));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 6e-14: tmp = x / z else: tmp = y / (z * (y / x)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 6e-14) tmp = Float64(x / z); else tmp = Float64(y / Float64(z * Float64(y / x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6e-14) tmp = x / z; else tmp = y / (z * (y / x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 6e-14], N[(x / z), $MachinePrecision], N[(y / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6 \cdot 10^{-14}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 5.9999999999999997e-14Initial program 97.3%
associate-*r/91.6%
associate-/l/87.2%
*-commutative87.2%
times-frac82.2%
Simplified82.2%
Taylor expanded in y around 0 68.2%
if 5.9999999999999997e-14 < y Initial program 96.7%
associate-*r/96.5%
associate-/l/85.0%
*-commutative85.0%
times-frac96.7%
Simplified96.7%
Taylor expanded in y around 0 28.8%
*-commutative28.8%
clear-num28.9%
frac-times39.7%
*-un-lft-identity39.7%
Applied egg-rr39.7%
Final simplification61.2%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 3e+43) (/ x z) (/ y (/ (* y z) x))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 3e+43) {
tmp = x / z;
} else {
tmp = y / ((y * z) / x);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 3d+43) then
tmp = x / z
else
tmp = y / ((y * z) / x)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3e+43) {
tmp = x / z;
} else {
tmp = y / ((y * z) / x);
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 3e+43: tmp = x / z else: tmp = y / ((y * z) / x) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 3e+43) tmp = Float64(x / z); else tmp = Float64(y / Float64(Float64(y * z) / x)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3e+43) tmp = x / z; else tmp = y / ((y * z) / x); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 3e+43], N[(x / z), $MachinePrecision], N[(y / N[(N[(y * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{+43}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{y \cdot z}{x}}\\
\end{array}
\end{array}
if y < 3.00000000000000017e43Initial program 97.5%
associate-*r/92.1%
associate-/l/87.9%
*-commutative87.9%
times-frac83.2%
Simplified83.2%
Taylor expanded in y around 0 66.5%
if 3.00000000000000017e43 < y Initial program 96.0%
associate-*r/95.8%
associate-/l/81.5%
*-commutative81.5%
times-frac96.1%
Simplified96.1%
Taylor expanded in y around 0 26.4%
frac-times31.3%
*-commutative31.3%
associate-/l*40.2%
Applied egg-rr40.2%
Final simplification61.3%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (/ x z))
y = abs(y);
double code(double x, double y, double z) {
return x / z;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x / z
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
return x / z;
}
y = abs(y) def code(x, y, z): return x / z
y = abs(y) function code(x, y, z) return Float64(x / z) end
y = abs(y) function tmp = code(x, y, z) tmp = x / z; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := N[(x / z), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\frac{x}{z}
\end{array}
Initial program 97.2%
associate-*r/92.8%
associate-/l/86.7%
*-commutative86.7%
times-frac85.8%
Simplified85.8%
Taylor expanded in y around 0 57.4%
Final simplification57.4%
(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 2023215
(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))