
(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 13 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}
(FPCore (x y z) :precision binary64 (if (or (<= z -2e-53) (not (<= z 3.4e-73))) (* (/ (sin y) y) (/ x z)) (/ x (* z (/ y (sin y))))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e-53) || !(z <= 3.4e-73)) {
tmp = (sin(y) / y) * (x / z);
} else {
tmp = x / (z * (y / sin(y)));
}
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) :: tmp
if ((z <= (-2d-53)) .or. (.not. (z <= 3.4d-73))) then
tmp = (sin(y) / y) * (x / z)
else
tmp = x / (z * (y / sin(y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2e-53) || !(z <= 3.4e-73)) {
tmp = (Math.sin(y) / y) * (x / z);
} else {
tmp = x / (z * (y / Math.sin(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e-53) or not (z <= 3.4e-73): tmp = (math.sin(y) / y) * (x / z) else: tmp = x / (z * (y / math.sin(y))) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e-53) || !(z <= 3.4e-73)) tmp = Float64(Float64(sin(y) / y) * Float64(x / z)); else tmp = Float64(x / Float64(z * Float64(y / sin(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2e-53) || ~((z <= 3.4e-73))) tmp = (sin(y) / y) * (x / z); else tmp = x / (z * (y / sin(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e-53], N[Not[LessEqual[z, 3.4e-73]], $MachinePrecision]], N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x / N[(z * N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-53} \lor \neg \left(z \leq 3.4 \cdot 10^{-73}\right):\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot \frac{y}{\sin y}}\\
\end{array}
\end{array}
if z < -2.00000000000000006e-53 or 3.40000000000000021e-73 < z Initial program 99.0%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
if -2.00000000000000006e-53 < z < 3.40000000000000021e-73Initial program 87.0%
associate-/l*99.7%
Simplified99.7%
div-inv99.6%
clear-num99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1e-37) (not (<= z 6.5e-66))) (* (/ (sin y) y) (/ x z)) (* x (/ (/ (sin y) z) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-37) || !(z <= 6.5e-66)) {
tmp = (sin(y) / y) * (x / z);
} else {
tmp = x * ((sin(y) / z) / y);
}
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) :: tmp
if ((z <= (-1d-37)) .or. (.not. (z <= 6.5d-66))) then
tmp = (sin(y) / y) * (x / z)
else
tmp = x * ((sin(y) / z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-37) || !(z <= 6.5e-66)) {
tmp = (Math.sin(y) / y) * (x / z);
} else {
tmp = x * ((Math.sin(y) / z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e-37) or not (z <= 6.5e-66): tmp = (math.sin(y) / y) * (x / z) else: tmp = x * ((math.sin(y) / z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e-37) || !(z <= 6.5e-66)) tmp = Float64(Float64(sin(y) / y) * Float64(x / z)); else tmp = Float64(x * Float64(Float64(sin(y) / z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e-37) || ~((z <= 6.5e-66))) tmp = (sin(y) / y) * (x / z); else tmp = x * ((sin(y) / z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-37], N[Not[LessEqual[z, 6.5e-66]], $MachinePrecision]], N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-37} \lor \neg \left(z \leq 6.5 \cdot 10^{-66}\right):\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\
\end{array}
\end{array}
if z < -1.00000000000000007e-37 or 6.50000000000000024e-66 < z Initial program 99.0%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
if -1.00000000000000007e-37 < z < 6.50000000000000024e-66Initial program 87.6%
associate-*r/99.5%
associate-/l/86.4%
associate-/r*99.6%
Simplified99.6%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (<= y 3.2e-8) (/ x z) (* x (/ (/ (sin y) z) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.2e-8) {
tmp = x / z;
} else {
tmp = x * ((sin(y) / z) / y);
}
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) :: tmp
if (y <= 3.2d-8) then
tmp = x / z
else
tmp = x * ((sin(y) / z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.2e-8) {
tmp = x / z;
} else {
tmp = x * ((Math.sin(y) / z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.2e-8: tmp = x / z else: tmp = x * ((math.sin(y) / z) / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.2e-8) tmp = Float64(x / z); else tmp = Float64(x * Float64(Float64(sin(y) / z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.2e-8) tmp = x / z; else tmp = x * ((sin(y) / z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.2e-8], N[(x / z), $MachinePrecision], N[(x * N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\
\end{array}
\end{array}
if y < 3.2000000000000002e-8Initial program 95.5%
associate-*r/97.8%
associate-/l/88.7%
associate-/r*90.4%
Simplified90.4%
Taylor expanded in y around 0 66.0%
if 3.2000000000000002e-8 < y Initial program 90.1%
associate-*r/92.6%
associate-/l/91.1%
associate-/r*92.5%
Simplified92.5%
Final simplification73.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y))) (if (<= x 1e-8) (* t_0 (/ x z)) (/ (* x t_0) z))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if (x <= 1e-8) {
tmp = t_0 * (x / z);
} else {
tmp = (x * t_0) / z;
}
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 = sin(y) / y
if (x <= 1d-8) then
tmp = t_0 * (x / z)
else
tmp = (x * t_0) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.sin(y) / y;
double tmp;
if (x <= 1e-8) {
tmp = t_0 * (x / z);
} else {
tmp = (x * t_0) / z;
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if x <= 1e-8: tmp = t_0 * (x / z) else: tmp = (x * t_0) / z return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if (x <= 1e-8) tmp = Float64(t_0 * Float64(x / z)); else tmp = Float64(Float64(x * t_0) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) / y; tmp = 0.0; if (x <= 1e-8) tmp = t_0 * (x / z); else tmp = (x * t_0) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, 1e-8], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;x \leq 10^{-8}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot t_0}{z}\\
\end{array}
\end{array}
if x < 1e-8Initial program 92.1%
associate-*l/98.3%
*-commutative98.3%
Simplified98.3%
if 1e-8 < x Initial program 99.8%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (<= y 2.4) (/ x z) (* (/ x (* z (* y 0.16666666666666666))) (/ 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.4) {
tmp = x / z;
} else {
tmp = (x / (z * (y * 0.16666666666666666))) * (1.0 / y);
}
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) :: tmp
if (y <= 2.4d0) then
tmp = x / z
else
tmp = (x / (z * (y * 0.16666666666666666d0))) * (1.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.4) {
tmp = x / z;
} else {
tmp = (x / (z * (y * 0.16666666666666666))) * (1.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.4: tmp = x / z else: tmp = (x / (z * (y * 0.16666666666666666))) * (1.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.4) tmp = Float64(x / z); else tmp = Float64(Float64(x / Float64(z * Float64(y * 0.16666666666666666))) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.4) tmp = x / z; else tmp = (x / (z * (y * 0.16666666666666666))) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.4], N[(x / z), $MachinePrecision], N[(N[(x / N[(z * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot \left(y \cdot 0.16666666666666666\right)} \cdot \frac{1}{y}\\
\end{array}
\end{array}
if y < 2.39999999999999991Initial program 95.5%
associate-*r/97.8%
associate-/l/88.7%
associate-/r*90.4%
Simplified90.4%
Taylor expanded in y around 0 66.0%
if 2.39999999999999991 < y Initial program 90.1%
associate-/l*91.1%
Simplified91.1%
associate-/r/91.1%
Applied egg-rr91.1%
Taylor expanded in y around 0 28.8%
Taylor expanded in y around inf 28.8%
*-commutative28.8%
*-commutative28.8%
*-commutative28.8%
associate-*r*28.8%
Simplified28.8%
associate-/r*30.1%
div-inv30.1%
associate-*r*30.1%
*-commutative30.1%
associate-*l*30.1%
Applied egg-rr30.1%
Final simplification55.9%
(FPCore (x y z) :precision binary64 (if (<= y 5000000.0) (/ x z) (* y (* x (/ (/ 1.0 y) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5000000.0) {
tmp = x / z;
} else {
tmp = y * (x * ((1.0 / y) / z));
}
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) :: tmp
if (y <= 5000000.0d0) then
tmp = x / z
else
tmp = y * (x * ((1.0d0 / y) / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5000000.0) {
tmp = x / z;
} else {
tmp = y * (x * ((1.0 / y) / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5000000.0: tmp = x / z else: tmp = y * (x * ((1.0 / y) / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5000000.0) tmp = Float64(x / z); else tmp = Float64(y * Float64(x * Float64(Float64(1.0 / y) / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5000000.0) tmp = x / z; else tmp = y * (x * ((1.0 / y) / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5000000.0], N[(x / z), $MachinePrecision], N[(y * N[(x * N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \frac{\frac{1}{y}}{z}\right)\\
\end{array}
\end{array}
if y < 5e6Initial program 95.5%
associate-*r/97.8%
associate-/l/88.8%
associate-/r*90.4%
Simplified90.4%
Taylor expanded in y around 0 65.7%
if 5e6 < y Initial program 90.0%
associate-*r/92.5%
associate-/l/91.0%
associate-/r*92.4%
Simplified92.4%
Taylor expanded in y around 0 17.3%
*-un-lft-identity17.3%
*-commutative17.3%
associate-/l/21.1%
Applied egg-rr21.1%
*-commutative21.1%
*-rgt-identity21.1%
associate-*l/19.1%
*-commutative19.1%
Applied egg-rr19.1%
div-inv19.1%
associate-*l*27.7%
*-commutative27.7%
associate-/r*27.1%
Applied egg-rr27.1%
Final simplification55.0%
(FPCore (x y z) :precision binary64 (if (<= y 200.0) (/ x z) (* y (* x (/ 1.0 (* y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 200.0) {
tmp = x / z;
} else {
tmp = y * (x * (1.0 / (y * z)));
}
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) :: tmp
if (y <= 200.0d0) then
tmp = x / z
else
tmp = y * (x * (1.0d0 / (y * z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 200.0) {
tmp = x / z;
} else {
tmp = y * (x * (1.0 / (y * z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 200.0: tmp = x / z else: tmp = y * (x * (1.0 / (y * z))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 200.0) tmp = Float64(x / z); else tmp = Float64(y * Float64(x * Float64(1.0 / Float64(y * z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 200.0) tmp = x / z; else tmp = y * (x * (1.0 / (y * z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 200.0], N[(x / z), $MachinePrecision], N[(y * N[(x * N[(1.0 / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 200:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \frac{1}{y \cdot z}\right)\\
\end{array}
\end{array}
if y < 200Initial program 95.5%
associate-*r/97.8%
associate-/l/88.8%
associate-/r*90.4%
Simplified90.4%
Taylor expanded in y around 0 65.7%
if 200 < y Initial program 90.0%
associate-*r/92.5%
associate-/l/91.0%
associate-/r*92.4%
Simplified92.4%
Taylor expanded in y around 0 17.5%
un-div-inv17.5%
clear-num17.6%
Applied egg-rr17.6%
associate-/r/17.5%
*-inverses17.5%
associate-/r*21.1%
div-inv21.1%
associate-*l*27.7%
*-commutative27.7%
Applied egg-rr27.7%
Final simplification55.2%
(FPCore (x y z) :precision binary64 (if (<= y 1.95e-5) (/ x z) (* y (/ 1.0 (* z (/ y x))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.95e-5) {
tmp = x / z;
} else {
tmp = y * (1.0 / (z * (y / x)));
}
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) :: tmp
if (y <= 1.95d-5) then
tmp = x / z
else
tmp = y * (1.0d0 / (z * (y / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.95e-5) {
tmp = x / z;
} else {
tmp = y * (1.0 / (z * (y / x)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.95e-5: tmp = x / z else: tmp = y * (1.0 / (z * (y / x))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.95e-5) tmp = Float64(x / z); else tmp = Float64(y * Float64(1.0 / Float64(z * Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.95e-5) tmp = x / z; else tmp = y * (1.0 / (z * (y / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.95e-5], N[(x / z), $MachinePrecision], N[(y * N[(1.0 / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.95 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{1}{z \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 1.95e-5Initial program 95.5%
associate-*r/97.8%
associate-/l/88.7%
associate-/r*90.4%
Simplified90.4%
Taylor expanded in y around 0 66.0%
if 1.95e-5 < y Initial program 90.1%
associate-*r/92.6%
associate-/l/91.1%
associate-/r*92.5%
Simplified92.5%
Taylor expanded in y around 0 17.3%
*-un-lft-identity17.3%
*-commutative17.3%
associate-/l/21.0%
Applied egg-rr21.0%
*-commutative21.0%
*-rgt-identity21.0%
associate-*l/19.0%
*-commutative19.0%
Applied egg-rr19.0%
associate-/l*29.7%
div-inv29.7%
*-un-lft-identity29.7%
times-frac29.5%
/-rgt-identity29.5%
Applied egg-rr29.5%
Final simplification55.7%
(FPCore (x y z) :precision binary64 (/ x (+ z (* y (* y (* z 0.16666666666666666))))))
double code(double x, double y, double z) {
return x / (z + (y * (y * (z * 0.16666666666666666))));
}
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 + (y * (y * (z * 0.16666666666666666d0))))
end function
public static double code(double x, double y, double z) {
return x / (z + (y * (y * (z * 0.16666666666666666))));
}
def code(x, y, z): return x / (z + (y * (y * (z * 0.16666666666666666))))
function code(x, y, z) return Float64(x / Float64(z + Float64(y * Float64(y * Float64(z * 0.16666666666666666))))) end
function tmp = code(x, y, z) tmp = x / (z + (y * (y * (z * 0.16666666666666666)))); end
code[x_, y_, z_] := N[(x / N[(z + N[(y * N[(y * N[(z * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z + y \cdot \left(y \cdot \left(z \cdot 0.16666666666666666\right)\right)}
\end{array}
Initial program 94.0%
associate-/l*95.5%
Simplified95.5%
associate-/r/89.5%
Applied egg-rr89.5%
Taylor expanded in y around 0 52.6%
*-commutative52.6%
+-commutative52.6%
distribute-rgt-in52.6%
*-commutative52.6%
associate-*r/52.2%
*-commutative52.2%
associate-/l*58.6%
*-inverses58.6%
*-commutative58.6%
associate-*l*58.6%
Applied egg-rr58.6%
Final simplification58.6%
(FPCore (x y z) :precision binary64 (if (<= y 3e+105) (/ x z) (* (/ x y) (/ y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3e+105) {
tmp = x / z;
} else {
tmp = (x / y) * (y / z);
}
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) :: tmp
if (y <= 3d+105) then
tmp = x / z
else
tmp = (x / y) * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3e+105) {
tmp = x / z;
} else {
tmp = (x / y) * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3e+105: tmp = x / z else: tmp = (x / y) * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3e+105) tmp = Float64(x / z); else tmp = Float64(Float64(x / y) * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3e+105) tmp = x / z; else tmp = (x / y) * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3e+105], N[(x / z), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{+105}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 3.0000000000000001e105Initial program 94.8%
associate-*r/98.1%
associate-/l/90.3%
associate-/r*91.7%
Simplified91.7%
Taylor expanded in y around 0 57.5%
if 3.0000000000000001e105 < y Initial program 89.4%
associate-*r/86.6%
associate-/l/84.1%
associate-/r*86.6%
Simplified86.6%
Taylor expanded in y around 0 23.4%
*-un-lft-identity23.4%
*-commutative23.4%
associate-/l/29.9%
Applied egg-rr29.9%
*-commutative29.9%
*-rgt-identity29.9%
associate-*l/26.3%
*-commutative26.3%
Applied egg-rr26.3%
times-frac30.0%
Applied egg-rr30.0%
Final simplification53.3%
(FPCore (x y z) :precision binary64 (if (<= y 3.75e+105) (/ x z) (/ (/ x y) (/ z y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.75e+105) {
tmp = x / z;
} else {
tmp = (x / y) / (z / y);
}
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) :: tmp
if (y <= 3.75d+105) then
tmp = x / z
else
tmp = (x / y) / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.75e+105) {
tmp = x / z;
} else {
tmp = (x / y) / (z / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.75e+105: tmp = x / z else: tmp = (x / y) / (z / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.75e+105) tmp = Float64(x / z); else tmp = Float64(Float64(x / y) / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.75e+105) tmp = x / z; else tmp = (x / y) / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.75e+105], N[(x / z), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.75 \cdot 10^{+105}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < 3.7500000000000001e105Initial program 94.8%
associate-*r/98.1%
associate-/l/90.3%
associate-/r*91.7%
Simplified91.7%
Taylor expanded in y around 0 57.5%
if 3.7500000000000001e105 < y Initial program 89.4%
associate-*r/86.6%
associate-/l/84.1%
associate-/r*86.6%
Simplified86.6%
Taylor expanded in y around 0 23.4%
*-un-lft-identity23.4%
*-commutative23.4%
associate-/l/29.9%
Applied egg-rr29.9%
*-rgt-identity29.9%
clear-num29.9%
un-div-inv29.9%
associate-*r/23.4%
associate-/r*30.0%
Applied egg-rr30.0%
Final simplification53.3%
(FPCore (x y z) :precision binary64 (/ 1.0 (/ z x)))
double code(double x, double y, double z) {
return 1.0 / (z / x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 / (z / x)
end function
public static double code(double x, double y, double z) {
return 1.0 / (z / x);
}
def code(x, y, z): return 1.0 / (z / x)
function code(x, y, z) return Float64(1.0 / Float64(z / x)) end
function tmp = code(x, y, z) tmp = 1.0 / (z / x); end
code[x_, y_, z_] := N[(1.0 / N[(z / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{z}{x}}
\end{array}
Initial program 94.0%
associate-*r/96.3%
associate-/l/89.4%
associate-/r*91.0%
Simplified91.0%
Taylor expanded in y around 0 52.2%
un-div-inv52.4%
clear-num52.4%
Applied egg-rr52.4%
Final simplification52.4%
(FPCore (x y z) :precision binary64 (/ x z))
double code(double x, double y, double z) {
return 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 = x / z
end function
public static double code(double x, double y, double z) {
return x / z;
}
def code(x, y, z): return x / z
function code(x, y, z) return Float64(x / z) end
function tmp = code(x, y, z) tmp = x / z; end
code[x_, y_, z_] := N[(x / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z}
\end{array}
Initial program 94.0%
associate-*r/96.3%
associate-/l/89.4%
associate-/r*91.0%
Simplified91.0%
Taylor expanded in y around 0 52.4%
Final simplification52.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 2023311
(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))