
(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 13 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 (- (/ (* (cos b) (cos a)) (sin b)) (sin a))))
double code(double r, double a, double b) {
return 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 = r / (((cos(b) * cos(a)) / sin(b)) - sin(a))
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));
}
def code(r, a, b): return r / (((math.cos(b) * math.cos(a)) / math.sin(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(b) * cos(a)) / sin(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / (((cos(b) * cos(a)) / sin(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos b \cdot \cos a}{\sin b} - \sin a}
\end{array}
Initial program 79.6%
associate-/l*79.5%
+-commutative79.5%
Simplified79.5%
cos-sum99.5%
div-sub99.5%
Applied egg-rr99.5%
Taylor expanded in b around 0 99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (- (/ (cos a) (tan b)) (sin a))))
double code(double r, double a, double b) {
return r / ((cos(a) / tan(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 / ((cos(a) / tan(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / ((Math.cos(a) / Math.tan(b)) - Math.sin(a));
}
def code(r, a, b): return r / ((math.cos(a) / math.tan(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(cos(a) / tan(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / ((cos(a) / tan(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a}{\tan b} - \sin a}
\end{array}
Initial program 79.6%
associate-/l*79.5%
+-commutative79.5%
Simplified79.5%
log1p-expm1-u43.8%
Applied egg-rr43.8%
log1p-expm1-u79.5%
cos-sum99.5%
div-sub99.5%
sub-neg99.5%
*-commutative99.5%
associate-/l*99.5%
quot-tan99.5%
associate-/l*99.5%
associate-/r/99.5%
Applied egg-rr99.5%
sub-neg99.5%
*-inverses99.5%
*-lft-identity99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.00014) (not (<= a 0.01))) (* r (/ (sin b) (cos a))) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00014) || !(a <= 0.01)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-0.00014d0)) .or. (.not. (a <= 0.01d0))) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00014) || !(a <= 0.01)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.00014) or not (a <= 0.01): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.00014) || !(a <= 0.01)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.00014) || ~((a <= 0.01))) tmp = r * (sin(b) / cos(a)); else tmp = r * (1.0 / ((1.0 / tan(b)) - a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.00014], N[Not[LessEqual[a, 0.01]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00014 \lor \neg \left(a \leq 0.01\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -1.3999999999999999e-4 or 0.0100000000000000002 < a Initial program 59.0%
associate-/l*59.0%
+-commutative59.0%
Simplified59.0%
clear-num58.2%
associate-/r/58.8%
clear-num58.9%
Applied egg-rr58.9%
Taylor expanded in b around 0 56.5%
if -1.3999999999999999e-4 < a < 0.0100000000000000002Initial program 98.9%
associate-/l*98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in a around 0 99.1%
+-commutative99.1%
mul-1-neg99.1%
unsub-neg99.1%
Simplified99.1%
clear-num98.5%
associate-/r/99.2%
clear-num99.1%
quot-tan99.2%
Applied egg-rr99.2%
Final simplification78.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -1e-5) (not (<= b 16500.0))) (* r (/ (sin b) (cos b))) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1e-5) || !(b <= 16500.0)) {
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 <= (-1d-5)) .or. (.not. (b <= 16500.0d0))) 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 <= -1e-5) || !(b <= 16500.0)) {
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 <= -1e-5) or not (b <= 16500.0): 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 <= -1e-5) || !(b <= 16500.0)) 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 <= -1e-5) || ~((b <= 16500.0))) 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, -1e-5], N[Not[LessEqual[b, 16500.0]], $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 -1 \cdot 10^{-5} \lor \neg \left(b \leq 16500\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.00000000000000008e-5 or 16500 < b Initial program 59.8%
associate-/l*59.8%
+-commutative59.8%
Simplified59.8%
clear-num59.7%
associate-/r/59.8%
clear-num59.8%
Applied egg-rr59.8%
Taylor expanded in a around 0 58.9%
if -1.00000000000000008e-5 < b < 16500Initial program 98.7%
associate-/l*98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.7%
associate-/r/98.8%
Applied egg-rr98.8%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -3e-6) (not (<= b 16500.0))) (/ r (/ (cos b) (sin b))) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -3e-6) || !(b <= 16500.0)) {
tmp = r / (cos(b) / 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 <= (-3d-6)) .or. (.not. (b <= 16500.0d0))) then
tmp = r / (cos(b) / 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 <= -3e-6) || !(b <= 16500.0)) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -3e-6) or not (b <= 16500.0): tmp = r / (math.cos(b) / math.sin(b)) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -3e-6) || !(b <= 16500.0)) tmp = Float64(r / Float64(cos(b) / 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 <= -3e-6) || ~((b <= 16500.0))) tmp = r / (cos(b) / sin(b)); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -3e-6], N[Not[LessEqual[b, 16500.0]], $MachinePrecision]], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{-6} \lor \neg \left(b \leq 16500\right):\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -3.0000000000000001e-6 or 16500 < b Initial program 59.8%
associate-/l*59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in a around 0 59.0%
if -3.0000000000000001e-6 < b < 16500Initial program 98.7%
associate-/l*98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.7%
associate-/r/98.8%
Applied egg-rr98.8%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (<= b -9.2e-5) (/ r (/ (cos b) (sin b))) (if (<= b 16500.0) (* b (/ r (cos a))) (/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -9.2e-5) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 16500.0) {
tmp = 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 <= (-9.2d-5)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 16500.0d0) then
tmp = 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 <= -9.2e-5) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 16500.0) {
tmp = 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 <= -9.2e-5: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 16500.0: tmp = 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 <= -9.2e-5) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 16500.0) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(Float64(r * sin(b)) / cos(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -9.2e-5) tmp = r / (cos(b) / sin(b)); elseif (b <= 16500.0) tmp = b * (r / cos(a)); else tmp = (r * sin(b)) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -9.2e-5], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 16500.0], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 16500:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\end{array}
\end{array}
if b < -9.20000000000000001e-5Initial program 60.0%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in a around 0 57.9%
if -9.20000000000000001e-5 < b < 16500Initial program 98.7%
associate-/l*98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.7%
associate-/r/98.8%
Applied egg-rr98.8%
if 16500 < b Initial program 59.6%
+-commutative59.6%
Simplified59.6%
Taylor expanded in a around 0 60.2%
Final simplification79.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 79.6%
associate-/l*79.5%
+-commutative79.5%
Simplified79.5%
associate-/r/79.6%
Applied egg-rr79.6%
Final simplification79.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -5.5e-5) (not (<= b 16500.0))) (/ r (- (/ 1.0 (tan b)) a)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -5.5e-5) || !(b <= 16500.0)) {
tmp = r / ((1.0 / tan(b)) - a);
} else {
tmp = b * (r / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-5.5d-5)) .or. (.not. (b <= 16500.0d0))) then
tmp = r / ((1.0d0 / tan(b)) - a)
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -5.5e-5) || !(b <= 16500.0)) {
tmp = r / ((1.0 / Math.tan(b)) - a);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -5.5e-5) or not (b <= 16500.0): tmp = r / ((1.0 / math.tan(b)) - a) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -5.5e-5) || !(b <= 16500.0)) tmp = Float64(r / Float64(Float64(1.0 / tan(b)) - a)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -5.5e-5) || ~((b <= 16500.0))) tmp = r / ((1.0 / tan(b)) - a); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -5.5e-5], N[Not[LessEqual[b, 16500.0]], $MachinePrecision]], N[(r / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-5} \lor \neg \left(b \leq 16500\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -5.5000000000000002e-5 or 16500 < b Initial program 59.8%
associate-/l*59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in a around 0 55.4%
+-commutative55.4%
mul-1-neg55.4%
unsub-neg55.4%
Simplified55.4%
expm1-log1p-u49.0%
expm1-udef48.9%
clear-num48.8%
quot-tan48.9%
Applied egg-rr48.9%
expm1-def49.0%
expm1-log1p55.4%
Simplified55.4%
if -5.5000000000000002e-5 < b < 16500Initial program 98.7%
associate-/l*98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.7%
associate-/r/98.8%
Applied egg-rr98.8%
Final simplification77.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (- (/ 1.0 (tan b)) a)))
(if (<= b -3.2e-5)
(* r (/ 1.0 t_0))
(if (<= b 16500.0) (* b (/ r (cos a))) (/ r t_0)))))
double code(double r, double a, double b) {
double t_0 = (1.0 / tan(b)) - a;
double tmp;
if (b <= -3.2e-5) {
tmp = r * (1.0 / t_0);
} else if (b <= 16500.0) {
tmp = b * (r / cos(a));
} else {
tmp = r / t_0;
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / tan(b)) - a
if (b <= (-3.2d-5)) then
tmp = r * (1.0d0 / t_0)
else if (b <= 16500.0d0) then
tmp = b * (r / cos(a))
else
tmp = r / t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = (1.0 / Math.tan(b)) - a;
double tmp;
if (b <= -3.2e-5) {
tmp = r * (1.0 / t_0);
} else if (b <= 16500.0) {
tmp = b * (r / Math.cos(a));
} else {
tmp = r / t_0;
}
return tmp;
}
def code(r, a, b): t_0 = (1.0 / math.tan(b)) - a tmp = 0 if b <= -3.2e-5: tmp = r * (1.0 / t_0) elif b <= 16500.0: tmp = b * (r / math.cos(a)) else: tmp = r / t_0 return tmp
function code(r, a, b) t_0 = Float64(Float64(1.0 / tan(b)) - a) tmp = 0.0 if (b <= -3.2e-5) tmp = Float64(r * Float64(1.0 / t_0)); elseif (b <= 16500.0) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(r / t_0); end return tmp end
function tmp_2 = code(r, a, b) t_0 = (1.0 / tan(b)) - a; tmp = 0.0; if (b <= -3.2e-5) tmp = r * (1.0 / t_0); elseif (b <= 16500.0) tmp = b * (r / cos(a)); else tmp = r / t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]}, If[LessEqual[b, -3.2e-5], N[(r * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 16500.0], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\tan b} - a\\
\mathbf{if}\;b \leq -3.2 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{1}{t_0}\\
\mathbf{elif}\;b \leq 16500:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{t_0}\\
\end{array}
\end{array}
if b < -3.19999999999999986e-5Initial program 60.0%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in a around 0 55.5%
+-commutative55.5%
mul-1-neg55.5%
unsub-neg55.5%
Simplified55.5%
clear-num55.3%
associate-/r/55.5%
clear-num55.4%
quot-tan55.4%
Applied egg-rr55.4%
if -3.19999999999999986e-5 < b < 16500Initial program 98.7%
associate-/l*98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.7%
associate-/r/98.8%
Applied egg-rr98.8%
if 16500 < b Initial program 59.6%
associate-/l*59.5%
+-commutative59.5%
Simplified59.5%
Taylor expanded in a around 0 55.3%
+-commutative55.3%
mul-1-neg55.3%
unsub-neg55.3%
Simplified55.3%
expm1-log1p-u53.3%
expm1-udef53.2%
clear-num53.3%
quot-tan53.3%
Applied egg-rr53.3%
expm1-def53.4%
expm1-log1p55.4%
Simplified55.4%
Final simplification77.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.7) (not (<= b 1.9e-18))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.7) || !(b <= 1.9e-18)) {
tmp = r * sin(b);
} 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 <= (-4.7d0)) .or. (.not. (b <= 1.9d-18))) then
tmp = r * sin(b)
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 <= -4.7) || !(b <= 1.9e-18)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.7) or not (b <= 1.9e-18): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.7) || !(b <= 1.9e-18)) tmp = Float64(r * sin(b)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.7) || ~((b <= 1.9e-18))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.7], N[Not[LessEqual[b, 1.9e-18]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.7 \lor \neg \left(b \leq 1.9 \cdot 10^{-18}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -4.70000000000000018 or 1.8999999999999999e-18 < b Initial program 60.0%
+-commutative60.0%
Simplified60.0%
Taylor expanded in b around 0 13.2%
Taylor expanded in a around 0 14.5%
*-commutative14.5%
Simplified14.5%
if -4.70000000000000018 < b < 1.8999999999999999e-18Initial program 99.5%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in b around 0 99.3%
clear-num98.0%
associate-/r/99.3%
clear-num99.4%
Applied egg-rr99.4%
Final simplification56.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.3) (not (<= b 1.9e-18))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.3) || !(b <= 1.9e-18)) {
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 <= (-1.3d0)) .or. (.not. (b <= 1.9d-18))) 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 <= -1.3) || !(b <= 1.9e-18)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.3) or not (b <= 1.9e-18): tmp = r * math.sin(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.3) || !(b <= 1.9e-18)) tmp = Float64(r * 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 <= -1.3) || ~((b <= 1.9e-18))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.3], N[Not[LessEqual[b, 1.9e-18]], $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 -1.3 \lor \neg \left(b \leq 1.9 \cdot 10^{-18}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.30000000000000004 or 1.8999999999999999e-18 < b Initial program 60.0%
+-commutative60.0%
Simplified60.0%
Taylor expanded in b around 0 13.2%
Taylor expanded in a around 0 14.5%
*-commutative14.5%
Simplified14.5%
if -1.30000000000000004 < b < 1.8999999999999999e-18Initial program 99.5%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in b around 0 99.3%
associate-/r/99.5%
Applied egg-rr99.5%
Final simplification56.7%
(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 79.6%
+-commutative79.6%
Simplified79.6%
Taylor expanded in b around 0 56.0%
Taylor expanded in a around 0 41.1%
*-commutative41.1%
Simplified41.1%
Final simplification41.1%
(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.6%
associate-/l*79.5%
+-commutative79.5%
Simplified79.5%
Taylor expanded in b around 0 52.1%
Taylor expanded in a around 0 36.4%
Final simplification36.4%
herbie shell --seed 2023318
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))