
(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 10 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.3%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= (sinh y) -4e-7)
(sinh y)
(if (<= (sinh y) 0.02)
(* (/ (sin x) x) y)
(* (sinh y) (+ 1.0 (* (* x x) -0.16666666666666666))))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -4e-7) {
tmp = sinh(y);
} else if (sinh(y) <= 0.02) {
tmp = (sin(x) / x) * y;
} else {
tmp = sinh(y) * (1.0 + ((x * 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 (sinh(y) <= (-4d-7)) then
tmp = sinh(y)
else if (sinh(y) <= 0.02d0) then
tmp = (sin(x) / x) * y
else
tmp = sinh(y) * (1.0d0 + ((x * x) * (-0.16666666666666666d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= -4e-7) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 0.02) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y) * (1.0 + ((x * x) * -0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -4e-7: tmp = math.sinh(y) elif math.sinh(y) <= 0.02: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) * (1.0 + ((x * x) * -0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -4e-7) tmp = sinh(y); elseif (sinh(y) <= 0.02) tmp = Float64(Float64(sin(x) / x) * y); else tmp = Float64(sinh(y) * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= -4e-7) tmp = sinh(y); elseif (sinh(y) <= 0.02) tmp = (sin(x) / x) * y; else tmp = sinh(y) * (1.0 + ((x * x) * -0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -4e-7], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 0.02], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[(N[Sinh[y], $MachinePrecision] * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -4 \cdot 10^{-7}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 0.02:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\
\end{array}
\end{array}
if (sinh.f64 y) < -3.9999999999999998e-7Initial program 99.6%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 83.8%
if -3.9999999999999998e-7 < (sinh.f64 y) < 0.0200000000000000004Initial program 78.4%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 98.9%
if 0.0200000000000000004 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 80.0%
*-commutative80.0%
unpow280.0%
Simplified80.0%
Final simplification91.2%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -4e-7) (sinh y) (if (<= (sinh y) 0.02) (* (sin x) (/ y x)) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -4e-7) {
tmp = sinh(y);
} else if (sinh(y) <= 0.02) {
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) <= (-4d-7)) then
tmp = sinh(y)
else if (sinh(y) <= 0.02d0) 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) <= -4e-7) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 0.02) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -4e-7: tmp = math.sinh(y) elif math.sinh(y) <= 0.02: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -4e-7) tmp = sinh(y); elseif (sinh(y) <= 0.02) 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) <= -4e-7) tmp = sinh(y); elseif (sinh(y) <= 0.02) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -4e-7], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 0.02], 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 -4 \cdot 10^{-7}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 0.02:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -3.9999999999999998e-7 or 0.0200000000000000004 < (sinh.f64 y) Initial program 99.7%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 78.8%
if -3.9999999999999998e-7 < (sinh.f64 y) < 0.0200000000000000004Initial program 78.4%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 77.4%
associate-/l*98.8%
associate-/r/98.8%
Simplified98.8%
Final simplification89.6%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -4e-7) (sinh y) (if (<= (sinh y) 0.02) (* (/ (sin x) x) y) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -4e-7) {
tmp = sinh(y);
} else if (sinh(y) <= 0.02) {
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) <= (-4d-7)) then
tmp = sinh(y)
else if (sinh(y) <= 0.02d0) 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) <= -4e-7) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 0.02) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -4e-7: tmp = math.sinh(y) elif math.sinh(y) <= 0.02: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -4e-7) tmp = sinh(y); elseif (sinh(y) <= 0.02) 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) <= -4e-7) tmp = sinh(y); elseif (sinh(y) <= 0.02) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -4e-7], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 0.02], 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 -4 \cdot 10^{-7}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 0.02:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -3.9999999999999998e-7 or 0.0200000000000000004 < (sinh.f64 y) Initial program 99.7%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 78.8%
if -3.9999999999999998e-7 < (sinh.f64 y) < 0.0200000000000000004Initial program 78.4%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 98.9%
Final simplification89.6%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -4e-7) (sinh y) (if (<= (sinh y) 2e-50) (/ x (/ x y)) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -4e-7) {
tmp = sinh(y);
} else if (sinh(y) <= 2e-50) {
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) <= (-4d-7)) then
tmp = sinh(y)
else if (sinh(y) <= 2d-50) 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) <= -4e-7) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 2e-50) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -4e-7: tmp = math.sinh(y) elif math.sinh(y) <= 2e-50: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -4e-7) tmp = sinh(y); elseif (sinh(y) <= 2e-50) 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) <= -4e-7) tmp = sinh(y); elseif (sinh(y) <= 2e-50) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -4e-7], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-50], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -4 \cdot 10^{-7}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 2 \cdot 10^{-50}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -3.9999999999999998e-7 or 2.00000000000000002e-50 < (sinh.f64 y) Initial program 99.8%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 76.9%
if -3.9999999999999998e-7 < (sinh.f64 y) < 2.00000000000000002e-50Initial program 77.3%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 77.2%
associate-/l*99.7%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in x around 0 70.5%
*-commutative70.5%
clear-num72.5%
un-div-inv72.6%
Applied egg-rr72.6%
Final simplification74.7%
(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.3%
associate-*r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y 4.9e+188) (* x (/ -1.0 (/ (- x) y))) (sqrt (* y y))))
double code(double x, double y) {
double tmp;
if (y <= 4.9e+188) {
tmp = x * (-1.0 / (-x / y));
} 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 <= 4.9d+188) then
tmp = x * ((-1.0d0) / (-x / y))
else
tmp = sqrt((y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4.9e+188) {
tmp = x * (-1.0 / (-x / y));
} else {
tmp = Math.sqrt((y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.9e+188: tmp = x * (-1.0 / (-x / y)) else: tmp = math.sqrt((y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 4.9e+188) tmp = Float64(x * Float64(-1.0 / Float64(Float64(-x) / y))); else tmp = sqrt(Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.9e+188) tmp = x * (-1.0 / (-x / y)); else tmp = sqrt((y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.9e+188], N[(x * N[(-1.0 / N[((-x) / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(y * y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.9 \cdot 10^{+188}:\\
\;\;\;\;x \cdot \frac{-1}{\frac{-x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y \cdot y}\\
\end{array}
\end{array}
if y < 4.9e188Initial program 86.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 48.5%
associate-/l*61.4%
associate-/r/73.7%
Simplified73.7%
Taylor expanded in x around 0 56.0%
*-commutative56.0%
clear-num57.1%
un-div-inv55.5%
Applied egg-rr55.5%
frac-2neg55.5%
div-inv57.1%
distribute-neg-frac57.1%
Applied egg-rr57.1%
if 4.9e188 < y Initial program 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in y around 0 6.2%
associate-/l*6.2%
associate-/r/48.7%
Simplified48.7%
Taylor expanded in x around 0 48.5%
add-sqr-sqrt48.5%
sqrt-unprod76.9%
pow276.9%
*-commutative76.9%
Applied egg-rr76.9%
*-commutative76.9%
associate-/r/76.9%
*-inverses76.9%
/-rgt-identity76.9%
unpow276.9%
Simplified76.9%
Final simplification59.1%
(FPCore (x y) :precision binary64 (* x (/ -1.0 (/ (- x) y))))
double code(double x, double y) {
return x * (-1.0 / (-x / y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * ((-1.0d0) / (-x / y))
end function
public static double code(double x, double y) {
return x * (-1.0 / (-x / y));
}
def code(x, y): return x * (-1.0 / (-x / y))
function code(x, y) return Float64(x * Float64(-1.0 / Float64(Float64(-x) / y))) end
function tmp = code(x, y) tmp = x * (-1.0 / (-x / y)); end
code[x_, y_] := N[(x * N[(-1.0 / N[((-x) / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{-1}{\frac{-x}{y}}
\end{array}
Initial program 88.3%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 44.2%
associate-/l*55.8%
associate-/r/71.2%
Simplified71.2%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
clear-num56.2%
un-div-inv54.8%
Applied egg-rr54.8%
frac-2neg54.8%
div-inv56.2%
distribute-neg-frac56.2%
Applied egg-rr56.2%
Final simplification56.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 88.3%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 44.2%
associate-/l*55.8%
associate-/r/71.2%
Simplified71.2%
Taylor expanded in x around 0 55.2%
Final simplification55.2%
(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.3%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 44.2%
associate-/l*55.8%
associate-/r/71.2%
Simplified71.2%
Taylor expanded in x around 0 27.1%
Final simplification27.1%
(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 2023238
(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))