
(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 9 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 89.1%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) (- INFINITY)) (not (<= (sinh y) 1e-11))) (sinh y) (* (sin x) (/ y x))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -((double) INFINITY)) || !(sinh(y) <= 1e-11)) {
tmp = sinh(y);
} else {
tmp = sin(x) * (y / x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -Double.POSITIVE_INFINITY) || !(Math.sinh(y) <= 1e-11)) {
tmp = Math.sinh(y);
} else {
tmp = Math.sin(x) * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -math.inf) or not (math.sinh(y) <= 1e-11): tmp = math.sinh(y) else: tmp = math.sin(x) * (y / x) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= Float64(-Inf)) || !(sinh(y) <= 1e-11)) 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) <= -Inf) || ~((sinh(y) <= 1e-11))) tmp = sinh(y); else tmp = sin(x) * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 1e-11]], $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 -\infty \lor \neg \left(\sinh y \leq 10^{-11}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if (sinh.f64 y) < -inf.0 or 9.99999999999999939e-12 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 74.8%
if -inf.0 < (sinh.f64 y) < 9.99999999999999939e-12Initial program 77.7%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 77.7%
associate-/l*99.8%
Simplified99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Final simplification87.0%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) (- INFINITY)) (not (<= (sinh y) 1e-11))) (sinh y) (* (/ (sin x) x) y)))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -((double) INFINITY)) || !(sinh(y) <= 1e-11)) {
tmp = sinh(y);
} else {
tmp = (sin(x) / x) * y;
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -Double.POSITIVE_INFINITY) || !(Math.sinh(y) <= 1e-11)) {
tmp = Math.sinh(y);
} else {
tmp = (Math.sin(x) / x) * y;
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -math.inf) or not (math.sinh(y) <= 1e-11): tmp = math.sinh(y) else: tmp = (math.sin(x) / x) * y return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= Float64(-Inf)) || !(sinh(y) <= 1e-11)) 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 ((sinh(y) <= -Inf) || ~((sinh(y) <= 1e-11))) tmp = sinh(y); else tmp = (sin(x) / x) * y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 1e-11]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -\infty \lor \neg \left(\sinh y \leq 10^{-11}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\end{array}
\end{array}
if (sinh.f64 y) < -inf.0 or 9.99999999999999939e-12 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 74.8%
if -inf.0 < (sinh.f64 y) < 9.99999999999999939e-12Initial program 77.7%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 99.9%
Final simplification87.1%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) (- INFINITY)) (not (<= (sinh y) 1e-11))) (sinh y) (* y (/ 1.0 (+ 1.0 (* x (* x 0.16666666666666666)))))))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -((double) INFINITY)) || !(sinh(y) <= 1e-11)) {
tmp = sinh(y);
} else {
tmp = y * (1.0 / (1.0 + (x * (x * 0.16666666666666666))));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) <= -Double.POSITIVE_INFINITY) || !(Math.sinh(y) <= 1e-11)) {
tmp = Math.sinh(y);
} else {
tmp = y * (1.0 / (1.0 + (x * (x * 0.16666666666666666))));
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) <= -math.inf) or not (math.sinh(y) <= 1e-11): tmp = math.sinh(y) else: tmp = y * (1.0 / (1.0 + (x * (x * 0.16666666666666666)))) return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= Float64(-Inf)) || !(sinh(y) <= 1e-11)) tmp = sinh(y); else tmp = Float64(y * Float64(1.0 / Float64(1.0 + Float64(x * Float64(x * 0.16666666666666666))))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) <= -Inf) || ~((sinh(y) <= 1e-11))) tmp = sinh(y); else tmp = y * (1.0 / (1.0 + (x * (x * 0.16666666666666666)))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Sinh[y], $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[Sinh[y], $MachinePrecision], 1e-11]], $MachinePrecision]], N[Sinh[y], $MachinePrecision], N[(y * N[(1.0 / N[(1.0 + N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -\infty \lor \neg \left(\sinh y \leq 10^{-11}\right):\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{1}{1 + x \cdot \left(x \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if (sinh.f64 y) < -inf.0 or 9.99999999999999939e-12 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 74.8%
if -inf.0 < (sinh.f64 y) < 9.99999999999999939e-12Initial program 77.7%
*-commutative77.7%
associate-/l*99.8%
Simplified99.8%
clear-num99.8%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 99.6%
Taylor expanded in x around 0 75.9%
clear-num75.8%
associate-/r/75.8%
*-commutative75.8%
+-commutative75.8%
distribute-lft-in75.8%
*-commutative75.8%
lft-mult-inverse76.0%
*-commutative76.0%
Applied egg-rr76.0%
Final simplification75.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (* x 0.16666666666666666))))
(if (or (<= y -12200.0) (not (<= y 5200000.0)))
(/ y t_0)
(* y (/ 1.0 (+ 1.0 t_0))))))
double code(double x, double y) {
double t_0 = x * (x * 0.16666666666666666);
double tmp;
if ((y <= -12200.0) || !(y <= 5200000.0)) {
tmp = y / t_0;
} else {
tmp = y * (1.0 / (1.0 + 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 = x * (x * 0.16666666666666666d0)
if ((y <= (-12200.0d0)) .or. (.not. (y <= 5200000.0d0))) then
tmp = y / t_0
else
tmp = y * (1.0d0 / (1.0d0 + t_0))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (x * 0.16666666666666666);
double tmp;
if ((y <= -12200.0) || !(y <= 5200000.0)) {
tmp = y / t_0;
} else {
tmp = y * (1.0 / (1.0 + t_0));
}
return tmp;
}
def code(x, y): t_0 = x * (x * 0.16666666666666666) tmp = 0 if (y <= -12200.0) or not (y <= 5200000.0): tmp = y / t_0 else: tmp = y * (1.0 / (1.0 + t_0)) return tmp
function code(x, y) t_0 = Float64(x * Float64(x * 0.16666666666666666)) tmp = 0.0 if ((y <= -12200.0) || !(y <= 5200000.0)) tmp = Float64(y / t_0); else tmp = Float64(y * Float64(1.0 / Float64(1.0 + t_0))); end return tmp end
function tmp_2 = code(x, y) t_0 = x * (x * 0.16666666666666666); tmp = 0.0; if ((y <= -12200.0) || ~((y <= 5200000.0))) tmp = y / t_0; else tmp = y * (1.0 / (1.0 + t_0)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[y, -12200.0], N[Not[LessEqual[y, 5200000.0]], $MachinePrecision]], N[(y / t$95$0), $MachinePrecision], N[(y * N[(1.0 / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot 0.16666666666666666\right)\\
\mathbf{if}\;y \leq -12200 \lor \neg \left(y \leq 5200000\right):\\
\;\;\;\;\frac{y}{t_0}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{1}{1 + t_0}\\
\end{array}
\end{array}
if y < -12200 or 5.2e6 < y Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
Simplified100.0%
clear-num100.0%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 4.3%
Taylor expanded in x around 0 3.6%
Taylor expanded in x around inf 37.8%
*-commutative37.8%
Simplified37.8%
if -12200 < y < 5.2e6Initial program 78.4%
*-commutative78.4%
associate-/l*99.8%
Simplified99.8%
clear-num99.8%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 97.0%
Taylor expanded in x around 0 74.0%
clear-num73.9%
associate-/r/73.9%
*-commutative73.9%
+-commutative73.9%
distribute-lft-in73.9%
*-commutative73.9%
lft-mult-inverse74.1%
*-commutative74.1%
Applied egg-rr74.1%
Final simplification56.1%
(FPCore (x y) :precision binary64 (if (<= y -4e-11) (/ y (* x (* x 0.16666666666666666))) (* x (/ 1.0 (/ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -4e-11) {
tmp = y / (x * (x * 0.16666666666666666));
} else {
tmp = x * (1.0 / (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 <= (-4d-11)) then
tmp = y / (x * (x * 0.16666666666666666d0))
else
tmp = x * (1.0d0 / (x / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -4e-11) {
tmp = y / (x * (x * 0.16666666666666666));
} else {
tmp = x * (1.0 / (x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4e-11: tmp = y / (x * (x * 0.16666666666666666)) else: tmp = x * (1.0 / (x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -4e-11) tmp = Float64(y / Float64(x * Float64(x * 0.16666666666666666))); else tmp = Float64(x * Float64(1.0 / Float64(x / y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4e-11) tmp = y / (x * (x * 0.16666666666666666)); else tmp = x * (1.0 / (x / y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4e-11], N[(y / N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-11}:\\
\;\;\;\;\frac{y}{x \cdot \left(x \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1}{\frac{x}{y}}\\
\end{array}
\end{array}
if y < -3.99999999999999976e-11Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
Simplified100.0%
clear-num100.0%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 5.8%
Taylor expanded in x around 0 3.8%
Taylor expanded in x around inf 39.1%
*-commutative39.1%
Simplified39.1%
if -3.99999999999999976e-11 < y Initial program 84.8%
Taylor expanded in y around 0 53.8%
Taylor expanded in x around 0 23.5%
frac-2neg23.5%
div-inv23.5%
distribute-rgt-neg-in23.5%
Applied egg-rr23.5%
associate-*l*59.4%
Simplified59.4%
un-div-inv59.5%
frac-2neg59.5%
clear-num60.3%
Applied egg-rr60.3%
Final simplification54.3%
(FPCore (x y) :precision binary64 (* x (/ 1.0 (/ x y))))
double code(double x, double y) {
return x * (1.0 / (x / y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 / (x / y))
end function
public static double code(double x, double y) {
return x * (1.0 / (x / y));
}
def code(x, y): return x * (1.0 / (x / y))
function code(x, y) return Float64(x * Float64(1.0 / Float64(x / y))) end
function tmp = code(x, y) tmp = x * (1.0 / (x / y)); end
code[x_, y_] := N[(x * N[(1.0 / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{1}{\frac{x}{y}}
\end{array}
Initial program 89.1%
Taylor expanded in y around 0 40.3%
Taylor expanded in x around 0 21.8%
frac-2neg21.8%
div-inv21.7%
distribute-rgt-neg-in21.7%
Applied egg-rr21.7%
associate-*l*50.8%
Simplified50.8%
un-div-inv50.8%
frac-2neg50.8%
clear-num51.4%
Applied egg-rr51.4%
Final simplification51.4%
(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.1%
Taylor expanded in y around 0 40.3%
Taylor expanded in x around 0 21.8%
associate-/l*49.9%
div-inv51.4%
clear-num50.8%
Applied egg-rr50.8%
Final simplification50.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 89.1%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 51.2%
Taylor expanded in x around 0 26.1%
Final simplification26.1%
(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 2023318
(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))