
(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 (/ 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 95.7%
associate-/l*97.9%
Simplified97.9%
clear-num97.8%
associate-/r/97.9%
clear-num98.0%
Applied egg-rr98.0%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.22e-5) (/ x (* z (+ 1.0 (* 0.16666666666666666 (* y y))))) (* (sin y) (/ x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.22e-5) {
tmp = x / (z * (1.0 + (0.16666666666666666 * (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 <= 1.22d-5) then
tmp = x / (z * (1.0d0 + (0.16666666666666666d0 * (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 <= 1.22e-5) {
tmp = x / (z * (1.0 + (0.16666666666666666 * (y * y))));
} else {
tmp = Math.sin(y) * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.22e-5: tmp = x / (z * (1.0 + (0.16666666666666666 * (y * y)))) else: tmp = math.sin(y) * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.22e-5) tmp = Float64(x / Float64(z * Float64(1.0 + Float64(0.16666666666666666 * 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 <= 1.22e-5) tmp = x / (z * (1.0 + (0.16666666666666666 * (y * y)))); else tmp = sin(y) * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.22e-5], N[(x / N[(z * N[(1.0 + N[(0.16666666666666666 * 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 1.22 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 1.22000000000000001e-5Initial program 98.0%
associate-/l*97.8%
Simplified97.8%
clear-num97.7%
associate-/r/97.8%
clear-num97.9%
Applied egg-rr97.9%
Taylor expanded in y around 0 77.2%
unpow277.2%
Simplified77.2%
if 1.22000000000000001e-5 < y Initial program 89.1%
associate-/l*98.1%
associate-/r/98.1%
associate-/l/89.0%
associate-/r/89.0%
associate-/r*98.2%
Simplified98.2%
Final simplification82.8%
(FPCore (x y z) :precision binary64 (* (/ (sin y) y) (/ x z)))
double code(double x, double y, double z) {
return (sin(y) / y) * (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 = (sin(y) / y) * (x / z)
end function
public static double code(double x, double y, double z) {
return (Math.sin(y) / y) * (x / z);
}
def code(x, y, z): return (math.sin(y) / y) * (x / z)
function code(x, y, z) return Float64(Float64(sin(y) / y) * Float64(x / z)) end
function tmp = code(x, y, z) tmp = (sin(y) / y) * (x / z); end
code[x_, y_, z_] := N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin y}{y} \cdot \frac{x}{z}
\end{array}
Initial program 95.7%
*-commutative95.7%
associate-*r/96.5%
Simplified96.5%
Final simplification96.5%
(FPCore (x y z) :precision binary64 (if (<= y 2.4) (* (/ x z) (+ 1.0 (* (* y y) -0.16666666666666666))) (* (/ 6.0 y) (/ (/ x y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.4) {
tmp = (x / z) * (1.0 + ((y * y) * -0.16666666666666666));
} else {
tmp = (6.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 <= 2.4d0) then
tmp = (x / z) * (1.0d0 + ((y * y) * (-0.16666666666666666d0)))
else
tmp = (6.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 <= 2.4) {
tmp = (x / z) * (1.0 + ((y * y) * -0.16666666666666666));
} else {
tmp = (6.0 / y) * ((x / y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.4: tmp = (x / z) * (1.0 + ((y * y) * -0.16666666666666666)) else: tmp = (6.0 / y) * ((x / y) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.4) tmp = Float64(Float64(x / z) * Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666))); else tmp = Float64(Float64(6.0 / y) * Float64(Float64(x / y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.4) tmp = (x / z) * (1.0 + ((y * y) * -0.16666666666666666)); else tmp = (6.0 / y) * ((x / y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.4], N[(N[(x / z), $MachinePrecision] * N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(6.0 / y), $MachinePrecision] * N[(N[(x / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 + \left(y \cdot y\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{y} \cdot \frac{\frac{x}{y}}{z}\\
\end{array}
\end{array}
if y < 2.39999999999999991Initial program 98.0%
*-commutative98.0%
associate-*r/96.4%
Simplified96.4%
Taylor expanded in y around 0 70.9%
unpow270.9%
Simplified70.9%
if 2.39999999999999991 < y Initial program 89.1%
associate-/l*98.1%
Simplified98.1%
Taylor expanded in y around 0 30.5%
*-commutative30.5%
unpow230.5%
Simplified30.5%
Taylor expanded in y around inf 30.5%
associate-*r/30.5%
unpow230.5%
associate-*r*30.6%
times-frac33.3%
associate-/r*33.3%
Simplified33.3%
Final simplification60.9%
(FPCore (x y z) :precision binary64 (if (<= y 2.5) (/ x z) (* 6.0 (/ (/ x z) (* y y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.5) {
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 <= 2.5d0) 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 <= 2.5) {
tmp = x / z;
} else {
tmp = 6.0 * ((x / z) / (y * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.5: tmp = x / z else: tmp = 6.0 * ((x / z) / (y * y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.5) tmp = Float64(x / z); else tmp = Float64(6.0 * Float64(Float64(x / z) / Float64(y * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.5) tmp = x / z; else tmp = 6.0 * ((x / z) / (y * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.5], N[(x / z), $MachinePrecision], N[(6.0 * N[(N[(x / z), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;6 \cdot \frac{\frac{x}{z}}{y \cdot y}\\
\end{array}
\end{array}
if y < 2.5Initial program 98.0%
associate-/l*97.8%
associate-/r/85.6%
associate-/l/77.6%
associate-/r/77.4%
associate-/r*78.1%
Simplified78.1%
Taylor expanded in y around 0 72.3%
if 2.5 < y Initial program 89.1%
associate-/l*98.1%
Simplified98.1%
Taylor expanded in y around 0 30.5%
*-commutative30.5%
unpow230.5%
Simplified30.5%
Taylor expanded in y around inf 30.5%
unpow230.5%
associate-*r*30.6%
Simplified30.6%
*-un-lft-identity30.6%
times-frac33.3%
*-commutative33.3%
Applied egg-rr33.3%
associate-/r*33.3%
frac-times33.2%
*-un-lft-identity33.2%
Applied egg-rr33.2%
Final simplification62.0%
(FPCore (x y z) :precision binary64 (if (<= y 2.5) (/ x z) (* 6.0 (/ (/ (/ x z) y) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.5) {
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 <= 2.5d0) 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 <= 2.5) {
tmp = x / z;
} else {
tmp = 6.0 * (((x / z) / y) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.5: tmp = x / z else: tmp = 6.0 * (((x / z) / y) / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.5) tmp = Float64(x / z); else tmp = Float64(6.0 * Float64(Float64(Float64(x / z) / y) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.5) tmp = x / z; else tmp = 6.0 * (((x / z) / y) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.5], N[(x / z), $MachinePrecision], N[(6.0 * N[(N[(N[(x / z), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;6 \cdot \frac{\frac{\frac{x}{z}}{y}}{y}\\
\end{array}
\end{array}
if y < 2.5Initial program 98.0%
associate-/l*97.8%
associate-/r/85.6%
associate-/l/77.6%
associate-/r/77.4%
associate-/r*78.1%
Simplified78.1%
Taylor expanded in y around 0 72.3%
if 2.5 < y Initial program 89.1%
associate-/l*98.1%
Simplified98.1%
Taylor expanded in y around 0 30.5%
*-commutative30.5%
unpow230.5%
Simplified30.5%
Taylor expanded in y around inf 30.5%
unpow230.5%
associate-*r*30.6%
Simplified30.6%
*-un-lft-identity30.6%
times-frac33.3%
*-commutative33.3%
Applied egg-rr33.3%
associate-*l/33.3%
*-un-lft-identity33.3%
associate-/r*33.3%
Applied egg-rr33.3%
Final simplification62.0%
(FPCore (x y z) :precision binary64 (if (<= y 2.5) (/ x z) (* (/ 6.0 y) (/ (/ x y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.5) {
tmp = x / z;
} else {
tmp = (6.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 <= 2.5d0) then
tmp = x / z
else
tmp = (6.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 <= 2.5) {
tmp = x / z;
} else {
tmp = (6.0 / y) * ((x / y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.5: tmp = x / z else: tmp = (6.0 / y) * ((x / y) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.5) tmp = Float64(x / z); else tmp = Float64(Float64(6.0 / y) * Float64(Float64(x / y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.5) tmp = x / z; else tmp = (6.0 / y) * ((x / y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.5], N[(x / z), $MachinePrecision], N[(N[(6.0 / y), $MachinePrecision] * N[(N[(x / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{y} \cdot \frac{\frac{x}{y}}{z}\\
\end{array}
\end{array}
if y < 2.5Initial program 98.0%
associate-/l*97.8%
associate-/r/85.6%
associate-/l/77.6%
associate-/r/77.4%
associate-/r*78.1%
Simplified78.1%
Taylor expanded in y around 0 72.3%
if 2.5 < y Initial program 89.1%
associate-/l*98.1%
Simplified98.1%
Taylor expanded in y around 0 30.5%
*-commutative30.5%
unpow230.5%
Simplified30.5%
Taylor expanded in y around inf 30.5%
associate-*r/30.5%
unpow230.5%
associate-*r*30.6%
times-frac33.3%
associate-/r*33.3%
Simplified33.3%
Final simplification62.0%
(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 95.7%
associate-/l*97.9%
Simplified97.9%
clear-num97.8%
associate-/r/97.9%
clear-num98.0%
Applied egg-rr98.0%
Taylor expanded in y around 0 64.8%
unpow264.8%
Simplified64.8%
Final simplification64.8%
(FPCore (x y z) :precision binary64 (/ x (+ z (* y (* y (* z 0.16666666666666666))))))
double code(double x, double y, double z) {
return x / (z + (y * (y * (z * 0.16666666666666666))));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x / (z + (y * (y * (z * 0.16666666666666666d0))))
end function
public static double code(double x, double y, double z) {
return x / (z + (y * (y * (z * 0.16666666666666666))));
}
def code(x, y, z): return x / (z + (y * (y * (z * 0.16666666666666666))))
function code(x, y, z) return Float64(x / Float64(z + Float64(y * Float64(y * Float64(z * 0.16666666666666666))))) end
function tmp = code(x, y, z) tmp = x / (z + (y * (y * (z * 0.16666666666666666)))); end
code[x_, y_, z_] := N[(x / N[(z + N[(y * N[(y * N[(z * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z + y \cdot \left(y \cdot \left(z \cdot 0.16666666666666666\right)\right)}
\end{array}
Initial program 95.7%
associate-/l*97.9%
Simplified97.9%
Taylor expanded in y around 0 64.8%
*-commutative64.8%
unpow264.8%
Simplified64.8%
Taylor expanded in z around 0 64.8%
*-commutative64.8%
unpow264.8%
associate-*r*64.8%
associate-*l*64.8%
associate-*l*64.8%
Simplified64.8%
Final simplification64.8%
(FPCore (x y z) :precision binary64 (if (<= y 6.5e+193) (/ x z) (* (/ x y) (/ y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.5e+193) {
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 <= 6.5d+193) 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 <= 6.5e+193) {
tmp = x / z;
} else {
tmp = (x / y) * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6.5e+193: tmp = x / z else: tmp = (x / y) * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6.5e+193) 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 <= 6.5e+193) tmp = x / z; else tmp = (x / y) * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6.5e+193], N[(x / z), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{+193}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 6.4999999999999997e193Initial program 97.5%
associate-/l*98.1%
associate-/r/88.2%
associate-/l/80.9%
associate-/r/80.7%
associate-/r*82.1%
Simplified82.1%
Taylor expanded in y around 0 63.5%
if 6.4999999999999997e193 < y Initial program 78.3%
associate-/l*95.8%
associate-/r/95.6%
associate-/l/78.5%
associate-/r/78.3%
associate-/r*95.8%
Simplified95.8%
Taylor expanded in x around 0 95.9%
Taylor expanded in y around 0 18.1%
*-commutative18.1%
*-commutative18.1%
times-frac21.8%
Applied egg-rr21.8%
Final simplification59.4%
(FPCore (x y z) :precision binary64 (if (<= y 8.5e-12) (/ x z) (/ y (* y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 8.5e-12) {
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 <= 8.5d-12) 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 <= 8.5e-12) {
tmp = x / z;
} else {
tmp = y / (y * (z / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 8.5e-12: tmp = x / z else: tmp = y / (y * (z / x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 8.5e-12) 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 <= 8.5e-12) tmp = x / z; else tmp = y / (y * (z / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 8.5e-12], N[(x / z), $MachinePrecision], N[(y / N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{-12}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y \cdot \frac{z}{x}}\\
\end{array}
\end{array}
if y < 8.4999999999999997e-12Initial program 98.0%
associate-/l*97.8%
associate-/r/85.5%
associate-/l/77.4%
associate-/r/77.1%
associate-/r*77.8%
Simplified77.8%
Taylor expanded in y around 0 72.1%
if 8.4999999999999997e-12 < y Initial program 89.4%
associate-/l*98.2%
associate-/r/98.2%
associate-/l/89.3%
associate-/r/89.3%
associate-/r*98.2%
Simplified98.2%
Taylor expanded in x around 0 98.3%
Taylor expanded in y around 0 27.0%
*-un-lft-identity27.0%
times-frac20.4%
*-commutative20.4%
Applied egg-rr20.4%
*-commutative20.4%
associate-/l*20.5%
frac-times34.3%
metadata-eval34.3%
div-inv34.3%
/-rgt-identity34.3%
Applied egg-rr34.3%
Final simplification61.7%
(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 95.7%
associate-/l*97.9%
associate-/r/88.9%
associate-/l/80.7%
associate-/r/80.4%
associate-/r*83.4%
Simplified83.4%
Taylor expanded in y around 0 58.0%
Final simplification58.0%
(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 2023287
(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))