
(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 11 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 (or (<= z -5.5e-18) (not (<= z 2e+66)))
(* 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 ((z <= -5.5e-18) || !(z <= 2e+66)) {
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 ((z <= (-5.5d-18)) .or. (.not. (z <= 2d+66))) 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 ((z <= -5.5e-18) || !(z <= 2e+66)) {
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 (z <= -5.5e-18) or not (z <= 2e+66): 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 ((z <= -5.5e-18) || !(z <= 2e+66)) 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 ((z <= -5.5e-18) || ~((z <= 2e+66))) 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[Or[LessEqual[z, -5.5e-18], N[Not[LessEqual[z, 2e+66]], $MachinePrecision]], 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}\;z \leq -5.5 \cdot 10^{-18} \lor \neg \left(z \leq 2 \cdot 10^{+66}\right):\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}
\end{array}
if z < -5.5e-18 or 1.99999999999999989e66 < z Initial program 99.8%
*-commutative99.8%
associate-*r/99.8%
Simplified99.8%
if -5.5e-18 < z < 1.99999999999999989e66Initial program 93.7%
associate-/l*99.7%
Simplified99.7%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y)) (t_1 (* x t_0))) (if (<= t_1 2e-266) (/ x (/ z t_0)) (/ t_1 z))))
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 <= 2e-266) {
tmp = x / (z / t_0);
} else {
tmp = t_1 / 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) :: t_1
real(8) :: tmp
t_0 = sin(y) / y
t_1 = x * t_0
if (t_1 <= 2d-266) then
tmp = x / (z / t_0)
else
tmp = t_1 / 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 t_1 = x * t_0;
double tmp;
if (t_1 <= 2e-266) {
tmp = x / (z / t_0);
} else {
tmp = t_1 / z;
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y t_1 = x * t_0 tmp = 0 if t_1 <= 2e-266: tmp = x / (z / t_0) else: tmp = t_1 / z 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 <= 2e-266) tmp = Float64(x / Float64(z / t_0)); else tmp = Float64(t_1 / z); 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 <= 2e-266) tmp = x / (z / t_0); else tmp = t_1 / z; 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, 2e-266], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
t_1 := x \cdot t_0\\
\mathbf{if}\;t_1 \leq 2 \cdot 10^{-266}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{z}\\
\end{array}
\end{array}
if (*.f64 x (/.f64 (sin.f64 y) y)) < 2e-266Initial program 94.0%
associate-/l*97.8%
Simplified97.8%
if 2e-266 < (*.f64 x (/.f64 (sin.f64 y) y)) Initial program 99.8%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (<= y 8.2e-7) (/ x (+ z (* 0.16666666666666666 (* z (* y y))))) (* (sin y) (/ x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 8.2e-7) {
tmp = x / (z + (0.16666666666666666 * (z * (y * y))));
} 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 <= 8.2d-7) then
tmp = x / (z + (0.16666666666666666d0 * (z * (y * y))))
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 <= 8.2e-7) {
tmp = x / (z + (0.16666666666666666 * (z * (y * y))));
} else {
tmp = Math.sin(y) * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 8.2e-7: tmp = x / (z + (0.16666666666666666 * (z * (y * y)))) else: tmp = math.sin(y) * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 8.2e-7) tmp = Float64(x / Float64(z + Float64(0.16666666666666666 * Float64(z * Float64(y * y))))); 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 <= 8.2e-7) tmp = x / (z + (0.16666666666666666 * (z * (y * y)))); else tmp = sin(y) * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 8.2e-7], N[(x / N[(z + N[(0.16666666666666666 * N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{z + 0.16666666666666666 \cdot \left(z \cdot \left(y \cdot y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 8.1999999999999998e-7Initial program 97.4%
associate-/l*97.6%
Simplified97.6%
Taylor expanded in y around 0 76.2%
*-commutative76.2%
unpow276.2%
Simplified76.2%
if 8.1999999999999998e-7 < y Initial program 93.4%
associate-/l*92.0%
associate-/r/91.9%
associate-/l/93.6%
associate-/r/93.6%
associate-/r*91.8%
Simplified91.8%
Final simplification79.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.5e+182) (* (/ (sin y) y) (/ x z)) (* (sin y) (/ x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.5e+182) {
tmp = (sin(y) / y) * (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.5d+182) then
tmp = (sin(y) / y) * (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.5e+182) {
tmp = (Math.sin(y) / y) * (x / z);
} else {
tmp = Math.sin(y) * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.5e+182: tmp = (math.sin(y) / y) * (x / z) else: tmp = math.sin(y) * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.5e+182) tmp = Float64(Float64(sin(y) / y) * 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 <= 1.5e+182) tmp = (sin(y) / y) * (x / z); else tmp = sin(y) * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.5e+182], N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{+182}:\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 1.5000000000000001e182Initial program 96.9%
*-commutative96.9%
associate-*r/96.2%
Simplified96.2%
if 1.5000000000000001e182 < y Initial program 92.9%
associate-/l*92.2%
associate-/r/92.2%
associate-/l/93.2%
associate-/r/93.1%
associate-/r*92.1%
Simplified92.1%
Final simplification95.8%
(FPCore (x y z) :precision binary64 (if (<= y 1.25e+70) (/ x z) (* 6.0 (/ x (* z (* y y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.25e+70) {
tmp = x / z;
} else {
tmp = 6.0 * (x / (z * (y * 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.25d+70) then
tmp = x / z
else
tmp = 6.0d0 * (x / (z * (y * y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.25e+70) {
tmp = x / z;
} else {
tmp = 6.0 * (x / (z * (y * y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.25e+70: tmp = x / z else: tmp = 6.0 * (x / (z * (y * y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.25e+70) tmp = Float64(x / z); else tmp = Float64(6.0 * Float64(x / Float64(z * Float64(y * y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.25e+70) tmp = x / z; else tmp = 6.0 * (x / (z * (y * y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.25e+70], N[(x / z), $MachinePrecision], N[(6.0 * N[(x / N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.25 \cdot 10^{+70}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;6 \cdot \frac{x}{z \cdot \left(y \cdot y\right)}\\
\end{array}
\end{array}
if y < 1.2500000000000001e70Initial program 97.6%
associate-/l*97.8%
associate-/r/89.9%
associate-/l/83.8%
associate-/r/82.7%
associate-/r*82.7%
Simplified82.7%
Taylor expanded in y around 0 70.5%
if 1.2500000000000001e70 < y Initial program 91.5%
associate-/l*89.5%
Simplified89.5%
Taylor expanded in y around 0 37.8%
*-commutative37.8%
unpow237.8%
Simplified37.8%
Taylor expanded in y around inf 37.8%
unpow237.8%
*-commutative37.8%
Simplified37.8%
Final simplification64.7%
(FPCore (x y z) :precision binary64 (if (<= y 9.5e+69) (/ x z) (* 6.0 (/ (/ (/ x y) y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 9.5e+69) {
tmp = x / z;
} else {
tmp = 6.0 * (((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 <= 9.5d+69) then
tmp = x / z
else
tmp = 6.0d0 * (((x / y) / y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 9.5e+69) {
tmp = x / z;
} else {
tmp = 6.0 * (((x / y) / y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 9.5e+69: tmp = x / z else: tmp = 6.0 * (((x / y) / y) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 9.5e+69) tmp = Float64(x / z); else tmp = Float64(6.0 * Float64(Float64(Float64(x / y) / y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 9.5e+69) tmp = x / z; else tmp = 6.0 * (((x / y) / y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 9.5e+69], N[(x / z), $MachinePrecision], N[(6.0 * N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.5 \cdot 10^{+69}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;6 \cdot \frac{\frac{\frac{x}{y}}{y}}{z}\\
\end{array}
\end{array}
if y < 9.4999999999999995e69Initial program 97.6%
associate-/l*97.8%
associate-/r/89.9%
associate-/l/83.8%
associate-/r/82.7%
associate-/r*82.7%
Simplified82.7%
Taylor expanded in y around 0 70.5%
if 9.4999999999999995e69 < y Initial program 91.5%
associate-/l*89.5%
Simplified89.5%
Taylor expanded in y around 0 37.8%
*-commutative37.8%
unpow237.8%
Simplified37.8%
Taylor expanded in y around inf 37.8%
unpow237.8%
*-commutative37.8%
associate-/r*37.8%
Simplified37.8%
Taylor expanded in x around 0 37.8%
unpow237.8%
associate-/r*37.8%
associate-/r*37.9%
Simplified37.9%
Final simplification64.7%
(FPCore (x y z) :precision binary64 (if (<= y 0.00018) (/ x z) (/ (* (/ (/ x z) y) 6.0) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.00018) {
tmp = x / z;
} else {
tmp = (((x / z) / y) * 6.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 <= 0.00018d0) then
tmp = x / z
else
tmp = (((x / z) / y) * 6.0d0) / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 0.00018) {
tmp = x / z;
} else {
tmp = (((x / z) / y) * 6.0) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.00018: tmp = x / z else: tmp = (((x / z) / y) * 6.0) / y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.00018) tmp = Float64(x / z); else tmp = Float64(Float64(Float64(Float64(x / z) / y) * 6.0) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.00018) tmp = x / z; else tmp = (((x / z) / y) * 6.0) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.00018], N[(x / z), $MachinePrecision], N[(N[(N[(N[(x / z), $MachinePrecision] / y), $MachinePrecision] * 6.0), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.00018:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{x}{z}}{y} \cdot 6}{y}\\
\end{array}
\end{array}
if y < 1.80000000000000011e-4Initial program 97.4%
associate-/l*97.6%
associate-/r/89.2%
associate-/l/82.6%
associate-/r/81.5%
associate-/r*81.6%
Simplified81.6%
Taylor expanded in y around 0 72.7%
if 1.80000000000000011e-4 < y Initial program 93.3%
associate-/l*91.8%
Simplified91.8%
Taylor expanded in y around 0 38.3%
*-commutative38.3%
unpow238.3%
Simplified38.3%
Taylor expanded in y around inf 38.3%
unpow238.3%
*-commutative38.3%
associate-/r*38.3%
Simplified38.3%
*-commutative38.3%
associate-/r*38.6%
associate-*l/38.6%
Applied egg-rr38.6%
Final simplification64.7%
(FPCore (x y z) :precision binary64 (/ x (+ z (* 0.16666666666666666 (* z (* y y))))))
double code(double x, double y, double z) {
return x / (z + (0.16666666666666666 * (z * (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 + (0.16666666666666666d0 * (z * (y * y))))
end function
public static double code(double x, double y, double z) {
return x / (z + (0.16666666666666666 * (z * (y * y))));
}
def code(x, y, z): return x / (z + (0.16666666666666666 * (z * (y * y))))
function code(x, y, z) return Float64(x / Float64(z + Float64(0.16666666666666666 * Float64(z * Float64(y * y))))) end
function tmp = code(x, y, z) tmp = x / (z + (0.16666666666666666 * (z * (y * y)))); end
code[x_, y_, z_] := N[(x / N[(z + N[(0.16666666666666666 * N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z + 0.16666666666666666 \cdot \left(z \cdot \left(y \cdot y\right)\right)}
\end{array}
Initial program 96.5%
associate-/l*96.3%
Simplified96.3%
Taylor expanded in y around 0 67.4%
*-commutative67.4%
unpow267.4%
Simplified67.4%
Final simplification67.4%
(FPCore (x y z) :precision binary64 (/ x (+ z (* (* y z) (* y 0.16666666666666666)))))
double code(double x, double y, double z) {
return x / (z + ((y * z) * (y * 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 * z) * (y * 0.16666666666666666d0)))
end function
public static double code(double x, double y, double z) {
return x / (z + ((y * z) * (y * 0.16666666666666666)));
}
def code(x, y, z): return x / (z + ((y * z) * (y * 0.16666666666666666)))
function code(x, y, z) return Float64(x / Float64(z + Float64(Float64(y * z) * Float64(y * 0.16666666666666666)))) end
function tmp = code(x, y, z) tmp = x / (z + ((y * z) * (y * 0.16666666666666666))); end
code[x_, y_, z_] := N[(x / N[(z + N[(N[(y * z), $MachinePrecision] * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z + \left(y \cdot z\right) \cdot \left(y \cdot 0.16666666666666666\right)}
\end{array}
Initial program 96.5%
associate-/l*96.3%
Simplified96.3%
Taylor expanded in y around 0 67.4%
*-commutative67.4%
unpow267.4%
Simplified67.4%
Taylor expanded in x around 0 67.4%
*-commutative67.4%
unpow267.4%
*-commutative67.4%
associate-*r*67.4%
*-commutative67.4%
associate-*r*67.4%
*-commutative67.4%
Simplified67.4%
Final simplification67.4%
(FPCore (x y z) :precision binary64 (if (<= y 2e+109) (/ x z) (/ (* x y) (* y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2e+109) {
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 <= 2d+109) 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 <= 2e+109) {
tmp = x / z;
} else {
tmp = (x * y) / (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2e+109: tmp = x / z else: tmp = (x * y) / (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2e+109) 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 <= 2e+109) tmp = x / z; else tmp = (x * y) / (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2e+109], N[(x / z), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+109}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y \cdot z}\\
\end{array}
\end{array}
if y < 1.99999999999999996e109Initial program 97.2%
associate-/l*97.0%
associate-/r/89.5%
associate-/l/84.0%
associate-/r/82.9%
associate-/r*82.6%
Simplified82.6%
Taylor expanded in y around 0 68.5%
if 1.99999999999999996e109 < y Initial program 92.3%
associate-/l*91.9%
associate-/r/91.8%
associate-/l/92.6%
associate-/r/92.4%
associate-/r*91.8%
Simplified91.8%
Taylor expanded in x around 0 91.8%
Taylor expanded in y around 0 28.4%
Final simplification62.8%
(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.5%
associate-/l*96.3%
associate-/r/89.8%
associate-/l/85.2%
associate-/r/84.3%
associate-/r*83.9%
Simplified83.9%
Taylor expanded in y around 0 61.4%
Final simplification61.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 2023297
(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))