
(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) (/ y (sinh y))))
double code(double x, double y) {
return sin(x) / (y / sinh(y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) / (y / sinh(y))
end function
public static double code(double x, double y) {
return Math.sin(x) / (y / Math.sinh(y));
}
def code(x, y): return math.sin(x) / (y / math.sinh(y))
function code(x, y) return Float64(sin(x) / Float64(y / sinh(y))) end
function tmp = code(x, y) tmp = sin(x) / (y / sinh(y)); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] / N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{\frac{y}{\sinh y}}
\end{array}
Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 1.0) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.0) {
tmp = sin(x);
} else {
tmp = x * t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = sinh(y) / y
if (t_0 <= 1.0d0) then
tmp = sin(x)
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sinh(y) / y;
double tmp;
if (t_0 <= 1.0) {
tmp = Math.sin(x);
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y): t_0 = math.sinh(y) / y tmp = 0 if t_0 <= 1.0: tmp = math.sin(x) else: tmp = x * t_0 return tmp
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (t_0 <= 1.0) tmp = sin(x); else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = sinh(y) / y; tmp = 0.0; if (t_0 <= 1.0) tmp = sin(x); else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, 1.0], N[Sin[x], $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;t_0 \leq 1:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1Initial program 100.0%
Taylor expanded in y around 0 100.0%
if 1 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
add-log-exp95.9%
*-un-lft-identity95.9%
log-prod95.9%
metadata-eval95.9%
add-log-exp100.0%
*-commutative100.0%
associate-*l/100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/l*77.5%
Simplified77.5%
Taylor expanded in x around 0 50.0%
associate-/r/72.5%
Applied egg-rr72.5%
Final simplification85.2%
(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 0.00014)
(sin x)
(if (<= y 6.2e+260)
(/ x (/ y (sinh y)))
(* 0.16666666666666666 (* y (* (sin x) y))))))
double code(double x, double y) {
double tmp;
if (y <= 0.00014) {
tmp = sin(x);
} else if (y <= 6.2e+260) {
tmp = x / (y / sinh(y));
} else {
tmp = 0.16666666666666666 * (y * (sin(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 <= 0.00014d0) then
tmp = sin(x)
else if (y <= 6.2d+260) then
tmp = x / (y / sinh(y))
else
tmp = 0.16666666666666666d0 * (y * (sin(x) * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.00014) {
tmp = Math.sin(x);
} else if (y <= 6.2e+260) {
tmp = x / (y / Math.sinh(y));
} else {
tmp = 0.16666666666666666 * (y * (Math.sin(x) * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.00014: tmp = math.sin(x) elif y <= 6.2e+260: tmp = x / (y / math.sinh(y)) else: tmp = 0.16666666666666666 * (y * (math.sin(x) * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.00014) tmp = sin(x); elseif (y <= 6.2e+260) tmp = Float64(x / Float64(y / sinh(y))); else tmp = Float64(0.16666666666666666 * Float64(y * Float64(sin(x) * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.00014) tmp = sin(x); elseif (y <= 6.2e+260) tmp = x / (y / sinh(y)); else tmp = 0.16666666666666666 * (y * (sin(x) * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.00014], N[Sin[x], $MachinePrecision], If[LessEqual[y, 6.2e+260], N[(x / N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.16666666666666666 * N[(y * N[(N[Sin[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.00014:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+260}:\\
\;\;\;\;\frac{x}{\frac{y}{\sinh y}}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(y \cdot \left(\sin x \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 1.3999999999999999e-4Initial program 100.0%
Taylor expanded in y around 0 63.7%
if 1.3999999999999999e-4 < y < 6.1999999999999996e260Initial program 99.9%
add-log-exp95.0%
*-un-lft-identity95.0%
log-prod95.0%
metadata-eval95.0%
add-log-exp99.9%
*-commutative99.9%
associate-*l/100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/l*74.1%
Simplified74.1%
Taylor expanded in x around 0 43.2%
associate-/r/69.1%
Applied egg-rr69.1%
*-commutative69.1%
clear-num69.1%
un-div-inv69.1%
Applied egg-rr69.1%
if 6.1999999999999996e260 < 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-*l*100.0%
Simplified100.0%
Final simplification66.1%
(FPCore (x y)
:precision binary64
(if (<= y 0.00012)
(sin x)
(if (<= y 1.35e+154)
(/ x (/ y (sinh y)))
(* 0.16666666666666666 (* (sin x) (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= 0.00012) {
tmp = sin(x);
} else if (y <= 1.35e+154) {
tmp = x / (y / sinh(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 <= 0.00012d0) then
tmp = sin(x)
else if (y <= 1.35d+154) then
tmp = x / (y / sinh(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 <= 0.00012) {
tmp = Math.sin(x);
} else if (y <= 1.35e+154) {
tmp = x / (y / Math.sinh(y));
} else {
tmp = 0.16666666666666666 * (Math.sin(x) * (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.00012: tmp = math.sin(x) elif y <= 1.35e+154: tmp = x / (y / math.sinh(y)) else: tmp = 0.16666666666666666 * (math.sin(x) * (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.00012) tmp = sin(x); elseif (y <= 1.35e+154) tmp = Float64(x / Float64(y / sinh(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 <= 0.00012) tmp = sin(x); elseif (y <= 1.35e+154) tmp = x / (y / sinh(y)); else tmp = 0.16666666666666666 * (sin(x) * (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.00012], N[Sin[x], $MachinePrecision], If[LessEqual[y, 1.35e+154], N[(x / N[(y / N[Sinh[y], $MachinePrecision]), $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 0.00012:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{x}{\frac{y}{\sinh y}}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(\sin x \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 1.20000000000000003e-4Initial program 100.0%
Taylor expanded in y around 0 63.7%
if 1.20000000000000003e-4 < y < 1.35000000000000003e154Initial program 99.9%
add-log-exp93.0%
*-un-lft-identity93.0%
log-prod93.0%
metadata-eval93.0%
add-log-exp99.9%
*-commutative99.9%
associate-*l/100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/l*82.9%
Simplified82.9%
Taylor expanded in x around 0 51.3%
associate-/r/68.4%
Applied egg-rr68.4%
*-commutative68.4%
clear-num68.5%
un-div-inv68.5%
Applied egg-rr68.5%
if 1.35000000000000003e154 < 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%
*-commutative100.0%
Simplified100.0%
Final simplification68.0%
(FPCore (x y) :precision binary64 (if (<= y 0.00026) (sin x) (/ x (/ y (sinh y)))))
double code(double x, double y) {
double tmp;
if (y <= 0.00026) {
tmp = sin(x);
} else {
tmp = x / (y / sinh(y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.00026d0) then
tmp = sin(x)
else
tmp = x / (y / sinh(y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.00026) {
tmp = Math.sin(x);
} else {
tmp = x / (y / Math.sinh(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.00026: tmp = math.sin(x) else: tmp = x / (y / math.sinh(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.00026) tmp = sin(x); else tmp = Float64(x / Float64(y / sinh(y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.00026) tmp = sin(x); else tmp = x / (y / sinh(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.00026], N[Sin[x], $MachinePrecision], N[(x / N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.00026:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{\sinh y}}\\
\end{array}
\end{array}
if y < 2.59999999999999977e-4Initial program 100.0%
Taylor expanded in y around 0 63.7%
if 2.59999999999999977e-4 < y Initial program 100.0%
add-log-exp95.6%
*-un-lft-identity95.6%
log-prod95.6%
metadata-eval95.6%
add-log-exp100.0%
*-commutative100.0%
associate-*l/100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/l*71.2%
Simplified71.2%
Taylor expanded in x around 0 41.0%
associate-/r/69.8%
Applied egg-rr69.8%
*-commutative69.8%
clear-num69.8%
un-div-inv69.8%
Applied egg-rr69.8%
Final simplification65.3%
(FPCore (x y) :precision binary64 (if (<= y 0.000102) (sin x) (* x (+ 1.0 (* 0.16666666666666666 (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= 0.000102) {
tmp = sin(x);
} else {
tmp = x * (1.0 + (0.16666666666666666 * (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 <= 0.000102d0) then
tmp = sin(x)
else
tmp = x * (1.0d0 + (0.16666666666666666d0 * (y * y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.000102) {
tmp = Math.sin(x);
} else {
tmp = x * (1.0 + (0.16666666666666666 * (y * y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.000102: tmp = math.sin(x) else: tmp = x * (1.0 + (0.16666666666666666 * (y * y))) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.000102) tmp = sin(x); else tmp = Float64(x * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.000102) tmp = sin(x); else tmp = x * (1.0 + (0.16666666666666666 * (y * y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.000102], N[Sin[x], $MachinePrecision], N[(x * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.000102:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 1.01999999999999999e-4Initial program 100.0%
Taylor expanded in y around 0 63.7%
if 1.01999999999999999e-4 < y Initial program 100.0%
Taylor expanded in y around 0 41.2%
unpow241.2%
Simplified41.2%
Taylor expanded in x around 0 36.9%
unpow236.9%
Simplified36.9%
Final simplification56.8%
(FPCore (x y) :precision binary64 (if (<= y 98000.0) x (* 0.16666666666666666 (* x (* y y)))))
double code(double x, double y) {
double tmp;
if (y <= 98000.0) {
tmp = x;
} else {
tmp = 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 <= 98000.0d0) then
tmp = x
else
tmp = 0.16666666666666666d0 * (x * (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 98000.0) {
tmp = x;
} else {
tmp = 0.16666666666666666 * (x * (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 98000.0: tmp = x else: tmp = 0.16666666666666666 * (x * (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 98000.0) tmp = x; else tmp = Float64(0.16666666666666666 * Float64(x * Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 98000.0) tmp = x; else tmp = 0.16666666666666666 * (x * (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 98000.0], x, N[(0.16666666666666666 * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 98000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 98000Initial program 100.0%
add-log-exp68.1%
*-un-lft-identity68.1%
log-prod68.1%
metadata-eval68.1%
add-log-exp100.0%
*-commutative100.0%
associate-*l/87.3%
Applied egg-rr87.3%
+-lft-identity87.3%
associate-/l*93.7%
Simplified93.7%
Taylor expanded in x around 0 54.0%
Taylor expanded in y around 0 33.8%
if 98000 < y Initial program 100.0%
Taylor expanded in y around 0 42.9%
unpow242.9%
Simplified42.9%
Taylor expanded in y around inf 42.9%
unpow242.9%
associate-*l*30.7%
Simplified30.7%
Taylor expanded in x around 0 38.5%
unpow238.5%
*-commutative38.5%
Simplified38.5%
Final simplification35.0%
(FPCore (x y) :precision binary64 (* x (+ 1.0 (* 0.16666666666666666 (* y y)))))
double code(double x, double y) {
return x * (1.0 + (0.16666666666666666 * (y * y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + (0.16666666666666666d0 * (y * y)))
end function
public static double code(double x, double y) {
return x * (1.0 + (0.16666666666666666 * (y * y)));
}
def code(x, y): return x * (1.0 + (0.16666666666666666 * (y * y)))
function code(x, y) return Float64(x * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))) end
function tmp = code(x, y) tmp = x * (1.0 + (0.16666666666666666 * (y * y))); end
code[x_, y_] := N[(x * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 73.2%
unpow273.2%
Simplified73.2%
Taylor expanded in x around 0 47.3%
unpow247.3%
Simplified47.3%
Final simplification47.3%
(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%
add-log-exp75.8%
*-un-lft-identity75.8%
log-prod75.8%
metadata-eval75.8%
add-log-exp100.0%
*-commutative100.0%
associate-*l/90.4%
Applied egg-rr90.4%
+-lft-identity90.4%
associate-/l*87.8%
Simplified87.8%
Taylor expanded in x around 0 51.0%
Taylor expanded in y around 0 26.2%
Final simplification26.2%
herbie shell --seed 2023256
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))