
(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 7 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 (<= (sinh y) 0.005) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 0.005) {
tmp = y * (sin(x) / x);
} else {
tmp = sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 0.005d0) then
tmp = y * (sin(x) / x)
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 0.005) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 0.005: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 0.005) tmp = Float64(y * Float64(sin(x) / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 0.005) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 0.005], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 0.005:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 0.0050000000000000001Initial program 81.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 46.1%
associate-/l*64.2%
Simplified64.2%
if 0.0050000000000000001 < (sinh.f64 y) Initial program 100.0%
*-commutative100.0%
add-sqr-sqrt52.5%
times-frac52.5%
Applied egg-rr52.5%
frac-times52.5%
*-commutative52.5%
add-sqr-sqrt100.0%
associate-*l/100.0%
associate-/r/100.0%
div-inv100.0%
associate-/r*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 75.4%
remove-double-div75.4%
expm1-log1p-u75.4%
expm1-undefine75.4%
Applied egg-rr75.4%
sub-neg75.4%
metadata-eval75.4%
+-commutative75.4%
log1p-undefine75.4%
rem-exp-log75.4%
associate-+r+75.4%
metadata-eval75.4%
+-lft-identity75.4%
Simplified75.4%
Final simplification66.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-88) (* x (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-88) {
tmp = x * (y / x);
} else {
tmp = sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 1d-88) then
tmp = x * (y / x)
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 1e-88) {
tmp = x * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e-88: tmp = x * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e-88) tmp = Float64(x * Float64(y / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e-88) tmp = x * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-88], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-88}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 9.99999999999999934e-89Initial program 81.2%
Taylor expanded in y around 0 43.2%
Taylor expanded in x around 0 23.4%
associate-/l*58.4%
*-commutative58.4%
Applied egg-rr58.4%
if 9.99999999999999934e-89 < (sinh.f64 y) Initial program 98.6%
*-commutative98.6%
add-sqr-sqrt53.3%
times-frac53.3%
Applied egg-rr53.3%
frac-times53.3%
*-commutative53.3%
add-sqr-sqrt98.6%
associate-*l/100.0%
associate-/r/99.9%
div-inv99.9%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 74.0%
remove-double-div74.0%
expm1-log1p-u74.0%
expm1-undefine64.9%
Applied egg-rr64.9%
sub-neg64.9%
metadata-eval64.9%
+-commutative64.9%
log1p-undefine64.9%
rem-exp-log64.9%
associate-+r+74.0%
metadata-eval74.0%
+-lft-identity74.0%
Simplified74.0%
Final simplification62.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ y x))) (t_1 (* -0.16666666666666666 (* x x))))
(if (<= x 2.3e+102)
t_0
(if (<= x 1.8e+158)
(* y (+ 1.0 t_1))
(if (or (<= x 1.75e+226) (not (<= x 1.5e+246))) t_0 (* y t_1))))))
double code(double x, double y) {
double t_0 = x * (y / x);
double t_1 = -0.16666666666666666 * (x * x);
double tmp;
if (x <= 2.3e+102) {
tmp = t_0;
} else if (x <= 1.8e+158) {
tmp = y * (1.0 + t_1);
} else if ((x <= 1.75e+226) || !(x <= 1.5e+246)) {
tmp = t_0;
} else {
tmp = y * t_1;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * (y / x)
t_1 = (-0.16666666666666666d0) * (x * x)
if (x <= 2.3d+102) then
tmp = t_0
else if (x <= 1.8d+158) then
tmp = y * (1.0d0 + t_1)
else if ((x <= 1.75d+226) .or. (.not. (x <= 1.5d+246))) then
tmp = t_0
else
tmp = y * t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (y / x);
double t_1 = -0.16666666666666666 * (x * x);
double tmp;
if (x <= 2.3e+102) {
tmp = t_0;
} else if (x <= 1.8e+158) {
tmp = y * (1.0 + t_1);
} else if ((x <= 1.75e+226) || !(x <= 1.5e+246)) {
tmp = t_0;
} else {
tmp = y * t_1;
}
return tmp;
}
def code(x, y): t_0 = x * (y / x) t_1 = -0.16666666666666666 * (x * x) tmp = 0 if x <= 2.3e+102: tmp = t_0 elif x <= 1.8e+158: tmp = y * (1.0 + t_1) elif (x <= 1.75e+226) or not (x <= 1.5e+246): tmp = t_0 else: tmp = y * t_1 return tmp
function code(x, y) t_0 = Float64(x * Float64(y / x)) t_1 = Float64(-0.16666666666666666 * Float64(x * x)) tmp = 0.0 if (x <= 2.3e+102) tmp = t_0; elseif (x <= 1.8e+158) tmp = Float64(y * Float64(1.0 + t_1)); elseif ((x <= 1.75e+226) || !(x <= 1.5e+246)) tmp = t_0; else tmp = Float64(y * t_1); end return tmp end
function tmp_2 = code(x, y) t_0 = x * (y / x); t_1 = -0.16666666666666666 * (x * x); tmp = 0.0; if (x <= 2.3e+102) tmp = t_0; elseif (x <= 1.8e+158) tmp = y * (1.0 + t_1); elseif ((x <= 1.75e+226) || ~((x <= 1.5e+246))) tmp = t_0; else tmp = y * t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.3e+102], t$95$0, If[LessEqual[x, 1.8e+158], N[(y * N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 1.75e+226], N[Not[LessEqual[x, 1.5e+246]], $MachinePrecision]], t$95$0, N[(y * t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{x}\\
t_1 := -0.16666666666666666 \cdot \left(x \cdot x\right)\\
\mathbf{if}\;x \leq 2.3 \cdot 10^{+102}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+158}:\\
\;\;\;\;y \cdot \left(1 + t\_1\right)\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{+226} \lor \neg \left(x \leq 1.5 \cdot 10^{+246}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\_1\\
\end{array}
\end{array}
if x < 2.2999999999999999e102 or 1.79999999999999994e158 < x < 1.7499999999999999e226 or 1.5e246 < x Initial program 85.5%
Taylor expanded in y around 0 36.9%
Taylor expanded in x around 0 23.2%
associate-/l*55.5%
*-commutative55.5%
Applied egg-rr55.5%
if 2.2999999999999999e102 < x < 1.79999999999999994e158Initial program 99.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 17.2%
associate-/l*17.4%
Simplified17.4%
Taylor expanded in x around 0 59.0%
unpow259.0%
Applied egg-rr59.0%
if 1.7499999999999999e226 < x < 1.5e246Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 26.9%
associate-/l*26.9%
Simplified26.9%
Taylor expanded in x around 0 25.4%
Taylor expanded in x around inf 25.4%
associate-*r*25.4%
*-commutative25.4%
*-commutative25.4%
Simplified25.4%
unpow225.4%
Applied egg-rr25.4%
Final simplification55.1%
(FPCore (x y) :precision binary64 (if (or (<= x 2.3e+102) (not (<= x 1.65e+158))) (* x (/ y x)) (* y (* -0.16666666666666666 (* x x)))))
double code(double x, double y) {
double tmp;
if ((x <= 2.3e+102) || !(x <= 1.65e+158)) {
tmp = x * (y / x);
} else {
tmp = y * (-0.16666666666666666 * (x * x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= 2.3d+102) .or. (.not. (x <= 1.65d+158))) then
tmp = x * (y / x)
else
tmp = y * ((-0.16666666666666666d0) * (x * x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= 2.3e+102) || !(x <= 1.65e+158)) {
tmp = x * (y / x);
} else {
tmp = y * (-0.16666666666666666 * (x * x));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= 2.3e+102) or not (x <= 1.65e+158): tmp = x * (y / x) else: tmp = y * (-0.16666666666666666 * (x * x)) return tmp
function code(x, y) tmp = 0.0 if ((x <= 2.3e+102) || !(x <= 1.65e+158)) tmp = Float64(x * Float64(y / x)); else tmp = Float64(y * Float64(-0.16666666666666666 * Float64(x * x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= 2.3e+102) || ~((x <= 1.65e+158))) tmp = x * (y / x); else tmp = y * (-0.16666666666666666 * (x * x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, 2.3e+102], N[Not[LessEqual[x, 1.65e+158]], $MachinePrecision]], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(y * N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.3 \cdot 10^{+102} \lor \neg \left(x \leq 1.65 \cdot 10^{+158}\right):\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\end{array}
\end{array}
if x < 2.2999999999999999e102 or 1.65000000000000009e158 < x Initial program 85.8%
Taylor expanded in y around 0 36.7%
Taylor expanded in x around 0 23.2%
associate-/l*54.6%
*-commutative54.6%
Applied egg-rr54.6%
if 2.2999999999999999e102 < x < 1.65000000000000009e158Initial program 99.8%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 17.2%
associate-/l*17.4%
Simplified17.4%
Taylor expanded in x around 0 59.0%
Taylor expanded in x around inf 59.0%
associate-*r*59.0%
*-commutative59.0%
*-commutative59.0%
Simplified59.0%
unpow259.0%
Applied egg-rr59.0%
Final simplification54.8%
(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%
Taylor expanded in y around 0 36.2%
Taylor expanded in x around 0 23.0%
associate-/l*53.2%
*-commutative53.2%
Applied egg-rr53.2%
Final simplification53.2%
(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.2%
associate-/l*50.0%
Simplified50.0%
Taylor expanded in x around 0 31.0%
Final simplification31.0%
(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 2024076
(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))