
(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 88.5%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 50000000000000.0) (* (sin x) (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 50000000000000.0) {
tmp = sin(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) <= 50000000000000.0d0) then
tmp = sin(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) <= 50000000000000.0) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 50000000000000.0: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 50000000000000.0) tmp = Float64(sin(x) * Float64(y / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 50000000000000.0) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 50000000000000.0], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 50000000000000:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 5e13Initial program 85.1%
*-commutative85.1%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 57.8%
associate-/l*72.5%
associate-/r/79.1%
Simplified79.1%
if 5e13 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 79.3%
Final simplification79.1%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 50000000000000.0) (* (/ (sin x) x) y) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 50000000000000.0) {
tmp = (sin(x) / x) * y;
} 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) <= 50000000000000.0d0) then
tmp = (sin(x) / x) * y
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 50000000000000.0) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 50000000000000.0: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 50000000000000.0) tmp = Float64(Float64(sin(x) / x) * y); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 50000000000000.0) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 50000000000000.0], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 50000000000000:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 5e13Initial program 85.1%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 72.5%
if 5e13 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 79.3%
Final simplification74.0%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 50000000000000.0) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 50000000000000.0) {
tmp = y / (x / sin(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) <= 50000000000000.0d0) then
tmp = y / (x / sin(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) <= 50000000000000.0) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 50000000000000.0: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 50000000000000.0) tmp = Float64(y / Float64(x / sin(x))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 50000000000000.0) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 50000000000000.0], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 50000000000000:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 5e13Initial program 85.1%
*-commutative85.1%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 57.8%
associate-/l*72.5%
Simplified72.5%
if 5e13 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 79.3%
Final simplification74.1%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1000000000000.0) (/ x (+ (* -0.16666666666666666 (* x y)) (/ x y))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1000000000000.0) {
tmp = x / ((-0.16666666666666666 * (x * y)) + (x / y));
} 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) <= 1000000000000.0d0) then
tmp = x / (((-0.16666666666666666d0) * (x * y)) + (x / y))
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 1000000000000.0) {
tmp = x / ((-0.16666666666666666 * (x * y)) + (x / y));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1000000000000.0: tmp = x / ((-0.16666666666666666 * (x * y)) + (x / y)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1000000000000.0) tmp = Float64(x / Float64(Float64(-0.16666666666666666 * Float64(x * y)) + Float64(x / y))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1000000000000.0) tmp = x / ((-0.16666666666666666 * (x * y)) + (x / y)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1000000000000.0], N[(x / N[(N[(-0.16666666666666666 * N[(x * y), $MachinePrecision]), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 1000000000000:\\
\;\;\;\;\frac{x}{-0.16666666666666666 \cdot \left(x \cdot y\right) + \frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1e12Initial program 85.1%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 72.0%
Taylor expanded in x around 0 54.6%
if 1e12 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 78.1%
Final simplification60.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}
Initial program 88.5%
*-commutative88.5%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= x 2.4e+229) (not (<= x 8.8e+290))) (* x (/ y x)) (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if ((x <= 2.4e+229) || !(x <= 8.8e+290)) {
tmp = x * (y / 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 ((x <= 2.4d+229) .or. (.not. (x <= 8.8d+290))) then
tmp = x * (y / x)
else
tmp = (x * y) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= 2.4e+229) || !(x <= 8.8e+290)) {
tmp = x * (y / x);
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= 2.4e+229) or not (x <= 8.8e+290): tmp = x * (y / x) else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if ((x <= 2.4e+229) || !(x <= 8.8e+290)) tmp = Float64(x * Float64(y / x)); else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= 2.4e+229) || ~((x <= 8.8e+290))) tmp = x * (y / x); else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, 2.4e+229], N[Not[LessEqual[x, 8.8e+290]], $MachinePrecision]], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{+229} \lor \neg \left(x \leq 8.8 \cdot 10^{+290}\right):\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if x < 2.4000000000000001e229 or 8.7999999999999999e290 < x Initial program 87.9%
*-commutative87.9%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 45.2%
associate-/l*57.3%
associate-/r/68.0%
Simplified68.0%
Taylor expanded in x around 0 55.3%
if 2.4000000000000001e229 < x < 8.7999999999999999e290Initial program 99.9%
Taylor expanded in y around 0 54.9%
Taylor expanded in x around 0 25.3%
*-commutative25.3%
Simplified25.3%
Final simplification53.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 88.5%
*-commutative88.5%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 45.7%
associate-/l*57.1%
associate-/r/67.3%
Simplified67.3%
Taylor expanded in x around 0 53.4%
Final simplification53.4%
(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 88.5%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 57.1%
Taylor expanded in x around 0 29.8%
Final simplification29.8%
(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 2024026
(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))