
(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 (* x (/ (sin y) y)))) (if (<= t_0 5e-194) (/ x (* (/ y (sin y)) z)) (/ t_0 z))))
double code(double x, double y, double z) {
double t_0 = x * (sin(y) / y);
double tmp;
if (t_0 <= 5e-194) {
tmp = x / ((y / sin(y)) * z);
} else {
tmp = 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 = x * (sin(y) / y)
if (t_0 <= 5d-194) then
tmp = x / ((y / sin(y)) * z)
else
tmp = t_0 / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (Math.sin(y) / y);
double tmp;
if (t_0 <= 5e-194) {
tmp = x / ((y / Math.sin(y)) * z);
} else {
tmp = t_0 / z;
}
return tmp;
}
def code(x, y, z): t_0 = x * (math.sin(y) / y) tmp = 0 if t_0 <= 5e-194: tmp = x / ((y / math.sin(y)) * z) else: tmp = t_0 / z return tmp
function code(x, y, z) t_0 = Float64(x * Float64(sin(y) / y)) tmp = 0.0 if (t_0 <= 5e-194) tmp = Float64(x / Float64(Float64(y / sin(y)) * z)); else tmp = Float64(t_0 / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (sin(y) / y); tmp = 0.0; if (t_0 <= 5e-194) tmp = x / ((y / sin(y)) * z); else tmp = t_0 / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-194], N[(x / N[(N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{\sin y}{y}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-194}:\\
\;\;\;\;\frac{x}{\frac{y}{\sin y} \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{z}\\
\end{array}
\end{array}
if (*.f64 x (/.f64 (sin.f64 y) y)) < 5.0000000000000002e-194Initial program 95.3%
associate-/l*98.1%
Simplified98.1%
clear-num98.0%
associate-/r/98.1%
clear-num98.2%
Applied egg-rr98.2%
if 5.0000000000000002e-194 < (*.f64 x (/.f64 (sin.f64 y) y)) Initial program 99.8%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (<= y 2.4e-13) (/ x z) (* (sin y) (/ x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.4e-13) {
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 <= 2.4d-13) 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 <= 2.4e-13) {
tmp = x / z;
} else {
tmp = Math.sin(y) * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.4e-13: tmp = x / z else: tmp = math.sin(y) * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.4e-13) tmp = Float64(x / z); else tmp = Float64(sin(y) * Float64(x / Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.4e-13) tmp = x / z; else tmp = sin(y) * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.4e-13], N[(x / z), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4 \cdot 10^{-13}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 2.3999999999999999e-13Initial program 97.8%
Taylor expanded in y around 0 75.7%
if 2.3999999999999999e-13 < y Initial program 94.1%
associate-*l/92.5%
times-frac91.2%
*-commutative91.2%
associate-*r/91.2%
*-commutative91.2%
Simplified91.2%
Final simplification79.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.7e-47) (/ x z) (* (/ (sin y) z) (/ x y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.7e-47) {
tmp = x / z;
} else {
tmp = (sin(y) / z) * (x / 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 <= 1.7d-47) then
tmp = x / z
else
tmp = (sin(y) / z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.7e-47) {
tmp = x / z;
} else {
tmp = (Math.sin(y) / z) * (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.7e-47: tmp = x / z else: tmp = (math.sin(y) / z) * (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.7e-47) tmp = Float64(x / z); else tmp = Float64(Float64(sin(y) / z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.7e-47) tmp = x / z; else tmp = (sin(y) / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.7e-47], N[(x / z), $MachinePrecision], N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.7 \cdot 10^{-47}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin y}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 1.7000000000000001e-47Initial program 97.8%
Taylor expanded in y around 0 75.1%
if 1.7000000000000001e-47 < y Initial program 94.5%
associate-*r/93.8%
associate-/l/91.0%
*-commutative91.0%
times-frac94.8%
Simplified94.8%
Final simplification80.5%
(FPCore (x y z) :precision binary64 (/ x (* (/ y (sin y)) z)))
double code(double x, double y, double z) {
return x / ((y / sin(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 / ((y / sin(y)) * z)
end function
public static double code(double x, double y, double z) {
return x / ((y / Math.sin(y)) * z);
}
def code(x, y, z): return x / ((y / math.sin(y)) * z)
function code(x, y, z) return Float64(x / Float64(Float64(y / sin(y)) * z)) end
function tmp = code(x, y, z) tmp = x / ((y / sin(y)) * z); end
code[x_, y_, z_] := N[(x / N[(N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{y}{\sin y} \cdot z}
\end{array}
Initial program 96.9%
associate-/l*96.2%
Simplified96.2%
clear-num96.1%
associate-/r/96.2%
clear-num96.3%
Applied egg-rr96.3%
Final simplification96.3%
(FPCore (x y z) :precision binary64 (if (<= y 2.5) (/ x z) (* (/ (/ x y) (* z 0.16666666666666666)) (/ 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.5) {
tmp = x / z;
} else {
tmp = ((x / y) / (z * 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.5d0) then
tmp = x / z
else
tmp = ((x / y) / (z * 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.5) {
tmp = x / z;
} else {
tmp = ((x / y) / (z * 0.16666666666666666)) * (1.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.5: tmp = x / z else: tmp = ((x / y) / (z * 0.16666666666666666)) * (1.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.5) tmp = Float64(x / z); else tmp = Float64(Float64(Float64(x / y) / Float64(z * 0.16666666666666666)) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.5) tmp = x / z; else tmp = ((x / y) / (z * 0.16666666666666666)) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.5], N[(x / z), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] / N[(z * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{z \cdot 0.16666666666666666} \cdot \frac{1}{y}\\
\end{array}
\end{array}
if y < 2.5Initial program 97.9%
Taylor expanded in y around 0 76.0%
if 2.5 < y Initial program 93.9%
associate-/l*90.9%
associate-/r/90.9%
Simplified90.9%
Taylor expanded in y around 0 28.5%
Taylor expanded in y around inf 28.5%
*-commutative28.5%
associate-*r*28.5%
Simplified28.5%
associate-/r*28.6%
div-inv28.6%
associate-/r*28.6%
Applied egg-rr28.6%
Final simplification64.1%
(FPCore (x y z) :precision binary64 (if (<= y 62.0) (/ x (/ z (+ 1.0 (* -0.16666666666666666 (* y y))))) (* (/ (/ x y) (* z 0.16666666666666666)) (/ 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 62.0) {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
} else {
tmp = ((x / y) / (z * 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 <= 62.0d0) then
tmp = x / (z / (1.0d0 + ((-0.16666666666666666d0) * (y * y))))
else
tmp = ((x / y) / (z * 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 <= 62.0) {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
} else {
tmp = ((x / y) / (z * 0.16666666666666666)) * (1.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 62.0: tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))) else: tmp = ((x / y) / (z * 0.16666666666666666)) * (1.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 62.0) tmp = Float64(x / Float64(z / Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))))); else tmp = Float64(Float64(Float64(x / y) / Float64(z * 0.16666666666666666)) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 62.0) tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))); else tmp = ((x / y) / (z * 0.16666666666666666)) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 62.0], N[(x / N[(z / N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] / N[(z * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 62:\\
\;\;\;\;\frac{x}{\frac{z}{1 + -0.16666666666666666 \cdot \left(y \cdot y\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{z \cdot 0.16666666666666666} \cdot \frac{1}{y}\\
\end{array}
\end{array}
if y < 62Initial program 97.9%
associate-/l*98.0%
Simplified98.0%
Taylor expanded in y around 0 74.0%
unpow274.0%
Simplified74.0%
if 62 < y Initial program 93.8%
associate-/l*90.8%
associate-/r/90.8%
Simplified90.8%
Taylor expanded in y around 0 29.0%
Taylor expanded in y around inf 29.0%
*-commutative29.0%
associate-*r*29.0%
Simplified29.0%
associate-/r*29.1%
div-inv29.1%
associate-/r*29.1%
Applied egg-rr29.1%
Final simplification62.9%
(FPCore (x y z) :precision binary64 (if (<= y 62.0) (/ (* x (+ 1.0 (* -0.16666666666666666 (* y y)))) z) (* (/ (/ x y) (* z 0.16666666666666666)) (/ 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 62.0) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = ((x / y) / (z * 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 <= 62.0d0) then
tmp = (x * (1.0d0 + ((-0.16666666666666666d0) * (y * y)))) / z
else
tmp = ((x / y) / (z * 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 <= 62.0) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = ((x / y) / (z * 0.16666666666666666)) * (1.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 62.0: tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z else: tmp = ((x / y) / (z * 0.16666666666666666)) * (1.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 62.0) tmp = Float64(Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y)))) / z); else tmp = Float64(Float64(Float64(x / y) / Float64(z * 0.16666666666666666)) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 62.0) tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z; else tmp = ((x / y) / (z * 0.16666666666666666)) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 62.0], N[(N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] / N[(z * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 62:\\
\;\;\;\;\frac{x \cdot \left(1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{z \cdot 0.16666666666666666} \cdot \frac{1}{y}\\
\end{array}
\end{array}
if y < 62Initial program 97.9%
Taylor expanded in y around 0 74.0%
unpow274.0%
Simplified74.0%
if 62 < y Initial program 93.8%
associate-/l*90.8%
associate-/r/90.8%
Simplified90.8%
Taylor expanded in y around 0 29.0%
Taylor expanded in y around inf 29.0%
*-commutative29.0%
associate-*r*29.0%
Simplified29.0%
associate-/r*29.1%
div-inv29.1%
associate-/r*29.1%
Applied egg-rr29.1%
Final simplification62.9%
(FPCore (x y z) :precision binary64 (if (<= y 2.5) (/ x z) (/ (/ x (* z (* y 0.16666666666666666))) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.5) {
tmp = x / z;
} else {
tmp = (x / (z * (y * 0.16666666666666666))) / 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.5d0) then
tmp = x / z
else
tmp = (x / (z * (y * 0.16666666666666666d0))) / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.5) {
tmp = x / z;
} else {
tmp = (x / (z * (y * 0.16666666666666666))) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.5: tmp = x / z else: tmp = (x / (z * (y * 0.16666666666666666))) / y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.5) tmp = Float64(x / z); else tmp = Float64(Float64(x / Float64(z * Float64(y * 0.16666666666666666))) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.5) tmp = x / z; else tmp = (x / (z * (y * 0.16666666666666666))) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.5], N[(x / z), $MachinePrecision], N[(N[(x / N[(z * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z \cdot \left(y \cdot 0.16666666666666666\right)}}{y}\\
\end{array}
\end{array}
if y < 2.5Initial program 97.9%
Taylor expanded in y around 0 76.0%
if 2.5 < y Initial program 93.9%
associate-/l*90.9%
associate-/r/90.9%
Simplified90.9%
Taylor expanded in y around 0 28.5%
Taylor expanded in y around inf 28.5%
*-commutative28.5%
associate-*r*28.5%
Simplified28.5%
clear-num28.5%
associate-/r/28.5%
associate-*r*28.5%
associate-*l*28.5%
*-commutative28.5%
Applied egg-rr28.5%
associate-*l/28.5%
*-un-lft-identity28.5%
associate-*r*28.5%
associate-/r*28.6%
associate-*l*28.6%
Applied egg-rr28.6%
Final simplification64.1%
(FPCore (x y z) :precision binary64 (if (<= y 200000000000.0) (/ x z) (* y (/ x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 200000000000.0) {
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 <= 200000000000.0d0) 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 <= 200000000000.0) {
tmp = x / z;
} else {
tmp = y * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 200000000000.0: tmp = x / z else: tmp = y * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 200000000000.0) tmp = Float64(x / z); else tmp = Float64(y * Float64(x / Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 200000000000.0) tmp = x / z; else tmp = y * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 200000000000.0], N[(x / z), $MachinePrecision], N[(y * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 200000000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 2e11Initial program 97.9%
Taylor expanded in y around 0 74.6%
if 2e11 < y Initial program 93.5%
associate-*l/91.8%
times-frac90.3%
*-commutative90.3%
associate-*r/90.3%
*-commutative90.3%
Simplified90.3%
Taylor expanded in y around 0 28.3%
Final simplification63.8%
(FPCore (x y z) :precision binary64 (if (<= y 4e-6) (/ x z) (/ y (* z (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e-6) {
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 <= 4d-6) 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 <= 4e-6) {
tmp = x / z;
} else {
tmp = y / (z * (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4e-6: tmp = x / z else: tmp = y / (z * (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4e-6) 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 <= 4e-6) tmp = x / z; else tmp = y / (z * (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4e-6], N[(x / z), $MachinePrecision], N[(y / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 3.99999999999999982e-6Initial program 97.9%
Taylor expanded in y around 0 76.0%
if 3.99999999999999982e-6 < y Initial program 93.9%
associate-*r/94.0%
associate-/l/90.9%
*-commutative90.9%
times-frac94.3%
Simplified94.3%
Taylor expanded in y around 0 18.5%
*-commutative18.5%
clear-num18.5%
frac-times27.8%
*-un-lft-identity27.8%
Applied egg-rr27.8%
Final simplification63.9%
(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.9%
associate-*r/91.6%
associate-/l/86.3%
*-commutative86.3%
times-frac83.1%
Simplified83.1%
Taylor expanded in y around 0 49.2%
*-commutative49.2%
clear-num48.3%
un-div-inv48.3%
Applied egg-rr48.3%
associate-/r/53.7%
associate-/r*56.5%
div-inv56.5%
associate-*l*56.9%
*-commutative56.9%
Applied egg-rr56.9%
*-commutative56.9%
associate-*l/57.2%
*-un-lft-identity57.2%
associate-/r/57.4%
*-commutative57.4%
associate-*l/54.9%
associate-/r*54.0%
clear-num54.1%
associate-/r/60.9%
*-inverses60.9%
*-un-lft-identity60.9%
Applied egg-rr60.9%
Final simplification60.9%
(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.9%
Taylor expanded in y around 0 60.7%
Final simplification60.7%
(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 2023221
(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))