
(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 14 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))))
(*
r
(/
(sin b)
(+ (- (* (cos a) (cos b)) t_0) (fma (- (sin b)) (sin a) t_0))))))
double code(double r, double a, double b) {
double t_0 = sin(b) * sin(a);
return r * (sin(b) / (((cos(a) * cos(b)) - t_0) + fma(-sin(b), sin(a), t_0)));
}
function code(r, a, b) t_0 = Float64(sin(b) * sin(a)) return Float64(r * Float64(sin(b) / Float64(Float64(Float64(cos(a) * cos(b)) - t_0) + fma(Float64(-sin(b)), sin(a), t_0)))) end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]}, N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
r \cdot \frac{\sin b}{\left(\cos a \cdot \cos b - t\_0\right) + \mathsf{fma}\left(-\sin b, \sin a, t\_0\right)}
\end{array}
\end{array}
Initial program 72.6%
associate-/l*72.7%
remove-double-neg72.7%
remove-double-neg72.7%
+-commutative72.7%
Simplified72.7%
cos-sum99.6%
*-un-lft-identity99.6%
prod-diff99.5%
Applied egg-rr99.5%
*-rgt-identity99.5%
fma-neg99.6%
*-commutative99.6%
*-commutative99.6%
fma-undefine99.6%
*-rgt-identity99.6%
distribute-lft-neg-in99.6%
*-rgt-identity99.6%
fma-undefine99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.6%
(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 72.6%
associate-/l*72.7%
remove-double-neg72.7%
remove-double-neg72.7%
+-commutative72.7%
Simplified72.7%
cos-sum99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (cos (+ b a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / (cos((b + a)) - (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((b + a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / (Math.cos((b + a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / (math.cos((b + a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(cos(Float64(b + a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / (cos((b + a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(b + a\right) - \sin b \cdot \sin a}
\end{array}
Initial program 72.6%
associate-/l*72.7%
remove-double-neg72.7%
remove-double-neg72.7%
+-commutative72.7%
Simplified72.7%
add-log-exp72.5%
Applied egg-rr72.5%
rem-log-exp72.7%
cos-sum99.6%
Applied egg-rr74.1%
Final simplification74.1%
(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 72.6%
associate-/l*72.7%
remove-double-neg72.7%
remove-double-neg72.7%
+-commutative72.7%
Simplified72.7%
add-log-exp72.5%
Applied egg-rr72.5%
add-sqr-sqrt72.2%
sqrt-unprod72.5%
prod-exp72.5%
cos-sum74.1%
*-commutative74.1%
cancel-sign-sub-inv74.1%
add-sqr-sqrt41.1%
sqrt-unprod72.4%
sqr-neg72.4%
sqrt-prod31.4%
add-sqr-sqrt71.7%
*-commutative71.7%
cos-diff72.5%
+-commutative72.5%
Applied egg-rr74.0%
Final simplification74.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.00073) (not (<= b 3.5e-6))) (* r (/ (sin b) (cos b))) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00073) || !(b <= 3.5e-6)) {
tmp = r * (sin(b) / cos(b));
} 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.00073d0)) .or. (.not. (b <= 3.5d-6))) then
tmp = r * (sin(b) / cos(b))
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.00073) || !(b <= 3.5e-6)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.00073) or not (b <= 3.5e-6): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.00073) || !(b <= 3.5e-6)) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.00073) || ~((b <= 3.5e-6))) tmp = r * (sin(b) / cos(b)); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.00073], N[Not[LessEqual[b, 3.5e-6]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00073 \lor \neg \left(b \leq 3.5 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -7.2999999999999996e-4 or 3.49999999999999995e-6 < b Initial program 49.1%
associate-/l*49.2%
remove-double-neg49.2%
remove-double-neg49.2%
+-commutative49.2%
Simplified49.2%
Taylor expanded in a around 0 49.4%
if -7.2999999999999996e-4 < b < 3.49999999999999995e-6Initial program 99.3%
associate-/l*99.4%
remove-double-neg99.4%
remove-double-neg99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in b around 0 99.3%
associate-/l*99.4%
Simplified99.4%
Final simplification72.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.0016) (not (<= b 7e-6))) (* r (/ (sin b) (cos b))) (* (sin b) (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0016) || !(b <= 7e-6)) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = sin(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.0016d0)) .or. (.not. (b <= 7d-6))) then
tmp = r * (sin(b) / cos(b))
else
tmp = sin(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.0016) || !(b <= 7e-6)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = Math.sin(b) * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.0016) or not (b <= 7e-6): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = math.sin(b) * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.0016) || !(b <= 7e-6)) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(sin(b) * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.0016) || ~((b <= 7e-6))) tmp = r * (sin(b) / cos(b)); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.0016], N[Not[LessEqual[b, 7e-6]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0016 \lor \neg \left(b \leq 7 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -0.00160000000000000008 or 6.99999999999999989e-6 < b Initial program 49.1%
associate-/l*49.2%
remove-double-neg49.2%
remove-double-neg49.2%
+-commutative49.2%
Simplified49.2%
Taylor expanded in a around 0 49.4%
if -0.00160000000000000008 < b < 6.99999999999999989e-6Initial program 99.3%
+-commutative99.3%
Simplified99.3%
associate-*r/99.4%
*-commutative99.4%
div-inv99.3%
associate-*l*99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 99.4%
Final simplification72.9%
(FPCore (r a b) :precision binary64 (if (<= b -0.00028) (/ r (/ (cos b) (sin b))) (if (<= b 8.5e-6) (* (sin b) (/ r (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.00028) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 8.5e-6) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = r * (sin(b) / 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 <= (-0.00028d0)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 8.5d-6) then
tmp = sin(b) * (r / cos(a))
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -0.00028) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 8.5e-6) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.00028: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 8.5e-6: tmp = math.sin(b) * (r / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.00028) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 8.5e-6) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.00028) tmp = r / (cos(b) / sin(b)); elseif (b <= 8.5e-6) tmp = sin(b) * (r / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.00028], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-6], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00028:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-6}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -2.7999999999999998e-4Initial program 44.9%
associate-/l*44.9%
remove-double-neg44.9%
remove-double-neg44.9%
+-commutative44.9%
Simplified44.9%
clear-num44.8%
un-div-inv44.9%
Applied egg-rr44.9%
Taylor expanded in a around 0 45.1%
if -2.7999999999999998e-4 < b < 8.4999999999999999e-6Initial program 99.3%
+-commutative99.3%
Simplified99.3%
associate-*r/99.4%
*-commutative99.4%
div-inv99.3%
associate-*l*99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 99.4%
if 8.4999999999999999e-6 < b Initial program 52.8%
associate-/l*53.0%
remove-double-neg53.0%
remove-double-neg53.0%
+-commutative53.0%
Simplified53.0%
Taylor expanded in a around 0 53.3%
Final simplification72.9%
(FPCore (r a b) :precision binary64 (if (<= b -3.6e-5) (/ (* r (sin b)) (cos b)) (if (<= b 6.4e-6) (* (sin b) (/ r (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -3.6e-5) {
tmp = (r * sin(b)) / cos(b);
} else if (b <= 6.4e-6) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = r * (sin(b) / 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 <= (-3.6d-5)) then
tmp = (r * sin(b)) / cos(b)
else if (b <= 6.4d-6) then
tmp = sin(b) * (r / cos(a))
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -3.6e-5) {
tmp = (r * Math.sin(b)) / Math.cos(b);
} else if (b <= 6.4e-6) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -3.6e-5: tmp = (r * math.sin(b)) / math.cos(b) elif b <= 6.4e-6: tmp = math.sin(b) * (r / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -3.6e-5) tmp = Float64(Float64(r * sin(b)) / cos(b)); elseif (b <= 6.4e-6) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -3.6e-5) tmp = (r * sin(b)) / cos(b); elseif (b <= 6.4e-6) tmp = sin(b) * (r / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -3.6e-5], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.4e-6], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-6}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -3.60000000000000009e-5Initial program 44.9%
associate-/l*44.9%
remove-double-neg44.9%
remove-double-neg44.9%
+-commutative44.9%
Simplified44.9%
Taylor expanded in a around 0 45.1%
*-commutative45.1%
Simplified45.1%
if -3.60000000000000009e-5 < b < 6.3999999999999997e-6Initial program 99.3%
+-commutative99.3%
Simplified99.3%
associate-*r/99.4%
*-commutative99.4%
div-inv99.3%
associate-*l*99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 99.4%
if 6.3999999999999997e-6 < b Initial program 52.8%
associate-/l*53.0%
remove-double-neg53.0%
remove-double-neg53.0%
+-commutative53.0%
Simplified53.0%
Taylor expanded in a around 0 53.3%
Final simplification72.9%
(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 72.6%
associate-/l*72.7%
remove-double-neg72.7%
remove-double-neg72.7%
+-commutative72.7%
Simplified72.7%
Final simplification72.7%
(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(r * Float64(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[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a - b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(a - b\right)}
\end{array}
Initial program 72.6%
associate-/l*72.7%
remove-double-neg72.7%
remove-double-neg72.7%
+-commutative72.7%
Simplified72.7%
add-log-exp72.5%
Applied egg-rr72.5%
rem-log-exp72.7%
cos-sum99.6%
*-commutative99.6%
cancel-sign-sub-inv99.6%
add-sqr-sqrt52.1%
sqrt-unprod83.9%
sqr-neg83.9%
sqrt-prod31.8%
add-sqr-sqrt72.7%
*-commutative72.7%
cos-diff72.8%
Applied egg-rr72.8%
Final simplification72.8%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos a))))
double code(double r, double a, double b) {
return r * (sin(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 * (sin(b) / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos(a));
}
def code(r, a, b): return r * (math.sin(b) / math.cos(a))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(a))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos(a)); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a}
\end{array}
Initial program 72.6%
associate-/l*72.7%
remove-double-neg72.7%
remove-double-neg72.7%
+-commutative72.7%
Simplified72.7%
Taylor expanded in b around 0 52.6%
Final simplification52.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -1260000000.0) (not (<= b 3.8e+16))) (* r (- (sin b))) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1260000000.0) || !(b <= 3.8e+16)) {
tmp = r * -sin(b);
} 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 <= (-1260000000.0d0)) .or. (.not. (b <= 3.8d+16))) then
tmp = r * -sin(b)
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 <= -1260000000.0) || !(b <= 3.8e+16)) {
tmp = r * -Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1260000000.0) or not (b <= 3.8e+16): tmp = r * -math.sin(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1260000000.0) || !(b <= 3.8e+16)) tmp = Float64(r * Float64(-sin(b))); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1260000000.0) || ~((b <= 3.8e+16))) tmp = r * -sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1260000000.0], N[Not[LessEqual[b, 3.8e+16]], $MachinePrecision]], N[(r * (-N[Sin[b], $MachinePrecision])), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1260000000 \lor \neg \left(b \leq 3.8 \cdot 10^{+16}\right):\\
\;\;\;\;r \cdot \left(-\sin b\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.26e9 or 3.8e16 < b Initial program 48.8%
associate-/l*48.9%
remove-double-neg48.9%
remove-double-neg48.9%
+-commutative48.9%
Simplified48.9%
add-log-exp48.7%
Applied egg-rr48.7%
Taylor expanded in b around 0 10.1%
rem-log-exp10.1%
*-commutative10.1%
frac-2neg10.1%
associate-*l/10.1%
add-sqr-sqrt5.5%
sqrt-unprod12.4%
sqr-neg12.4%
sqrt-unprod6.9%
add-sqr-sqrt13.3%
Applied egg-rr13.3%
Taylor expanded in a around 0 13.3%
Simplified13.3%
if -1.26e9 < b < 3.8e16Initial program 95.4%
associate-/l*95.5%
remove-double-neg95.5%
remove-double-neg95.5%
+-commutative95.5%
Simplified95.5%
Taylor expanded in b around 0 93.3%
associate-/l*93.4%
Simplified93.4%
Final simplification54.3%
(FPCore (r a b) :precision binary64 (* r (sin b)))
double code(double r, double a, double b) {
return r * sin(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)
end function
public static double code(double r, double a, double b) {
return r * Math.sin(b);
}
def code(r, a, b): return r * math.sin(b)
function code(r, a, b) return Float64(r * sin(b)) end
function tmp = code(r, a, b) tmp = r * sin(b); end
code[r_, a_, b_] := N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \sin b
\end{array}
Initial program 72.6%
associate-/l*72.7%
remove-double-neg72.7%
remove-double-neg72.7%
+-commutative72.7%
Simplified72.7%
add-log-exp72.5%
Applied egg-rr72.5%
Taylor expanded in b around 0 52.5%
Taylor expanded in a around 0 35.9%
Final simplification35.9%
(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 72.6%
associate-/l*72.7%
remove-double-neg72.7%
remove-double-neg72.7%
+-commutative72.7%
Simplified72.7%
Taylor expanded in b around 0 49.4%
associate-/l*49.4%
Simplified49.4%
Taylor expanded in a around 0 32.3%
Final simplification32.3%
herbie shell --seed 2024047
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))