
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (if (<= (/ (sinh y) y) 1.0) (sin x) (/ (* x (sinh y)) y)))
double code(double x, double y) {
double tmp;
if ((sinh(y) / y) <= 1.0) {
tmp = sin(x);
} else {
tmp = (x * sinh(y)) / 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) / y) <= 1.0d0) then
tmp = sin(x)
else
tmp = (x * sinh(y)) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) / y) <= 1.0) {
tmp = Math.sin(x);
} else {
tmp = (x * Math.sinh(y)) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) / y) <= 1.0: tmp = math.sin(x) else: tmp = (x * math.sinh(y)) / y return tmp
function code(x, y) tmp = 0.0 if (Float64(sinh(y) / y) <= 1.0) tmp = sin(x); else tmp = Float64(Float64(x * sinh(y)) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) / y) <= 1.0) tmp = sin(x); else tmp = (x * sinh(y)) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision], 1.0], N[Sin[x], $MachinePrecision], N[(N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sinh y}{y} \leq 1:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{y}\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1Initial program 100.0%
Taylor expanded in y around 0 100.0%
if 1 < (/.f64 (sinh.f64 y) y) Initial program 99.9%
add-log-exp96.6%
*-un-lft-identity96.6%
log-prod96.6%
metadata-eval96.6%
add-log-exp99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in x around 0 78.3%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 1.0) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.0) {
tmp = sin(x);
} else {
tmp = x * 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 = sinh(y) / y
if (t_0 <= 1.0d0) then
tmp = sin(x)
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sinh(y) / y;
double tmp;
if (t_0 <= 1.0) {
tmp = Math.sin(x);
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y): t_0 = math.sinh(y) / y tmp = 0 if t_0 <= 1.0: tmp = math.sin(x) else: tmp = x * t_0 return tmp
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (t_0 <= 1.0) tmp = sin(x); else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = sinh(y) / y; tmp = 0.0; if (t_0 <= 1.0) tmp = sin(x); else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, 1.0], N[Sin[x], $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;t\_0 \leq 1:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1Initial program 100.0%
Taylor expanded in y around 0 100.0%
if 1 < (/.f64 (sinh.f64 y) y) Initial program 99.9%
Taylor expanded in x around 0 78.3%
(FPCore (x y)
:precision binary64
(if (<= y 1600.0)
(sin x)
(if (<= y 3.9e+88)
(* -0.16666666666666666 (pow x 3.0))
(+ x (* (* y y) (* x 0.16666666666666666))))))
double code(double x, double y) {
double tmp;
if (y <= 1600.0) {
tmp = sin(x);
} else if (y <= 3.9e+88) {
tmp = -0.16666666666666666 * pow(x, 3.0);
} else {
tmp = x + ((y * y) * (x * 0.16666666666666666));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1600.0d0) then
tmp = sin(x)
else if (y <= 3.9d+88) then
tmp = (-0.16666666666666666d0) * (x ** 3.0d0)
else
tmp = x + ((y * y) * (x * 0.16666666666666666d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1600.0) {
tmp = Math.sin(x);
} else if (y <= 3.9e+88) {
tmp = -0.16666666666666666 * Math.pow(x, 3.0);
} else {
tmp = x + ((y * y) * (x * 0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1600.0: tmp = math.sin(x) elif y <= 3.9e+88: tmp = -0.16666666666666666 * math.pow(x, 3.0) else: tmp = x + ((y * y) * (x * 0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1600.0) tmp = sin(x); elseif (y <= 3.9e+88) tmp = Float64(-0.16666666666666666 * (x ^ 3.0)); else tmp = Float64(x + Float64(Float64(y * y) * Float64(x * 0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1600.0) tmp = sin(x); elseif (y <= 3.9e+88) tmp = -0.16666666666666666 * (x ^ 3.0); else tmp = x + ((y * y) * (x * 0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1600.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 3.9e+88], N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * y), $MachinePrecision] * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1600:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{+88}:\\
\;\;\;\;-0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot y\right) \cdot \left(x \cdot 0.16666666666666666\right)\\
\end{array}
\end{array}
if y < 1600Initial program 100.0%
Taylor expanded in y around 0 65.2%
if 1600 < y < 3.9000000000000001e88Initial program 100.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 13.5%
distribute-rgt-in13.5%
*-lft-identity13.5%
associate-*l*13.5%
pow-plus13.5%
metadata-eval13.5%
Simplified13.5%
Taylor expanded in x around inf 13.1%
if 3.9000000000000001e88 < y Initial program 100.0%
Taylor expanded in y around 0 59.7%
associate-*r*59.7%
Simplified59.7%
Taylor expanded in x around 0 58.7%
*-commutative58.7%
*-commutative58.7%
associate-*r*58.7%
Simplified58.7%
unpow258.7%
Applied egg-rr58.7%
Taylor expanded in x around 0 58.7%
(FPCore (x y) :precision binary64 (if (<= y 1.5e-10) (sin x) (+ x (* (* y y) (* x 0.16666666666666666)))))
double code(double x, double y) {
double tmp;
if (y <= 1.5e-10) {
tmp = sin(x);
} else {
tmp = x + ((y * y) * (x * 0.16666666666666666));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.5d-10) then
tmp = sin(x)
else
tmp = x + ((y * y) * (x * 0.16666666666666666d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.5e-10) {
tmp = Math.sin(x);
} else {
tmp = x + ((y * y) * (x * 0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.5e-10: tmp = math.sin(x) else: tmp = x + ((y * y) * (x * 0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.5e-10) tmp = sin(x); else tmp = Float64(x + Float64(Float64(y * y) * Float64(x * 0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.5e-10) tmp = sin(x); else tmp = x + ((y * y) * (x * 0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.5e-10], N[Sin[x], $MachinePrecision], N[(x + N[(N[(y * y), $MachinePrecision] * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{-10}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot y\right) \cdot \left(x \cdot 0.16666666666666666\right)\\
\end{array}
\end{array}
if y < 1.5e-10Initial program 100.0%
Taylor expanded in y around 0 65.5%
if 1.5e-10 < y Initial program 100.0%
Taylor expanded in y around 0 45.4%
associate-*r*45.4%
Simplified45.4%
Taylor expanded in x around 0 44.3%
*-commutative44.3%
*-commutative44.3%
associate-*r*44.3%
Simplified44.3%
unpow244.3%
Applied egg-rr44.3%
Taylor expanded in x around 0 43.9%
(FPCore (x y) :precision binary64 (+ x (* (* y y) (* x 0.16666666666666666))))
double code(double x, double y) {
return x + ((y * y) * (x * 0.16666666666666666));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((y * y) * (x * 0.16666666666666666d0))
end function
public static double code(double x, double y) {
return x + ((y * y) * (x * 0.16666666666666666));
}
def code(x, y): return x + ((y * y) * (x * 0.16666666666666666))
function code(x, y) return Float64(x + Float64(Float64(y * y) * Float64(x * 0.16666666666666666))) end
function tmp = code(x, y) tmp = x + ((y * y) * (x * 0.16666666666666666)); end
code[x_, y_] := N[(x + N[(N[(y * y), $MachinePrecision] * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot y\right) \cdot \left(x \cdot 0.16666666666666666\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 74.7%
associate-*r*74.7%
Simplified74.7%
Taylor expanded in x around 0 65.1%
*-commutative65.1%
*-commutative65.1%
associate-*r*65.1%
Simplified65.1%
unpow265.1%
Applied egg-rr65.1%
Taylor expanded in x around 0 47.3%
(FPCore (x y) :precision binary64 (if (<= x 4100000.0) x 0.5))
double code(double x, double y) {
double tmp;
if (x <= 4100000.0) {
tmp = x;
} else {
tmp = 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 4100000.0d0) then
tmp = x
else
tmp = 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 4100000.0) {
tmp = x;
} else {
tmp = 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 4100000.0: tmp = x else: tmp = 0.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 4100000.0) tmp = x; else tmp = 0.5; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4100000.0) tmp = x; else tmp = 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 4100000.0], x, 0.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4100000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < 4.1e6Initial program 100.0%
Taylor expanded in x around 0 81.4%
Taylor expanded in y around 0 31.9%
if 4.1e6 < x Initial program 100.0%
add-log-exp99.5%
*-un-lft-identity99.5%
log-prod99.5%
metadata-eval99.5%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/99.7%
Simplified99.7%
Applied egg-rr8.7%
(FPCore (x y) :precision binary64 0.5)
double code(double x, double y) {
return 0.5;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.5d0
end function
public static double code(double x, double y) {
return 0.5;
}
def code(x, y): return 0.5
function code(x, y) return 0.5 end
function tmp = code(x, y) tmp = 0.5; end
code[x_, y_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
Simplified89.5%
Applied egg-rr4.9%
(FPCore (x y) :precision binary64 0.3333333333333333)
double code(double x, double y) {
return 0.3333333333333333;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.3333333333333333d0
end function
public static double code(double x, double y) {
return 0.3333333333333333;
}
def code(x, y): return 0.3333333333333333
function code(x, y) return 0.3333333333333333 end
function tmp = code(x, y) tmp = 0.3333333333333333; end
code[x_, y_] := 0.3333333333333333
\begin{array}{l}
\\
0.3333333333333333
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
Simplified89.5%
Applied egg-rr4.7%
(FPCore (x y) :precision binary64 0.25)
double code(double x, double y) {
return 0.25;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.25d0
end function
public static double code(double x, double y) {
return 0.25;
}
def code(x, y): return 0.25
function code(x, y) return 0.25 end
function tmp = code(x, y) tmp = 0.25; end
code[x_, y_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
Simplified89.5%
Applied egg-rr4.6%
(FPCore (x y) :precision binary64 0.16666666666666666)
double code(double x, double y) {
return 0.16666666666666666;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.16666666666666666d0
end function
public static double code(double x, double y) {
return 0.16666666666666666;
}
def code(x, y): return 0.16666666666666666
function code(x, y) return 0.16666666666666666 end
function tmp = code(x, y) tmp = 0.16666666666666666; end
code[x_, y_] := 0.16666666666666666
\begin{array}{l}
\\
0.16666666666666666
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
Simplified89.5%
Applied egg-rr4.4%
(FPCore (x y) :precision binary64 0.027777777777777776)
double code(double x, double y) {
return 0.027777777777777776;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.027777777777777776d0
end function
public static double code(double x, double y) {
return 0.027777777777777776;
}
def code(x, y): return 0.027777777777777776
function code(x, y) return 0.027777777777777776 end
function tmp = code(x, y) tmp = 0.027777777777777776; end
code[x_, y_] := 0.027777777777777776
\begin{array}{l}
\\
0.027777777777777776
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
Simplified89.5%
Applied egg-rr4.1%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
Simplified89.5%
Applied egg-rr5.0%
(FPCore (x y) :precision binary64 -3.0)
double code(double x, double y) {
return -3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -3.0d0
end function
public static double code(double x, double y) {
return -3.0;
}
def code(x, y): return -3.0
function code(x, y) return -3.0 end
function tmp = code(x, y) tmp = -3.0; end
code[x_, y_] := -3.0
\begin{array}{l}
\\
-3
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
Simplified89.5%
Applied egg-rr4.3%
herbie shell --seed 2024130
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))