
(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 18 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 (let* ((t_0 (* (sin b) (sin a)))) (/ (* (sin b) r) (+ (* -2.0 t_0) (+ t_0 (* (cos a) (cos b)))))))
double code(double r, double a, double b) {
double t_0 = sin(b) * sin(a);
return (sin(b) * r) / ((-2.0 * t_0) + (t_0 + (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
real(8) :: t_0
t_0 = sin(b) * sin(a)
code = (sin(b) * r) / (((-2.0d0) * t_0) + (t_0 + (cos(a) * cos(b))))
end function
public static double code(double r, double a, double b) {
double t_0 = Math.sin(b) * Math.sin(a);
return (Math.sin(b) * r) / ((-2.0 * t_0) + (t_0 + (Math.cos(a) * Math.cos(b))));
}
def code(r, a, b): t_0 = math.sin(b) * math.sin(a) return (math.sin(b) * r) / ((-2.0 * t_0) + (t_0 + (math.cos(a) * math.cos(b))))
function code(r, a, b) t_0 = Float64(sin(b) * sin(a)) return Float64(Float64(sin(b) * r) / Float64(Float64(-2.0 * t_0) + Float64(t_0 + Float64(cos(a) * cos(b))))) end
function tmp = code(r, a, b) t_0 = sin(b) * sin(a); tmp = (sin(b) * r) / ((-2.0 * t_0) + (t_0 + (cos(a) * cos(b)))); end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(-2.0 * t$95$0), $MachinePrecision] + N[(t$95$0 + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
\frac{\sin b \cdot r}{-2 \cdot t_0 + \left(t_0 + \cos a \cdot \cos b\right)}
\end{array}
\end{array}
Initial program 70.2%
+-commutative70.2%
Simplified70.2%
cos-sum99.4%
*-un-lft-identity99.4%
*-un-lft-identity99.4%
prod-diff99.4%
Applied egg-rr99.4%
*-rgt-identity99.4%
*-commutative99.4%
distribute-lft-neg-in99.4%
*-commutative99.4%
fma-udef99.4%
*-rgt-identity99.4%
distribute-lft-neg-in99.4%
*-rgt-identity99.4%
fma-udef99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in r around 0 99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (fma (cos b) (cos a) (* (sin b) (- (sin a))))))
double code(double r, double a, double b) {
return (sin(b) * r) / fma(cos(b), cos(a), (sin(b) * -sin(a)));
}
function code(r, a, b) return Float64(Float64(sin(b) * r) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a))))) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 70.2%
+-commutative70.2%
Simplified70.2%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-def99.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(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 70.2%
associate-*r/70.1%
*-commutative70.1%
+-commutative70.1%
Simplified70.1%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (- (* (cos a) (cos b)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (sin(b) * r) / ((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 = (sin(b) * r) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (math.sin(b) * r) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / ((cos(a) * cos(b)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $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{\sin b \cdot r}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 70.2%
+-commutative70.2%
Simplified70.2%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (+ (* -2.0 (* (sin b) (sin a))) (cos (- a b)))))
double code(double r, double a, double b) {
return (sin(b) * r) / ((-2.0 * (sin(b) * sin(a))) + 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 = (sin(b) * r) / (((-2.0d0) * (sin(b) * sin(a))) + cos((a - b)))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / ((-2.0 * (Math.sin(b) * Math.sin(a))) + Math.cos((a - b)));
}
def code(r, a, b): return (math.sin(b) * r) / ((-2.0 * (math.sin(b) * math.sin(a))) + math.cos((a - b)))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(Float64(-2.0 * Float64(sin(b) * sin(a))) + cos(Float64(a - b)))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / ((-2.0 * (sin(b) * sin(a))) + cos((a - b))); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(-2.0 * N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Cos[N[(a - b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{-2 \cdot \left(\sin b \cdot \sin a\right) + \cos \left(a - b\right)}
\end{array}
Initial program 70.2%
+-commutative70.2%
Simplified70.2%
cos-sum99.4%
*-un-lft-identity99.4%
*-un-lft-identity99.4%
prod-diff99.4%
Applied egg-rr99.4%
*-rgt-identity99.4%
*-commutative99.4%
distribute-lft-neg-in99.4%
*-commutative99.4%
fma-udef99.4%
*-rgt-identity99.4%
distribute-lft-neg-in99.4%
*-rgt-identity99.4%
fma-udef99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in r around 0 99.4%
expm1-log1p-u99.3%
expm1-udef99.0%
+-commutative99.0%
cos-diff71.0%
Applied egg-rr71.0%
expm1-def71.3%
expm1-log1p71.3%
Simplified71.3%
Final simplification71.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.0036) (not (<= b 0.00245))) (* (sin b) (/ r (cos b))) (/ (* b r) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0036) || !(b <= 0.00245)) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = (b * r) / cos((b + 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 <= (-0.0036d0)) .or. (.not. (b <= 0.00245d0))) then
tmp = sin(b) * (r / cos(b))
else
tmp = (b * r) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0036) || !(b <= 0.00245)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = (b * r) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.0036) or not (b <= 0.00245): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = (b * r) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.0036) || !(b <= 0.00245)) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(Float64(b * r) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.0036) || ~((b <= 0.00245))) tmp = sin(b) * (r / cos(b)); else tmp = (b * r) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.0036], N[Not[LessEqual[b, 0.00245]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0036 \lor \neg \left(b \leq 0.00245\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -0.0035999999999999999 or 0.0024499999999999999 < b Initial program 47.4%
+-commutative47.4%
Simplified47.4%
cos-sum99.2%
cancel-sign-sub-inv99.2%
fma-def99.2%
Applied egg-rr99.2%
Taylor expanded in a around 0 47.6%
associate-*r/47.7%
Simplified47.7%
if -0.0035999999999999999 < b < 0.0024499999999999999Initial program 98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.5%
Final simplification70.3%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.0062) (not (<= a 0.0027))) (* r (/ (sin b) (cos a))) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0062) || !(a <= 0.0027)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * (1.0 / ((1.0 / tan(b)) - 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 ((a <= (-0.0062d0)) .or. (.not. (a <= 0.0027d0))) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0062) || !(a <= 0.0027)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.0062) or not (a <= 0.0027): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.0062) || !(a <= 0.0027)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.0062) || ~((a <= 0.0027))) tmp = r * (sin(b) / cos(a)); else tmp = r * (1.0 / ((1.0 / tan(b)) - a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.0062], N[Not[LessEqual[a, 0.0027]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0062 \lor \neg \left(a \leq 0.0027\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -0.00619999999999999978 or 0.0027000000000000001 < a Initial program 48.4%
associate-*r/48.3%
*-commutative48.3%
+-commutative48.3%
Simplified48.3%
Taylor expanded in b around 0 48.1%
if -0.00619999999999999978 < a < 0.0027000000000000001Initial program 98.2%
associate-/l*98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in a around 0 99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.2%
clear-num99.2%
quot-tan99.4%
Applied egg-rr99.4%
Final simplification70.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.056) (not (<= a 0.00058))) (/ r (/ (cos a) (sin b))) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.056) || !(a <= 0.00058)) {
tmp = r / (cos(a) / sin(b));
} else {
tmp = r * (1.0 / ((1.0 / tan(b)) - 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 ((a <= (-0.056d0)) .or. (.not. (a <= 0.00058d0))) then
tmp = r / (cos(a) / sin(b))
else
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.056) || !(a <= 0.00058)) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.056) or not (a <= 0.00058): tmp = r / (math.cos(a) / math.sin(b)) else: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.056) || !(a <= 0.00058)) tmp = Float64(r / Float64(cos(a) / sin(b))); else tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.056) || ~((a <= 0.00058))) tmp = r / (cos(a) / sin(b)); else tmp = r * (1.0 / ((1.0 / tan(b)) - a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.056], N[Not[LessEqual[a, 0.00058]], $MachinePrecision]], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.056 \lor \neg \left(a \leq 0.00058\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -0.0560000000000000012 or 5.8e-4 < a Initial program 48.4%
associate-/l*48.4%
+-commutative48.4%
Simplified48.4%
Taylor expanded in b around 0 48.2%
if -0.0560000000000000012 < a < 5.8e-4Initial program 98.2%
associate-/l*98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in a around 0 99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.2%
clear-num99.2%
quot-tan99.4%
Applied egg-rr99.4%
Final simplification70.6%
(FPCore (r a b)
:precision binary64
(if (<= a -0.0045)
(/ (* b r) (cos (+ b a)))
(if (<= a 0.03)
(* r (/ 1.0 (- (/ 1.0 (tan b)) a)))
(* r (log1p (/ b (cos a)))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.0045) {
tmp = (b * r) / cos((b + a));
} else if (a <= 0.03) {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
} else {
tmp = r * log1p((b / cos(a)));
}
return tmp;
}
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.0045) {
tmp = (b * r) / Math.cos((b + a));
} else if (a <= 0.03) {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
} else {
tmp = r * Math.log1p((b / Math.cos(a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.0045: tmp = (b * r) / math.cos((b + a)) elif a <= 0.03: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) else: tmp = r * math.log1p((b / math.cos(a))) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.0045) tmp = Float64(Float64(b * r) / cos(Float64(b + a))); elseif (a <= 0.03) tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); else tmp = Float64(r * log1p(Float64(b / cos(a)))); end return tmp end
code[r_, a_, b_] := If[LessEqual[a, -0.0045], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.03], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Log[1 + N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0045:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\
\mathbf{elif}\;a \leq 0.03:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \mathsf{log1p}\left(\frac{b}{\cos a}\right)\\
\end{array}
\end{array}
if a < -0.00449999999999999966Initial program 46.5%
+-commutative46.5%
Simplified46.5%
Taylor expanded in b around 0 43.3%
if -0.00449999999999999966 < a < 0.029999999999999999Initial program 98.2%
associate-/l*98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in a around 0 99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.2%
clear-num99.2%
quot-tan99.4%
Applied egg-rr99.4%
if 0.029999999999999999 < a Initial program 50.3%
associate-*r/50.3%
*-commutative50.3%
+-commutative50.3%
Simplified50.3%
add-log-exp12.9%
Applied egg-rr12.9%
Taylor expanded in b around 0 8.6%
*-un-lft-identity8.6%
log-prod8.6%
metadata-eval8.6%
+-commutative8.6%
log1p-udef46.0%
Applied egg-rr46.0%
+-lft-identity46.0%
Simplified46.0%
Final simplification68.6%
(FPCore (r a b)
:precision binary64
(if (<= a -0.0028)
(/ (sin b) (/ (cos a) r))
(if (<= a 0.0029)
(* 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.0028) {
tmp = sin(b) / (cos(a) / r);
} else if (a <= 0.0029) {
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.0028d0)) then
tmp = sin(b) / (cos(a) / r)
else if (a <= 0.0029d0) 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.0028) {
tmp = Math.sin(b) / (Math.cos(a) / r);
} else if (a <= 0.0029) {
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.0028: tmp = math.sin(b) / (math.cos(a) / r) elif a <= 0.0029: 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.0028) tmp = Float64(sin(b) / Float64(cos(a) / r)); elseif (a <= 0.0029) 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.0028) tmp = sin(b) / (cos(a) / r); elseif (a <= 0.0029) 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.0028], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.0029], 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.0028:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\mathbf{elif}\;a \leq 0.0029:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -0.00279999999999999997Initial program 46.5%
associate-*r/46.5%
*-commutative46.5%
+-commutative46.5%
Simplified46.5%
associate-*l/46.5%
associate-/l*46.5%
Applied egg-rr46.5%
Taylor expanded in b around 0 46.8%
if -0.00279999999999999997 < a < 0.0029Initial program 98.2%
associate-/l*98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in a around 0 99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.2%
clear-num99.2%
quot-tan99.4%
Applied egg-rr99.4%
if 0.0029 < a Initial program 50.3%
associate-/l*50.4%
+-commutative50.4%
Simplified50.4%
Taylor expanded in b around 0 49.6%
Final simplification70.6%
(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 70.2%
associate-/l*70.1%
+-commutative70.1%
Simplified70.1%
associate-/r/70.2%
Applied egg-rr70.2%
Final simplification70.2%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (- (/ 1.0 (tan b)) a)))
(if (<= b -0.053)
(/ r t_0)
(if (<= b 8.2e-5) (/ (* b r) (cos (+ b a))) (* r (/ 1.0 t_0))))))
double code(double r, double a, double b) {
double t_0 = (1.0 / tan(b)) - a;
double tmp;
if (b <= -0.053) {
tmp = r / t_0;
} else if (b <= 8.2e-5) {
tmp = (b * r) / cos((b + a));
} else {
tmp = r * (1.0 / t_0);
}
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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / tan(b)) - a
if (b <= (-0.053d0)) then
tmp = r / t_0
else if (b <= 8.2d-5) then
tmp = (b * r) / cos((b + a))
else
tmp = r * (1.0d0 / t_0)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = (1.0 / Math.tan(b)) - a;
double tmp;
if (b <= -0.053) {
tmp = r / t_0;
} else if (b <= 8.2e-5) {
tmp = (b * r) / Math.cos((b + a));
} else {
tmp = r * (1.0 / t_0);
}
return tmp;
}
def code(r, a, b): t_0 = (1.0 / math.tan(b)) - a tmp = 0 if b <= -0.053: tmp = r / t_0 elif b <= 8.2e-5: tmp = (b * r) / math.cos((b + a)) else: tmp = r * (1.0 / t_0) return tmp
function code(r, a, b) t_0 = Float64(Float64(1.0 / tan(b)) - a) tmp = 0.0 if (b <= -0.053) tmp = Float64(r / t_0); elseif (b <= 8.2e-5) tmp = Float64(Float64(b * r) / cos(Float64(b + a))); else tmp = Float64(r * Float64(1.0 / t_0)); end return tmp end
function tmp_2 = code(r, a, b) t_0 = (1.0 / tan(b)) - a; tmp = 0.0; if (b <= -0.053) tmp = r / t_0; elseif (b <= 8.2e-5) tmp = (b * r) / cos((b + a)); else tmp = r * (1.0 / t_0); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]}, If[LessEqual[b, -0.053], N[(r / t$95$0), $MachinePrecision], If[LessEqual[b, 8.2e-5], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\tan b} - a\\
\mathbf{if}\;b \leq -0.053:\\
\;\;\;\;\frac{r}{t_0}\\
\mathbf{elif}\;b \leq 8.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{t_0}\\
\end{array}
\end{array}
if b < -0.0529999999999999985Initial program 50.5%
associate-/l*50.5%
+-commutative50.5%
Simplified50.5%
Taylor expanded in a around 0 46.9%
mul-1-neg46.9%
unsub-neg46.9%
Simplified46.9%
expm1-log1p-u33.5%
expm1-udef33.3%
clear-num33.3%
quot-tan33.3%
Applied egg-rr33.3%
expm1-def33.6%
expm1-log1p47.0%
Simplified47.0%
if -0.0529999999999999985 < b < 8.20000000000000009e-5Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 97.9%
if 8.20000000000000009e-5 < b Initial program 45.0%
associate-/l*45.1%
+-commutative45.1%
Simplified45.1%
Taylor expanded in a around 0 42.6%
mul-1-neg42.6%
unsub-neg42.6%
Simplified42.6%
div-inv42.5%
clear-num42.6%
quot-tan42.6%
Applied egg-rr42.6%
Final simplification68.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.053) (not (<= b 0.00023))) (/ r (- (/ 1.0 (tan b)) a)) (/ (* b r) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.053) || !(b <= 0.00023)) {
tmp = r / ((1.0 / tan(b)) - a);
} else {
tmp = (b * r) / 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 <= (-0.053d0)) .or. (.not. (b <= 0.00023d0))) then
tmp = r / ((1.0d0 / tan(b)) - a)
else
tmp = (b * r) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.053) || !(b <= 0.00023)) {
tmp = r / ((1.0 / Math.tan(b)) - a);
} else {
tmp = (b * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.053) or not (b <= 0.00023): tmp = r / ((1.0 / math.tan(b)) - a) else: tmp = (b * r) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.053) || !(b <= 0.00023)) tmp = Float64(r / Float64(Float64(1.0 / tan(b)) - a)); else tmp = Float64(Float64(b * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.053) || ~((b <= 0.00023))) tmp = r / ((1.0 / tan(b)) - a); else tmp = (b * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.053], N[Not[LessEqual[b, 0.00023]], $MachinePrecision]], N[(r / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.053 \lor \neg \left(b \leq 0.00023\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\end{array}
\end{array}
if b < -0.0529999999999999985 or 2.3000000000000001e-4 < b Initial program 47.5%
associate-/l*47.6%
+-commutative47.6%
Simplified47.6%
Taylor expanded in a around 0 44.6%
mul-1-neg44.6%
unsub-neg44.6%
Simplified44.6%
expm1-log1p-u32.3%
expm1-udef32.1%
clear-num32.0%
quot-tan32.0%
Applied egg-rr32.0%
expm1-def32.3%
expm1-log1p44.6%
Simplified44.6%
if -0.0529999999999999985 < b < 2.3000000000000001e-4Initial program 97.9%
associate-*r/97.9%
*-commutative97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 97.5%
Final simplification68.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.053) (not (<= b 0.00028))) (/ r (- (/ 1.0 (tan b)) a)) (/ (* b r) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.053) || !(b <= 0.00028)) {
tmp = r / ((1.0 / tan(b)) - a);
} else {
tmp = (b * r) / cos((b + 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 <= (-0.053d0)) .or. (.not. (b <= 0.00028d0))) then
tmp = r / ((1.0d0 / tan(b)) - a)
else
tmp = (b * r) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.053) || !(b <= 0.00028)) {
tmp = r / ((1.0 / Math.tan(b)) - a);
} else {
tmp = (b * r) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.053) or not (b <= 0.00028): tmp = r / ((1.0 / math.tan(b)) - a) else: tmp = (b * r) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.053) || !(b <= 0.00028)) tmp = Float64(r / Float64(Float64(1.0 / tan(b)) - a)); else tmp = Float64(Float64(b * r) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.053) || ~((b <= 0.00028))) tmp = r / ((1.0 / tan(b)) - a); else tmp = (b * r) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.053], N[Not[LessEqual[b, 0.00028]], $MachinePrecision]], N[(r / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.053 \lor \neg \left(b \leq 0.00028\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -0.0529999999999999985 or 2.7999999999999998e-4 < b Initial program 47.5%
associate-/l*47.6%
+-commutative47.6%
Simplified47.6%
Taylor expanded in a around 0 44.6%
mul-1-neg44.6%
unsub-neg44.6%
Simplified44.6%
expm1-log1p-u32.3%
expm1-udef32.1%
clear-num32.0%
quot-tan32.0%
Applied egg-rr32.0%
expm1-def32.3%
expm1-log1p44.6%
Simplified44.6%
if -0.0529999999999999985 < b < 2.7999999999999998e-4Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 97.9%
Final simplification68.5%
(FPCore (r a b) :precision binary64 (* r (/ b (cos a))))
double code(double r, double a, double b) {
return r * (b / cos(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 * (b / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos(a));
}
def code(r, a, b): return r * (b / math.cos(a))
function code(r, a, b) return Float64(r * Float64(b / cos(a))) end
function tmp = code(r, a, b) tmp = r * (b / cos(a)); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos a}
\end{array}
Initial program 70.2%
associate-*r/70.1%
*-commutative70.1%
+-commutative70.1%
Simplified70.1%
Taylor expanded in b around 0 46.0%
Final simplification46.0%
(FPCore (r a b) :precision binary64 (/ (* b r) (cos a)))
double code(double r, double a, double b) {
return (b * r) / cos(a);
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (b * r) / cos(a)
end function
public static double code(double r, double a, double b) {
return (b * r) / Math.cos(a);
}
def code(r, a, b): return (b * r) / math.cos(a)
function code(r, a, b) return Float64(Float64(b * r) / cos(a)) end
function tmp = code(r, a, b) tmp = (b * r) / cos(a); end
code[r_, a_, b_] := N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot r}{\cos a}
\end{array}
Initial program 70.2%
associate-*r/70.1%
*-commutative70.1%
+-commutative70.1%
Simplified70.1%
Taylor expanded in b around 0 46.1%
Final simplification46.1%
(FPCore (r a b) :precision binary64 (* r (log1p b)))
double code(double r, double a, double b) {
return r * log1p(b);
}
public static double code(double r, double a, double b) {
return r * Math.log1p(b);
}
def code(r, a, b): return r * math.log1p(b)
function code(r, a, b) return Float64(r * log1p(b)) end
code[r_, a_, b_] := N[(r * N[Log[1 + b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \mathsf{log1p}\left(b\right)
\end{array}
Initial program 70.2%
associate-*r/70.1%
*-commutative70.1%
+-commutative70.1%
Simplified70.1%
add-log-exp37.4%
Applied egg-rr37.4%
Taylor expanded in b around 0 13.6%
Taylor expanded in a around 0 13.2%
log1p-def29.3%
Simplified29.3%
Final simplification29.3%
(FPCore (r a b) :precision binary64 (* b r))
double code(double r, double a, double b) {
return b * r;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = b * r
end function
public static double code(double r, double a, double b) {
return b * r;
}
def code(r, a, b): return b * r
function code(r, a, b) return Float64(b * r) end
function tmp = code(r, a, b) tmp = b * r; end
code[r_, a_, b_] := N[(b * r), $MachinePrecision]
\begin{array}{l}
\\
b \cdot r
\end{array}
Initial program 70.2%
associate-*r/70.1%
*-commutative70.1%
+-commutative70.1%
Simplified70.1%
Taylor expanded in b around 0 46.0%
Taylor expanded in a around 0 29.3%
Final simplification29.3%
herbie shell --seed 2023199
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))