
(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 10 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 (let* ((t_0 (/ (sin y) y))) (if (<= y 5.2e+204) (/ (* x t_0) z) (/ x (/ z t_0)))))
y = abs(y);
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if (y <= 5.2e+204) {
tmp = (x * t_0) / z;
} else {
tmp = x / (z / t_0);
}
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) :: t_0
real(8) :: tmp
t_0 = sin(y) / y
if (y <= 5.2d+204) then
tmp = (x * t_0) / z
else
tmp = x / (z / t_0)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double t_0 = Math.sin(y) / y;
double tmp;
if (y <= 5.2e+204) {
tmp = (x * t_0) / z;
} else {
tmp = x / (z / t_0);
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if y <= 5.2e+204: tmp = (x * t_0) / z else: tmp = x / (z / t_0) return tmp
y = abs(y) function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if (y <= 5.2e+204) tmp = Float64(Float64(x * t_0) / z); else tmp = Float64(x / Float64(z / t_0)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = sin(y) / y; tmp = 0.0; if (y <= 5.2e+204) tmp = (x * t_0) / z; else tmp = x / (z / t_0); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, 5.2e+204], N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;y \leq 5.2 \cdot 10^{+204}:\\
\;\;\;\;\frac{x \cdot t_0}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}
\end{array}
if y < 5.2000000000000002e204Initial program 98.6%
if 5.2000000000000002e204 < y Initial program 73.1%
associate-/l*95.7%
Simplified95.7%
Final simplification98.4%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y))) (if (<= t_0 -1e-198) (* (/ (sin y) z) (/ x y)) (/ x (/ z t_0)))))
y = abs(y);
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if (t_0 <= -1e-198) {
tmp = (sin(y) / z) * (x / y);
} else {
tmp = x / (z / t_0);
}
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) :: t_0
real(8) :: tmp
t_0 = sin(y) / y
if (t_0 <= (-1d-198)) then
tmp = (sin(y) / z) * (x / y)
else
tmp = x / (z / t_0)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double t_0 = Math.sin(y) / y;
double tmp;
if (t_0 <= -1e-198) {
tmp = (Math.sin(y) / z) * (x / y);
} else {
tmp = x / (z / t_0);
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if t_0 <= -1e-198: tmp = (math.sin(y) / z) * (x / y) else: tmp = x / (z / t_0) return tmp
y = abs(y) function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if (t_0 <= -1e-198) tmp = Float64(Float64(sin(y) / z) * Float64(x / y)); else tmp = Float64(x / Float64(z / t_0)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = sin(y) / y; tmp = 0.0; if (t_0 <= -1e-198) tmp = (sin(y) / z) * (x / y); else tmp = x / (z / t_0); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-198], N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{-198}:\\
\;\;\;\;\frac{\sin y}{z} \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}
\end{array}
if (/.f64 (sin.f64 y) y) < -9.9999999999999991e-199Initial program 99.6%
associate-*r/99.4%
associate-/l/84.8%
*-commutative84.8%
times-frac99.5%
Simplified99.5%
if -9.9999999999999991e-199 < (/.f64 (sin.f64 y) y) Initial program 95.6%
associate-/l*97.2%
Simplified97.2%
Final simplification97.6%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 2.45e-23) (/ x z) (if (<= y 1.1e+198) (* (/ (sin y) z) (/ x y)) (* (sin y) (/ x (* y z))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2.45e-23) {
tmp = x / z;
} else if (y <= 1.1e+198) {
tmp = (sin(y) / z) * (x / y);
} 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 <= 2.45d-23) then
tmp = x / z
else if (y <= 1.1d+198) then
tmp = (sin(y) / z) * (x / y)
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 <= 2.45e-23) {
tmp = x / z;
} else if (y <= 1.1e+198) {
tmp = (Math.sin(y) / z) * (x / y);
} else {
tmp = Math.sin(y) * (x / (y * z));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 2.45e-23: tmp = x / z elif y <= 1.1e+198: tmp = (math.sin(y) / z) * (x / y) else: tmp = math.sin(y) * (x / (y * z)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 2.45e-23) tmp = Float64(x / z); elseif (y <= 1.1e+198) tmp = Float64(Float64(sin(y) / z) * Float64(x / y)); 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 <= 2.45e-23) tmp = x / z; elseif (y <= 1.1e+198) tmp = (sin(y) / z) * (x / y); 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, 2.45e-23], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.1e+198], N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $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 2.45 \cdot 10^{-23}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+198}:\\
\;\;\;\;\frac{\sin y}{z} \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 2.4499999999999999e-23Initial program 98.4%
associate-*l/96.9%
times-frac81.0%
*-commutative81.0%
associate-*r/78.4%
*-commutative78.4%
Simplified78.4%
Taylor expanded in y around 0 73.4%
if 2.4499999999999999e-23 < y < 1.1e198Initial program 99.5%
associate-*r/99.6%
associate-/l/87.1%
*-commutative87.1%
times-frac99.5%
Simplified99.5%
if 1.1e198 < y Initial program 73.1%
associate-*l/87.6%
times-frac95.6%
*-commutative95.6%
associate-*r/95.6%
*-commutative95.6%
Simplified95.6%
Final simplification80.1%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 2.25e-8) (/ x z) (* (sin y) (/ x (* y z)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2.25e-8) {
tmp = x / 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 <= 2.25d-8) then
tmp = x / 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 <= 2.25e-8) {
tmp = x / z;
} else {
tmp = Math.sin(y) * (x / (y * z));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 2.25e-8: tmp = x / z else: tmp = math.sin(y) * (x / (y * z)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 2.25e-8) tmp = Float64(x / 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 <= 2.25e-8) tmp = x / 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, 2.25e-8], N[(x / 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 2.25 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 2.24999999999999996e-8Initial program 98.5%
associate-*l/96.9%
times-frac81.4%
*-commutative81.4%
associate-*r/78.9%
*-commutative78.9%
Simplified78.9%
Taylor expanded in y around 0 73.9%
if 2.24999999999999996e-8 < y Initial program 89.8%
associate-*l/93.7%
times-frac89.4%
*-commutative89.4%
associate-*r/89.4%
*-commutative89.4%
Simplified89.4%
Final simplification77.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 18.5) (/ x (/ z (+ 1.0 (* -0.16666666666666666 (* y y))))) (/ (/ 1.0 (+ (* 0.16666666666666666 (/ (* y z) x)) (/ z (* y x)))) y)))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 18.5) {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
} else {
tmp = (1.0 / ((0.16666666666666666 * ((y * z) / x)) + (z / (y * 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 <= 18.5d0) then
tmp = x / (z / (1.0d0 + ((-0.16666666666666666d0) * (y * y))))
else
tmp = (1.0d0 / ((0.16666666666666666d0 * ((y * z) / x)) + (z / (y * 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 <= 18.5) {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
} else {
tmp = (1.0 / ((0.16666666666666666 * ((y * z) / x)) + (z / (y * x)))) / y;
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 18.5: tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))) else: tmp = (1.0 / ((0.16666666666666666 * ((y * z) / x)) + (z / (y * x)))) / y return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 18.5) tmp = Float64(x / Float64(z / Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))))); else tmp = Float64(Float64(1.0 / Float64(Float64(0.16666666666666666 * Float64(Float64(y * z) / x)) + Float64(z / Float64(y * x)))) / y); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 18.5) tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))); else tmp = (1.0 / ((0.16666666666666666 * ((y * z) / x)) + (z / (y * x)))) / y; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 18.5], N[(x / N[(z / N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(0.16666666666666666 * N[(N[(y * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(z / N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 18.5:\\
\;\;\;\;\frac{x}{\frac{z}{1 + -0.16666666666666666 \cdot \left(y \cdot y\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{0.16666666666666666 \cdot \frac{y \cdot z}{x} + \frac{z}{y \cdot x}}}{y}\\
\end{array}
\end{array}
if y < 18.5Initial program 98.5%
associate-/l*96.9%
Simplified96.9%
Taylor expanded in y around 0 70.0%
unpow270.0%
Simplified70.0%
if 18.5 < y Initial program 89.8%
associate-*l/93.7%
times-frac89.4%
*-commutative89.4%
associate-*r/89.4%
*-commutative89.4%
Simplified89.4%
associate-*r/89.4%
times-frac93.7%
*-commutative93.7%
associate-*r/93.7%
Applied egg-rr93.7%
clear-num93.6%
associate-*l/93.7%
associate-/l*93.7%
Applied egg-rr93.7%
Taylor expanded in y around 0 28.8%
Final simplification59.5%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 18.5) (/ x (/ z (+ 1.0 (* -0.16666666666666666 (* y y))))) (/ y (* z (/ y x)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 18.5) {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
} else {
tmp = y / (z * (y / 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 <= 18.5d0) then
tmp = x / (z / (1.0d0 + ((-0.16666666666666666d0) * (y * y))))
else
tmp = y / (z * (y / 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 <= 18.5) {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
} else {
tmp = y / (z * (y / x));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 18.5: tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))) else: tmp = y / (z * (y / x)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 18.5) tmp = Float64(x / Float64(z / Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))))); else tmp = Float64(y / Float64(z * Float64(y / x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 18.5) tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))); else tmp = y / (z * (y / x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 18.5], N[(x / N[(z / N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 18.5:\\
\;\;\;\;\frac{x}{\frac{z}{1 + -0.16666666666666666 \cdot \left(y \cdot y\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 18.5Initial program 98.5%
associate-/l*96.9%
Simplified96.9%
Taylor expanded in y around 0 70.0%
unpow270.0%
Simplified70.0%
if 18.5 < y Initial program 89.8%
associate-*r/89.8%
associate-/l/89.4%
*-commutative89.4%
times-frac89.8%
Simplified89.8%
Taylor expanded in y around 0 22.7%
*-commutative22.7%
clear-num22.8%
frac-times28.2%
*-un-lft-identity28.2%
Applied egg-rr28.2%
Final simplification59.4%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 1e+27) (/ x z) (* y (/ (/ x y) z))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 1e+27) {
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 <= 1d+27) 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 <= 1e+27) {
tmp = x / z;
} else {
tmp = y * ((x / y) / z);
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 1e+27: tmp = x / z else: tmp = y * ((x / y) / z) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 1e+27) 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 <= 1e+27) 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, 1e+27], 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 10^{+27}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\frac{x}{y}}{z}\\
\end{array}
\end{array}
if y < 1e27Initial program 98.5%
associate-*l/97.0%
times-frac81.8%
*-commutative81.8%
associate-*r/79.3%
*-commutative79.3%
Simplified79.3%
Taylor expanded in y around 0 73.5%
if 1e27 < y Initial program 89.1%
associate-*l/93.4%
times-frac88.8%
*-commutative88.8%
associate-*r/88.7%
*-commutative88.7%
Simplified88.7%
associate-*r/88.8%
times-frac93.4%
*-commutative93.4%
associate-*r/93.4%
Applied egg-rr93.4%
Taylor expanded in y around 0 17.5%
associate-/l*17.8%
Simplified17.8%
associate-/r/17.7%
associate-*r/20.7%
div-inv20.7%
associate-*l*26.5%
Applied egg-rr26.5%
associate-*l/26.5%
*-un-lft-identity26.5%
Applied egg-rr26.5%
Final simplification62.3%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 2e-10) (/ x z) (/ y (* y (/ z x)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2e-10) {
tmp = x / z;
} else {
tmp = 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 <= 2d-10) then
tmp = x / z
else
tmp = 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 <= 2e-10) {
tmp = x / z;
} else {
tmp = y / (y * (z / x));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 2e-10: tmp = x / z else: tmp = y / (y * (z / x)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 2e-10) tmp = Float64(x / z); else tmp = Float64(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 <= 2e-10) tmp = x / z; else tmp = 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, 2e-10], N[(x / z), $MachinePrecision], N[(y / N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y \cdot \frac{z}{x}}\\
\end{array}
\end{array}
if y < 2.00000000000000007e-10Initial program 98.5%
associate-*l/96.9%
times-frac81.4%
*-commutative81.4%
associate-*r/78.9%
*-commutative78.9%
Simplified78.9%
Taylor expanded in y around 0 73.9%
if 2.00000000000000007e-10 < y Initial program 89.8%
associate-*r/89.8%
associate-/l/89.4%
*-commutative89.4%
times-frac89.8%
Simplified89.8%
Taylor expanded in y around 0 22.7%
associate-*r/19.9%
associate-/r/20.0%
associate-/l/27.8%
Applied egg-rr27.8%
Final simplification62.2%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 2.6e-8) (/ x z) (/ y (* z (/ y x)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2.6e-8) {
tmp = x / z;
} else {
tmp = y / (z * (y / 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.6d-8) then
tmp = x / z
else
tmp = y / (z * (y / 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.6e-8) {
tmp = x / z;
} else {
tmp = y / (z * (y / x));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 2.6e-8: tmp = x / z else: tmp = y / (z * (y / x)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 2.6e-8) tmp = Float64(x / z); else tmp = Float64(y / Float64(z * Float64(y / x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.6e-8) tmp = x / z; else tmp = y / (z * (y / x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 2.6e-8], N[(x / z), $MachinePrecision], N[(y / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.6 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 2.6000000000000001e-8Initial program 98.5%
associate-*l/96.9%
times-frac81.4%
*-commutative81.4%
associate-*r/78.9%
*-commutative78.9%
Simplified78.9%
Taylor expanded in y around 0 73.9%
if 2.6000000000000001e-8 < y Initial program 89.8%
associate-*r/89.8%
associate-/l/89.4%
*-commutative89.4%
times-frac89.8%
Simplified89.8%
Taylor expanded in y around 0 22.7%
*-commutative22.7%
clear-num22.8%
frac-times28.2%
*-un-lft-identity28.2%
Applied egg-rr28.2%
Final simplification62.3%
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.3%
associate-*l/96.1%
times-frac83.5%
*-commutative83.5%
associate-*r/81.5%
*-commutative81.5%
Simplified81.5%
Taylor expanded in y around 0 60.3%
Final simplification60.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 2023214
(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))