
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 86.1%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y 1.4e+154) (* (sin x) (/ y x)) (sqrt (pow y 2.0))))
double code(double x, double y) {
double tmp;
if (y <= 1.4e+154) {
tmp = sin(x) * (y / x);
} else {
tmp = sqrt(pow(y, 2.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.4d+154) then
tmp = sin(x) * (y / x)
else
tmp = sqrt((y ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.4e+154) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sqrt(Math.pow(y, 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.4e+154: tmp = math.sin(x) * (y / x) else: tmp = math.sqrt(math.pow(y, 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.4e+154) tmp = Float64(sin(x) * Float64(y / x)); else tmp = sqrt((y ^ 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.4e+154) tmp = sin(x) * (y / x); else tmp = sqrt((y ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.4e+154], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[Power[y, 2.0], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{y}^{2}}\\
\end{array}
\end{array}
if y < 1.4e154Initial program 84.2%
*-commutative84.2%
add-sqr-sqrt38.8%
times-frac45.8%
Applied egg-rr45.8%
Taylor expanded in y around 0 40.8%
*-commutative40.8%
associate-*r/66.6%
Simplified66.6%
if 1.4e154 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 6.3%
Taylor expanded in x around 0 21.1%
add-sqr-sqrt21.1%
sqrt-unprod93.8%
pow293.8%
*-commutative93.8%
associate-/l*93.8%
Applied egg-rr93.8%
*-inverses93.8%
*-rgt-identity93.8%
Simplified93.8%
Final simplification70.0%
(FPCore (x y) :precision binary64 (if (<= y 1.35e+42) (* y (/ (sin x) x)) (/ (/ y x) (/ 1.0 x))))
double code(double x, double y) {
double tmp;
if (y <= 1.35e+42) {
tmp = y * (sin(x) / x);
} else {
tmp = (y / x) / (1.0 / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.35d+42) then
tmp = y * (sin(x) / x)
else
tmp = (y / x) / (1.0d0 / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.35e+42) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = (y / x) / (1.0 / x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.35e+42: tmp = y * (math.sin(x) / x) else: tmp = (y / x) / (1.0 / x) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.35e+42) tmp = Float64(y * Float64(sin(x) / x)); else tmp = Float64(Float64(y / x) / Float64(1.0 / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.35e+42) tmp = y * (sin(x) / x); else tmp = (y / x) / (1.0 / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.35e+42], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+42}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{\frac{1}{x}}\\
\end{array}
\end{array}
if y < 1.35e42Initial program 82.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 45.3%
associate-/l*62.9%
Simplified62.9%
if 1.35e42 < y Initial program 100.0%
*-commutative100.0%
add-sqr-sqrt41.1%
times-frac41.1%
Applied egg-rr41.1%
Taylor expanded in y around 0 5.1%
*-commutative5.1%
associate-*r/51.9%
Simplified51.9%
associate-*r/5.1%
*-commutative5.1%
associate-*l/51.9%
associate-/r/5.1%
div-inv5.1%
associate-/r*51.9%
Applied egg-rr51.9%
Taylor expanded in x around 0 51.8%
Final simplification60.5%
(FPCore (x y) :precision binary64 (* (sin x) (/ y x)))
double code(double x, double y) {
return sin(x) * (y / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (y / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (y / x);
}
def code(x, y): return math.sin(x) * (y / x)
function code(x, y) return Float64(sin(x) * Float64(y / x)) end
function tmp = code(x, y) tmp = sin(x) * (y / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{y}{x}
\end{array}
Initial program 86.1%
*-commutative86.1%
add-sqr-sqrt39.0%
times-frac45.2%
Applied egg-rr45.2%
Taylor expanded in y around 0 36.5%
*-commutative36.5%
associate-*r/66.3%
Simplified66.3%
Final simplification66.3%
(FPCore (x y) :precision binary64 (* x (/ y x)))
double code(double x, double y) {
return x * (y / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (y / x)
end function
public static double code(double x, double y) {
return x * (y / x);
}
def code(x, y): return x * (y / x)
function code(x, y) return Float64(x * Float64(y / x)) end
function tmp = code(x, y) tmp = x * (y / x); end
code[x_, y_] := N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y}{x}
\end{array}
Initial program 86.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 36.5%
Taylor expanded in x around 0 18.7%
associate-/l*52.6%
*-commutative52.6%
Applied egg-rr52.6%
Final simplification52.6%
(FPCore (x y) :precision binary64 y)
double code(double x, double y) {
return y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y
end function
public static double code(double x, double y) {
return y;
}
def code(x, y): return y
function code(x, y) return y end
function tmp = code(x, y) tmp = y; end
code[x_, y_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 86.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 36.5%
associate-/l*50.2%
Simplified50.2%
Taylor expanded in x around 0 26.7%
Final simplification26.7%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
herbie shell --seed 2024055
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(* (sin x) (/ (sinh y) x))
(/ (* (sin x) (sinh y)) x))