
(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}
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(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}
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (fma (cos b) (cos a) (- (* (sin b) (sin a)))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(cos(b), cos(a), -(sin(b) * sin(a))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(-Float64(sin(b) * sin(a)))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + (-N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, -\sin b \cdot \sin a\right)}
\end{array}
Initial program 79.2%
+-commutative79.2%
Simplified79.2%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
Final simplification99.5%
(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(r * Float64(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[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[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 b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 79.2%
+-commutative79.2%
Simplified79.2%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(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 79.2%
associate-*r/79.2%
+-commutative79.2%
Simplified79.2%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b)
:precision binary64
(if (<= a -0.00038)
(/ (* r (sin b)) (cos a))
(if (<= a 13.0)
(* (sin b) (/ r (cos b)))
(* r (* (sin b) (/ 1.0 (cos a)))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.00038) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 13.0) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = r * (sin(b) * (1.0 / 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 (a <= (-0.00038d0)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 13.0d0) then
tmp = sin(b) * (r / cos(b))
else
tmp = r * (sin(b) * (1.0d0 / cos(a)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.00038) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 13.0) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = r * (Math.sin(b) * (1.0 / Math.cos(a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.00038: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 13.0: tmp = math.sin(b) * (r / math.cos(b)) else: tmp = r * (math.sin(b) * (1.0 / math.cos(a))) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.00038) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 13.0) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(r * Float64(sin(b) * Float64(1.0 / cos(a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.00038) tmp = (r * sin(b)) / cos(a); elseif (a <= 13.0) tmp = sin(b) * (r / cos(b)); else tmp = r * (sin(b) * (1.0 / cos(a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.00038], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 13.0], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] * N[(1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00038:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 13:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \left(\sin b \cdot \frac{1}{\cos a}\right)\\
\end{array}
\end{array}
if a < -3.8000000000000002e-4Initial program 63.9%
associate-*r/64.0%
+-commutative64.0%
Simplified64.0%
Taylor expanded in b around 0 63.7%
if -3.8000000000000002e-4 < a < 13Initial program 98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in a around 0 98.6%
*-commutative98.6%
associate-/l*98.6%
Simplified98.6%
if 13 < a Initial program 51.9%
+-commutative51.9%
Simplified51.9%
clear-num51.9%
associate-/r/52.0%
Applied egg-rr52.0%
Taylor expanded in b around 0 52.1%
Final simplification79.3%
(FPCore (r a b)
:precision binary64
(if (<= a -0.0077)
(/ (* r (sin b)) (cos a))
(if (<= a 13.0)
(* r (* (sin b) (/ 1.0 (cos b))))
(* r (* (sin b) (/ 1.0 (cos a)))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.0077) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 13.0) {
tmp = r * (sin(b) * (1.0 / cos(b)));
} else {
tmp = r * (sin(b) * (1.0 / 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 (a <= (-0.0077d0)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 13.0d0) then
tmp = r * (sin(b) * (1.0d0 / cos(b)))
else
tmp = r * (sin(b) * (1.0d0 / cos(a)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.0077) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 13.0) {
tmp = r * (Math.sin(b) * (1.0 / Math.cos(b)));
} else {
tmp = r * (Math.sin(b) * (1.0 / Math.cos(a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.0077: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 13.0: tmp = r * (math.sin(b) * (1.0 / math.cos(b))) else: tmp = r * (math.sin(b) * (1.0 / math.cos(a))) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.0077) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 13.0) tmp = Float64(r * Float64(sin(b) * Float64(1.0 / cos(b)))); else tmp = Float64(r * Float64(sin(b) * Float64(1.0 / cos(a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.0077) tmp = (r * sin(b)) / cos(a); elseif (a <= 13.0) tmp = r * (sin(b) * (1.0 / cos(b))); else tmp = r * (sin(b) * (1.0 / cos(a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.0077], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 13.0], N[(r * N[(N[Sin[b], $MachinePrecision] * N[(1.0 / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] * N[(1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0077:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 13:\\
\;\;\;\;r \cdot \left(\sin b \cdot \frac{1}{\cos b}\right)\\
\mathbf{else}:\\
\;\;\;\;r \cdot \left(\sin b \cdot \frac{1}{\cos a}\right)\\
\end{array}
\end{array}
if a < -0.0077000000000000002Initial program 63.9%
associate-*r/64.0%
+-commutative64.0%
Simplified64.0%
Taylor expanded in b around 0 63.7%
if -0.0077000000000000002 < a < 13Initial program 98.6%
+-commutative98.6%
Simplified98.6%
clear-num98.5%
associate-/r/98.6%
Applied egg-rr98.6%
Taylor expanded in a around 0 98.6%
if 13 < a Initial program 51.9%
+-commutative51.9%
Simplified51.9%
clear-num51.9%
associate-/r/52.0%
Applied egg-rr52.0%
Taylor expanded in b around 0 52.1%
Final simplification79.3%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.0002) (not (<= a 13.0))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0002) || !(a <= 13.0)) {
tmp = r * (sin(b) / 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 ((a <= (-0.0002d0)) .or. (.not. (a <= 13.0d0))) then
tmp = r * (sin(b) / 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 ((a <= -0.0002) || !(a <= 13.0)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.0002) or not (a <= 13.0): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.0002) || !(a <= 13.0)) tmp = Float64(r * Float64(sin(b) / 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 ((a <= -0.0002) || ~((a <= 13.0))) tmp = r * (sin(b) / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.0002], N[Not[LessEqual[a, 13.0]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / 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}\;a \leq -0.0002 \lor \neg \left(a \leq 13\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -2.0000000000000001e-4 or 13 < a Initial program 58.0%
+-commutative58.0%
Simplified58.0%
Taylor expanded in b around 0 58.0%
if -2.0000000000000001e-4 < a < 13Initial program 98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in a around 0 98.6%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.0032) (not (<= a 13.0))) (* r (/ (sin b) (cos a))) (* (sin b) (/ r (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0032) || !(a <= 13.0)) {
tmp = r * (sin(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 ((a <= (-0.0032d0)) .or. (.not. (a <= 13.0d0))) then
tmp = r * (sin(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 ((a <= -0.0032) || !(a <= 13.0)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.0032) or not (a <= 13.0): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.0032) || !(a <= 13.0)) tmp = Float64(r * Float64(sin(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 ((a <= -0.0032) || ~((a <= 13.0))) tmp = r * (sin(b) / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.0032], N[Not[LessEqual[a, 13.0]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0032 \lor \neg \left(a \leq 13\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if a < -0.00320000000000000015 or 13 < a Initial program 58.0%
+-commutative58.0%
Simplified58.0%
Taylor expanded in b around 0 58.0%
if -0.00320000000000000015 < a < 13Initial program 98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in a around 0 98.6%
*-commutative98.6%
associate-/l*98.6%
Simplified98.6%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (<= a -0.000245) (/ (* r (sin b)) (cos a)) (if (<= a 13.0) (* (sin b) (/ r (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.000245) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 13.0) {
tmp = sin(b) * (r / cos(b));
} 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 (a <= (-0.000245d0)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 13.0d0) then
tmp = sin(b) * (r / cos(b))
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 (a <= -0.000245) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 13.0) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.000245: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 13.0: tmp = math.sin(b) * (r / math.cos(b)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.000245) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 13.0) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.000245) tmp = (r * sin(b)) / cos(a); elseif (a <= 13.0) tmp = sin(b) * (r / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.000245], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 13.0], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000245:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 13:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -2.4499999999999999e-4Initial program 63.9%
associate-*r/64.0%
+-commutative64.0%
Simplified64.0%
Taylor expanded in b around 0 63.7%
if -2.4499999999999999e-4 < a < 13Initial program 98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in a around 0 98.6%
*-commutative98.6%
associate-/l*98.6%
Simplified98.6%
if 13 < a Initial program 51.9%
+-commutative51.9%
Simplified51.9%
Taylor expanded in b around 0 52.1%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (* r (* (sin b) (/ 1.0 (cos (+ b a))))))
double code(double r, double a, double b) {
return r * (sin(b) * (1.0 / 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) * (1.0d0 / cos((b + a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) * (1.0 / Math.cos((b + a))));
}
def code(r, a, b): return r * (math.sin(b) * (1.0 / math.cos((b + a))))
function code(r, a, b) return Float64(r * Float64(sin(b) * Float64(1.0 / cos(Float64(b + a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) * (1.0 / cos((b + a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] * N[(1.0 / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \left(\sin b \cdot \frac{1}{\cos \left(b + a\right)}\right)
\end{array}
Initial program 79.2%
+-commutative79.2%
Simplified79.2%
clear-num79.2%
associate-/r/79.3%
Applied egg-rr79.3%
Final simplification79.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(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 79.2%
Final simplification79.2%
(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 79.2%
+-commutative79.2%
Simplified79.2%
Taylor expanded in b around 0 55.0%
Final simplification55.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(b * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = b * (r / cos(a)); end
code[r_, a_, b_] := N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{r}{\cos a}
\end{array}
Initial program 79.2%
+-commutative79.2%
Simplified79.2%
Taylor expanded in b around 0 50.9%
associate-/l*50.6%
Simplified50.6%
Final simplification50.6%
(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 79.2%
+-commutative79.2%
Simplified79.2%
Taylor expanded in b around 0 51.0%
Final simplification51.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 79.2%
+-commutative79.2%
Simplified79.2%
Taylor expanded in b around 0 50.9%
associate-/l*50.6%
Simplified50.6%
Taylor expanded in a around 0 33.7%
Final simplification33.7%
herbie shell --seed 2024078
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))