
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y 13.0)
(sin x)
(if (<= y 1.4e+154)
(* x (/ (sinh y) y))
(* 0.16666666666666666 (* (sin x) (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= 13.0) {
tmp = sin(x);
} else if (y <= 1.4e+154) {
tmp = x * (sinh(y) / y);
} else {
tmp = 0.16666666666666666 * (sin(x) * (y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 13.0d0) then
tmp = sin(x)
else if (y <= 1.4d+154) then
tmp = x * (sinh(y) / y)
else
tmp = 0.16666666666666666d0 * (sin(x) * (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 13.0) {
tmp = Math.sin(x);
} else if (y <= 1.4e+154) {
tmp = x * (Math.sinh(y) / y);
} else {
tmp = 0.16666666666666666 * (Math.sin(x) * (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 13.0: tmp = math.sin(x) elif y <= 1.4e+154: tmp = x * (math.sinh(y) / y) else: tmp = 0.16666666666666666 * (math.sin(x) * (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 13.0) tmp = sin(x); elseif (y <= 1.4e+154) tmp = Float64(x * Float64(sinh(y) / y)); else tmp = Float64(0.16666666666666666 * Float64(sin(x) * Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 13.0) tmp = sin(x); elseif (y <= 1.4e+154) tmp = x * (sinh(y) / y); else tmp = 0.16666666666666666 * (sin(x) * (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 13.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 1.4e+154], N[(x * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(0.16666666666666666 * N[(N[Sin[x], $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 13:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;x \cdot \frac{\sinh y}{y}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(\sin x \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 13Initial program 100.0%
Taylor expanded in y around 0 64.9%
if 13 < y < 1.4e154Initial program 100.0%
*-commutative100.0%
associate-/r/82.8%
Simplified82.8%
Taylor expanded in x around 0 62.1%
associate-/r/79.3%
Applied egg-rr79.3%
if 1.4e154 < y Initial program 100.0%
Taylor expanded in y around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*96.6%
associate-*l*66.9%
Simplified66.9%
Taylor expanded in y around 0 100.0%
unpow2100.0%
*-commutative100.0%
Simplified100.0%
Final simplification69.9%
(FPCore (x y)
:precision binary64
(if (<= y 13.0)
(* (sin x) (+ 1.0 (* 0.16666666666666666 (* y y))))
(if (<= y 1.4e+154)
(* x (/ (sinh y) y))
(* 0.16666666666666666 (* (sin x) (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= 13.0) {
tmp = sin(x) * (1.0 + (0.16666666666666666 * (y * y)));
} else if (y <= 1.4e+154) {
tmp = x * (sinh(y) / y);
} else {
tmp = 0.16666666666666666 * (sin(x) * (y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 13.0d0) then
tmp = sin(x) * (1.0d0 + (0.16666666666666666d0 * (y * y)))
else if (y <= 1.4d+154) then
tmp = x * (sinh(y) / y)
else
tmp = 0.16666666666666666d0 * (sin(x) * (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 13.0) {
tmp = Math.sin(x) * (1.0 + (0.16666666666666666 * (y * y)));
} else if (y <= 1.4e+154) {
tmp = x * (Math.sinh(y) / y);
} else {
tmp = 0.16666666666666666 * (Math.sin(x) * (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 13.0: tmp = math.sin(x) * (1.0 + (0.16666666666666666 * (y * y))) elif y <= 1.4e+154: tmp = x * (math.sinh(y) / y) else: tmp = 0.16666666666666666 * (math.sin(x) * (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 13.0) tmp = Float64(sin(x) * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))); elseif (y <= 1.4e+154) tmp = Float64(x * Float64(sinh(y) / y)); else tmp = Float64(0.16666666666666666 * Float64(sin(x) * Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 13.0) tmp = sin(x) * (1.0 + (0.16666666666666666 * (y * y))); elseif (y <= 1.4e+154) tmp = x * (sinh(y) / y); else tmp = 0.16666666666666666 * (sin(x) * (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 13.0], N[(N[Sin[x], $MachinePrecision] * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.4e+154], N[(x * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(0.16666666666666666 * N[(N[Sin[x], $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 13:\\
\;\;\;\;\sin x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;x \cdot \frac{\sinh y}{y}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(\sin x \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 13Initial program 100.0%
Taylor expanded in y around 0 82.5%
unpow282.5%
Simplified82.5%
if 13 < y < 1.4e154Initial program 100.0%
*-commutative100.0%
associate-/r/82.8%
Simplified82.8%
Taylor expanded in x around 0 62.1%
associate-/r/79.3%
Applied egg-rr79.3%
if 1.4e154 < y Initial program 100.0%
Taylor expanded in y around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*96.6%
associate-*l*66.9%
Simplified66.9%
Taylor expanded in y around 0 100.0%
unpow2100.0%
*-commutative100.0%
Simplified100.0%
Final simplification83.9%
(FPCore (x y) :precision binary64 (if (<= y 13.0) (sin x) (* x (/ (sinh y) y))))
double code(double x, double y) {
double tmp;
if (y <= 13.0) {
tmp = sin(x);
} else {
tmp = x * (sinh(y) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 13.0d0) then
tmp = sin(x)
else
tmp = x * (sinh(y) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 13.0) {
tmp = Math.sin(x);
} else {
tmp = x * (Math.sinh(y) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 13.0: tmp = math.sin(x) else: tmp = x * (math.sinh(y) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 13.0) tmp = sin(x); else tmp = Float64(x * Float64(sinh(y) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 13.0) tmp = sin(x); else tmp = x * (sinh(y) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 13.0], N[Sin[x], $MachinePrecision], N[(x * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 13:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sinh y}{y}\\
\end{array}
\end{array}
if y < 13Initial program 100.0%
Taylor expanded in y around 0 64.9%
if 13 < y Initial program 100.0%
*-commutative100.0%
associate-/r/72.2%
Simplified72.2%
Taylor expanded in x around 0 57.4%
associate-/r/85.2%
Applied egg-rr85.2%
Final simplification69.2%
(FPCore (x y) :precision binary64 (if (<= y 2.3e+33) (sin x) (+ x (* 0.16666666666666666 (* x (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= 2.3e+33) {
tmp = sin(x);
} else {
tmp = x + (0.16666666666666666 * (x * (y * y)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.3d+33) then
tmp = sin(x)
else
tmp = x + (0.16666666666666666d0 * (x * (y * y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.3e+33) {
tmp = Math.sin(x);
} else {
tmp = x + (0.16666666666666666 * (x * (y * y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.3e+33: tmp = math.sin(x) else: tmp = x + (0.16666666666666666 * (x * (y * y))) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.3e+33) tmp = sin(x); else tmp = Float64(x + Float64(0.16666666666666666 * Float64(x * Float64(y * y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.3e+33) tmp = sin(x); else tmp = x + (0.16666666666666666 * (x * (y * y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.3e+33], N[Sin[x], $MachinePrecision], N[(x + N[(0.16666666666666666 * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.3 \cdot 10^{+33}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x + 0.16666666666666666 \cdot \left(x \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 2.30000000000000011e33Initial program 100.0%
Taylor expanded in y around 0 63.7%
if 2.30000000000000011e33 < y Initial program 100.0%
*-commutative100.0%
associate-/r/70.0%
Simplified70.0%
Taylor expanded in x around 0 56.0%
Taylor expanded in y around 0 57.4%
unpow257.4%
Simplified57.4%
Final simplification62.4%
(FPCore (x y) :precision binary64 (if (<= y 13.0) x (* y (* 0.16666666666666666 (* x y)))))
double code(double x, double y) {
double tmp;
if (y <= 13.0) {
tmp = x;
} else {
tmp = y * (0.16666666666666666 * (x * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 13.0d0) then
tmp = x
else
tmp = y * (0.16666666666666666d0 * (x * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 13.0) {
tmp = x;
} else {
tmp = y * (0.16666666666666666 * (x * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 13.0: tmp = x else: tmp = y * (0.16666666666666666 * (x * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 13.0) tmp = x; else tmp = Float64(y * Float64(0.16666666666666666 * Float64(x * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 13.0) tmp = x; else tmp = y * (0.16666666666666666 * (x * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 13.0], x, N[(y * N[(0.16666666666666666 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 13:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(0.16666666666666666 \cdot \left(x \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 13Initial program 100.0%
*-commutative100.0%
associate-/r/88.4%
Simplified88.4%
Taylor expanded in x around 0 48.7%
Taylor expanded in y around 0 34.6%
if 13 < y Initial program 100.0%
Taylor expanded in y around 0 48.7%
unpow248.7%
Simplified48.7%
Taylor expanded in y around inf 48.7%
unpow248.7%
associate-*r*48.7%
*-commutative48.7%
associate-*r*47.2%
associate-*l*33.4%
Simplified33.4%
Taylor expanded in x around 0 39.5%
Final simplification35.6%
(FPCore (x y) :precision binary64 (if (<= y 65.0) x (* (* y y) (* x 0.16666666666666666))))
double code(double x, double y) {
double tmp;
if (y <= 65.0) {
tmp = x;
} else {
tmp = (y * y) * (x * 0.16666666666666666);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 65.0d0) then
tmp = x
else
tmp = (y * y) * (x * 0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 65.0) {
tmp = x;
} else {
tmp = (y * y) * (x * 0.16666666666666666);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 65.0: tmp = x else: tmp = (y * y) * (x * 0.16666666666666666) return tmp
function code(x, y) tmp = 0.0 if (y <= 65.0) tmp = x; else tmp = Float64(Float64(y * y) * Float64(x * 0.16666666666666666)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 65.0) tmp = x; else tmp = (y * y) * (x * 0.16666666666666666); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 65.0], x, N[(N[(y * y), $MachinePrecision] * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 65:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot 0.16666666666666666\right)\\
\end{array}
\end{array}
if y < 65Initial program 100.0%
*-commutative100.0%
associate-/r/88.4%
Simplified88.4%
Taylor expanded in x around 0 48.7%
Taylor expanded in y around 0 34.6%
if 65 < y Initial program 100.0%
Taylor expanded in y around 0 48.7%
unpow248.7%
Simplified48.7%
Taylor expanded in y around inf 48.7%
unpow248.7%
associate-*r*48.7%
*-commutative48.7%
associate-*r*47.2%
associate-*l*33.4%
Simplified33.4%
Taylor expanded in x around 0 39.5%
Taylor expanded in y around 0 53.3%
associate-*r*53.3%
*-commutative53.3%
unpow253.3%
Simplified53.3%
Final simplification38.5%
(FPCore (x y) :precision binary64 (+ x (* 0.16666666666666666 (* x (* y y)))))
double code(double x, double y) {
return x + (0.16666666666666666 * (x * (y * y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (0.16666666666666666d0 * (x * (y * y)))
end function
public static double code(double x, double y) {
return x + (0.16666666666666666 * (x * (y * y)));
}
def code(x, y): return x + (0.16666666666666666 * (x * (y * y)))
function code(x, y) return Float64(x + Float64(0.16666666666666666 * Float64(x * Float64(y * y)))) end
function tmp = code(x, y) tmp = x + (0.16666666666666666 * (x * (y * y))); end
code[x_, y_] := N[(x + N[(0.16666666666666666 * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + 0.16666666666666666 \cdot \left(x \cdot \left(y \cdot y\right)\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/85.0%
Simplified85.0%
Taylor expanded in x around 0 50.5%
Taylor expanded in y around 0 49.7%
unpow249.7%
Simplified49.7%
Final simplification49.7%
(FPCore (x y) :precision binary64 (if (<= y 200000000000.0) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 200000000000.0) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 200000000000.0d0) then
tmp = x
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 200000000000.0) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 200000000000.0: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 200000000000.0) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 200000000000.0) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 200000000000.0], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 200000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 2e11Initial program 100.0%
*-commutative100.0%
associate-/r/88.6%
Simplified88.6%
Taylor expanded in x around 0 49.2%
Taylor expanded in y around 0 34.3%
if 2e11 < y Initial program 100.0%
associate-*r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 21.0%
Final simplification31.6%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/85.0%
Simplified85.0%
Taylor expanded in x around 0 50.5%
Taylor expanded in y around 0 27.9%
Final simplification27.9%
herbie shell --seed 2023279
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))