
(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}
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 1.6e-5) (/ (* x (+ 1.0 (* -0.16666666666666666 (* y y)))) z) (* (/ (sin y) z) (/ x y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e-5) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = (sin(y) / z) * (x / y);
}
return tmp;
}
NOTE: y should be positive before calling this function
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.6d-5) then
tmp = (x * (1.0d0 + ((-0.16666666666666666d0) * (y * y)))) / z
else
tmp = (sin(y) / z) * (x / y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e-5) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = (Math.sin(y) / z) * (x / y);
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 1.6e-5: tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z else: tmp = (math.sin(y) / z) * (x / y) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 1.6e-5) tmp = Float64(Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y)))) / z); else tmp = Float64(Float64(sin(y) / z) * Float64(x / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.6e-5) tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z; else tmp = (sin(y) / z) * (x / y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 1.6e-5], N[(N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{x \cdot \left(1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin y}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 1.59999999999999993e-5Initial program 97.7%
Taylor expanded in y around 0 68.5%
unpow268.5%
Simplified68.5%
if 1.59999999999999993e-5 < y Initial program 93.2%
associate-*r/93.3%
associate-/l/85.6%
*-commutative85.6%
times-frac93.3%
Simplified93.3%
Final simplification74.3%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 0.0002) (/ (* x (+ 1.0 (* -0.16666666666666666 (* y y)))) z) (* (sin y) (/ x (* y z)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 0.0002) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = sin(y) * (x / (y * z));
}
return tmp;
}
NOTE: y should be positive before calling this function
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.0002d0) then
tmp = (x * (1.0d0 + ((-0.16666666666666666d0) * (y * y)))) / z
else
tmp = sin(y) * (x / (y * z))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 0.0002) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = Math.sin(y) * (x / (y * z));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 0.0002: tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z else: tmp = math.sin(y) * (x / (y * z)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 0.0002) tmp = Float64(Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y)))) / z); else tmp = Float64(sin(y) * Float64(x / Float64(y * z))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.0002) tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z; else tmp = sin(y) * (x / (y * z)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 0.0002], N[(N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.0002:\\
\;\;\;\;\frac{x \cdot \left(1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 2.0000000000000001e-4Initial program 97.7%
Taylor expanded in y around 0 68.5%
unpow268.5%
Simplified68.5%
if 2.0000000000000001e-4 < y Initial program 93.2%
associate-*l/91.8%
times-frac85.6%
*-commutative85.6%
associate-*r/85.8%
*-commutative85.8%
Simplified85.8%
Final simplification72.6%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
y = abs(y);
double code(double x, double y, double z) {
return (x * (sin(y) / y)) / z;
}
NOTE: y should be positive before calling this function
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
y = Math.abs(y);
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
y = abs(y) def code(x, y, z): return (x * (math.sin(y) / y)) / z
y = abs(y) function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
y = abs(y) function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
Initial program 96.7%
Final simplification96.7%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 6.2) (/ (* x (+ 1.0 (* -0.16666666666666666 (* y y)))) z) (/ (/ 6.0 y) (* y (/ z x)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 6.2) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = (6.0 / y) / (y * (z / x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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.2d0) then
tmp = (x * (1.0d0 + ((-0.16666666666666666d0) * (y * y)))) / z
else
tmp = (6.0d0 / y) / (y * (z / x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 6.2) {
tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z;
} else {
tmp = (6.0 / y) / (y * (z / x));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 6.2: tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z else: tmp = (6.0 / y) / (y * (z / x)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 6.2) tmp = Float64(Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y)))) / z); else tmp = Float64(Float64(6.0 / y) / Float64(y * Float64(z / x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6.2) tmp = (x * (1.0 + (-0.16666666666666666 * (y * y)))) / z; else tmp = (6.0 / y) / (y * (z / x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 6.2], N[(N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(6.0 / y), $MachinePrecision] / N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2:\\
\;\;\;\;\frac{x \cdot \left(1 + -0.16666666666666666 \cdot \left(y \cdot y\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{6}{y}}{y \cdot \frac{z}{x}}\\
\end{array}
\end{array}
if y < 6.20000000000000018Initial program 97.7%
Taylor expanded in y around 0 68.5%
unpow268.5%
Simplified68.5%
if 6.20000000000000018 < y Initial program 93.2%
associate-/l*85.7%
associate-/r/85.7%
Simplified85.7%
Taylor expanded in y around 0 27.0%
Taylor expanded in y around inf 27.0%
associate-*r/27.0%
times-frac26.8%
unpow226.8%
Simplified26.8%
*-commutative26.8%
clear-num26.8%
associate-/r*26.9%
frac-times27.0%
*-un-lft-identity27.0%
Applied egg-rr27.0%
Final simplification58.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 2.4) (/ x z) (* 6.0 (/ x (* z (* y y))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2.4) {
tmp = x / z;
} else {
tmp = 6.0 * (x / (z * (y * y)));
}
return tmp;
}
NOTE: y should be positive before calling this function
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
else
tmp = 6.0d0 * (x / (z * (y * y)))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.4) {
tmp = x / z;
} else {
tmp = 6.0 * (x / (z * (y * y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 2.4: tmp = x / z else: tmp = 6.0 * (x / (z * (y * y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 2.4) tmp = Float64(x / z); else tmp = Float64(6.0 * Float64(x / Float64(z * Float64(y * y)))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.4) tmp = x / z; else tmp = 6.0 * (x / (z * (y * y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 2.4], N[(x / z), $MachinePrecision], N[(6.0 * N[(x / N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;6 \cdot \frac{x}{z \cdot \left(y \cdot y\right)}\\
\end{array}
\end{array}
if y < 2.39999999999999991Initial program 97.7%
associate-*l/97.4%
times-frac81.7%
*-commutative81.7%
associate-*r/80.0%
*-commutative80.0%
Simplified80.0%
Taylor expanded in y around 0 71.2%
if 2.39999999999999991 < y Initial program 93.2%
associate-/l*85.7%
associate-/r/85.7%
Simplified85.7%
Taylor expanded in y around 0 27.0%
Taylor expanded in y around inf 27.0%
unpow227.0%
Simplified27.0%
Final simplification60.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 2.4) (/ x z) (/ (* x (/ 6.0 y)) (* y z))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2.4) {
tmp = x / z;
} else {
tmp = (x * (6.0 / y)) / (y * z);
}
return tmp;
}
NOTE: y should be positive before calling this function
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
else
tmp = (x * (6.0d0 / y)) / (y * z)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.4) {
tmp = x / z;
} else {
tmp = (x * (6.0 / y)) / (y * z);
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 2.4: tmp = x / z else: tmp = (x * (6.0 / y)) / (y * z) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 2.4) tmp = Float64(x / z); else tmp = Float64(Float64(x * Float64(6.0 / y)) / Float64(y * z)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.4) tmp = x / z; else tmp = (x * (6.0 / y)) / (y * z); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 2.4], N[(x / z), $MachinePrecision], N[(N[(x * N[(6.0 / y), $MachinePrecision]), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{6}{y}}{y \cdot z}\\
\end{array}
\end{array}
if y < 2.39999999999999991Initial program 97.7%
associate-*l/97.4%
times-frac81.7%
*-commutative81.7%
associate-*r/80.0%
*-commutative80.0%
Simplified80.0%
Taylor expanded in y around 0 71.2%
if 2.39999999999999991 < y Initial program 93.2%
associate-/l*85.7%
associate-/r/85.7%
Simplified85.7%
Taylor expanded in y around 0 27.0%
Taylor expanded in y around inf 27.0%
associate-*r/27.0%
times-frac26.8%
unpow226.8%
Simplified26.8%
associate-/r*26.9%
frac-times27.0%
Applied egg-rr27.0%
Final simplification60.9%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 2.4) (/ x z) (/ (/ 6.0 y) (* y (/ z x)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2.4) {
tmp = x / z;
} else {
tmp = (6.0 / y) / (y * (z / x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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
else
tmp = (6.0d0 / y) / (y * (z / x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.4) {
tmp = x / z;
} else {
tmp = (6.0 / y) / (y * (z / x));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 2.4: tmp = x / z else: tmp = (6.0 / y) / (y * (z / x)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 2.4) tmp = Float64(x / z); else tmp = Float64(Float64(6.0 / y) / Float64(y * Float64(z / x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.4) tmp = x / z; else tmp = (6.0 / y) / (y * (z / x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 2.4], N[(x / z), $MachinePrecision], N[(N[(6.0 / y), $MachinePrecision] / N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{6}{y}}{y \cdot \frac{z}{x}}\\
\end{array}
\end{array}
if y < 2.39999999999999991Initial program 97.7%
associate-*l/97.4%
times-frac81.7%
*-commutative81.7%
associate-*r/80.0%
*-commutative80.0%
Simplified80.0%
Taylor expanded in y around 0 71.2%
if 2.39999999999999991 < y Initial program 93.2%
associate-/l*85.7%
associate-/r/85.7%
Simplified85.7%
Taylor expanded in y around 0 27.0%
Taylor expanded in y around inf 27.0%
associate-*r/27.0%
times-frac26.8%
unpow226.8%
Simplified26.8%
*-commutative26.8%
clear-num26.8%
associate-/r*26.9%
frac-times27.0%
*-un-lft-identity27.0%
Applied egg-rr27.0%
Final simplification60.9%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 1.2e-8) (/ x z) (* (/ x y) (/ y z))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.2e-8) {
tmp = x / z;
} else {
tmp = (x / y) * (y / z);
}
return tmp;
}
NOTE: y should be positive before calling this function
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.2d-8) then
tmp = x / z
else
tmp = (x / y) * (y / z)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.2e-8) {
tmp = x / z;
} else {
tmp = (x / y) * (y / z);
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 1.2e-8: tmp = x / z else: tmp = (x / y) * (y / z) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 1.2e-8) tmp = Float64(x / z); else tmp = Float64(Float64(x / y) * Float64(y / z)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.2e-8) tmp = x / z; else tmp = (x / y) * (y / z); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 1.2e-8], N[(x / z), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 1.19999999999999999e-8Initial program 97.7%
associate-*l/97.4%
times-frac81.7%
*-commutative81.7%
associate-*r/80.0%
*-commutative80.0%
Simplified80.0%
Taylor expanded in y around 0 71.2%
if 1.19999999999999999e-8 < y Initial program 93.2%
associate-*r/93.3%
associate-/l/85.6%
*-commutative85.6%
times-frac93.3%
Simplified93.3%
Taylor expanded in y around 0 11.1%
Final simplification57.1%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 1.45e-8) (/ x z) (* y (/ (/ x y) z))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.45e-8) {
tmp = x / z;
} else {
tmp = y * ((x / y) / z);
}
return tmp;
}
NOTE: y should be positive before calling this function
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.45d-8) then
tmp = x / z
else
tmp = y * ((x / y) / z)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.45e-8) {
tmp = x / z;
} else {
tmp = y * ((x / y) / z);
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 1.45e-8: tmp = x / z else: tmp = y * ((x / y) / z) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 1.45e-8) tmp = Float64(x / z); else tmp = Float64(y * Float64(Float64(x / y) / z)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.45e-8) tmp = x / z; else tmp = y * ((x / y) / z); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 1.45e-8], N[(x / z), $MachinePrecision], N[(y * N[(N[(x / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.45 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\frac{x}{y}}{z}\\
\end{array}
\end{array}
if y < 1.4500000000000001e-8Initial program 97.7%
associate-*l/97.4%
times-frac81.7%
*-commutative81.7%
associate-*r/80.0%
*-commutative80.0%
Simplified80.0%
Taylor expanded in y around 0 71.2%
if 1.4500000000000001e-8 < y Initial program 93.2%
associate-*r/93.3%
associate-/l/85.6%
*-commutative85.6%
times-frac93.3%
Simplified93.3%
Taylor expanded in y around 0 11.1%
*-commutative11.1%
clear-num11.1%
un-div-inv11.1%
Applied egg-rr11.1%
associate-/r/26.1%
Applied egg-rr26.1%
Final simplification60.6%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 1.4e-8) (/ x z) (/ y (/ z (/ x y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.4e-8) {
tmp = x / z;
} else {
tmp = y / (z / (x / y));
}
return tmp;
}
NOTE: y should be positive before calling this function
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.4d-8) then
tmp = x / z
else
tmp = y / (z / (x / y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.4e-8) {
tmp = x / z;
} else {
tmp = y / (z / (x / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 1.4e-8: tmp = x / z else: tmp = y / (z / (x / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 1.4e-8) tmp = Float64(x / z); else tmp = Float64(y / Float64(z / Float64(x / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.4e-8) tmp = x / z; else tmp = y / (z / (x / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 1.4e-8], N[(x / z), $MachinePrecision], N[(y / N[(z / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{\frac{x}{y}}}\\
\end{array}
\end{array}
if y < 1.4e-8Initial program 97.7%
associate-*l/97.4%
times-frac81.7%
*-commutative81.7%
associate-*r/80.0%
*-commutative80.0%
Simplified80.0%
Taylor expanded in y around 0 71.2%
if 1.4e-8 < y Initial program 93.2%
associate-*r/93.3%
associate-/l/85.6%
*-commutative85.6%
times-frac93.3%
Simplified93.3%
Taylor expanded in y around 0 11.1%
*-commutative11.1%
clear-num11.1%
frac-times26.1%
*-un-lft-identity26.1%
*-commutative26.1%
clear-num26.1%
un-div-inv26.1%
Applied egg-rr26.1%
Final simplification60.6%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (/ x z))
y = abs(y);
double code(double x, double y, double z) {
return x / z;
}
NOTE: y should be positive before calling this function
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
y = Math.abs(y);
public static double code(double x, double y, double z) {
return x / z;
}
y = abs(y) def code(x, y, z): return x / z
y = abs(y) function code(x, y, z) return Float64(x / z) end
y = abs(y) function tmp = code(x, y, z) tmp = x / z; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := N[(x / z), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\frac{x}{z}
\end{array}
Initial program 96.7%
associate-*l/96.1%
times-frac82.6%
*-commutative82.6%
associate-*r/81.3%
*-commutative81.3%
Simplified81.3%
Taylor expanded in y around 0 56.3%
Final simplification56.3%
(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 2023229
(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))