
(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}
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y))) (if (<= z 5e-143) (/ 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 (z <= 5e-143) {
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 (z <= 5d-143) 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 (z <= 5e-143) {
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 z <= 5e-143: 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 (z <= 5e-143) 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 (z <= 5e-143) 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[z, 5e-143], 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}\;z \leq 5 \cdot 10^{-143}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot t_0}{z}\\
\end{array}
\end{array}
if z < 5.0000000000000002e-143Initial program 95.2%
associate-/l*98.5%
Simplified98.5%
if 5.0000000000000002e-143 < z Initial program 99.8%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (sin y) y))) (if (<= t_0 -1e-285) (* (/ (sin y) z) (/ x y)) (/ x (/ z t_0)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if (t_0 <= -1e-285) {
tmp = (sin(y) / z) * (x / y);
} else {
tmp = x / (z / t_0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = sin(y) / y
if (t_0 <= (-1d-285)) then
tmp = (sin(y) / z) * (x / y)
else
tmp = x / (z / t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.sin(y) / y;
double tmp;
if (t_0 <= -1e-285) {
tmp = (Math.sin(y) / z) * (x / y);
} else {
tmp = x / (z / t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if t_0 <= -1e-285: tmp = (math.sin(y) / z) * (x / y) else: tmp = x / (z / t_0) return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if (t_0 <= -1e-285) tmp = Float64(Float64(sin(y) / z) * Float64(x / y)); else tmp = Float64(x / Float64(z / t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) / y; tmp = 0.0; if (t_0 <= -1e-285) tmp = (sin(y) / z) * (x / y); else tmp = x / (z / t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-285], 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}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{-285}:\\
\;\;\;\;\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) < -1.00000000000000007e-285Initial program 97.6%
associate-*r/97.8%
associate-/l/89.5%
*-commutative89.5%
times-frac97.6%
Simplified97.6%
if -1.00000000000000007e-285 < (/.f64 (sin.f64 y) y) Initial program 96.9%
associate-/l*98.9%
Simplified98.9%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.48) (not (<= y 6.5e-24))) (* (sin y) (/ x (* z y))) (/ x (/ z (+ 1.0 (* -0.16666666666666666 (* y y)))))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.48) || !(y <= 6.5e-24)) {
tmp = sin(y) * (x / (z * y));
} else {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (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 <= (-0.48d0)) .or. (.not. (y <= 6.5d-24))) then
tmp = sin(y) * (x / (z * y))
else
tmp = x / (z / (1.0d0 + ((-0.16666666666666666d0) * (y * y))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.48) || !(y <= 6.5e-24)) {
tmp = Math.sin(y) * (x / (z * y));
} else {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.48) or not (y <= 6.5e-24): tmp = math.sin(y) * (x / (z * y)) else: tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.48) || !(y <= 6.5e-24)) tmp = Float64(sin(y) * Float64(x / Float64(z * y))); else tmp = Float64(x / Float64(z / Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.48) || ~((y <= 6.5e-24))) tmp = sin(y) * (x / (z * y)); else tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.48], N[Not[LessEqual[y, 6.5e-24]], $MachinePrecision]], N[(N[Sin[y], $MachinePrecision] * N[(x / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.48 \lor \neg \left(y \leq 6.5 \cdot 10^{-24}\right):\\
\;\;\;\;\sin y \cdot \frac{x}{z \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{1 + -0.16666666666666666 \cdot \left(y \cdot y\right)}}\\
\end{array}
\end{array}
if y < -0.47999999999999998 or 6.5e-24 < y Initial program 93.7%
associate-*l/93.2%
times-frac93.3%
*-commutative93.3%
associate-*r/93.3%
*-commutative93.3%
Simplified93.3%
if -0.47999999999999998 < y < 6.5e-24Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification96.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.48) (not (<= y 7.8e-19))) (* (/ (sin y) z) (/ x y)) (/ x (/ z (+ 1.0 (* -0.16666666666666666 (* y y)))))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.48) || !(y <= 7.8e-19)) {
tmp = (sin(y) / z) * (x / y);
} else {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (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 <= (-0.48d0)) .or. (.not. (y <= 7.8d-19))) then
tmp = (sin(y) / z) * (x / y)
else
tmp = x / (z / (1.0d0 + ((-0.16666666666666666d0) * (y * y))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.48) || !(y <= 7.8e-19)) {
tmp = (Math.sin(y) / z) * (x / y);
} else {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.48) or not (y <= 7.8e-19): tmp = (math.sin(y) / z) * (x / y) else: tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.48) || !(y <= 7.8e-19)) tmp = Float64(Float64(sin(y) / z) * Float64(x / y)); else tmp = Float64(x / Float64(z / Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.48) || ~((y <= 7.8e-19))) tmp = (sin(y) / z) * (x / y); else tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.48], N[Not[LessEqual[y, 7.8e-19]], $MachinePrecision]], N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.48 \lor \neg \left(y \leq 7.8 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{\sin y}{z} \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{1 + -0.16666666666666666 \cdot \left(y \cdot y\right)}}\\
\end{array}
\end{array}
if y < -0.47999999999999998 or 7.7999999999999999e-19 < y Initial program 93.6%
associate-*r/93.7%
associate-/l/93.2%
*-commutative93.2%
times-frac93.7%
Simplified93.7%
if -0.47999999999999998 < y < 7.7999999999999999e-19Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification97.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.8e+32) (not (<= y 5e-8))) (/ (/ x y) (+ (/ z y) (* (* z y) 0.16666666666666666))) (/ x (/ z (+ 1.0 (* -0.16666666666666666 (* y y)))))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.8e+32) || !(y <= 5e-8)) {
tmp = (x / y) / ((z / y) + ((z * y) * 0.16666666666666666));
} else {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (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 <= (-4.8d+32)) .or. (.not. (y <= 5d-8))) then
tmp = (x / y) / ((z / y) + ((z * y) * 0.16666666666666666d0))
else
tmp = x / (z / (1.0d0 + ((-0.16666666666666666d0) * (y * y))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4.8e+32) || !(y <= 5e-8)) {
tmp = (x / y) / ((z / y) + ((z * y) * 0.16666666666666666));
} else {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.8e+32) or not (y <= 5e-8): tmp = (x / y) / ((z / y) + ((z * y) * 0.16666666666666666)) else: tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.8e+32) || !(y <= 5e-8)) tmp = Float64(Float64(x / y) / Float64(Float64(z / y) + Float64(Float64(z * y) * 0.16666666666666666))); else tmp = Float64(x / Float64(z / Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.8e+32) || ~((y <= 5e-8))) tmp = (x / y) / ((z / y) + ((z * y) * 0.16666666666666666)); else tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.8e+32], N[Not[LessEqual[y, 5e-8]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] / N[(N[(z / y), $MachinePrecision] + N[(N[(z * y), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{+32} \lor \neg \left(y \leq 5 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{z}{y} + \left(z \cdot y\right) \cdot 0.16666666666666666}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{1 + -0.16666666666666666 \cdot \left(y \cdot y\right)}}\\
\end{array}
\end{array}
if y < -4.79999999999999983e32 or 4.9999999999999998e-8 < y Initial program 93.2%
associate-/l*92.8%
associate-/r/92.8%
Simplified92.8%
Taylor expanded in y around 0 29.2%
expm1-log1p-u15.5%
expm1-udef15.4%
*-commutative15.4%
Applied egg-rr15.4%
expm1-def15.5%
expm1-log1p29.2%
*-commutative29.2%
associate-*l*29.2%
*-commutative29.2%
Simplified29.2%
Taylor expanded in x around 0 29.2%
associate-/r*29.3%
*-commutative29.3%
*-commutative29.3%
Simplified29.3%
if -4.79999999999999983e32 < y < 4.9999999999999998e-8Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 98.0%
unpow298.0%
Simplified98.0%
Final simplification67.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.3e+32) (not (<= y 32000000.0))) (* (/ 6.0 z) (/ x (* y y))) (/ x (/ z (+ 1.0 (* -0.16666666666666666 (* y y)))))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.3e+32) || !(y <= 32000000.0)) {
tmp = (6.0 / z) * (x / (y * y));
} else {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (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 <= (-4.3d+32)) .or. (.not. (y <= 32000000.0d0))) then
tmp = (6.0d0 / z) * (x / (y * y))
else
tmp = x / (z / (1.0d0 + ((-0.16666666666666666d0) * (y * y))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4.3e+32) || !(y <= 32000000.0)) {
tmp = (6.0 / z) * (x / (y * y));
} else {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.3e+32) or not (y <= 32000000.0): tmp = (6.0 / z) * (x / (y * y)) else: tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.3e+32) || !(y <= 32000000.0)) tmp = Float64(Float64(6.0 / z) * Float64(x / Float64(y * y))); else tmp = Float64(x / Float64(z / Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.3e+32) || ~((y <= 32000000.0))) tmp = (6.0 / z) * (x / (y * y)); else tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.3e+32], N[Not[LessEqual[y, 32000000.0]], $MachinePrecision]], N[(N[(6.0 / z), $MachinePrecision] * N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{+32} \lor \neg \left(y \leq 32000000\right):\\
\;\;\;\;\frac{6}{z} \cdot \frac{x}{y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{1 + -0.16666666666666666 \cdot \left(y \cdot y\right)}}\\
\end{array}
\end{array}
if y < -4.2999999999999997e32 or 3.2e7 < y Initial program 93.1%
associate-/l*92.7%
associate-/r/92.7%
Simplified92.7%
Taylor expanded in y around 0 27.9%
expm1-log1p-u14.9%
expm1-udef14.8%
*-commutative14.8%
Applied egg-rr14.8%
expm1-def14.9%
expm1-log1p27.9%
*-commutative27.9%
associate-*l*27.9%
*-commutative27.9%
Simplified27.9%
Taylor expanded in y around inf 27.9%
associate-*r/27.9%
*-commutative27.9%
times-frac28.0%
unpow228.0%
Simplified28.0%
if -4.2999999999999997e32 < y < 3.2e7Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 98.1%
unpow298.1%
Simplified98.1%
Final simplification67.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.45) (not (<= y 2.5))) (* 6.0 (/ x (* z (* y y)))) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.45) || !(y <= 2.5)) {
tmp = 6.0 * (x / (z * (y * y)));
} else {
tmp = 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) :: tmp
if ((y <= (-2.45d0)) .or. (.not. (y <= 2.5d0))) then
tmp = 6.0d0 * (x / (z * (y * y)))
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.45) || !(y <= 2.5)) {
tmp = 6.0 * (x / (z * (y * y)));
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.45) or not (y <= 2.5): tmp = 6.0 * (x / (z * (y * y))) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.45) || !(y <= 2.5)) tmp = Float64(6.0 * Float64(x / Float64(z * Float64(y * y)))); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.45) || ~((y <= 2.5))) tmp = 6.0 * (x / (z * (y * y))); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.45], N[Not[LessEqual[y, 2.5]], $MachinePrecision]], N[(6.0 * N[(x / N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.45 \lor \neg \left(y \leq 2.5\right):\\
\;\;\;\;6 \cdot \frac{x}{z \cdot \left(y \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.4500000000000002 or 2.5 < y Initial program 93.3%
associate-/l*92.9%
associate-/r/92.9%
Simplified92.9%
Taylor expanded in y around 0 27.2%
Taylor expanded in y around inf 27.2%
unpow227.2%
*-commutative27.2%
Simplified27.2%
if -2.4500000000000002 < y < 2.5Initial program 100.0%
Taylor expanded in y around 0 99.5%
Final simplification67.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.45) (not (<= y 2.5))) (* (/ 6.0 z) (/ x (* y y))) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.45) || !(y <= 2.5)) {
tmp = (6.0 / z) * (x / (y * y));
} else {
tmp = 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) :: tmp
if ((y <= (-2.45d0)) .or. (.not. (y <= 2.5d0))) then
tmp = (6.0d0 / z) * (x / (y * y))
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.45) || !(y <= 2.5)) {
tmp = (6.0 / z) * (x / (y * y));
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.45) or not (y <= 2.5): tmp = (6.0 / z) * (x / (y * y)) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.45) || !(y <= 2.5)) tmp = Float64(Float64(6.0 / z) * Float64(x / Float64(y * y))); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.45) || ~((y <= 2.5))) tmp = (6.0 / z) * (x / (y * y)); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.45], N[Not[LessEqual[y, 2.5]], $MachinePrecision]], N[(N[(6.0 / z), $MachinePrecision] * N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.45 \lor \neg \left(y \leq 2.5\right):\\
\;\;\;\;\frac{6}{z} \cdot \frac{x}{y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.4500000000000002 or 2.5 < y Initial program 93.3%
associate-/l*92.9%
associate-/r/92.9%
Simplified92.9%
Taylor expanded in y around 0 27.2%
expm1-log1p-u14.6%
expm1-udef14.5%
*-commutative14.5%
Applied egg-rr14.5%
expm1-def14.6%
expm1-log1p27.2%
*-commutative27.2%
associate-*l*27.2%
*-commutative27.2%
Simplified27.2%
Taylor expanded in y around inf 27.2%
associate-*r/27.2%
*-commutative27.2%
times-frac27.3%
unpow227.3%
Simplified27.3%
if -2.4500000000000002 < y < 2.5Initial program 100.0%
Taylor expanded in y around 0 99.5%
Final simplification67.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.15e+61) (not (<= y 6.5e-24))) (* y (/ x (* z y))) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.15e+61) || !(y <= 6.5e-24)) {
tmp = y * (x / (z * y));
} else {
tmp = 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) :: tmp
if ((y <= (-1.15d+61)) .or. (.not. (y <= 6.5d-24))) then
tmp = y * (x / (z * y))
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.15e+61) || !(y <= 6.5e-24)) {
tmp = y * (x / (z * y));
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.15e+61) or not (y <= 6.5e-24): tmp = y * (x / (z * y)) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.15e+61) || !(y <= 6.5e-24)) tmp = Float64(y * Float64(x / Float64(z * y))); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.15e+61) || ~((y <= 6.5e-24))) tmp = y * (x / (z * y)); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.15e+61], N[Not[LessEqual[y, 6.5e-24]], $MachinePrecision]], N[(y * N[(x / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+61} \lor \neg \left(y \leq 6.5 \cdot 10^{-24}\right):\\
\;\;\;\;y \cdot \frac{x}{z \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -1.15e61 or 6.5e-24 < y Initial program 93.1%
associate-*l/92.6%
times-frac92.7%
*-commutative92.7%
associate-*r/92.7%
*-commutative92.7%
Simplified92.7%
Taylor expanded in y around 0 33.0%
if -1.15e61 < y < 6.5e-24Initial program 100.0%
Taylor expanded in y around 0 93.1%
Final simplification67.0%
(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 97.0%
Taylor expanded in y around 0 61.0%
Final simplification61.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 2023185
(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))