
(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 (if (or (<= z -4.9e+45) (not (<= z 5e-102))) (* (/ (sin y) y) (/ x z)) (/ x (* y (/ z (sin y))))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.9e+45) || !(z <= 5e-102)) {
tmp = (sin(y) / y) * (x / z);
} else {
tmp = x / (y * (z / sin(y)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-4.9d+45)) .or. (.not. (z <= 5d-102))) then
tmp = (sin(y) / y) * (x / z)
else
tmp = x / (y * (z / sin(y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.9e+45) || !(z <= 5e-102)) {
tmp = (Math.sin(y) / y) * (x / z);
} else {
tmp = x / (y * (z / Math.sin(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.9e+45) or not (z <= 5e-102): tmp = (math.sin(y) / y) * (x / z) else: tmp = x / (y * (z / math.sin(y))) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.9e+45) || !(z <= 5e-102)) tmp = Float64(Float64(sin(y) / y) * Float64(x / z)); else tmp = Float64(x / Float64(y * Float64(z / sin(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.9e+45) || ~((z <= 5e-102))) tmp = (sin(y) / y) * (x / z); else tmp = x / (y * (z / sin(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.9e+45], N[Not[LessEqual[z, 5e-102]], $MachinePrecision]], N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * N[(z / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.9 \cdot 10^{+45} \lor \neg \left(z \leq 5 \cdot 10^{-102}\right):\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \frac{z}{\sin y}}\\
\end{array}
\end{array}
if z < -4.9000000000000002e45 or 5.00000000000000026e-102 < z Initial program 99.2%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
if -4.9000000000000002e45 < z < 5.00000000000000026e-102Initial program 90.9%
associate-/l*99.7%
Simplified99.7%
associate-/r/91.3%
*-commutative91.3%
div-inv91.2%
associate-*l*82.7%
Applied egg-rr82.7%
*-commutative82.7%
*-commutative82.7%
associate-*l/81.4%
div-inv81.5%
associate-/r/87.7%
associate-/l/99.6%
Applied egg-rr99.6%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.2e+45) (not (<= z 1.2e+20))) (* (sin y) (/ (/ x z) y)) (* x (/ (/ (sin y) z) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.2e+45) || !(z <= 1.2e+20)) {
tmp = sin(y) * ((x / z) / y);
} else {
tmp = x * ((sin(y) / z) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-6.2d+45)) .or. (.not. (z <= 1.2d+20))) then
tmp = sin(y) * ((x / z) / y)
else
tmp = x * ((sin(y) / z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6.2e+45) || !(z <= 1.2e+20)) {
tmp = Math.sin(y) * ((x / z) / y);
} else {
tmp = x * ((Math.sin(y) / z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.2e+45) or not (z <= 1.2e+20): tmp = math.sin(y) * ((x / z) / y) else: tmp = x * ((math.sin(y) / z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.2e+45) || !(z <= 1.2e+20)) tmp = Float64(sin(y) * Float64(Float64(x / z) / y)); else tmp = Float64(x * Float64(Float64(sin(y) / z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.2e+45) || ~((z <= 1.2e+20))) tmp = sin(y) * ((x / z) / y); else tmp = x * ((sin(y) / z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.2e+45], N[Not[LessEqual[z, 1.2e+20]], $MachinePrecision]], N[(N[Sin[y], $MachinePrecision] * N[(N[(x / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+45} \lor \neg \left(z \leq 1.2 \cdot 10^{+20}\right):\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{z}}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\
\end{array}
\end{array}
if z < -6.19999999999999975e45 or 1.2e20 < z Initial program 99.9%
associate-*r/92.7%
associate-/l/92.7%
associate-/r*74.2%
Simplified74.2%
Taylor expanded in x around 0 90.0%
associate-*l/89.9%
associate-/l/97.1%
*-commutative97.1%
Simplified97.1%
if -6.19999999999999975e45 < z < 1.2e20Initial program 91.9%
associate-*r/99.6%
associate-/l/91.5%
associate-/r*99.4%
Simplified99.4%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.5e-144) (not (<= z 2.6e-102))) (* (/ (sin y) y) (/ x z)) (* x (/ (/ (sin y) z) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.5e-144) || !(z <= 2.6e-102)) {
tmp = (sin(y) / y) * (x / z);
} else {
tmp = x * ((sin(y) / z) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.5d-144)) .or. (.not. (z <= 2.6d-102))) then
tmp = (sin(y) / y) * (x / z)
else
tmp = x * ((sin(y) / z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.5e-144) || !(z <= 2.6e-102)) {
tmp = (Math.sin(y) / y) * (x / z);
} else {
tmp = x * ((Math.sin(y) / z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.5e-144) or not (z <= 2.6e-102): tmp = (math.sin(y) / y) * (x / z) else: tmp = x * ((math.sin(y) / z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.5e-144) || !(z <= 2.6e-102)) tmp = Float64(Float64(sin(y) / y) * Float64(x / z)); else tmp = Float64(x * Float64(Float64(sin(y) / z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.5e-144) || ~((z <= 2.6e-102))) tmp = (sin(y) / y) * (x / z); else tmp = x * ((sin(y) / z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.5e-144], N[Not[LessEqual[z, 2.6e-102]], $MachinePrecision]], N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{-144} \lor \neg \left(z \leq 2.6 \cdot 10^{-102}\right):\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\
\end{array}
\end{array}
if z < -1.4999999999999999e-144 or 2.59999999999999986e-102 < z Initial program 98.5%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
if -1.4999999999999999e-144 < z < 2.59999999999999986e-102Initial program 87.7%
associate-*r/99.5%
associate-/l/86.4%
associate-/r*99.5%
Simplified99.5%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (<= y 2.5e-11) (/ x z) (* x (/ (/ (sin y) z) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.5e-11) {
tmp = x / z;
} else {
tmp = x * ((sin(y) / z) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 2.5d-11) then
tmp = x / z
else
tmp = x * ((sin(y) / z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.5e-11) {
tmp = x / z;
} else {
tmp = x * ((Math.sin(y) / z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.5e-11: tmp = x / z else: tmp = x * ((math.sin(y) / z) / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.5e-11) tmp = Float64(x / z); else tmp = Float64(x * Float64(Float64(sin(y) / z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.5e-11) tmp = x / z; else tmp = x * ((sin(y) / z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.5e-11], N[(x / z), $MachinePrecision], N[(x * N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\
\end{array}
\end{array}
if y < 2.50000000000000009e-11Initial program 95.8%
associate-*r/98.6%
associate-/l/91.8%
associate-/r*87.2%
Simplified87.2%
Taylor expanded in y around 0 71.7%
if 2.50000000000000009e-11 < y Initial program 93.9%
associate-*r/92.5%
associate-/l/92.5%
associate-/r*92.5%
Simplified92.5%
Final simplification78.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y))) (if (<= x 5.5e-71) (/ x (/ z t_0)) (/ (* x t_0) z))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if (x <= 5.5e-71) {
tmp = x / (z / t_0);
} else {
tmp = (x * 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 = sin(y) / y
if (x <= 5.5d-71) then
tmp = x / (z / t_0)
else
tmp = (x * t_0) / 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 (x <= 5.5e-71) {
tmp = x / (z / t_0);
} else {
tmp = (x * t_0) / z;
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if x <= 5.5e-71: tmp = x / (z / t_0) else: tmp = (x * t_0) / z return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if (x <= 5.5e-71) tmp = Float64(x / Float64(z / t_0)); else tmp = Float64(Float64(x * t_0) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) / y; tmp = 0.0; if (x <= 5.5e-71) tmp = x / (z / t_0); else tmp = (x * t_0) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, 5.5e-71], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;x \leq 5.5 \cdot 10^{-71}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot t_0}{z}\\
\end{array}
\end{array}
if x < 5.4999999999999997e-71Initial program 93.1%
associate-/l*99.3%
Simplified99.3%
if 5.4999999999999997e-71 < x Initial program 99.6%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y))) (if (<= z 7e-102) (/ x (/ z t_0)) (* t_0 (/ x z)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if (z <= 7e-102) {
tmp = x / (z / t_0);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = sin(y) / y
if (z <= 7d-102) then
tmp = x / (z / t_0)
else
tmp = t_0 * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.sin(y) / y;
double tmp;
if (z <= 7e-102) {
tmp = x / (z / t_0);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if z <= 7e-102: tmp = x / (z / t_0) else: tmp = t_0 * (x / z) return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if (z <= 7e-102) tmp = Float64(x / Float64(z / t_0)); else tmp = Float64(t_0 * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) / y; tmp = 0.0; if (z <= 7e-102) tmp = x / (z / t_0); else tmp = t_0 * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[z, 7e-102], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;z \leq 7 \cdot 10^{-102}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < 6.99999999999999973e-102Initial program 93.5%
associate-/l*98.1%
Simplified98.1%
if 6.99999999999999973e-102 < z Initial program 98.7%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (<= y 2.5e-11) (/ x z) (* y (* (/ 1.0 z) (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.5e-11) {
tmp = x / z;
} else {
tmp = y * ((1.0 / 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 <= 2.5d-11) then
tmp = x / z
else
tmp = y * ((1.0d0 / z) * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.5e-11) {
tmp = x / z;
} else {
tmp = y * ((1.0 / z) * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.5e-11: tmp = x / z else: tmp = y * ((1.0 / z) * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.5e-11) tmp = Float64(x / z); else tmp = Float64(y * Float64(Float64(1.0 / z) * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.5e-11) tmp = x / z; else tmp = y * ((1.0 / z) * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.5e-11], N[(x / z), $MachinePrecision], N[(y * N[(N[(1.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(\frac{1}{z} \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if y < 2.50000000000000009e-11Initial program 95.8%
associate-*r/98.6%
associate-/l/91.8%
associate-/r*87.2%
Simplified87.2%
Taylor expanded in y around 0 71.7%
if 2.50000000000000009e-11 < y Initial program 93.9%
associate-*r/92.5%
associate-/l/92.5%
associate-/r*92.5%
Simplified92.5%
Taylor expanded in y around 0 15.7%
*-un-lft-identity15.7%
*-inverses15.7%
associate-*l/15.6%
*-commutative15.6%
associate-*l*15.4%
div-inv15.4%
associate-/l*23.6%
Applied egg-rr23.6%
div-inv23.6%
div-inv23.6%
clear-num22.5%
associate-*l*36.0%
Applied egg-rr36.0%
Final simplification60.5%
(FPCore (x y z) :precision binary64 (if (<= y 1e+21) (/ x z) (* x (/ y (* z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1e+21) {
tmp = x / z;
} else {
tmp = x * (y / (z * y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1d+21) then
tmp = x / z
else
tmp = x * (y / (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1e+21) {
tmp = x / z;
} else {
tmp = x * (y / (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1e+21: tmp = x / z else: tmp = x * (y / (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1e+21) tmp = Float64(x / z); else tmp = Float64(x * Float64(y / Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1e+21) tmp = x / z; else tmp = x * (y / (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1e+21], N[(x / z), $MachinePrecision], N[(x * N[(y / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+21}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z \cdot y}\\
\end{array}
\end{array}
if y < 1e21Initial program 95.9%
associate-*r/98.6%
associate-/l/92.0%
associate-/r*87.6%
Simplified87.6%
Taylor expanded in y around 0 71.3%
if 1e21 < y Initial program 93.5%
associate-*r/92.1%
associate-/l/92.1%
associate-/r*92.1%
Simplified92.1%
Taylor expanded in y around 0 12.6%
*-commutative12.6%
associate-/l/21.8%
associate-*l/21.5%
Applied egg-rr21.5%
associate-/l*34.4%
associate-/r/21.8%
Applied egg-rr21.8%
Final simplification56.8%
(FPCore (x y z) :precision binary64 (if (<= y 2.5e-11) (/ x z) (/ y (* z (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.5e-11) {
tmp = x / z;
} else {
tmp = y / (z * (y / x));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 2.5d-11) then
tmp = x / z
else
tmp = y / (z * (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.5e-11) {
tmp = x / z;
} else {
tmp = y / (z * (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.5e-11: tmp = x / z else: tmp = y / (z * (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.5e-11) tmp = Float64(x / z); else tmp = Float64(y / Float64(z * Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.5e-11) tmp = x / z; else tmp = y / (z * (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.5e-11], N[(x / z), $MachinePrecision], N[(y / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 2.50000000000000009e-11Initial program 95.8%
associate-*r/98.6%
associate-/l/91.8%
associate-/r*87.2%
Simplified87.2%
Taylor expanded in y around 0 71.7%
if 2.50000000000000009e-11 < y Initial program 93.9%
associate-*r/92.5%
associate-/l/92.5%
associate-/r*92.5%
Simplified92.5%
Taylor expanded in y around 0 15.7%
*-un-lft-identity15.7%
*-inverses15.7%
un-div-inv15.7%
times-frac23.8%
associate-/l*35.9%
*-commutative35.9%
*-un-lft-identity35.9%
times-frac36.0%
/-rgt-identity36.0%
Applied egg-rr36.0%
Final simplification60.5%
(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 95.2%
associate-*r/96.7%
associate-/l/92.0%
associate-/r*88.9%
Simplified88.9%
associate-/l/92.0%
associate-*r/88.6%
*-commutative88.6%
frac-times95.8%
clear-num95.6%
un-div-inv95.9%
Applied egg-rr95.9%
Taylor expanded in y around 0 54.2%
Final simplification54.2%
(FPCore (x y z) :precision binary64 (/ x z))
double code(double x, double y, double z) {
return x / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x / z
end function
public static double code(double x, double y, double z) {
return x / z;
}
def code(x, y, z): return x / z
function code(x, y, z) return Float64(x / z) end
function tmp = code(x, y, z) tmp = x / z; end
code[x_, y_, z_] := N[(x / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z}
\end{array}
Initial program 95.2%
associate-*r/96.7%
associate-/l/92.0%
associate-/r*88.9%
Simplified88.9%
Taylor expanded in y around 0 54.2%
Final simplification54.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (sin y))) (t_1 (/ (* x (/ 1.0 t_0)) z)))
(if (< z -4.2173720203427147e-29)
t_1
(if (< z 4.446702369113811e+64) (/ x (* z t_0)) t_1))))
double code(double x, double y, double z) {
double t_0 = y / sin(y);
double t_1 = (x * (1.0 / t_0)) / z;
double tmp;
if (z < -4.2173720203427147e-29) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x / (z * t_0);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y / sin(y)
t_1 = (x * (1.0d0 / t_0)) / z
if (z < (-4.2173720203427147d-29)) then
tmp = t_1
else if (z < 4.446702369113811d+64) then
tmp = x / (z * t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / Math.sin(y);
double t_1 = (x * (1.0 / t_0)) / z;
double tmp;
if (z < -4.2173720203427147e-29) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x / (z * t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y / math.sin(y) t_1 = (x * (1.0 / t_0)) / z tmp = 0 if z < -4.2173720203427147e-29: tmp = t_1 elif z < 4.446702369113811e+64: tmp = x / (z * t_0) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y / sin(y)) t_1 = Float64(Float64(x * Float64(1.0 / t_0)) / z) tmp = 0.0 if (z < -4.2173720203427147e-29) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = Float64(x / Float64(z * t_0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / sin(y); t_1 = (x * (1.0 / t_0)) / z; tmp = 0.0; if (z < -4.2173720203427147e-29) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = x / (z * t_0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Less[z, -4.2173720203427147e-29], t$95$1, If[Less[z, 4.446702369113811e+64], N[(x / N[(z * t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{\sin y}\\
t_1 := \frac{x \cdot \frac{1}{t_0}}{z}\\
\mathbf{if}\;z < -4.2173720203427147 \cdot 10^{-29}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\
\;\;\;\;\frac{x}{z \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2023320
(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))