
(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) (/ (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 89.1%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 200000.0) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 200000.0) {
tmp = y * (sin(x) / 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) <= 200000.0d0) then
tmp = y * (sin(x) / 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) <= 200000.0) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 200000.0: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 200000.0) tmp = Float64(y * Float64(sin(x) / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 200000.0) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 200000.0], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 200000:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2e5Initial program 85.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 50.4%
associate-/l*65.3%
Simplified65.3%
if 2e5 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 72.1%
clear-num72.1%
un-div-inv72.1%
Applied egg-rr72.1%
associate-/r/72.1%
*-inverses72.1%
*-lft-identity72.1%
Simplified72.1%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-69) (/ x (/ x y)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-69) {
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) <= 2d-69) 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) <= 2e-69) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-69: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-69) 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) <= 2e-69) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-69], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1.9999999999999999e-69Initial program 83.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 72.0%
Taylor expanded in x around 0 57.9%
clear-num59.4%
un-div-inv58.4%
Applied egg-rr58.4%
if 1.9999999999999999e-69 < (sinh.f64 y) Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 67.0%
clear-num67.0%
un-div-inv67.0%
Applied egg-rr67.0%
associate-/r/67.0%
*-inverses67.0%
*-lft-identity67.0%
Simplified67.0%
(FPCore (x y) :precision binary64 (* x (/ (sinh y) x)))
double code(double x, double y) {
return x * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sinh(y) / x)
end function
public static double code(double x, double y) {
return x * (Math.sinh(y) / x);
}
def code(x, y): return x * (math.sinh(y) / x)
function code(x, y) return Float64(x * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = x * (sinh(y) / x); end
code[x_, y_] := N[(x * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 89.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 71.6%
(FPCore (x y) :precision binary64 (if (<= y 1.06e-43) (/ x (/ x y)) (* (+ x (* -0.16666666666666666 (* x (* x x)))) (/ y x))))
double code(double x, double y) {
double tmp;
if (y <= 1.06e-43) {
tmp = x / (x / y);
} else {
tmp = (x + (-0.16666666666666666 * (x * (x * 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 (y <= 1.06d-43) then
tmp = x / (x / y)
else
tmp = (x + ((-0.16666666666666666d0) * (x * (x * x)))) * (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.06e-43) {
tmp = x / (x / y);
} else {
tmp = (x + (-0.16666666666666666 * (x * (x * x)))) * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.06e-43: tmp = x / (x / y) else: tmp = (x + (-0.16666666666666666 * (x * (x * x)))) * (y / x) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.06e-43) tmp = Float64(x / Float64(x / y)); else tmp = Float64(Float64(x + Float64(-0.16666666666666666 * Float64(x * Float64(x * x)))) * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.06e-43) tmp = x / (x / y); else tmp = (x + (-0.16666666666666666 * (x * (x * x)))) * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.06e-43], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(-0.16666666666666666 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.06 \cdot 10^{-43}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\left(x + -0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \frac{y}{x}\\
\end{array}
\end{array}
if y < 1.05999999999999994e-43Initial program 84.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 72.4%
Taylor expanded in x around 0 57.3%
clear-num58.8%
un-div-inv57.8%
Applied egg-rr57.8%
if 1.05999999999999994e-43 < y Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 40.5%
Taylor expanded in x around 0 48.0%
distribute-rgt-in48.0%
*-lft-identity48.0%
associate-*l*48.0%
unpow248.0%
unpow348.0%
Simplified48.0%
unpow348.0%
pow248.0%
Applied egg-rr48.0%
unpow248.0%
Applied egg-rr48.0%
Final simplification54.7%
(FPCore (x y) :precision binary64 (if (<= y 6.8e+138) (* x (/ 1.0 (/ x y))) (if (<= y 5.6e+216) (* -0.16666666666666666 (* y (* x x))) (* x (/ y x)))))
double code(double x, double y) {
double tmp;
if (y <= 6.8e+138) {
tmp = x * (1.0 / (x / y));
} else if (y <= 5.6e+216) {
tmp = -0.16666666666666666 * (y * (x * 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 (y <= 6.8d+138) then
tmp = x * (1.0d0 / (x / y))
else if (y <= 5.6d+216) then
tmp = (-0.16666666666666666d0) * (y * (x * x))
else
tmp = x * (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 6.8e+138) {
tmp = x * (1.0 / (x / y));
} else if (y <= 5.6e+216) {
tmp = -0.16666666666666666 * (y * (x * x));
} else {
tmp = x * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 6.8e+138: tmp = x * (1.0 / (x / y)) elif y <= 5.6e+216: tmp = -0.16666666666666666 * (y * (x * x)) else: tmp = x * (y / x) return tmp
function code(x, y) tmp = 0.0 if (y <= 6.8e+138) tmp = Float64(x * Float64(1.0 / Float64(x / y))); elseif (y <= 5.6e+216) tmp = Float64(-0.16666666666666666 * Float64(y * Float64(x * x))); else tmp = Float64(x * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 6.8e+138) tmp = x * (1.0 / (x / y)); elseif (y <= 5.6e+216) tmp = -0.16666666666666666 * (y * (x * x)); else tmp = x * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 6.8e+138], N[(x * N[(1.0 / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.6e+216], N[(-0.16666666666666666 * N[(y * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.8 \cdot 10^{+138}:\\
\;\;\;\;x \cdot \frac{1}{\frac{x}{y}}\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+216}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(y \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if y < 6.80000000000000022e138Initial program 86.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 67.3%
clear-num66.7%
associate-/r/67.3%
Applied egg-rr67.3%
Taylor expanded in x around 0 52.0%
associate-/r/53.3%
Applied egg-rr53.3%
if 6.80000000000000022e138 < y < 5.59999999999999963e216Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 23.5%
Taylor expanded in x around 0 42.7%
distribute-rgt-in42.7%
*-lft-identity42.7%
associate-*l*42.7%
unpow242.7%
unpow342.7%
Simplified42.7%
Taylor expanded in x around inf 21.3%
unpow242.7%
Applied egg-rr21.3%
if 5.59999999999999963e216 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 55.6%
Taylor expanded in x around 0 54.2%
Final simplification50.2%
(FPCore (x y) :precision binary64 (if (<= y 7.8e+138) (/ x (/ x y)) (if (<= y 6.5e+216) (* -0.16666666666666666 (* y (* x x))) (* x (/ y x)))))
double code(double x, double y) {
double tmp;
if (y <= 7.8e+138) {
tmp = x / (x / y);
} else if (y <= 6.5e+216) {
tmp = -0.16666666666666666 * (y * (x * 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 (y <= 7.8d+138) then
tmp = x / (x / y)
else if (y <= 6.5d+216) then
tmp = (-0.16666666666666666d0) * (y * (x * x))
else
tmp = x * (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 7.8e+138) {
tmp = x / (x / y);
} else if (y <= 6.5e+216) {
tmp = -0.16666666666666666 * (y * (x * x));
} else {
tmp = x * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7.8e+138: tmp = x / (x / y) elif y <= 6.5e+216: tmp = -0.16666666666666666 * (y * (x * x)) else: tmp = x * (y / x) return tmp
function code(x, y) tmp = 0.0 if (y <= 7.8e+138) tmp = Float64(x / Float64(x / y)); elseif (y <= 6.5e+216) tmp = Float64(-0.16666666666666666 * Float64(y * Float64(x * x))); else tmp = Float64(x * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7.8e+138) tmp = x / (x / y); elseif (y <= 6.5e+216) tmp = -0.16666666666666666 * (y * (x * x)); else tmp = x * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7.8e+138], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.5e+216], N[(-0.16666666666666666 * N[(y * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.8 \cdot 10^{+138}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+216}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(y \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if y < 7.7999999999999996e138Initial program 86.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 67.3%
Taylor expanded in x around 0 52.1%
clear-num53.3%
un-div-inv52.0%
Applied egg-rr52.0%
if 7.7999999999999996e138 < y < 6.50000000000000029e216Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 23.5%
Taylor expanded in x around 0 42.7%
distribute-rgt-in42.7%
*-lft-identity42.7%
associate-*l*42.7%
unpow242.7%
unpow342.7%
Simplified42.7%
Taylor expanded in x around inf 21.3%
unpow242.7%
Applied egg-rr21.3%
if 6.50000000000000029e216 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 55.6%
Taylor expanded in x around 0 54.2%
Final simplification49.2%
(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%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 62.3%
Taylor expanded in x around 0 49.3%
(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 x around 0 71.6%
Taylor expanded in y around 0 25.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}
herbie shell --seed 2024181
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (* (sin x) (/ (sinh y) x)))
(/ (* (sin x) (sinh y)) x))