
(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 89.5%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 0.5) (* y (/ (sin x) x)) (* x (/ (sinh y) x))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 0.5) {
tmp = y * (sin(x) / x);
} else {
tmp = x * (sinh(y) / x);
}
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.5d0) then
tmp = y * (sin(x) / x)
else
tmp = x * (sinh(y) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 0.5) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = x * (Math.sinh(y) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 0.5: tmp = y * (math.sin(x) / x) else: tmp = x * (math.sinh(y) / x) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 0.5) tmp = Float64(y * Float64(sin(x) / x)); else tmp = Float64(x * Float64(sinh(y) / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 0.5) tmp = y * (sin(x) / x); else tmp = x * (sinh(y) / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 0.5], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 0.5:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sinh y}{x}\\
\end{array}
\end{array}
if (sinh.f64 y) < 0.5Initial program 86.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 49.7%
associate-/l*63.4%
Simplified63.4%
if 0.5 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 65.6%
(FPCore (x y) :precision binary64 (* x (/ (sinh y) x)))
double code(double x, double y) {
return x * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sinh(y) / x)
end function
public static double code(double x, double y) {
return x * (Math.sinh(y) / x);
}
def code(x, y): return x * (math.sinh(y) / x)
function code(x, y) return Float64(x * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = x * (sinh(y) / x); end
code[x_, y_] := N[(x * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 89.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 72.0%
(FPCore (x y)
:precision binary64
(if (<= y 0.118)
(/ x (/ x y))
(if (<= y 3.2e+220)
(/ (* x (+ y (* -0.16666666666666666 (* y (* x x))))) x)
(* x (/ y x)))))
double code(double x, double y) {
double tmp;
if (y <= 0.118) {
tmp = x / (x / y);
} else if (y <= 3.2e+220) {
tmp = (x * (y + (-0.16666666666666666 * (y * (x * x))))) / x;
} else {
tmp = x * (y / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.118d0) then
tmp = x / (x / y)
else if (y <= 3.2d+220) then
tmp = (x * (y + ((-0.16666666666666666d0) * (y * (x * x))))) / x
else
tmp = x * (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.118) {
tmp = x / (x / y);
} else if (y <= 3.2e+220) {
tmp = (x * (y + (-0.16666666666666666 * (y * (x * x))))) / x;
} else {
tmp = x * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.118: tmp = x / (x / y) elif y <= 3.2e+220: tmp = (x * (y + (-0.16666666666666666 * (y * (x * x))))) / x else: tmp = x * (y / x) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.118) tmp = Float64(x / Float64(x / y)); elseif (y <= 3.2e+220) tmp = Float64(Float64(x * Float64(y + Float64(-0.16666666666666666 * Float64(y * Float64(x * x))))) / x); else tmp = Float64(x * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.118) tmp = x / (x / y); elseif (y <= 3.2e+220) tmp = (x * (y + (-0.16666666666666666 * (y * (x * x))))) / x; else tmp = x * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.118], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+220], N[(N[(x * N[(y + N[(-0.16666666666666666 * N[(y * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.118:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+220}:\\
\;\;\;\;\frac{x \cdot \left(y + -0.16666666666666666 \cdot \left(y \cdot \left(x \cdot x\right)\right)\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if y < 0.11799999999999999Initial program 86.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 74.4%
Taylor expanded in y around 0 56.1%
clear-num56.1%
un-div-inv55.2%
Applied egg-rr55.2%
if 0.11799999999999999 < y < 3.19999999999999989e220Initial program 100.0%
Taylor expanded in y around 0 4.0%
Taylor expanded in x around 0 36.1%
unpow236.1%
Applied egg-rr36.1%
if 3.19999999999999989e220 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 77.8%
Taylor expanded in y around 0 67.6%
Final simplification52.8%
(FPCore (x y) :precision binary64 (if (or (<= x 3.2) (not (<= x 3.4e+211))) (* x (/ y x)) (* (* x x) (* y -0.16666666666666666))))
double code(double x, double y) {
double tmp;
if ((x <= 3.2) || !(x <= 3.4e+211)) {
tmp = x * (y / x);
} else {
tmp = (x * x) * (y * -0.16666666666666666);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= 3.2d0) .or. (.not. (x <= 3.4d+211))) then
tmp = x * (y / x)
else
tmp = (x * x) * (y * (-0.16666666666666666d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= 3.2) || !(x <= 3.4e+211)) {
tmp = x * (y / x);
} else {
tmp = (x * x) * (y * -0.16666666666666666);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= 3.2) or not (x <= 3.4e+211): tmp = x * (y / x) else: tmp = (x * x) * (y * -0.16666666666666666) return tmp
function code(x, y) tmp = 0.0 if ((x <= 3.2) || !(x <= 3.4e+211)) tmp = Float64(x * Float64(y / x)); else tmp = Float64(Float64(x * x) * Float64(y * -0.16666666666666666)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= 3.2) || ~((x <= 3.4e+211))) tmp = x * (y / x); else tmp = (x * x) * (y * -0.16666666666666666); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, 3.2], N[Not[LessEqual[x, 3.4e+211]], $MachinePrecision]], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2 \lor \neg \left(x \leq 3.4 \cdot 10^{+211}\right):\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot -0.16666666666666666\right)\\
\end{array}
\end{array}
if x < 3.2000000000000002 or 3.3999999999999999e211 < x Initial program 87.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 81.3%
Taylor expanded in y around 0 56.1%
if 3.2000000000000002 < x < 3.3999999999999999e211Initial program 99.9%
Taylor expanded in y around 0 45.0%
Taylor expanded in x around 0 34.4%
Taylor expanded in x around inf 27.5%
*-commutative27.5%
*-commutative27.5%
*-commutative27.5%
associate-*r*27.5%
Simplified27.5%
unpow234.4%
Applied egg-rr27.5%
Final simplification51.7%
(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 89.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 72.0%
Taylor expanded in y around 0 48.9%
(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 89.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 59.9%
clear-num59.5%
associate-/r/59.7%
Applied egg-rr59.7%
Taylor expanded in x around 0 25.9%
(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 2024170
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (* (sin x) (/ (sinh y) x)))
(/ (* (sin x) (sinh y)) x))