
(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 15 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 (* (sin b) (/ r (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (r / ((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 = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / 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}
\\
\sin b \cdot \frac{r}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 70.1%
*-commutative70.1%
associate-/r/70.1%
+-commutative70.1%
Simplified70.1%
div-inv70.1%
clear-num70.2%
*-commutative70.2%
Applied egg-rr70.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(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 70.1%
+-commutative70.1%
Simplified70.1%
cos-sum99.5%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (cos b) (cos a) 0.0)))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), 0.0);
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), 0.0)) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, 0\right)}
\end{array}
Initial program 70.1%
associate-*r/70.2%
+-commutative70.2%
Simplified70.2%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-def99.4%
Applied egg-rr99.4%
add-sqr-sqrt45.4%
sqrt-unprod83.3%
sqr-neg83.3%
sqrt-unprod37.8%
add-sqr-sqrt70.2%
sin-mult71.4%
div-sub71.4%
cos-diff70.6%
add-sqr-sqrt38.2%
sqrt-unprod71.5%
sqr-neg71.5%
sqrt-unprod33.3%
add-sqr-sqrt72.4%
cancel-sign-sub-inv72.4%
cos-sum71.6%
Applied egg-rr71.6%
+-inverses71.6%
Simplified71.6%
Final simplification71.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.0048) (not (<= b 5.4e-5))) (* r (/ (sin b) (cos b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0048) || !(b <= 5.4e-5)) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = (r * b) / 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.0048d0)) .or. (.not. (b <= 5.4d-5))) then
tmp = r * (sin(b) / cos(b))
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0048) || !(b <= 5.4e-5)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.0048) or not (b <= 5.4e-5): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.0048) || !(b <= 5.4e-5)) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.0048) || ~((b <= 5.4e-5))) tmp = r * (sin(b) / cos(b)); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.0048], N[Not[LessEqual[b, 5.4e-5]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0048 \lor \neg \left(b \leq 5.4 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -0.00479999999999999958 or 5.3999999999999998e-5 < b Initial program 47.4%
+-commutative47.4%
Simplified47.4%
Taylor expanded in a around 0 47.6%
if -0.00479999999999999958 < b < 5.3999999999999998e-5Initial program 98.5%
associate-*r/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 (<= b -0.0034) (not (<= b 5.4e-5))) (* (sin b) (/ r (cos b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0034) || !(b <= 5.4e-5)) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = (r * b) / 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.0034d0)) .or. (.not. (b <= 5.4d-5))) then
tmp = sin(b) * (r / cos(b))
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0034) || !(b <= 5.4e-5)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.0034) or not (b <= 5.4e-5): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.0034) || !(b <= 5.4e-5)) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.0034) || ~((b <= 5.4e-5))) tmp = sin(b) * (r / cos(b)); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.0034], N[Not[LessEqual[b, 5.4e-5]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0034 \lor \neg \left(b \leq 5.4 \cdot 10^{-5}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -0.00339999999999999981 or 5.3999999999999998e-5 < b Initial program 47.4%
*-commutative47.4%
associate-/r/47.4%
+-commutative47.4%
Simplified47.4%
div-inv47.4%
clear-num47.5%
*-commutative47.5%
Applied egg-rr47.5%
Taylor expanded in a around 0 47.7%
if -0.00339999999999999981 < b < 5.3999999999999998e-5Initial program 98.5%
associate-*r/98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.5%
Final simplification70.3%
(FPCore (r a b) :precision binary64 (if (<= b -0.0034) (* (sin b) (/ r (cos b))) (if (<= b 0.00022) (/ (* r b) (cos (+ b a))) (/ (sin b) (/ (cos b) r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.0034) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 0.00022) {
tmp = (r * b) / cos((b + 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) :: tmp
if (b <= (-0.0034d0)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 0.00022d0) then
tmp = (r * b) / cos((b + 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 tmp;
if (b <= -0.0034) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 0.00022) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = Math.sin(b) / (Math.cos(b) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.0034: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 0.00022: tmp = (r * b) / math.cos((b + a)) else: tmp = math.sin(b) / (math.cos(b) / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.0034) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 0.00022) tmp = Float64(Float64(r * b) / cos(Float64(b + a))); else tmp = Float64(sin(b) / Float64(cos(b) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.0034) tmp = sin(b) * (r / cos(b)); elseif (b <= 0.00022) tmp = (r * b) / cos((b + a)); else tmp = sin(b) / (cos(b) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.0034], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.00022], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0034:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 0.00022:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\end{array}
\end{array}
if b < -0.00339999999999999981Initial program 50.1%
*-commutative50.1%
associate-/r/50.1%
+-commutative50.1%
Simplified50.1%
div-inv50.1%
clear-num50.2%
*-commutative50.2%
Applied egg-rr50.2%
Taylor expanded in a around 0 50.0%
if -0.00339999999999999981 < b < 2.20000000000000008e-4Initial program 98.5%
associate-*r/98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.5%
if 2.20000000000000008e-4 < b Initial program 45.1%
*-commutative45.1%
associate-/r/45.1%
+-commutative45.1%
Simplified45.1%
Taylor expanded in a around 0 45.8%
Final simplification70.3%
(FPCore (r a b) :precision binary64 (if (<= b -0.004) (/ (* r (sin b)) (cos b)) (if (<= b 6.5e-5) (/ (* r b) (cos (+ b a))) (/ (sin b) (/ (cos b) r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.004) {
tmp = (r * sin(b)) / cos(b);
} else if (b <= 6.5e-5) {
tmp = (r * b) / cos((b + 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) :: tmp
if (b <= (-0.004d0)) then
tmp = (r * sin(b)) / cos(b)
else if (b <= 6.5d-5) then
tmp = (r * b) / cos((b + 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 tmp;
if (b <= -0.004) {
tmp = (r * Math.sin(b)) / Math.cos(b);
} else if (b <= 6.5e-5) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = Math.sin(b) / (Math.cos(b) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.004: tmp = (r * math.sin(b)) / math.cos(b) elif b <= 6.5e-5: tmp = (r * b) / math.cos((b + a)) else: tmp = math.sin(b) / (math.cos(b) / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.004) tmp = Float64(Float64(r * sin(b)) / cos(b)); elseif (b <= 6.5e-5) tmp = Float64(Float64(r * b) / cos(Float64(b + a))); else tmp = Float64(sin(b) / Float64(cos(b) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.004) tmp = (r * sin(b)) / cos(b); elseif (b <= 6.5e-5) tmp = (r * b) / cos((b + a)); else tmp = sin(b) / (cos(b) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.004], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e-5], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.004:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\end{array}
\end{array}
if b < -0.0040000000000000001Initial program 50.1%
+-commutative50.1%
Simplified50.1%
Taylor expanded in a around 0 50.0%
if -0.0040000000000000001 < b < 6.49999999999999943e-5Initial program 98.5%
associate-*r/98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.5%
if 6.49999999999999943e-5 < b Initial program 45.1%
*-commutative45.1%
associate-/r/45.1%
+-commutative45.1%
Simplified45.1%
Taylor expanded in a around 0 45.8%
Final simplification70.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 70.1%
Final simplification70.1%
(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.1%
*-commutative70.1%
associate-/r/70.1%
+-commutative70.1%
Simplified70.1%
div-inv70.1%
clear-num70.2%
*-commutative70.2%
Applied egg-rr70.2%
Final simplification70.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 70.1%
+-commutative70.1%
Simplified70.1%
Taylor expanded in b around 0 50.3%
Final simplification50.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.6) (not (<= b 3.7))) (/ (sin b) (/ 1.0 r)) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.6) || !(b <= 3.7)) {
tmp = sin(b) / (1.0 / r);
} else {
tmp = (r * b) / 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 <= (-4.6d0)) .or. (.not. (b <= 3.7d0))) then
tmp = sin(b) / (1.0d0 / r)
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -4.6) || !(b <= 3.7)) {
tmp = Math.sin(b) / (1.0 / r);
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.6) or not (b <= 3.7): tmp = math.sin(b) / (1.0 / r) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.6) || !(b <= 3.7)) tmp = Float64(sin(b) / Float64(1.0 / r)); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.6) || ~((b <= 3.7))) tmp = sin(b) / (1.0 / r); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.6], N[Not[LessEqual[b, 3.7]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] / N[(1.0 / r), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \lor \neg \left(b \leq 3.7\right):\\
\;\;\;\;\frac{\sin b}{\frac{1}{r}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -4.5999999999999996 or 3.7000000000000002 < b Initial program 46.8%
*-commutative46.8%
associate-/r/46.8%
+-commutative46.8%
Simplified46.8%
clear-num46.8%
inv-pow46.8%
Applied egg-rr46.8%
unpow-146.8%
+-commutative46.8%
Simplified46.8%
associate-/r/46.8%
+-commutative46.8%
cos-sum99.1%
prod-diff99.2%
*-commutative99.2%
fma-neg99.1%
cos-sum46.8%
distribute-lft-in46.8%
+-commutative46.8%
associate-/r/46.8%
+-commutative46.8%
clear-num46.8%
Applied egg-rr44.0%
*-commutative44.0%
associate-*r/44.0%
*-rgt-identity44.0%
count-244.0%
Simplified44.0%
Taylor expanded in a around 0 44.7%
Taylor expanded in b around 0 12.0%
if -4.5999999999999996 < b < 3.7000000000000002Initial program 97.9%
associate-*r/97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 96.6%
Final simplification50.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.0) (not (<= b 4800.0))) (/ (sin b) (/ 1.0 r)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.0) || !(b <= 4800.0)) {
tmp = sin(b) / (1.0 / r);
} 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 <= (-1.0d0)) .or. (.not. (b <= 4800.0d0))) then
tmp = sin(b) / (1.0d0 / r)
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 <= -1.0) || !(b <= 4800.0)) {
tmp = Math.sin(b) / (1.0 / r);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.0) or not (b <= 4800.0): tmp = math.sin(b) / (1.0 / r) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.0) || !(b <= 4800.0)) tmp = Float64(sin(b) / Float64(1.0 / r)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.0) || ~((b <= 4800.0))) tmp = sin(b) / (1.0 / r); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.0], N[Not[LessEqual[b, 4800.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] / N[(1.0 / r), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \lor \neg \left(b \leq 4800\right):\\
\;\;\;\;\frac{\sin b}{\frac{1}{r}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1 or 4800 < b Initial program 46.8%
*-commutative46.8%
associate-/r/46.8%
+-commutative46.8%
Simplified46.8%
clear-num46.8%
inv-pow46.8%
Applied egg-rr46.8%
unpow-146.8%
+-commutative46.8%
Simplified46.8%
associate-/r/46.8%
+-commutative46.8%
cos-sum99.1%
prod-diff99.2%
*-commutative99.2%
fma-neg99.1%
cos-sum46.8%
distribute-lft-in46.8%
+-commutative46.8%
associate-/r/46.8%
+-commutative46.8%
clear-num46.8%
Applied egg-rr44.0%
*-commutative44.0%
associate-*r/44.0%
*-rgt-identity44.0%
count-244.0%
Simplified44.0%
Taylor expanded in a around 0 44.7%
Taylor expanded in b around 0 12.0%
if -1 < b < 4800Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 96.2%
Final simplification50.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -11.0) (not (<= b 4800.0))) (/ (sin b) (/ 1.0 r)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -11.0) || !(b <= 4800.0)) {
tmp = sin(b) / (1.0 / r);
} 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 <= (-11.0d0)) .or. (.not. (b <= 4800.0d0))) then
tmp = sin(b) / (1.0d0 / r)
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 <= -11.0) || !(b <= 4800.0)) {
tmp = Math.sin(b) / (1.0 / r);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -11.0) or not (b <= 4800.0): tmp = math.sin(b) / (1.0 / r) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -11.0) || !(b <= 4800.0)) tmp = Float64(sin(b) / Float64(1.0 / r)); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -11.0) || ~((b <= 4800.0))) tmp = sin(b) / (1.0 / r); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -11.0], N[Not[LessEqual[b, 4800.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] / N[(1.0 / r), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -11 \lor \neg \left(b \leq 4800\right):\\
\;\;\;\;\frac{\sin b}{\frac{1}{r}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -11 or 4800 < b Initial program 46.8%
*-commutative46.8%
associate-/r/46.8%
+-commutative46.8%
Simplified46.8%
clear-num46.8%
inv-pow46.8%
Applied egg-rr46.8%
unpow-146.8%
+-commutative46.8%
Simplified46.8%
associate-/r/46.8%
+-commutative46.8%
cos-sum99.1%
prod-diff99.2%
*-commutative99.2%
fma-neg99.1%
cos-sum46.8%
distribute-lft-in46.8%
+-commutative46.8%
associate-/r/46.8%
+-commutative46.8%
clear-num46.8%
Applied egg-rr44.0%
*-commutative44.0%
associate-*r/44.0%
*-rgt-identity44.0%
count-244.0%
Simplified44.0%
Taylor expanded in a around 0 44.7%
Taylor expanded in b around 0 12.0%
if -11 < b < 4800Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 96.3%
Final simplification50.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.1%
+-commutative70.1%
Simplified70.1%
Taylor expanded in b around 0 46.0%
Final simplification46.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 70.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 B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))