
(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}
(FPCore (x y z) :precision binary64 (if (<= z 1e-84) (/ x (/ z (/ (sin y) y))) (/ (/ x z) (/ y (sin y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1e-84) {
tmp = x / (z / (sin(y) / y));
} 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 <= 1d-84) then
tmp = x / (z / (sin(y) / y))
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 <= 1e-84) {
tmp = x / (z / (Math.sin(y) / y));
} else {
tmp = (x / z) / (y / Math.sin(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1e-84: tmp = x / (z / (math.sin(y) / y)) else: tmp = (x / z) / (y / math.sin(y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1e-84) tmp = Float64(x / Float64(z / Float64(sin(y) / y))); else tmp = Float64(Float64(x / z) / Float64(y / sin(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1e-84) tmp = x / (z / (sin(y) / y)); else tmp = (x / z) / (y / sin(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1e-84], N[(x / N[(z / N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] / N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{-84}:\\
\;\;\;\;\frac{x}{\frac{z}{\frac{\sin y}{y}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y}{\sin y}}\\
\end{array}
\end{array}
if z < 1e-84Initial program 94.7%
associate-/l*98.8%
Simplified98.8%
if 1e-84 < z Initial program 99.7%
associate-*r/91.3%
Simplified91.3%
associate-*r/99.7%
associate-*l/99.7%
clear-num99.7%
un-div-inv99.8%
Applied egg-rr99.8%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y)) (t_1 (* x t_0))) (if (<= t_1 -4e-196) (/ t_1 z) (/ x (/ z t_0)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double t_1 = x * t_0;
double tmp;
if (t_1 <= -4e-196) {
tmp = t_1 / z;
} else {
tmp = x / (z / t_0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(y) / y
t_1 = x * t_0
if (t_1 <= (-4d-196)) then
tmp = t_1 / z
else
tmp = x / (z / t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.sin(y) / y;
double t_1 = x * t_0;
double tmp;
if (t_1 <= -4e-196) {
tmp = t_1 / z;
} else {
tmp = x / (z / t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y t_1 = x * t_0 tmp = 0 if t_1 <= -4e-196: tmp = t_1 / z else: tmp = x / (z / t_0) return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) t_1 = Float64(x * t_0) tmp = 0.0 if (t_1 <= -4e-196) tmp = Float64(t_1 / z); else tmp = Float64(x / Float64(z / t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) / y; t_1 = x * t_0; tmp = 0.0; if (t_1 <= -4e-196) tmp = t_1 / z; else tmp = x / (z / t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-196], N[(t$95$1 / z), $MachinePrecision], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
t_1 := x \cdot t_0\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{-196}:\\
\;\;\;\;\frac{t_1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}
\end{array}
if (*.f64 x (/.f64 (sin.f64 y) y)) < -4.0000000000000002e-196Initial program 99.7%
if -4.0000000000000002e-196 < (*.f64 x (/.f64 (sin.f64 y) y)) Initial program 93.5%
associate-/l*98.6%
Simplified98.6%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y))) (if (<= z 1.7e-101) (* x (/ t_0 z)) (* t_0 (/ x z)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if (z <= 1.7e-101) {
tmp = x * (t_0 / z);
} else {
tmp = t_0 * (x / 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 (z <= 1.7d-101) then
tmp = x * (t_0 / z)
else
tmp = t_0 * (x / 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 (z <= 1.7e-101) {
tmp = x * (t_0 / z);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if z <= 1.7e-101: tmp = x * (t_0 / z) else: tmp = t_0 * (x / z) return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if (z <= 1.7e-101) tmp = Float64(x * Float64(t_0 / z)); else tmp = Float64(t_0 * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) / y; tmp = 0.0; if (z <= 1.7e-101) tmp = x * (t_0 / z); else tmp = t_0 * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[z, 1.7e-101], N[(x * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;z \leq 1.7 \cdot 10^{-101}:\\
\;\;\;\;x \cdot \frac{t_0}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < 1.69999999999999995e-101Initial program 95.0%
associate-*r/98.6%
Simplified98.6%
if 1.69999999999999995e-101 < z Initial program 98.5%
associate-*l/99.7%
*-commutative99.7%
Simplified99.7%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y))) (if (<= z 1e-91) (/ x (/ z t_0)) (* t_0 (/ x z)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if (z <= 1e-91) {
tmp = x / (z / t_0);
} else {
tmp = t_0 * (x / 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 (z <= 1d-91) then
tmp = x / (z / t_0)
else
tmp = t_0 * (x / 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 (z <= 1e-91) {
tmp = x / (z / t_0);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if z <= 1e-91: tmp = x / (z / t_0) else: tmp = t_0 * (x / z) return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if (z <= 1e-91) tmp = Float64(x / Float64(z / t_0)); else tmp = Float64(t_0 * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) / y; tmp = 0.0; if (z <= 1e-91) tmp = x / (z / t_0); else tmp = t_0 * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[z, 1e-91], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;z \leq 10^{-91}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < 1.00000000000000002e-91Initial program 95.1%
associate-/l*98.8%
Simplified98.8%
if 1.00000000000000002e-91 < z Initial program 98.4%
associate-*l/99.7%
*-commutative99.7%
Simplified99.7%
Final simplification99.1%
(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(x * Float64(Float64(sin(y) / y) / z)) end
function tmp = code(x, y, z) tmp = x * ((sin(y) / y) / z); end
code[x_, y_, z_] := N[(x * N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{\sin y}{y}}{z}
\end{array}
Initial program 96.1%
associate-*r/96.6%
Simplified96.6%
Final simplification96.6%
(FPCore (x y z) :precision binary64 (if (<= y 2.05e-8) (/ x z) (/ y (* (/ 1.0 x) (/ y (/ 1.0 z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.05e-8) {
tmp = x / z;
} else {
tmp = y / ((1.0 / x) * (y / (1.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) :: tmp
if (y <= 2.05d-8) then
tmp = x / z
else
tmp = y / ((1.0d0 / x) * (y / (1.0d0 / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.05e-8) {
tmp = x / z;
} else {
tmp = y / ((1.0 / x) * (y / (1.0 / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.05e-8: tmp = x / z else: tmp = y / ((1.0 / x) * (y / (1.0 / z))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.05e-8) tmp = Float64(x / z); else tmp = Float64(y / Float64(Float64(1.0 / x) * Float64(y / Float64(1.0 / z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.05e-8) tmp = x / z; else tmp = y / ((1.0 / x) * (y / (1.0 / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.05e-8], N[(x / z), $MachinePrecision], N[(y / N[(N[(1.0 / x), $MachinePrecision] * N[(y / N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.05 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{1}{x} \cdot \frac{y}{\frac{1}{z}}}\\
\end{array}
\end{array}
if y < 2.05000000000000016e-8Initial program 97.1%
associate-*r/98.3%
Simplified98.3%
Taylor expanded in y around 0 75.7%
if 2.05000000000000016e-8 < y Initial program 92.6%
associate-*r/90.9%
Simplified90.9%
associate-/l/89.7%
associate-*r/89.9%
*-commutative89.9%
*-commutative89.9%
associate-/l*88.8%
Applied egg-rr88.8%
Taylor expanded in y around 0 33.2%
associate-/l*32.9%
*-un-lft-identity32.9%
div-inv32.9%
times-frac33.2%
Applied egg-rr33.2%
Final simplification66.2%
(FPCore (x y z) :precision binary64 (if (<= y 0.2) (/ x z) (* y (/ x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.2) {
tmp = x / z;
} else {
tmp = y * (x / (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 <= 0.2d0) then
tmp = x / z
else
tmp = y * (x / (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 0.2) {
tmp = x / z;
} else {
tmp = y * (x / (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.2: tmp = x / z else: tmp = y * (x / (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.2) tmp = Float64(x / z); else tmp = Float64(y * Float64(x / Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.2) tmp = x / z; else tmp = y * (x / (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.2], N[(x / z), $MachinePrecision], N[(y * N[(x / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.2:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z \cdot y}\\
\end{array}
\end{array}
if y < 0.20000000000000001Initial program 97.1%
associate-*r/98.3%
Simplified98.3%
Taylor expanded in y around 0 75.8%
if 0.20000000000000001 < y Initial program 92.5%
associate-*r/90.8%
Simplified90.8%
Taylor expanded in y around 0 18.3%
div-inv18.3%
clear-num19.5%
Applied egg-rr19.5%
associate-/r/18.3%
rgt-mult-inverse18.3%
un-div-inv18.3%
associate-/r*24.8%
associate-/r/32.1%
clear-num32.1%
associate-/r/32.1%
clear-num32.1%
remove-double-div29.6%
Applied egg-rr29.6%
Final simplification65.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.85e-8) (/ x z) (/ y (* y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.85e-8) {
tmp = x / z;
} else {
tmp = y / (y * (z / 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.85d-8) then
tmp = x / z
else
tmp = y / (y * (z / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.85e-8) {
tmp = x / z;
} else {
tmp = y / (y * (z / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.85e-8: tmp = x / z else: tmp = y / (y * (z / x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.85e-8) tmp = Float64(x / z); else tmp = Float64(y / Float64(y * Float64(z / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.85e-8) tmp = x / z; else tmp = y / (y * (z / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.85e-8], N[(x / z), $MachinePrecision], N[(y / N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.85 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y \cdot \frac{z}{x}}\\
\end{array}
\end{array}
if y < 1.85e-8Initial program 97.1%
associate-*r/98.3%
Simplified98.3%
Taylor expanded in y around 0 75.7%
if 1.85e-8 < y Initial program 92.6%
associate-*r/90.9%
Simplified90.9%
associate-/l/89.7%
associate-*r/89.9%
*-commutative89.9%
*-commutative89.9%
associate-/l*88.8%
Applied egg-rr88.8%
Taylor expanded in y around 0 33.2%
div-inv33.2%
associate-*l*32.9%
div-inv32.9%
Applied egg-rr32.9%
Final simplification66.2%
(FPCore (x y z) :precision binary64 (if (<= y 2.95e+90) (/ x z) (/ y (* z (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.95e+90) {
tmp = x / z;
} else {
tmp = y / (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 <= 2.95d+90) then
tmp = x / z
else
tmp = y / (z * (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.95e+90) {
tmp = x / z;
} else {
tmp = y / (z * (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.95e+90: tmp = x / z else: tmp = y / (z * (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.95e+90) tmp = Float64(x / z); else tmp = Float64(y / Float64(z * Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.95e+90) tmp = x / z; else tmp = y / (z * (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.95e+90], N[(x / z), $MachinePrecision], N[(y / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.95 \cdot 10^{+90}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 2.95000000000000019e90Initial program 97.2%
associate-*r/98.4%
Simplified98.4%
Taylor expanded in y around 0 72.9%
if 2.95000000000000019e90 < y Initial program 90.1%
associate-*r/87.8%
Simplified87.8%
associate-/l/86.3%
associate-*r/86.4%
*-commutative86.4%
*-commutative86.4%
associate-/l*85.0%
Applied egg-rr85.0%
Taylor expanded in y around 0 32.2%
associate-/l*31.8%
associate-/r/32.1%
Applied egg-rr32.1%
Final simplification66.2%
(FPCore (x y z) :precision binary64 (if (<= y 20000000000.0) (/ x z) (/ y (/ (* z y) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= 20000000000.0) {
tmp = x / z;
} else {
tmp = y / ((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 <= 20000000000.0d0) then
tmp = x / z
else
tmp = y / ((z * y) / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 20000000000.0) {
tmp = x / z;
} else {
tmp = y / ((z * y) / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 20000000000.0: tmp = x / z else: tmp = y / ((z * y) / x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 20000000000.0) tmp = Float64(x / z); else tmp = Float64(y / Float64(Float64(z * y) / x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 20000000000.0) tmp = x / z; else tmp = y / ((z * y) / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 20000000000.0], N[(x / z), $MachinePrecision], N[(y / N[(N[(z * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 20000000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z \cdot y}{x}}\\
\end{array}
\end{array}
if y < 2e10Initial program 97.1%
associate-*r/98.3%
Simplified98.3%
Taylor expanded in y around 0 75.2%
if 2e10 < y Initial program 92.1%
associate-*r/90.3%
Simplified90.3%
associate-/l/89.0%
associate-*r/89.2%
*-commutative89.2%
*-commutative89.2%
associate-/l*88.0%
Applied egg-rr88.0%
Taylor expanded in y around 0 32.0%
Final simplification66.2%
(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 96.1%
associate-*r/96.6%
Simplified96.6%
Taylor expanded in y around 0 63.1%
div-inv63.2%
clear-num63.2%
Applied egg-rr63.2%
Final simplification63.2%
(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 96.1%
associate-*r/96.6%
Simplified96.6%
Taylor expanded in y around 0 63.2%
Final simplification63.2%
(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 2023306
(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))