
(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 (- (/ (* (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.5%
associate-*r/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.5%
associate-*r/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%
sub-neg99.5%
*-commutative99.5%
associate-/l*99.5%
Applied egg-rr99.5%
unsub-neg99.5%
quot-tan99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -9e-6) (not (<= b 16500.0))) (* r (/ (sin b) (cos b))) (* b (/ r (cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -9e-6) || !(b <= 16500.0)) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = b * (r / 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 <= (-9d-6)) .or. (.not. (b <= 16500.0d0))) then
tmp = r * (sin(b) / cos(b))
else
tmp = b * (r / cos((b + a)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -9e-6) || !(b <= 16500.0)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = b * (r / Math.cos((b + a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -9e-6) or not (b <= 16500.0): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = b * (r / math.cos((b + a))) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -9e-6) || !(b <= 16500.0)) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(b * Float64(r / cos(Float64(b + a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -9e-6) || ~((b <= 16500.0))) tmp = r * (sin(b) / cos(b)); else tmp = b * (r / cos((b + a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -9e-6], 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[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-6} \lor \neg \left(b \leq 16500\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -9.00000000000000023e-6 or 16500 < b Initial program 59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in a around 0 58.9%
if -9.00000000000000023e-6 < b < 16500Initial program 98.6%
associate-*r/98.7%
associate-/l*98.6%
+-commutative98.6%
Simplified98.6%
associate-/r/98.8%
Applied egg-rr98.8%
Taylor expanded in b around 0 98.8%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.5e-5) (not (<= b 16500.0))) (* (sin b) (/ r (cos b))) (* b (/ r (cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.5e-5) || !(b <= 16500.0)) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = b * (r / 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 <= (-1.5d-5)) .or. (.not. (b <= 16500.0d0))) then
tmp = sin(b) * (r / cos(b))
else
tmp = b * (r / cos((b + a)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -1.5e-5) || !(b <= 16500.0)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = b * (r / Math.cos((b + a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.5e-5) or not (b <= 16500.0): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = b * (r / math.cos((b + a))) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.5e-5) || !(b <= 16500.0)) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(b * Float64(r / cos(Float64(b + a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.5e-5) || ~((b <= 16500.0))) tmp = sin(b) * (r / cos(b)); else tmp = b * (r / cos((b + a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.5e-5], N[Not[LessEqual[b, 16500.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-5} \lor \neg \left(b \leq 16500\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -1.50000000000000004e-5 or 16500 < b Initial program 59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in a around 0 59.0%
associate-/l*59.0%
associate-/r/59.0%
Simplified59.0%
if -1.50000000000000004e-5 < b < 16500Initial program 98.6%
associate-*r/98.7%
associate-/l*98.6%
+-commutative98.6%
Simplified98.6%
associate-/r/98.8%
Applied egg-rr98.8%
Taylor expanded in b around 0 98.8%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (<= b -1.8e-5) (/ r (/ (cos b) (sin b))) (if (<= b 16500.0) (* b (/ r (cos (+ b a)))) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.8e-5) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 16500.0) {
tmp = b * (r / cos((b + 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 (b <= (-1.8d-5)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 16500.0d0) then
tmp = b * (r / cos((b + 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 (b <= -1.8e-5) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 16500.0) {
tmp = b * (r / Math.cos((b + a)));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.8e-5: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 16500.0: tmp = b * (r / math.cos((b + a))) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.8e-5) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 16500.0) tmp = Float64(b * Float64(r / cos(Float64(b + 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 (b <= -1.8e-5) tmp = r / (cos(b) / sin(b)); elseif (b <= 16500.0) tmp = b * (r / cos((b + a))); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.8e-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[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.8 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 16500:\\
\;\;\;\;b \cdot \frac{r}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -1.80000000000000005e-5Initial program 60.0%
associate-*r/60.0%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in a around 0 57.9%
if -1.80000000000000005e-5 < b < 16500Initial program 98.6%
associate-*r/98.7%
associate-/l*98.6%
+-commutative98.6%
Simplified98.6%
associate-/r/98.8%
Applied egg-rr98.8%
Taylor expanded in b around 0 98.8%
if 16500 < b Initial program 59.5%
+-commutative59.5%
Simplified59.5%
Taylor expanded in a around 0 60.2%
associate-/l*60.0%
associate-/r/60.1%
Simplified60.1%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (<= b -0.000102) (/ r (/ (cos b) (sin b))) (if (<= b 16500.0) (* b (/ r (cos (+ b a)))) (/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.000102) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 16500.0) {
tmp = b * (r / cos((b + a)));
} else {
tmp = (r * sin(b)) / cos(b);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-0.000102d0)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 16500.0d0) then
tmp = b * (r / cos((b + a)))
else
tmp = (r * sin(b)) / cos(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -0.000102) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 16500.0) {
tmp = b * (r / Math.cos((b + a)));
} else {
tmp = (r * Math.sin(b)) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.000102: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 16500.0: tmp = b * (r / math.cos((b + a))) else: tmp = (r * math.sin(b)) / math.cos(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.000102) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 16500.0) tmp = Float64(b * Float64(r / cos(Float64(b + 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 <= -0.000102) tmp = r / (cos(b) / sin(b)); elseif (b <= 16500.0) tmp = b * (r / cos((b + a))); else tmp = (r * sin(b)) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.000102], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 16500.0], N[(b * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $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 -0.000102:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 16500:\\
\;\;\;\;b \cdot \frac{r}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\end{array}
\end{array}
if b < -1.01999999999999999e-4Initial program 60.0%
associate-*r/60.0%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in a around 0 57.9%
if -1.01999999999999999e-4 < b < 16500Initial program 98.6%
associate-*r/98.7%
associate-/l*98.6%
+-commutative98.6%
Simplified98.6%
associate-/r/98.8%
Applied egg-rr98.8%
Taylor expanded in b around 0 98.8%
if 16500 < b Initial program 59.5%
+-commutative59.5%
Simplified59.5%
Taylor expanded in a around 0 60.2%
Final simplification79.2%
(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.5%
Final simplification79.5%
(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.5%
associate-*r/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 (* 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.5%
+-commutative79.5%
Simplified79.5%
Taylor expanded in b around 0 56.0%
Final simplification56.0%
(FPCore (r a b) :precision binary64 (if (<= b -3.9) (* r (sin b)) (if (<= b 2.5) (* b (/ r (cos (+ b a)))) (/ (sin b) (/ 1.0 r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -3.9) {
tmp = r * sin(b);
} else if (b <= 2.5) {
tmp = b * (r / cos((b + a)));
} else {
tmp = sin(b) / (1.0 / 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 <= (-3.9d0)) then
tmp = r * sin(b)
else if (b <= 2.5d0) then
tmp = b * (r / cos((b + a)))
else
tmp = sin(b) / (1.0d0 / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -3.9) {
tmp = r * Math.sin(b);
} else if (b <= 2.5) {
tmp = b * (r / Math.cos((b + a)));
} else {
tmp = Math.sin(b) / (1.0 / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -3.9: tmp = r * math.sin(b) elif b <= 2.5: tmp = b * (r / math.cos((b + a))) else: tmp = math.sin(b) / (1.0 / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -3.9) tmp = Float64(r * sin(b)); elseif (b <= 2.5) tmp = Float64(b * Float64(r / cos(Float64(b + a)))); else tmp = Float64(sin(b) / Float64(1.0 / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -3.9) tmp = r * sin(b); elseif (b <= 2.5) tmp = b * (r / cos((b + a))); else tmp = sin(b) / (1.0 / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -3.9], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5], N[(b * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(1.0 / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.9:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{elif}\;b \leq 2.5:\\
\;\;\;\;b \cdot \frac{r}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{1}{r}}\\
\end{array}
\end{array}
if b < -3.89999999999999991Initial program 60.0%
associate-*r/60.0%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
associate-/r/60.1%
Applied egg-rr60.1%
Taylor expanded in b around 0 12.0%
Taylor expanded in a around 0 13.1%
if -3.89999999999999991 < b < 2.5Initial program 99.4%
associate-*r/99.5%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
associate-/r/99.5%
Applied egg-rr99.5%
Taylor expanded in b around 0 99.5%
if 2.5 < b Initial program 58.6%
associate-*r/58.7%
associate-/l*58.6%
+-commutative58.6%
Simplified58.6%
associate-/r/58.6%
Applied egg-rr58.6%
Taylor expanded in b around 0 11.7%
Taylor expanded in r around 0 11.7%
*-commutative11.7%
*-rgt-identity11.7%
times-frac11.7%
/-rgt-identity11.7%
associate-/r/11.7%
Simplified11.7%
Taylor expanded in a around 0 13.2%
Final simplification56.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.45) (not (<= b 1.9e-18))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.45) || !(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 <= (-1.45d0)) .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 <= -1.45) || !(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 <= -1.45) 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 <= -1.45) || !(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 <= -1.45) || ~((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, -1.45], 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 -1.45 \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 < -1.44999999999999996 or 1.8999999999999999e-18 < b Initial program 59.9%
associate-*r/60.0%
associate-/l*60.0%
+-commutative60.0%
Simplified60.0%
associate-/r/60.0%
Applied egg-rr60.0%
Taylor expanded in b around 0 13.2%
Taylor expanded in a around 0 14.5%
if -1.44999999999999996 < b < 1.8999999999999999e-18Initial program 99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in b around 0 99.4%
Final simplification56.6%
(FPCore (r a b) :precision binary64 (if (<= b -1.25) (* r (sin b)) (if (<= b 1.1) (/ (* r b) (cos a)) (/ (sin b) (/ 1.0 r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.25) {
tmp = r * sin(b);
} else if (b <= 1.1) {
tmp = (r * b) / cos(a);
} else {
tmp = sin(b) / (1.0 / 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 <= (-1.25d0)) then
tmp = r * sin(b)
else if (b <= 1.1d0) then
tmp = (r * b) / cos(a)
else
tmp = sin(b) / (1.0d0 / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -1.25) {
tmp = r * Math.sin(b);
} else if (b <= 1.1) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = Math.sin(b) / (1.0 / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.25: tmp = r * math.sin(b) elif b <= 1.1: tmp = (r * b) / math.cos(a) else: tmp = math.sin(b) / (1.0 / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.25) tmp = Float64(r * sin(b)); elseif (b <= 1.1) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(sin(b) / Float64(1.0 / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -1.25) tmp = r * sin(b); elseif (b <= 1.1) tmp = (r * b) / cos(a); else tmp = sin(b) / (1.0 / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.25], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(1.0 / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{elif}\;b \leq 1.1:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{1}{r}}\\
\end{array}
\end{array}
if b < -1.25Initial program 60.0%
associate-*r/60.0%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
associate-/r/60.1%
Applied egg-rr60.1%
Taylor expanded in b around 0 12.0%
Taylor expanded in a around 0 13.1%
if -1.25 < b < 1.1000000000000001Initial program 99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in b around 0 99.5%
if 1.1000000000000001 < b Initial program 58.6%
associate-*r/58.7%
associate-/l*58.6%
+-commutative58.6%
Simplified58.6%
associate-/r/58.6%
Applied egg-rr58.6%
Taylor expanded in b around 0 11.7%
Taylor expanded in r around 0 11.7%
*-commutative11.7%
*-rgt-identity11.7%
times-frac11.7%
/-rgt-identity11.7%
associate-/r/11.7%
Simplified11.7%
Taylor expanded in a around 0 13.2%
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.5%
associate-*r/79.6%
associate-/l*79.5%
+-commutative79.5%
Simplified79.5%
associate-/r/79.6%
Applied egg-rr79.6%
Taylor expanded in b around 0 56.0%
Taylor expanded in a around 0 41.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.5%
+-commutative79.5%
Simplified79.5%
Taylor expanded in b around 0 52.2%
Taylor expanded in a around 0 36.4%
Final simplification36.4%
herbie shell --seed 2023318
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))