
(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(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(-Float64(sin(b) * sin(a))))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + (-N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, -\sin b \cdot \sin a\right)}
\end{array}
Initial program 76.3%
associate-*r/76.3%
+-commutative76.3%
Simplified76.3%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (sin b) (/ (fma (cos b) (cos a) (- (* (sin b) (sin a)))) r)))
double code(double r, double a, double b) {
return sin(b) / (fma(cos(b), cos(a), -(sin(b) * sin(a))) / r);
}
function code(r, a, b) return Float64(sin(b) / Float64(fma(cos(b), cos(a), Float64(-Float64(sin(b) * sin(a)))) / r)) end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + (-N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision])), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\frac{\mathsf{fma}\left(\cos b, \cos a, -\sin b \cdot \sin a\right)}{r}}
\end{array}
Initial program 76.3%
*-commutative76.3%
associate-/r/76.2%
+-commutative76.2%
Simplified76.2%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.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 76.3%
+-commutative76.3%
Simplified76.3%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.2e-8) (not (<= b 3.4e-10))) (* r (/ (sin b) (cos b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.2e-8) || !(b <= 3.4e-10)) {
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 <= (-4.2d-8)) .or. (.not. (b <= 3.4d-10))) 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 <= -4.2e-8) || !(b <= 3.4e-10)) {
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 <= -4.2e-8) or not (b <= 3.4e-10): 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 <= -4.2e-8) || !(b <= 3.4e-10)) 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 <= -4.2e-8) || ~((b <= 3.4e-10))) 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, -4.2e-8], N[Not[LessEqual[b, 3.4e-10]], $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 -4.2 \cdot 10^{-8} \lor \neg \left(b \leq 3.4 \cdot 10^{-10}\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 < -4.19999999999999989e-8 or 3.40000000000000015e-10 < b Initial program 49.2%
+-commutative49.2%
Simplified49.2%
Taylor expanded in a around 0 49.5%
if -4.19999999999999989e-8 < b < 3.40000000000000015e-10Initial program 99.8%
associate-*r/99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 99.8%
Final simplification76.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.2e-8) (not (<= b 3.4e-10))) (/ (sin b) (/ (cos b) r)) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.2e-8) || !(b <= 3.4e-10)) {
tmp = sin(b) / (cos(b) / 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.2d-8)) .or. (.not. (b <= 3.4d-10))) then
tmp = sin(b) / (cos(b) / 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.2e-8) || !(b <= 3.4e-10)) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.2e-8) or not (b <= 3.4e-10): tmp = math.sin(b) / (math.cos(b) / r) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.2e-8) || !(b <= 3.4e-10)) tmp = Float64(sin(b) / Float64(cos(b) / 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.2e-8) || ~((b <= 3.4e-10))) tmp = sin(b) / (cos(b) / r); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.2e-8], N[Not[LessEqual[b, 3.4e-10]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / 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.2 \cdot 10^{-8} \lor \neg \left(b \leq 3.4 \cdot 10^{-10}\right):\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -4.19999999999999989e-8 or 3.40000000000000015e-10 < b Initial program 49.2%
*-commutative49.2%
associate-/r/49.3%
+-commutative49.3%
Simplified49.3%
Taylor expanded in a around 0 49.6%
if -4.19999999999999989e-8 < b < 3.40000000000000015e-10Initial program 99.8%
associate-*r/99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 99.8%
Final simplification76.5%
(FPCore (r a b) :precision binary64 (if (<= b -4.2e-8) (* (sin b) (/ r (cos b))) (if (<= b 3.4e-10) (/ (* r b) (cos (+ b a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -4.2e-8) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 3.4e-10) {
tmp = (r * b) / 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 <= (-4.2d-8)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 3.4d-10) then
tmp = (r * b) / 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 <= -4.2e-8) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 3.4e-10) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -4.2e-8: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 3.4e-10: tmp = (r * b) / 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 <= -4.2e-8) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 3.4e-10) tmp = Float64(Float64(r * b) / cos(Float64(b + 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 (b <= -4.2e-8) tmp = sin(b) * (r / cos(b)); elseif (b <= 3.4e-10) tmp = (r * b) / cos((b + a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -4.2e-8], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-10], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + 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}\;b \leq -4.2 \cdot 10^{-8}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-10}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -4.19999999999999989e-8Initial program 55.3%
associate-*r/55.3%
+-commutative55.3%
Simplified55.3%
cos-sum99.1%
*-un-lft-identity99.1%
*-un-lft-identity99.1%
prod-diff99.1%
Applied egg-rr99.1%
*-commutative99.1%
*-rgt-identity99.1%
distribute-lft-neg-in99.1%
*-commutative99.1%
fma-udef99.1%
*-rgt-identity99.1%
distribute-lft-neg-in99.1%
*-rgt-identity99.1%
fma-udef99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in a around 0 55.4%
associate-*r/55.4%
Simplified55.4%
if -4.19999999999999989e-8 < b < 3.40000000000000015e-10Initial program 99.8%
associate-*r/99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 99.8%
if 3.40000000000000015e-10 < b Initial program 43.2%
+-commutative43.2%
Simplified43.2%
Taylor expanded in a around 0 43.8%
Final simplification76.4%
(FPCore (r a b) :precision binary64 (if (<= b 3.3e-10) (* r (expm1 (/ b (cos a)))) (* r (sin b))))
double code(double r, double a, double b) {
double tmp;
if (b <= 3.3e-10) {
tmp = r * expm1((b / cos(a)));
} else {
tmp = r * sin(b);
}
return tmp;
}
public static double code(double r, double a, double b) {
double tmp;
if (b <= 3.3e-10) {
tmp = r * Math.expm1((b / Math.cos(a)));
} else {
tmp = r * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 3.3e-10: tmp = r * math.expm1((b / math.cos(a))) else: tmp = r * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 3.3e-10) tmp = Float64(r * expm1(Float64(b / cos(a)))); else tmp = Float64(r * sin(b)); end return tmp end
code[r_, a_, b_] := If[LessEqual[b, 3.3e-10], N[(r * N[(Exp[N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.3 \cdot 10^{-10}:\\
\;\;\;\;r \cdot \mathsf{expm1}\left(\frac{b}{\cos a}\right)\\
\mathbf{else}:\\
\;\;\;\;r \cdot \sin b\\
\end{array}
\end{array}
if b < 3.3e-10Initial program 86.4%
+-commutative86.4%
Simplified86.4%
clear-num86.3%
associate-/r/86.3%
Applied egg-rr86.3%
Taylor expanded in b around 0 73.6%
expm1-log1p-u73.0%
associate-*l/73.1%
*-un-lft-identity73.1%
Applied egg-rr73.1%
Taylor expanded in b around 0 72.6%
if 3.3e-10 < b Initial program 43.2%
+-commutative43.2%
Simplified43.2%
clear-num43.2%
associate-/r/43.1%
Applied egg-rr43.1%
Taylor expanded in b around 0 10.7%
Taylor expanded in a around 0 15.8%
Final simplification59.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 76.3%
Final simplification76.3%
(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 76.3%
+-commutative76.3%
Simplified76.3%
Taylor expanded in b around 0 58.9%
Final simplification58.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -92.0) (not (<= b 3.4e-10))) (* r (sin b)) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -92.0) || !(b <= 3.4e-10)) {
tmp = r * sin(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 <= (-92.0d0)) .or. (.not. (b <= 3.4d-10))) then
tmp = r * sin(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 <= -92.0) || !(b <= 3.4e-10)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -92.0) or not (b <= 3.4e-10): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -92.0) || !(b <= 3.4e-10)) tmp = Float64(r * sin(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 <= -92.0) || ~((b <= 3.4e-10))) tmp = r * sin(b); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -92.0], N[Not[LessEqual[b, 3.4e-10]], $MachinePrecision]], N[(r * N[Sin[b], $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 -92 \lor \neg \left(b \leq 3.4 \cdot 10^{-10}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -92 or 3.40000000000000015e-10 < b Initial program 47.9%
+-commutative47.9%
Simplified47.9%
clear-num47.9%
associate-/r/47.8%
Applied egg-rr47.8%
Taylor expanded in b around 0 10.8%
Taylor expanded in a around 0 14.7%
if -92 < b < 3.40000000000000015e-10Initial program 99.8%
associate-*r/99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 98.8%
Final simplification60.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.7) (not (<= b 3.4e-10))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.7) || !(b <= 3.4e-10)) {
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.7d0)) .or. (.not. (b <= 3.4d-10))) 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.7) || !(b <= 3.4e-10)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.7) or not (b <= 3.4e-10): 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.7) || !(b <= 3.4e-10)) 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.7) || ~((b <= 3.4e-10))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.7], N[Not[LessEqual[b, 3.4e-10]], $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.7 \lor \neg \left(b \leq 3.4 \cdot 10^{-10}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.69999999999999996 or 3.40000000000000015e-10 < b Initial program 47.9%
+-commutative47.9%
Simplified47.9%
clear-num47.9%
associate-/r/47.8%
Applied egg-rr47.8%
Taylor expanded in b around 0 10.8%
Taylor expanded in a around 0 14.7%
if -1.69999999999999996 < b < 3.40000000000000015e-10Initial program 99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 98.7%
Final simplification60.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -35.0) (not (<= b 3.4e-10))) (* r (sin b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -35.0) || !(b <= 3.4e-10)) {
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 <= (-35.0d0)) .or. (.not. (b <= 3.4d-10))) 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 <= -35.0) || !(b <= 3.4e-10)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -35.0) or not (b <= 3.4e-10): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -35.0) || !(b <= 3.4e-10)) tmp = Float64(r * sin(b)); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -35.0) || ~((b <= 3.4e-10))) tmp = r * sin(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -35.0], N[Not[LessEqual[b, 3.4e-10]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -35 \lor \neg \left(b \leq 3.4 \cdot 10^{-10}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -35 or 3.40000000000000015e-10 < b Initial program 47.9%
+-commutative47.9%
Simplified47.9%
clear-num47.9%
associate-/r/47.8%
Applied egg-rr47.8%
Taylor expanded in b around 0 10.8%
Taylor expanded in a around 0 14.7%
if -35 < b < 3.40000000000000015e-10Initial program 99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 98.7%
Final simplification60.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 76.3%
+-commutative76.3%
Simplified76.3%
clear-num76.2%
associate-/r/76.2%
Applied egg-rr76.2%
Taylor expanded in b around 0 58.9%
Taylor expanded in a around 0 41.7%
Final simplification41.7%
(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 76.3%
+-commutative76.3%
Simplified76.3%
Taylor expanded in b around 0 56.1%
Taylor expanded in a around 0 37.2%
Final simplification37.2%
herbie shell --seed 2023215
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))