
(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 (cos b) (cos a) (* (sin a) (- (sin b))))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), (sin(a) * -sin(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(sin(a) * Float64(-sin(b))))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin a \cdot \left(-\sin b\right)\right)}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.5%
fma-neg99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (/ (- (* (cos b) (cos a)) (* (sin b) (sin a))) (sin b))))
double code(double r, double a, double b) {
return r / (((cos(b) * cos(a)) - (sin(b) * sin(a))) / 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 / (((cos(b) * cos(a)) - (sin(b) * sin(a))) / sin(b))
end function
public static double code(double r, double a, double b) {
return r / (((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))) / Math.sin(b));
}
def code(r, a, b): return r / (((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))) / math.sin(b))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))) / sin(b))) end
function tmp = code(r, a, b) tmp = r / (((cos(b) * cos(a)) - (sin(b) * sin(a))) / sin(b)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos b \cdot \cos a - \sin b \cdot \sin a}{\sin b}}
\end{array}
Initial program 77.4%
associate-/l*77.3%
+-commutative77.3%
Simplified77.3%
cos-sum99.5%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos b) (cos a)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(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) * cos(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) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (* (cos b) (cos a))))
double code(double r, double a, double b) {
return (r * sin(b)) / (cos(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(b) * cos(a))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / (Math.cos(b) * Math.cos(a));
}
def code(r, a, b): return (r * math.sin(b)) / (math.cos(b) * math.cos(a))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(cos(b) * cos(a))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / (cos(b) * cos(a)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult78.8%
div-sub78.8%
cos-sum79.4%
sub-neg79.4%
add-sqr-sqrt50.0%
sqrt-unprod78.3%
sqr-neg78.3%
sqrt-unprod38.9%
add-sqr-sqrt78.0%
cos-diff78.7%
Applied egg-rr78.7%
+-inverses78.7%
Simplified78.7%
Final simplification78.7%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.00052) (not (<= a 0.0018))) (/ 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.00052) || !(a <= 0.0018)) {
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.00052d0)) .or. (.not. (a <= 0.0018d0))) 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.00052) || !(a <= 0.0018)) {
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.00052) or not (a <= 0.0018): 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.00052) || !(a <= 0.0018)) 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.00052) || ~((a <= 0.0018))) 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.00052], N[Not[LessEqual[a, 0.0018]], $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.00052 \lor \neg \left(a \leq 0.0018\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 < -5.19999999999999954e-4 or 0.0018 < a Initial program 55.5%
associate-/l*55.5%
+-commutative55.5%
Simplified55.5%
Taylor expanded in b around 0 54.4%
if -5.19999999999999954e-4 < a < 0.0018Initial program 98.7%
associate-/l*98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in a around 0 98.9%
+-commutative98.9%
mul-1-neg98.9%
unsub-neg98.9%
Simplified98.9%
clear-num97.1%
associate-/r/98.9%
clear-num98.9%
quot-tan99.0%
Applied egg-rr99.0%
Final simplification77.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.8e-6) (not (<= b 9.2e+14))) (/ r (/ (cos b) (sin b))) (/ r (/ (cos a) (sin b)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.8e-6) || !(b <= 9.2e+14)) {
tmp = r / (cos(b) / sin(b));
} 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 ((b <= (-4.8d-6)) .or. (.not. (b <= 9.2d+14))) then
tmp = r / (cos(b) / sin(b))
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 ((b <= -4.8e-6) || !(b <= 9.2e+14)) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.8e-6) or not (b <= 9.2e+14): tmp = r / (math.cos(b) / math.sin(b)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.8e-6) || !(b <= 9.2e+14)) tmp = Float64(r / Float64(cos(b) / sin(b))); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.8e-6) || ~((b <= 9.2e+14))) tmp = r / (cos(b) / sin(b)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.8e-6], N[Not[LessEqual[b, 9.2e+14]], $MachinePrecision]], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{-6} \lor \neg \left(b \leq 9.2 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if b < -4.7999999999999998e-6 or 9.2e14 < b Initial program 56.2%
associate-/l*56.2%
+-commutative56.2%
Simplified56.2%
Taylor expanded in a around 0 55.8%
if -4.7999999999999998e-6 < b < 9.2e14Initial program 97.7%
associate-/l*97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in b around 0 97.5%
Final simplification77.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -9e-5) (not (<= b 9.2e+14))) (/ (sin b) (/ (cos b) r)) (/ r (/ (cos a) (sin b)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -9e-5) || !(b <= 9.2e+14)) {
tmp = sin(b) / (cos(b) / r);
} 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 ((b <= (-9d-5)) .or. (.not. (b <= 9.2d+14))) then
tmp = sin(b) / (cos(b) / r)
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 ((b <= -9e-5) || !(b <= 9.2e+14)) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -9e-5) or not (b <= 9.2e+14): tmp = math.sin(b) / (math.cos(b) / r) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -9e-5) || !(b <= 9.2e+14)) tmp = Float64(sin(b) / Float64(cos(b) / r)); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -9e-5) || ~((b <= 9.2e+14))) tmp = sin(b) / (cos(b) / r); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -9e-5], N[Not[LessEqual[b, 9.2e+14]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-5} \lor \neg \left(b \leq 9.2 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if b < -9.00000000000000057e-5 or 9.2e14 < b Initial program 56.2%
associate-/l*56.2%
+-commutative56.2%
Simplified56.2%
Taylor expanded in a around 0 55.8%
*-commutative55.8%
associate-/l*55.8%
Simplified55.8%
if -9.00000000000000057e-5 < b < 9.2e14Initial program 97.7%
associate-/l*97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in b around 0 97.5%
Final simplification77.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -9e-7) (not (<= b 9.2e+14))) (/ (sin b) (/ (cos b) r)) (/ (* r (sin b)) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -9e-7) || !(b <= 9.2e+14)) {
tmp = sin(b) / (cos(b) / r);
} else {
tmp = (r * sin(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 <= (-9d-7)) .or. (.not. (b <= 9.2d+14))) then
tmp = sin(b) / (cos(b) / r)
else
tmp = (r * sin(b)) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -9e-7) || !(b <= 9.2e+14)) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else {
tmp = (r * Math.sin(b)) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -9e-7) or not (b <= 9.2e+14): tmp = math.sin(b) / (math.cos(b) / r) else: tmp = (r * math.sin(b)) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -9e-7) || !(b <= 9.2e+14)) tmp = Float64(sin(b) / Float64(cos(b) / r)); else tmp = Float64(Float64(r * sin(b)) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -9e-7) || ~((b <= 9.2e+14))) tmp = sin(b) / (cos(b) / r); else tmp = (r * sin(b)) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -9e-7], N[Not[LessEqual[b, 9.2e+14]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-7} \lor \neg \left(b \leq 9.2 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\end{array}
\end{array}
if b < -8.99999999999999959e-7 or 9.2e14 < b Initial program 56.2%
associate-/l*56.2%
+-commutative56.2%
Simplified56.2%
Taylor expanded in a around 0 55.8%
*-commutative55.8%
associate-/l*55.8%
Simplified55.8%
if -8.99999999999999959e-7 < b < 9.2e14Initial program 97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in b around 0 97.7%
Final simplification77.2%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (sin b))))
(if (<= b -2.15e-6)
(/ t_0 (cos b))
(if (<= b 9.2e+14) (/ t_0 (cos a)) (/ (sin b) (/ (cos b) r))))))
double code(double r, double a, double b) {
double t_0 = r * sin(b);
double tmp;
if (b <= -2.15e-6) {
tmp = t_0 / cos(b);
} else if (b <= 9.2e+14) {
tmp = t_0 / cos(a);
} else {
tmp = sin(b) / (cos(b) / r);
}
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 = r * sin(b)
if (b <= (-2.15d-6)) then
tmp = t_0 / cos(b)
else if (b <= 9.2d+14) then
tmp = t_0 / cos(a)
else
tmp = sin(b) / (cos(b) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = r * Math.sin(b);
double tmp;
if (b <= -2.15e-6) {
tmp = t_0 / Math.cos(b);
} else if (b <= 9.2e+14) {
tmp = t_0 / Math.cos(a);
} else {
tmp = Math.sin(b) / (Math.cos(b) / r);
}
return tmp;
}
def code(r, a, b): t_0 = r * math.sin(b) tmp = 0 if b <= -2.15e-6: tmp = t_0 / math.cos(b) elif b <= 9.2e+14: tmp = t_0 / math.cos(a) else: tmp = math.sin(b) / (math.cos(b) / r) return tmp
function code(r, a, b) t_0 = Float64(r * sin(b)) tmp = 0.0 if (b <= -2.15e-6) tmp = Float64(t_0 / cos(b)); elseif (b <= 9.2e+14) tmp = Float64(t_0 / cos(a)); else tmp = Float64(sin(b) / Float64(cos(b) / r)); end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * sin(b); tmp = 0.0; if (b <= -2.15e-6) tmp = t_0 / cos(b); elseif (b <= 9.2e+14) tmp = t_0 / cos(a); else tmp = sin(b) / (cos(b) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.15e-6], N[(t$95$0 / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.2e+14], N[(t$95$0 / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \sin b\\
\mathbf{if}\;b \leq -2.15 \cdot 10^{-6}:\\
\;\;\;\;\frac{t_0}{\cos b}\\
\mathbf{elif}\;b \leq 9.2 \cdot 10^{+14}:\\
\;\;\;\;\frac{t_0}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\end{array}
\end{array}
if b < -2.15000000000000017e-6Initial program 58.1%
+-commutative58.1%
Simplified58.1%
Taylor expanded in a around 0 58.4%
if -2.15000000000000017e-6 < b < 9.2e14Initial program 97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in b around 0 97.7%
if 9.2e14 < b Initial program 54.5%
associate-/l*54.6%
+-commutative54.6%
Simplified54.6%
Taylor expanded in a around 0 53.3%
*-commutative53.3%
associate-/l*53.4%
Simplified53.4%
Final simplification77.2%
(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.4%
Applied egg-rr77.4%
Final simplification77.4%
(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%
+-commutative77.3%
Simplified77.3%
clear-num76.2%
associate-/r/77.3%
clear-num77.4%
Applied egg-rr77.4%
Final simplification77.4%
(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 -5.2e-5) (not (<= b 1.8e-12))) (/ r (- (/ 1.0 (tan b)) a)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -5.2e-5) || !(b <= 1.8e-12)) {
tmp = r / ((1.0 / tan(b)) - a);
} 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 <= (-5.2d-5)) .or. (.not. (b <= 1.8d-12))) then
tmp = r / ((1.0d0 / tan(b)) - a)
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 <= -5.2e-5) || !(b <= 1.8e-12)) {
tmp = r / ((1.0 / Math.tan(b)) - a);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -5.2e-5) or not (b <= 1.8e-12): tmp = r / ((1.0 / math.tan(b)) - a) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -5.2e-5) || !(b <= 1.8e-12)) tmp = Float64(r / Float64(Float64(1.0 / tan(b)) - a)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -5.2e-5) || ~((b <= 1.8e-12))) tmp = r / ((1.0 / tan(b)) - a); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -5.2e-5], N[Not[LessEqual[b, 1.8e-12]], $MachinePrecision]], N[(r / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.2 \cdot 10^{-5} \lor \neg \left(b \leq 1.8 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -5.19999999999999968e-5 or 1.8e-12 < b Initial program 56.1%
associate-/l*56.1%
+-commutative56.1%
Simplified56.1%
Taylor expanded in a around 0 52.1%
+-commutative52.1%
mul-1-neg52.1%
unsub-neg52.1%
Simplified52.1%
expm1-log1p-u40.8%
expm1-udef15.9%
clear-num15.9%
quot-tan15.9%
Applied egg-rr15.9%
expm1-def40.8%
expm1-log1p52.2%
Simplified52.2%
if -5.19999999999999968e-5 < b < 1.8e-12Initial program 99.5%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in b around 0 99.3%
clear-num97.5%
associate-/r/99.3%
clear-num99.5%
Applied egg-rr99.5%
Final simplification75.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 77.4%
associate-/l*77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in b around 0 52.2%
clear-num51.0%
associate-/r/52.2%
clear-num52.3%
Applied egg-rr52.3%
Final simplification52.3%
(FPCore (r a b) :precision binary64 (/ r (- (+ (* b -0.3333333333333333) (/ 1.0 b)) a)))
double code(double r, double a, double b) {
return r / (((b * -0.3333333333333333) + (1.0 / 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 / (((b * (-0.3333333333333333d0)) + (1.0d0 / b)) - a)
end function
public static double code(double r, double a, double b) {
return r / (((b * -0.3333333333333333) + (1.0 / b)) - a);
}
def code(r, a, b): return r / (((b * -0.3333333333333333) + (1.0 / b)) - a)
function code(r, a, b) return Float64(r / Float64(Float64(Float64(b * -0.3333333333333333) + Float64(1.0 / b)) - a)) end
function tmp = code(r, a, b) tmp = r / (((b * -0.3333333333333333) + (1.0 / b)) - a); end
code[r_, a_, b_] := N[(r / N[(N[(N[(b * -0.3333333333333333), $MachinePrecision] + N[(1.0 / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\left(b \cdot -0.3333333333333333 + \frac{1}{b}\right) - a}
\end{array}
Initial program 77.4%
associate-/l*77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in a around 0 57.8%
+-commutative57.8%
mul-1-neg57.8%
unsub-neg57.8%
Simplified57.8%
Taylor expanded in b around 0 35.2%
Final simplification35.2%
(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%
+-commutative77.3%
Simplified77.3%
Taylor expanded in b around 0 52.2%
Taylor expanded in a around 0 35.2%
*-commutative35.2%
Simplified35.2%
Final simplification35.2%
herbie shell --seed 2023300
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))