
(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.9%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -0.2) (sinh y) (if (<= (sinh y) 1e-6) (* (sin x) (/ y x)) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -0.2) {
tmp = sinh(y);
} else if (sinh(y) <= 1e-6) {
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) <= (-0.2d0)) then
tmp = sinh(y)
else if (sinh(y) <= 1d-6) 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) <= -0.2) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 1e-6) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -0.2: tmp = math.sinh(y) elif math.sinh(y) <= 1e-6: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -0.2) tmp = sinh(y); elseif (sinh(y) <= 1e-6) 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) <= -0.2) tmp = sinh(y); elseif (sinh(y) <= 1e-6) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -0.2], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-6], 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 -0.2:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 10^{-6}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -0.20000000000000001 or 9.99999999999999955e-7 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 83.7%
if -0.20000000000000001 < (sinh.f64 y) < 9.99999999999999955e-7Initial program 78.7%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 77.7%
associate-/l*98.9%
associate-/r/98.8%
Simplified98.8%
Final simplification91.6%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -2e-124) (sinh y) (if (<= (sinh y) 4e-30) (* x (/ y x)) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -2e-124) {
tmp = sinh(y);
} else if (sinh(y) <= 4e-30) {
tmp = 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) <= (-2d-124)) then
tmp = sinh(y)
else if (sinh(y) <= 4d-30) then
tmp = 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) <= -2e-124) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 4e-30) {
tmp = x * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -2e-124: tmp = math.sinh(y) elif math.sinh(y) <= 4e-30: tmp = x * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -2e-124) tmp = sinh(y); elseif (sinh(y) <= 4e-30) tmp = Float64(x * Float64(y / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= -2e-124) tmp = sinh(y); elseif (sinh(y) <= 4e-30) tmp = x * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -2e-124], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-30], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -2 \cdot 10^{-124}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 4 \cdot 10^{-30}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -1.99999999999999987e-124 or 4e-30 < (sinh.f64 y) Initial program 98.7%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 76.6%
if -1.99999999999999987e-124 < (sinh.f64 y) < 4e-30Initial program 74.0%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 74.0%
Taylor expanded in x around 0 23.7%
associate-/l*49.6%
associate-/r/73.5%
Applied egg-rr73.5%
Final simplification75.4%
(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.9%
associate-*r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y -0.06)
(sinh y)
(if (<= y 0.00082)
(/ y (/ x (sin x)))
(if (<= y 8.6e+89)
(* (sinh y) (+ 1.0 (* (* x x) -0.16666666666666666)))
(sinh y)))))
double code(double x, double y) {
double tmp;
if (y <= -0.06) {
tmp = sinh(y);
} else if (y <= 0.00082) {
tmp = y / (x / sin(x));
} else if (y <= 8.6e+89) {
tmp = sinh(y) * (1.0 + ((x * x) * -0.16666666666666666));
} 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 (y <= (-0.06d0)) then
tmp = sinh(y)
else if (y <= 0.00082d0) then
tmp = y / (x / sin(x))
else if (y <= 8.6d+89) then
tmp = sinh(y) * (1.0d0 + ((x * x) * (-0.16666666666666666d0)))
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -0.06) {
tmp = Math.sinh(y);
} else if (y <= 0.00082) {
tmp = y / (x / Math.sin(x));
} else if (y <= 8.6e+89) {
tmp = Math.sinh(y) * (1.0 + ((x * x) * -0.16666666666666666));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -0.06: tmp = math.sinh(y) elif y <= 0.00082: tmp = y / (x / math.sin(x)) elif y <= 8.6e+89: tmp = math.sinh(y) * (1.0 + ((x * x) * -0.16666666666666666)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= -0.06) tmp = sinh(y); elseif (y <= 0.00082) tmp = Float64(y / Float64(x / sin(x))); elseif (y <= 8.6e+89) tmp = Float64(sinh(y) * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -0.06) tmp = sinh(y); elseif (y <= 0.00082) tmp = y / (x / sin(x)); elseif (y <= 8.6e+89) tmp = sinh(y) * (1.0 + ((x * x) * -0.16666666666666666)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -0.06], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 0.00082], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.6e+89], N[(N[Sinh[y], $MachinePrecision] * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.06:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;y \leq 0.00082:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{+89}:\\
\;\;\;\;\sinh y \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < -0.059999999999999998 or 8.6000000000000003e89 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 87.5%
if -0.059999999999999998 < y < 8.1999999999999998e-4Initial program 78.7%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 77.7%
associate-/l*98.9%
Simplified98.9%
if 8.1999999999999998e-4 < y < 8.6000000000000003e89Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 89.5%
*-commutative89.5%
unpow289.5%
Simplified89.5%
Final simplification93.6%
(FPCore (x y) :precision binary64 (if (<= y -0.06) (sinh y) (if (<= y 9.6e-5) (/ y (/ x (sin x))) (sinh y))))
double code(double x, double y) {
double tmp;
if (y <= -0.06) {
tmp = sinh(y);
} else if (y <= 9.6e-5) {
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 (y <= (-0.06d0)) then
tmp = sinh(y)
else if (y <= 9.6d-5) 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 (y <= -0.06) {
tmp = Math.sinh(y);
} else if (y <= 9.6e-5) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -0.06: tmp = math.sinh(y) elif y <= 9.6e-5: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= -0.06) tmp = sinh(y); elseif (y <= 9.6e-5) 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 (y <= -0.06) tmp = sinh(y); elseif (y <= 9.6e-5) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -0.06], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 9.6e-5], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.06:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;y \leq 9.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < -0.059999999999999998 or 9.6000000000000002e-5 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 83.7%
if -0.059999999999999998 < y < 9.6000000000000002e-5Initial program 78.7%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 77.7%
associate-/l*98.9%
Simplified98.9%
Final simplification91.6%
(FPCore (x y) :precision binary64 (if (<= y 1.35e+147) (* x (/ y x)) (sqrt (* y y))))
double code(double x, double y) {
double tmp;
if (y <= 1.35e+147) {
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 (y <= 1.35d+147) 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 (y <= 1.35e+147) {
tmp = x * (y / x);
} else {
tmp = Math.sqrt((y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.35e+147: tmp = x * (y / x) else: tmp = math.sqrt((y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.35e+147) 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 (y <= 1.35e+147) tmp = x * (y / x); else tmp = sqrt((y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.35e+147], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(y * y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+147}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y \cdot y}\\
\end{array}
\end{array}
if y < 1.34999999999999999e147Initial program 87.4%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 48.2%
Taylor expanded in x around 0 23.4%
associate-/l*31.3%
associate-/r/50.9%
Applied egg-rr50.9%
if 1.34999999999999999e147 < y Initial program 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in y around 0 6.1%
Taylor expanded in x around 0 14.6%
associate-/l*6.0%
*-inverses6.0%
/-rgt-identity6.0%
add-sqr-sqrt6.0%
sqrt-unprod81.5%
Applied egg-rr81.5%
Final simplification54.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 88.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 42.9%
Taylor expanded in x around 0 22.3%
associate-/l*28.2%
associate-/r/51.1%
Applied egg-rr51.1%
Final simplification51.1%
(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.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 42.9%
associate-/l*54.0%
Simplified54.0%
Taylor expanded in x around 0 28.2%
Final simplification28.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 2023182
(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))