
(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 83.6%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= (sinh y) (- INFINITY)) (not (<= (sinh y) 1.5e-22))) (* (sinh y) (+ 1.0 (* (* x x) -0.16666666666666666))) (* (/ (sin x) x) y)))
double code(double x, double y) {
double tmp;
if ((sinh(y) <= -((double) INFINITY)) || !(sinh(y) <= 1.5e-22)) {
tmp = sinh(y) * (1.0 + ((x * x) * -0.16666666666666666));
} 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) <= 1.5e-22)) {
tmp = Math.sinh(y) * (1.0 + ((x * x) * -0.16666666666666666));
} 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) <= 1.5e-22): tmp = math.sinh(y) * (1.0 + ((x * x) * -0.16666666666666666)) else: tmp = (math.sin(x) / x) * y return tmp
function code(x, y) tmp = 0.0 if ((sinh(y) <= Float64(-Inf)) || !(sinh(y) <= 1.5e-22)) tmp = Float64(sinh(y) * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))); 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) <= 1.5e-22))) tmp = sinh(y) * (1.0 + ((x * x) * -0.16666666666666666)); 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], 1.5e-22]], $MachinePrecision]], N[(N[Sinh[y], $MachinePrecision] * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $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 1.5 \cdot 10^{-22}\right):\\
\;\;\;\;\sinh y \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\end{array}
\end{array}
if (sinh.f64 y) < -inf.0 or 1.5e-22 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.6%
*-commutative77.6%
unpow277.6%
Simplified77.6%
if -inf.0 < (sinh.f64 y) < 1.5e-22Initial program 67.9%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 99.7%
Final simplification88.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) (- INFINITY)) (sinh y) (if (<= (sinh y) 1.5e-22) (* (/ (sin x) x) y) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -((double) INFINITY)) {
tmp = sinh(y);
} else if (sinh(y) <= 1.5e-22) {
tmp = (sin(x) / x) * y;
} else {
tmp = sinh(y);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= -Double.POSITIVE_INFINITY) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 1.5e-22) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -math.inf: tmp = math.sinh(y) elif math.sinh(y) <= 1.5e-22: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= Float64(-Inf)) tmp = sinh(y); elseif (sinh(y) <= 1.5e-22) 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) <= -Inf) tmp = sinh(y); elseif (sinh(y) <= 1.5e-22) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], (-Infinity)], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 1.5e-22], 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 -\infty:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 1.5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -inf.0 or 1.5e-22 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 73.6%
if -inf.0 < (sinh.f64 y) < 1.5e-22Initial program 67.9%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 99.7%
Final simplification87.0%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -1e-89) (sinh y) (if (<= (sinh y) 1.5e-22) (/ x (/ x y)) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -1e-89) {
tmp = sinh(y);
} else if (sinh(y) <= 1.5e-22) {
tmp = 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) <= (-1d-89)) then
tmp = sinh(y)
else if (sinh(y) <= 1.5d-22) then
tmp = 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) <= -1e-89) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 1.5e-22) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -1e-89: tmp = math.sinh(y) elif math.sinh(y) <= 1.5e-22: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -1e-89) tmp = sinh(y); elseif (sinh(y) <= 1.5e-22) tmp = Float64(x / Float64(x / y)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= -1e-89) tmp = sinh(y); elseif (sinh(y) <= 1.5e-22) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -1e-89], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 1.5e-22], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -1 \cdot 10^{-89}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 1.5 \cdot 10^{-22}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -1.00000000000000004e-89 or 1.5e-22 < (sinh.f64 y) Initial program 98.8%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 71.2%
if -1.00000000000000004e-89 < (sinh.f64 y) < 1.5e-22Initial program 62.6%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in y around 0 62.6%
associate-/l*99.8%
Simplified99.8%
associate-/l*62.6%
clear-num61.5%
associate-/r/62.6%
*-commutative62.6%
Applied egg-rr62.6%
Taylor expanded in x around 0 13.6%
associate-*l/13.6%
*-un-lft-identity13.6%
*-commutative13.6%
associate-/l*73.9%
Applied egg-rr73.9%
Final simplification72.3%
(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 83.6%
associate-*r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= x 1.15e-23) (* x (/ y x)) (sqrt (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 1.15e-23) {
tmp = x * (y / x);
} else {
tmp = sqrt((y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1.15d-23) then
tmp = x * (y / x)
else
tmp = sqrt((y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.15e-23) {
tmp = x * (y / x);
} else {
tmp = Math.sqrt((y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.15e-23: tmp = x * (y / x) else: tmp = math.sqrt((y * y)) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.15e-23) tmp = Float64(x * Float64(y / x)); else tmp = sqrt(Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.15e-23) tmp = x * (y / x); else tmp = sqrt((y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.15e-23], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(y * y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.15 \cdot 10^{-23}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y \cdot y}\\
\end{array}
\end{array}
if x < 1.15000000000000005e-23Initial program 77.7%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 33.3%
Taylor expanded in x around 0 19.5%
associate-/l*38.8%
associate-/r/58.6%
Applied egg-rr58.6%
if 1.15000000000000005e-23 < x Initial program 99.8%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 51.5%
Taylor expanded in x around 0 9.5%
associate-/l*5.4%
*-inverses5.4%
/-rgt-identity5.4%
add-sqr-sqrt2.9%
sqrt-unprod31.5%
Applied egg-rr31.5%
Final simplification51.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ 1.0 y) (* y -0.16666666666666666))))
(if (<= x 6.8e+153)
(* x (/ y x))
(if (<= x 6.6e+180)
(+ (/ 1.0 t_0) (* -0.16666666666666666 (/ (* x x) t_0)))
(/ x (/ x y))))))
double code(double x, double y) {
double t_0 = (1.0 / y) + (y * -0.16666666666666666);
double tmp;
if (x <= 6.8e+153) {
tmp = x * (y / x);
} else if (x <= 6.6e+180) {
tmp = (1.0 / t_0) + (-0.16666666666666666 * ((x * x) / t_0));
} 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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / y) + (y * (-0.16666666666666666d0))
if (x <= 6.8d+153) then
tmp = x * (y / x)
else if (x <= 6.6d+180) then
tmp = (1.0d0 / t_0) + ((-0.16666666666666666d0) * ((x * x) / t_0))
else
tmp = x / (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (1.0 / y) + (y * -0.16666666666666666);
double tmp;
if (x <= 6.8e+153) {
tmp = x * (y / x);
} else if (x <= 6.6e+180) {
tmp = (1.0 / t_0) + (-0.16666666666666666 * ((x * x) / t_0));
} else {
tmp = x / (x / y);
}
return tmp;
}
def code(x, y): t_0 = (1.0 / y) + (y * -0.16666666666666666) tmp = 0 if x <= 6.8e+153: tmp = x * (y / x) elif x <= 6.6e+180: tmp = (1.0 / t_0) + (-0.16666666666666666 * ((x * x) / t_0)) else: tmp = x / (x / y) return tmp
function code(x, y) t_0 = Float64(Float64(1.0 / y) + Float64(y * -0.16666666666666666)) tmp = 0.0 if (x <= 6.8e+153) tmp = Float64(x * Float64(y / x)); elseif (x <= 6.6e+180) tmp = Float64(Float64(1.0 / t_0) + Float64(-0.16666666666666666 * Float64(Float64(x * x) / t_0))); else tmp = Float64(x / Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = (1.0 / y) + (y * -0.16666666666666666); tmp = 0.0; if (x <= 6.8e+153) tmp = x * (y / x); elseif (x <= 6.6e+180) tmp = (1.0 / t_0) + (-0.16666666666666666 * ((x * x) / t_0)); else tmp = x / (x / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 / y), $MachinePrecision] + N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 6.8e+153], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.6e+180], N[(N[(1.0 / t$95$0), $MachinePrecision] + N[(-0.16666666666666666 * N[(N[(x * x), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{y} + y \cdot -0.16666666666666666\\
\mathbf{if}\;x \leq 6.8 \cdot 10^{+153}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{+180}:\\
\;\;\;\;\frac{1}{t_0} + -0.16666666666666666 \cdot \frac{x \cdot x}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\end{array}
\end{array}
if x < 6.7999999999999995e153Initial program 81.5%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 35.8%
Taylor expanded in x around 0 17.2%
associate-/l*33.2%
associate-/r/51.3%
Applied egg-rr51.3%
if 6.7999999999999995e153 < x < 6.59999999999999978e180Initial program 99.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 50.4%
Taylor expanded in x around 0 50.7%
*-commutative50.7%
unpow250.7%
*-commutative50.7%
Simplified50.7%
if 6.59999999999999978e180 < x Initial program 99.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 57.0%
associate-/l*57.1%
Simplified57.1%
associate-/l*57.0%
clear-num56.9%
associate-/r/57.0%
*-commutative57.0%
Applied egg-rr57.0%
Taylor expanded in x around 0 7.8%
associate-*l/7.8%
*-un-lft-identity7.8%
*-commutative7.8%
associate-/l*45.1%
Applied egg-rr45.1%
Final simplification50.6%
(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 83.6%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 38.1%
Taylor expanded in x around 0 16.8%
associate-/l*29.9%
associate-/r/49.6%
Applied egg-rr49.6%
Final simplification49.6%
(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 83.6%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 38.1%
associate-/l*54.5%
Simplified54.5%
Taylor expanded in x around 0 29.9%
Final simplification29.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 2023242
(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))