
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (sin a) (- (sin b)) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(sin(a), -sin(b), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(sin(a), Float64(-sin(b)), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \cos b\right)}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.4%
sub-neg99.4%
Applied egg-rr99.4%
+-commutative99.4%
distribute-lft-neg-in99.4%
*-commutative99.4%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a))));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
associate-/l*77.3%
remove-double-neg77.3%
sin-neg77.3%
neg-mul-177.3%
associate-/r*77.3%
associate-/l*77.4%
*-commutative77.4%
associate-*l/77.3%
associate-/l*77.3%
sin-neg77.3%
distribute-lft-neg-in77.3%
distribute-rgt-neg-in77.3%
associate-/l*77.3%
metadata-eval77.3%
/-rgt-identity77.3%
+-commutative77.3%
Simplified77.3%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos a) (cos b)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(a) * cos(b)) - (sin(b) * sin(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(a) * cos(b)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return r * (sin(b) / (cos(a) * cos(b)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / (cos(a) * cos(b)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / (Math.cos(a) * Math.cos(b)));
}
def code(r, a, b): return r * (math.sin(b) / (math.cos(a) * math.cos(b)))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(cos(a) * cos(b)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / (cos(a) * cos(b))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b}
\end{array}
Initial program 77.4%
associate-/l*77.3%
remove-double-neg77.3%
sin-neg77.3%
neg-mul-177.3%
associate-/r*77.3%
associate-/l*77.4%
*-commutative77.4%
associate-*l/77.3%
associate-/l*77.3%
sin-neg77.3%
distribute-lft-neg-in77.3%
distribute-rgt-neg-in77.3%
associate-/l*77.3%
metadata-eval77.3%
/-rgt-identity77.3%
+-commutative77.3%
Simplified77.3%
cos-sum99.4%
Applied egg-rr99.4%
sin-mult77.9%
div-sub77.9%
cos-diff78.2%
*-commutative78.2%
*-commutative78.2%
cos-diff77.9%
cos-sum78.5%
sub-neg78.5%
*-commutative78.5%
*-commutative78.5%
distribute-rgt-neg-in78.5%
add-sqr-sqrt39.9%
sqrt-unprod77.6%
sqr-neg77.6%
sqrt-unprod37.7%
add-sqr-sqrt76.9%
cos-diff77.9%
Applied egg-rr77.9%
+-inverses77.9%
Simplified77.9%
Final simplification77.9%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (* (cos a) (cos b))))
double code(double r, double a, double b) {
return (r * sin(b)) / (cos(a) * cos(b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / (cos(a) * cos(b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / (Math.cos(a) * Math.cos(b));
}
def code(r, a, b): return (r * math.sin(b)) / (math.cos(a) * math.cos(b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(cos(a) * cos(b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / (cos(a) * cos(b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos a \cdot \cos b}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.4%
Applied egg-rr99.4%
sin-mult77.9%
div-sub77.9%
cos-diff78.2%
*-commutative78.2%
*-commutative78.2%
cos-diff77.9%
cos-sum78.5%
sub-neg78.5%
*-commutative78.5%
*-commutative78.5%
distribute-rgt-neg-in78.5%
add-sqr-sqrt39.9%
sqrt-unprod77.6%
sqr-neg77.6%
sqrt-unprod37.7%
add-sqr-sqrt76.9%
cos-diff77.9%
Applied egg-rr77.9%
+-inverses77.9%
Simplified77.9%
Final simplification77.9%
(FPCore (r a b) :precision binary64 (if (<= b -2.9e-8) (* r (tan b)) (if (<= b 4e-6) (/ (* r b) (cos a)) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.9e-8) {
tmp = r * tan(b);
} else if (b <= 4e-6) {
tmp = (r * b) / cos(a);
} else {
tmp = sin(b) * (r / cos(b));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-2.9d-8)) then
tmp = r * tan(b)
else if (b <= 4d-6) then
tmp = (r * b) / cos(a)
else
tmp = sin(b) * (r / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2.9e-8) {
tmp = r * Math.tan(b);
} else if (b <= 4e-6) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.9e-8: tmp = r * math.tan(b) elif b <= 4e-6: tmp = (r * b) / math.cos(a) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2.9e-8) tmp = Float64(r * tan(b)); elseif (b <= 4e-6) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(sin(b) * Float64(r / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2.9e-8) tmp = r * tan(b); elseif (b <= 4e-6) tmp = (r * b) / cos(a); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.9e-8], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e-6], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-8}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -2.9000000000000002e-8Initial program 55.6%
associate-/l*55.6%
remove-double-neg55.6%
sin-neg55.6%
neg-mul-155.6%
associate-/r*55.6%
associate-/l*55.6%
*-commutative55.6%
associate-*l/55.7%
associate-/l*55.7%
sin-neg55.7%
distribute-lft-neg-in55.7%
distribute-rgt-neg-in55.7%
associate-/l*55.7%
metadata-eval55.7%
/-rgt-identity55.7%
+-commutative55.7%
Simplified55.7%
Taylor expanded in a around 0 53.1%
expm1-log1p-u39.6%
expm1-udef38.4%
quot-tan38.4%
Applied egg-rr38.4%
expm1-def39.7%
expm1-log1p53.2%
Simplified53.2%
if -2.9000000000000002e-8 < b < 3.99999999999999982e-6Initial program 98.6%
associate-/l*98.5%
remove-double-neg98.5%
sin-neg98.5%
neg-mul-198.5%
associate-/r*98.5%
associate-/l*98.6%
*-commutative98.6%
associate-*l/98.5%
associate-/l*98.5%
sin-neg98.5%
distribute-lft-neg-in98.5%
distribute-rgt-neg-in98.5%
associate-/l*98.5%
metadata-eval98.5%
/-rgt-identity98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.6%
if 3.99999999999999982e-6 < b Initial program 57.1%
associate-/l*57.1%
+-commutative57.1%
Simplified57.1%
Taylor expanded in a around 0 57.2%
associate-/r/57.3%
Applied egg-rr57.3%
Final simplification76.9%
(FPCore (r a b)
:precision binary64
(if (<= a -0.00084)
(* r (/ (sin b) (cos a)))
(if (<= a 0.00078)
(* r (/ 1.0 (- (/ 1.0 (tan b)) a)))
(/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.00084) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 0.00078) {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
} else {
tmp = r / (cos(a) / sin(b));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.00084d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 0.00078d0) then
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
else
tmp = r / (cos(a) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.00084) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 0.00078) {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.00084: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 0.00078: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.00084) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 0.00078) tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.00084) tmp = r * (sin(b) / cos(a)); elseif (a <= 0.00078) tmp = r * (1.0 / ((1.0 / tan(b)) - a)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.00084], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.00078], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00084:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 0.00078:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -8.4000000000000003e-4Initial program 47.7%
associate-/l*47.6%
remove-double-neg47.6%
sin-neg47.6%
neg-mul-147.6%
associate-/r*47.6%
associate-/l*47.7%
*-commutative47.7%
associate-*l/47.6%
associate-/l*47.6%
sin-neg47.6%
distribute-lft-neg-in47.6%
distribute-rgt-neg-in47.6%
associate-/l*47.6%
metadata-eval47.6%
/-rgt-identity47.6%
+-commutative47.6%
Simplified47.6%
Taylor expanded in b around 0 46.4%
if -8.4000000000000003e-4 < a < 7.79999999999999986e-4Initial program 99.3%
associate-/l*99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in a around 0 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.4%
clear-num99.4%
quot-tan99.4%
Applied egg-rr99.4%
if 7.79999999999999986e-4 < a Initial program 62.5%
associate-/l*62.6%
+-commutative62.6%
Simplified62.6%
Taylor expanded in b around 0 61.7%
Final simplification77.0%
(FPCore (r a b)
:precision binary64
(if (<= a -0.000185)
(/ (* r (sin b)) (cos a))
(if (<= a 0.0027)
(* r (/ 1.0 (- (/ 1.0 (tan b)) a)))
(/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.000185) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 0.0027) {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
} else {
tmp = r / (cos(a) / sin(b));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.000185d0)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 0.0027d0) then
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
else
tmp = r / (cos(a) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.000185) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 0.0027) {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.000185: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 0.0027: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.000185) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 0.0027) tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.000185) tmp = (r * sin(b)) / cos(a); elseif (a <= 0.0027) tmp = r * (1.0 / ((1.0 / tan(b)) - a)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.000185], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.0027], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000185:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 0.0027:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -1.85e-4Initial program 47.7%
+-commutative47.7%
Simplified47.7%
Taylor expanded in b around 0 46.5%
if -1.85e-4 < a < 0.0027000000000000001Initial program 99.3%
associate-/l*99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in a around 0 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.4%
clear-num99.4%
quot-tan99.4%
Applied egg-rr99.4%
if 0.0027000000000000001 < a Initial program 62.5%
associate-/l*62.6%
+-commutative62.6%
Simplified62.6%
Taylor expanded in b around 0 61.7%
Final simplification77.0%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ b a)))))
double code(double r, double a, double b) {
return sin(b) * (r / cos((b + a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((b + a)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((b + a)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((b + a))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(b + a\right)}
\end{array}
Initial program 77.4%
associate-/l*77.3%
+-commutative77.3%
Simplified77.3%
associate-/r/77.0%
Applied egg-rr77.0%
Final simplification77.0%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ b a)))))
double code(double r, double a, double b) {
return r * (sin(b) / cos((b + a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos((b + a)));
}
def code(r, a, b): return r * (math.sin(b) / math.cos((b + a)))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos((b + a))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 77.4%
associate-/l*77.3%
remove-double-neg77.3%
sin-neg77.3%
neg-mul-177.3%
associate-/r*77.3%
associate-/l*77.4%
*-commutative77.4%
associate-*l/77.3%
associate-/l*77.3%
sin-neg77.3%
distribute-lft-neg-in77.3%
distribute-rgt-neg-in77.3%
associate-/l*77.3%
metadata-eval77.3%
/-rgt-identity77.3%
+-commutative77.3%
Simplified77.3%
Final simplification77.3%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ b a))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((b + a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((b + a))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((b + a));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((b + a))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(b + a))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((b + a)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 77.4%
Final simplification77.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.9e-8) (not (<= b 4e-6))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.9e-8) || !(b <= 4e-6)) {
tmp = r * tan(b);
} else {
tmp = r * (b / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-2.9d-8)) .or. (.not. (b <= 4d-6))) then
tmp = r * tan(b)
else
tmp = r * (b / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -2.9e-8) || !(b <= 4e-6)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.9e-8) or not (b <= 4e-6): tmp = r * math.tan(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.9e-8) || !(b <= 4e-6)) tmp = Float64(r * tan(b)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2.9e-8) || ~((b <= 4e-6))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.9e-8], N[Not[LessEqual[b, 4e-6]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-8} \lor \neg \left(b \leq 4 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -2.9000000000000002e-8 or 3.99999999999999982e-6 < b Initial program 56.5%
associate-/l*56.4%
remove-double-neg56.4%
sin-neg56.4%
neg-mul-156.4%
associate-/r*56.4%
associate-/l*56.5%
*-commutative56.5%
associate-*l/56.5%
associate-/l*56.5%
sin-neg56.5%
distribute-lft-neg-in56.5%
distribute-rgt-neg-in56.5%
associate-/l*56.5%
metadata-eval56.5%
/-rgt-identity56.5%
+-commutative56.5%
Simplified56.5%
Taylor expanded in a around 0 55.4%
expm1-log1p-u41.5%
expm1-udef40.5%
quot-tan40.5%
Applied egg-rr40.5%
expm1-def41.5%
expm1-log1p55.5%
Simplified55.5%
if -2.9000000000000002e-8 < b < 3.99999999999999982e-6Initial program 98.6%
associate-/l*98.5%
remove-double-neg98.5%
sin-neg98.5%
neg-mul-198.5%
associate-/r*98.5%
associate-/l*98.6%
*-commutative98.6%
associate-*l/98.5%
associate-/l*98.5%
sin-neg98.5%
distribute-lft-neg-in98.5%
distribute-rgt-neg-in98.5%
associate-/l*98.5%
metadata-eval98.5%
/-rgt-identity98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.5%
Final simplification76.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.9e-8) (not (<= b 1.15e-6))) (* r (tan b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.9e-8) || !(b <= 1.15e-6)) {
tmp = r * tan(b);
} else {
tmp = (r * b) / cos(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-2.9d-8)) .or. (.not. (b <= 1.15d-6))) then
tmp = r * tan(b)
else
tmp = (r * b) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -2.9e-8) || !(b <= 1.15e-6)) {
tmp = r * Math.tan(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.9e-8) or not (b <= 1.15e-6): tmp = r * math.tan(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.9e-8) || !(b <= 1.15e-6)) tmp = Float64(r * tan(b)); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2.9e-8) || ~((b <= 1.15e-6))) tmp = r * tan(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.9e-8], N[Not[LessEqual[b, 1.15e-6]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-8} \lor \neg \left(b \leq 1.15 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -2.9000000000000002e-8 or 1.15e-6 < b Initial program 56.5%
associate-/l*56.4%
remove-double-neg56.4%
sin-neg56.4%
neg-mul-156.4%
associate-/r*56.4%
associate-/l*56.5%
*-commutative56.5%
associate-*l/56.5%
associate-/l*56.5%
sin-neg56.5%
distribute-lft-neg-in56.5%
distribute-rgt-neg-in56.5%
associate-/l*56.5%
metadata-eval56.5%
/-rgt-identity56.5%
+-commutative56.5%
Simplified56.5%
Taylor expanded in a around 0 55.4%
expm1-log1p-u41.5%
expm1-udef40.5%
quot-tan40.5%
Applied egg-rr40.5%
expm1-def41.5%
expm1-log1p55.5%
Simplified55.5%
if -2.9000000000000002e-8 < b < 1.15e-6Initial program 98.6%
associate-/l*98.5%
remove-double-neg98.5%
sin-neg98.5%
neg-mul-198.5%
associate-/r*98.5%
associate-/l*98.6%
*-commutative98.6%
associate-*l/98.5%
associate-/l*98.5%
sin-neg98.5%
distribute-lft-neg-in98.5%
distribute-rgt-neg-in98.5%
associate-/l*98.5%
metadata-eval98.5%
/-rgt-identity98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.6%
Final simplification76.9%
(FPCore (r a b) :precision binary64 (* r (tan b)))
double code(double r, double a, double b) {
return r * tan(b);
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * tan(b)
end function
public static double code(double r, double a, double b) {
return r * Math.tan(b);
}
def code(r, a, b): return r * math.tan(b)
function code(r, a, b) return Float64(r * tan(b)) end
function tmp = code(r, a, b) tmp = r * tan(b); end
code[r_, a_, b_] := N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \tan b
\end{array}
Initial program 77.4%
associate-/l*77.3%
remove-double-neg77.3%
sin-neg77.3%
neg-mul-177.3%
associate-/r*77.3%
associate-/l*77.4%
*-commutative77.4%
associate-*l/77.3%
associate-/l*77.3%
sin-neg77.3%
distribute-lft-neg-in77.3%
distribute-rgt-neg-in77.3%
associate-/l*77.3%
metadata-eval77.3%
/-rgt-identity77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in a around 0 60.2%
expm1-log1p-u53.2%
expm1-udef35.5%
quot-tan35.5%
Applied egg-rr35.5%
expm1-def53.2%
expm1-log1p60.2%
Simplified60.2%
Final simplification60.2%
(FPCore (r a b) :precision binary64 (/ r (+ (* b -0.3333333333333333) (/ 1.0 b))))
double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r / ((b * (-0.3333333333333333d0)) + (1.0d0 / b))
end function
public static double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / b));
}
def code(r, a, b): return r / ((b * -0.3333333333333333) + (1.0 / b))
function code(r, a, b) return Float64(r / Float64(Float64(b * -0.3333333333333333) + Float64(1.0 / b))) end
function tmp = code(r, a, b) tmp = r / ((b * -0.3333333333333333) + (1.0 / b)); end
code[r_, a_, b_] := N[(r / N[(N[(b * -0.3333333333333333), $MachinePrecision] + N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}}
\end{array}
Initial program 77.4%
associate-/l*77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in a around 0 60.1%
Taylor expanded in b around 0 36.0%
Final simplification36.0%
(FPCore (r a b) :precision binary64 (* r b))
double code(double r, double a, double b) {
return r * b;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * b
end function
public static double code(double r, double a, double b) {
return r * b;
}
def code(r, a, b): return r * b
function code(r, a, b) return Float64(r * b) end
function tmp = code(r, a, b) tmp = r * b; end
code[r_, a_, b_] := N[(r * b), $MachinePrecision]
\begin{array}{l}
\\
r \cdot b
\end{array}
Initial program 77.4%
associate-/l*77.3%
remove-double-neg77.3%
sin-neg77.3%
neg-mul-177.3%
associate-/r*77.3%
associate-/l*77.4%
*-commutative77.4%
associate-*l/77.3%
associate-/l*77.3%
sin-neg77.3%
distribute-lft-neg-in77.3%
distribute-rgt-neg-in77.3%
associate-/l*77.3%
metadata-eval77.3%
/-rgt-identity77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in b around 0 52.0%
Taylor expanded in a around 0 35.4%
*-commutative35.4%
Simplified35.4%
Final simplification35.4%
herbie shell --seed 2024011
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))