
(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 (let* ((t_0 (/ (sin y) y))) (if (<= (/ (* x t_0) z) 4e+39) (* t_0 (/ x z)) (/ x (/ z t_0)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if (((x * t_0) / z) <= 4e+39) {
tmp = t_0 * (x / 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) :: tmp
t_0 = sin(y) / y
if (((x * t_0) / z) <= 4d+39) then
tmp = t_0 * (x / 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 tmp;
if (((x * t_0) / z) <= 4e+39) {
tmp = t_0 * (x / z);
} else {
tmp = x / (z / t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if ((x * t_0) / z) <= 4e+39: tmp = t_0 * (x / z) else: tmp = x / (z / t_0) return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if (Float64(Float64(x * t_0) / z) <= 4e+39) tmp = Float64(t_0 * Float64(x / 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; tmp = 0.0; if (((x * t_0) / z) <= 4e+39) tmp = t_0 * (x / 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]}, If[LessEqual[N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], 4e+39], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;\frac{x \cdot t_0}{z} \leq 4 \cdot 10^{+39}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) < 3.99999999999999976e39Initial program 96.8%
*-commutative96.8%
associate-*r/98.9%
Simplified98.9%
if 3.99999999999999976e39 < (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) Initial program 99.8%
associate-/l*99.9%
Simplified99.9%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y))) (if (<= t_0 2e-296) (* (sin y) (/ (/ x y) z)) (* t_0 (/ x z)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if (t_0 <= 2e-296) {
tmp = sin(y) * ((x / y) / 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 (t_0 <= 2d-296) then
tmp = sin(y) * ((x / y) / 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 (t_0 <= 2e-296) {
tmp = Math.sin(y) * ((x / y) / z);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if t_0 <= 2e-296: tmp = math.sin(y) * ((x / y) / z) else: tmp = t_0 * (x / z) return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if (t_0 <= 2e-296) tmp = Float64(sin(y) * Float64(Float64(x / y) / 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 (t_0 <= 2e-296) tmp = sin(y) * ((x / y) / 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[t$95$0, 2e-296], N[(N[Sin[y], $MachinePrecision] * N[(N[(x / y), $MachinePrecision] / 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}\;t_0 \leq 2 \cdot 10^{-296}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\end{array}
\end{array}
if (/.f64 (sin.f64 y) y) < 2e-296Initial program 98.9%
associate-/l*86.2%
Simplified86.2%
clear-num86.1%
associate-/r/86.1%
clear-num86.1%
Applied egg-rr86.1%
Taylor expanded in x around 0 86.1%
associate-*r/86.1%
associate-/r*98.9%
Simplified98.9%
if 2e-296 < (/.f64 (sin.f64 y) y) Initial program 97.1%
*-commutative97.1%
associate-*r/99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (<= (/ (sin y) y) -2e-289) (* (sin y) (/ (/ x y) z)) (/ x (* z (/ y (sin y))))))
double code(double x, double y, double z) {
double tmp;
if ((sin(y) / y) <= -2e-289) {
tmp = sin(y) * ((x / y) / 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 ((sin(y) / y) <= (-2d-289)) then
tmp = sin(y) * ((x / y) / 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 ((Math.sin(y) / y) <= -2e-289) {
tmp = Math.sin(y) * ((x / y) / z);
} else {
tmp = x / (z * (y / Math.sin(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (math.sin(y) / y) <= -2e-289: tmp = math.sin(y) * ((x / y) / z) else: tmp = x / (z * (y / math.sin(y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(sin(y) / y) <= -2e-289) tmp = Float64(sin(y) * Float64(Float64(x / y) / 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 ((sin(y) / y) <= -2e-289) tmp = sin(y) * ((x / y) / z); else tmp = x / (z * (y / sin(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], -2e-289], N[(N[Sin[y], $MachinePrecision] * N[(N[(x / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(x / N[(z * N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin y}{y} \leq -2 \cdot 10^{-289}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot \frac{y}{\sin y}}\\
\end{array}
\end{array}
if (/.f64 (sin.f64 y) y) < -2e-289Initial program 99.4%
associate-/l*84.0%
Simplified84.0%
clear-num83.9%
associate-/r/83.9%
clear-num83.9%
Applied egg-rr83.9%
Taylor expanded in x around 0 83.9%
associate-*r/83.9%
associate-/r*99.4%
Simplified99.4%
if -2e-289 < (/.f64 (sin.f64 y) y) Initial program 97.0%
associate-/l*99.0%
Simplified99.0%
clear-num98.8%
associate-/r/99.0%
clear-num99.0%
Applied egg-rr99.0%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (<= y 1.85e-8) (/ x z) (* (sin y) (/ (/ x y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.85e-8) {
tmp = x / z;
} else {
tmp = sin(y) * ((x / 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 <= 1.85d-8) then
tmp = x / z
else
tmp = sin(y) * ((x / y) / z)
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 = Math.sin(y) * ((x / y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.85e-8: tmp = x / z else: tmp = math.sin(y) * ((x / y) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.85e-8) tmp = Float64(x / z); else tmp = Float64(sin(y) * Float64(Float64(x / y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.85e-8) tmp = x / z; else tmp = sin(y) * ((x / y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.85e-8], N[(x / z), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(N[(x / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.85 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z}\\
\end{array}
\end{array}
if y < 1.85e-8Initial program 98.2%
associate-/l*97.5%
associate-/r/86.5%
associate-/l/80.9%
associate-/r/77.3%
associate-/r*77.5%
Simplified77.5%
Taylor expanded in y around 0 73.3%
if 1.85e-8 < y Initial program 94.8%
associate-/l*91.2%
Simplified91.2%
clear-num91.0%
associate-/r/91.1%
clear-num91.0%
Applied egg-rr91.0%
Taylor expanded in x around 0 91.0%
associate-*r/91.1%
associate-/r*95.0%
Simplified95.0%
Final simplification77.9%
(FPCore (x y z) :precision binary64 (if (<= y 6.4e+28) (* (/ x z) (+ 1.0 (* (* y y) -0.16666666666666666))) (/ (/ y (/ y x)) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.4e+28) {
tmp = (x / z) * (1.0 + ((y * y) * -0.16666666666666666));
} else {
tmp = (y / (y / 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) :: tmp
if (y <= 6.4d+28) then
tmp = (x / z) * (1.0d0 + ((y * y) * (-0.16666666666666666d0)))
else
tmp = (y / (y / x)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 6.4e+28) {
tmp = (x / z) * (1.0 + ((y * y) * -0.16666666666666666));
} else {
tmp = (y / (y / x)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6.4e+28: tmp = (x / z) * (1.0 + ((y * y) * -0.16666666666666666)) else: tmp = (y / (y / x)) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6.4e+28) tmp = Float64(Float64(x / z) * Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666))); else tmp = Float64(Float64(y / Float64(y / x)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6.4e+28) tmp = (x / z) * (1.0 + ((y * y) * -0.16666666666666666)); else tmp = (y / (y / x)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6.4e+28], N[(N[(x / z), $MachinePrecision] * N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.4 \cdot 10^{+28}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 + \left(y \cdot y\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{\frac{y}{x}}}{z}\\
\end{array}
\end{array}
if y < 6.4000000000000001e28Initial program 98.2%
*-commutative98.2%
associate-*r/96.8%
Simplified96.8%
Taylor expanded in y around 0 70.2%
unpow270.2%
Simplified70.2%
if 6.4000000000000001e28 < y Initial program 94.2%
associate-*r/94.2%
clear-num89.8%
Applied egg-rr89.8%
Taylor expanded in y around 0 22.6%
clear-num22.6%
clear-num22.6%
remove-double-div22.6%
*-inverses22.6%
associate-/r*22.3%
associate-/r/22.3%
Applied egg-rr22.3%
associate-*l/22.3%
*-un-lft-identity22.3%
associate-/l*27.9%
Applied egg-rr27.9%
Final simplification62.3%
(FPCore (x y z) :precision binary64 (if (<= y 3.7e-11) (/ x z) (/ (/ 1.0 (/ (/ y x) y)) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.7e-11) {
tmp = x / z;
} else {
tmp = (1.0 / ((y / x) / 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 <= 3.7d-11) then
tmp = x / z
else
tmp = (1.0d0 / ((y / x) / y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.7e-11) {
tmp = x / z;
} else {
tmp = (1.0 / ((y / x) / y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.7e-11: tmp = x / z else: tmp = (1.0 / ((y / x) / y)) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.7e-11) tmp = Float64(x / z); else tmp = Float64(Float64(1.0 / Float64(Float64(y / x) / y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.7e-11) tmp = x / z; else tmp = (1.0 / ((y / x) / y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.7e-11], N[(x / z), $MachinePrecision], N[(N[(1.0 / N[(N[(y / x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.7 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{\frac{y}{x}}{y}}}{z}\\
\end{array}
\end{array}
if y < 3.7000000000000001e-11Initial program 98.2%
associate-/l*97.5%
associate-/r/86.5%
associate-/l/80.8%
associate-/r/77.2%
associate-/r*77.4%
Simplified77.4%
Taylor expanded in y around 0 73.1%
if 3.7000000000000001e-11 < y Initial program 94.9%
associate-*r/94.9%
clear-num91.1%
Applied egg-rr91.1%
Taylor expanded in y around 0 23.6%
*-un-lft-identity23.6%
times-frac28.4%
Applied egg-rr28.4%
associate-*l/28.4%
*-un-lft-identity28.4%
Applied egg-rr28.4%
Final simplification63.3%
(FPCore (x y z) :precision binary64 (/ x (* z (+ 1.0 (* 0.16666666666666666 (* y y))))))
double code(double x, double y, double z) {
return x / (z * (1.0 + (0.16666666666666666 * (y * y))));
}
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 * (1.0d0 + (0.16666666666666666d0 * (y * y))))
end function
public static double code(double x, double y, double z) {
return x / (z * (1.0 + (0.16666666666666666 * (y * y))));
}
def code(x, y, z): return x / (z * (1.0 + (0.16666666666666666 * (y * y))))
function code(x, y, z) return Float64(x / Float64(z * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y))))) end
function tmp = code(x, y, z) tmp = x / (z * (1.0 + (0.16666666666666666 * (y * y)))); end
code[x_, y_, z_] := N[(x / N[(z * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)}
\end{array}
Initial program 97.5%
associate-/l*96.2%
Simplified96.2%
clear-num96.0%
associate-/r/96.1%
clear-num96.1%
Applied egg-rr96.1%
Taylor expanded in y around 0 68.7%
unpow268.7%
Simplified68.7%
Final simplification68.7%
(FPCore (x y z) :precision binary64 (/ (/ x z) (+ 1.0 (* 0.16666666666666666 (* y y)))))
double code(double x, double y, double z) {
return (x / z) / (1.0 + (0.16666666666666666 * (y * y)));
}
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) / (1.0d0 + (0.16666666666666666d0 * (y * y)))
end function
public static double code(double x, double y, double z) {
return (x / z) / (1.0 + (0.16666666666666666 * (y * y)));
}
def code(x, y, z): return (x / z) / (1.0 + (0.16666666666666666 * (y * y)))
function code(x, y, z) return Float64(Float64(x / z) / Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))) end
function tmp = code(x, y, z) tmp = (x / z) / (1.0 + (0.16666666666666666 * (y * y))); end
code[x_, y_, z_] := N[(N[(x / z), $MachinePrecision] / N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x}{z}}{1 + 0.16666666666666666 \cdot \left(y \cdot y\right)}
\end{array}
Initial program 97.5%
associate-/l*96.2%
associate-/r/87.5%
associate-/l/83.9%
associate-/r/81.1%
associate-/r*80.4%
Simplified80.4%
associate-*l/82.9%
*-commutative82.9%
frac-times95.8%
clear-num95.8%
un-div-inv95.8%
Applied egg-rr95.8%
Taylor expanded in y around 0 69.4%
unpow268.7%
Simplified69.4%
Final simplification69.4%
(FPCore (x y z) :precision binary64 (if (<= y 0.0001) (/ x z) (/ (* y (/ x y)) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.0001) {
tmp = x / z;
} else {
tmp = (y * (x / 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 <= 0.0001d0) then
tmp = x / z
else
tmp = (y * (x / y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 0.0001) {
tmp = x / z;
} else {
tmp = (y * (x / y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.0001: tmp = x / z else: tmp = (y * (x / y)) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.0001) tmp = Float64(x / z); else tmp = Float64(Float64(y * Float64(x / y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.0001) tmp = x / z; else tmp = (y * (x / y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.0001], N[(x / z), $MachinePrecision], N[(N[(y * N[(x / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.0001:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \frac{x}{y}}{z}\\
\end{array}
\end{array}
if y < 1.00000000000000005e-4Initial program 98.2%
associate-/l*97.5%
associate-/r/86.5%
associate-/l/80.9%
associate-/r/77.3%
associate-/r*77.5%
Simplified77.5%
Taylor expanded in y around 0 73.3%
if 1.00000000000000005e-4 < y Initial program 94.8%
associate-*r/94.8%
clear-num90.9%
Applied egg-rr90.9%
Taylor expanded in y around 0 22.2%
*-un-lft-identity22.2%
times-frac27.1%
Applied egg-rr27.1%
associate-*l/27.1%
*-un-lft-identity27.1%
associate-/r/27.1%
clear-num27.0%
Applied egg-rr27.0%
Final simplification63.3%
(FPCore (x y z) :precision binary64 (if (<= y 4.7e-5) (/ x z) (/ (/ y (/ y x)) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.7e-5) {
tmp = x / z;
} else {
tmp = (y / (y / 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) :: tmp
if (y <= 4.7d-5) then
tmp = x / z
else
tmp = (y / (y / x)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.7e-5) {
tmp = x / z;
} else {
tmp = (y / (y / x)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.7e-5: tmp = x / z else: tmp = (y / (y / x)) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.7e-5) tmp = Float64(x / z); else tmp = Float64(Float64(y / Float64(y / x)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.7e-5) tmp = x / z; else tmp = (y / (y / x)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.7e-5], N[(x / z), $MachinePrecision], N[(N[(y / N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.7 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{\frac{y}{x}}}{z}\\
\end{array}
\end{array}
if y < 4.69999999999999972e-5Initial program 98.2%
associate-/l*97.5%
associate-/r/86.5%
associate-/l/80.9%
associate-/r/77.3%
associate-/r*77.5%
Simplified77.5%
Taylor expanded in y around 0 73.3%
if 4.69999999999999972e-5 < y Initial program 94.8%
associate-*r/94.8%
clear-num90.9%
Applied egg-rr90.9%
Taylor expanded in y around 0 22.5%
clear-num22.5%
clear-num22.5%
remove-double-div22.5%
*-inverses22.5%
associate-/r*22.2%
associate-/r/22.2%
Applied egg-rr22.2%
associate-*l/22.2%
*-un-lft-identity22.2%
associate-/l*27.1%
Applied egg-rr27.1%
Final simplification63.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 97.5%
associate-/l*96.2%
Simplified96.2%
clear-num96.0%
associate-/r/96.1%
clear-num96.1%
Applied egg-rr96.1%
clear-num95.8%
associate-/r/96.0%
associate-/r*96.4%
clear-num96.4%
Applied egg-rr96.4%
Taylor expanded in y around 0 62.2%
associate-*l/62.4%
associate-/l*62.4%
Applied egg-rr62.4%
Final simplification62.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 97.5%
associate-/l*96.2%
associate-/r/87.5%
associate-/l/83.9%
associate-/r/81.1%
associate-/r*80.4%
Simplified80.4%
Taylor expanded in y around 0 62.4%
Final simplification62.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 2023263
(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))