
(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) x) (sinh y)))
double code(double x, double y) {
return (sin(x) / x) * sinh(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) / x) * sinh(y)
end function
public static double code(double x, double y) {
return (Math.sin(x) / x) * Math.sinh(y);
}
def code(x, y): return (math.sin(x) / x) * math.sinh(y)
function code(x, y) return Float64(Float64(sin(x) / x) * sinh(y)) end
function tmp = code(x, y) tmp = (sin(x) / x) * sinh(y); end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{x} \cdot \sinh y
\end{array}
Initial program 90.1%
associate-*l/99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -5000000000000.0) (not (<= (sinh y) 0.002))) (sinh y) (* (sin x) (/ y x))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -5000000000000.0) || !(sinh(y) <= 0.002)) {
tmp = sinh(y);
} else {
tmp = sin(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 ((sinh(y) <= (-5000000000000.0d0)) .or. (.not. (sinh(y) <= 0.002d0))) then
tmp = sinh(y)
else
tmp = sin(x) * (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -5000000000000.0) || !(Math.sinh(y) <= 0.002)) {
tmp = Math.sinh(y);
} else {
tmp = Math.sin(x) * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -5000000000000.0) or not (math.sinh(y) <= 0.002): tmp = math.sinh(y) else: tmp = math.sin(x) * (y / x) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -5000000000000.0) || !(sinh(y) <= 0.002)) tmp = sinh(y); else tmp = Float64(sin(x) * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) <= -5000000000000.0) || ~((sinh(y) <= 0.002))) tmp = sinh(y); else tmp = sin(x) * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -5000000000000.0], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 0.002]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -5000000000000 \lor \neg \left(\sinh y \leq 0.002\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if (sinh.f64 y) < -5e12 or 2e-3 < (sinh.f64 y) Initial program 99.2%
associate-*l/99.2%
Simplified99.2%
Taylor expanded in x around 0 81.2%
if -5e12 < (sinh.f64 y) < 2e-3Initial program 81.9%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 81.0%
associate-/l*98.9%
Simplified98.9%
associate-/r/98.9%
Applied egg-rr98.9%
Final simplification90.4%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) -2e-47) (not (<= (sinh y) 0.002))) (sinh y) (/ x (/ x y))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -2e-47) || !(sinh(y) <= 0.002)) {
tmp = sinh(y);
} else {
tmp = x / (x / 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) <= (-2d-47)) .or. (.not. (sinh(y) <= 0.002d0))) then
tmp = sinh(y)
else
tmp = x / (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -2e-47) || !(Math.sinh(y) <= 0.002)) {
tmp = Math.sinh(y);
} else {
tmp = x / (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -2e-47) or not (math.sinh(y) <= 0.002): tmp = math.sinh(y) else: tmp = x / (x / y) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= -2e-47) || !(sinh(y) <= 0.002)) tmp = sinh(y); else tmp = Float64(x / Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) <= -2e-47) || ~((sinh(y) <= 0.002))) tmp = sinh(y); else tmp = x / (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], -2e-47], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 0.002]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -2 \cdot 10^{-47} \lor \neg \left(\sinh y \leq 0.002\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\end{array}
\end{array}
if (sinh.f64 y) < -1.9999999999999999e-47 or 2e-3 < (sinh.f64 y) Initial program 99.2%
associate-*l/99.2%
Simplified99.2%
Taylor expanded in x around 0 79.8%
if -1.9999999999999999e-47 < (sinh.f64 y) < 2e-3Initial program 81.1%
Taylor expanded in y around 0 80.7%
Taylor expanded in x around 0 28.7%
*-commutative28.7%
Simplified28.7%
associate-/l*47.5%
associate-/r/75.1%
Applied egg-rr75.1%
*-commutative75.1%
clear-num76.7%
un-div-inv76.8%
Applied egg-rr76.8%
Final simplification78.3%
(FPCore (x y)
:precision binary64
(if (<= y -0.48)
(sinh y)
(if (<= y 0.0034)
(* (/ (sin x) x) y)
(if (<= y 6.8e+272)
(sinh y)
(+ y (* -0.16666666666666666 (* y (pow x 2.0))))))))
double code(double x, double y) {
double tmp;
if (y <= -0.48) {
tmp = sinh(y);
} else if (y <= 0.0034) {
tmp = (sin(x) / x) * y;
} else if (y <= 6.8e+272) {
tmp = sinh(y);
} else {
tmp = y + (-0.16666666666666666 * (y * pow(x, 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 <= (-0.48d0)) then
tmp = sinh(y)
else if (y <= 0.0034d0) then
tmp = (sin(x) / x) * y
else if (y <= 6.8d+272) then
tmp = sinh(y)
else
tmp = y + ((-0.16666666666666666d0) * (y * (x ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -0.48) {
tmp = Math.sinh(y);
} else if (y <= 0.0034) {
tmp = (Math.sin(x) / x) * y;
} else if (y <= 6.8e+272) {
tmp = Math.sinh(y);
} else {
tmp = y + (-0.16666666666666666 * (y * Math.pow(x, 2.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -0.48: tmp = math.sinh(y) elif y <= 0.0034: tmp = (math.sin(x) / x) * y elif y <= 6.8e+272: tmp = math.sinh(y) else: tmp = y + (-0.16666666666666666 * (y * math.pow(x, 2.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -0.48) tmp = sinh(y); elseif (y <= 0.0034) tmp = Float64(Float64(sin(x) / x) * y); elseif (y <= 6.8e+272) tmp = sinh(y); else tmp = Float64(y + Float64(-0.16666666666666666 * Float64(y * (x ^ 2.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -0.48) tmp = sinh(y); elseif (y <= 0.0034) tmp = (sin(x) / x) * y; elseif (y <= 6.8e+272) tmp = sinh(y); else tmp = y + (-0.16666666666666666 * (y * (x ^ 2.0))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -0.48], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 0.0034], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 6.8e+272], N[Sinh[y], $MachinePrecision], N[(y + N[(-0.16666666666666666 * N[(y * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.48:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;y \leq 0.0034:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{+272}:\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;y + -0.16666666666666666 \cdot \left(y \cdot {x}^{2}\right)\\
\end{array}
\end{array}
if y < -0.47999999999999998 or 0.00339999999999999981 < y < 6.80000000000000021e272Initial program 99.2%
associate-*l/99.2%
Simplified99.2%
Taylor expanded in x around 0 84.5%
if -0.47999999999999998 < y < 0.00339999999999999981Initial program 81.9%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 98.9%
if 6.80000000000000021e272 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in y around 0 6.4%
Taylor expanded in x around 0 84.9%
Final simplification92.1%
(FPCore (x y) :precision binary64 (if (or (<= y -0.48) (not (<= y 0.0034))) (sinh y) (* (/ (sin x) x) y)))
double code(double x, double y) {
double tmp;
if ((y <= -0.48) || !(y <= 0.0034)) {
tmp = sinh(y);
} else {
tmp = (sin(x) / 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.48d0)) .or. (.not. (y <= 0.0034d0))) then
tmp = sinh(y)
else
tmp = (sin(x) / x) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -0.48) || !(y <= 0.0034)) {
tmp = Math.sinh(y);
} else {
tmp = (Math.sin(x) / x) * y;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -0.48) or not (y <= 0.0034): tmp = math.sinh(y) else: tmp = (math.sin(x) / x) * y return tmp
function code(x, y) tmp = 0.0 if ((y <= -0.48) || !(y <= 0.0034)) tmp = sinh(y); else tmp = Float64(Float64(sin(x) / x) * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -0.48) || ~((y <= 0.0034))) tmp = sinh(y); else tmp = (sin(x) / x) * y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -0.48], N[Not[LessEqual[y, 0.0034]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.48 \lor \neg \left(y \leq 0.0034\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\end{array}
\end{array}
if y < -0.47999999999999998 or 0.00339999999999999981 < y Initial program 99.2%
associate-*l/99.2%
Simplified99.2%
Taylor expanded in x around 0 81.2%
if -0.47999999999999998 < y < 0.00339999999999999981Initial program 81.9%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 98.9%
Final simplification90.5%
(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 90.1%
Taylor expanded in y around 0 44.7%
Taylor expanded in x around 0 22.6%
*-commutative22.6%
Simplified22.6%
associate-/l*27.2%
associate-/r/53.8%
Applied egg-rr53.8%
Final simplification53.8%
(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 90.1%
associate-*l/99.5%
Simplified99.5%
Taylor expanded in y around 0 54.1%
Taylor expanded in x around 0 27.2%
Final simplification27.2%
(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 2023302
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:herbie-target
(* (sin x) (/ (sinh y) x))
(/ (* (sin x) (sinh y)) x))