
(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 (/ (* r (sin b)) (- (* (cos b) (cos a)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 75.3%
associate-*r/75.3%
+-commutative75.3%
Simplified75.3%
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 75.3%
+-commutative75.3%
Simplified75.3%
cos-sum99.5%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (* (cos b) (cos a)))))
double code(double r, double a, double b) {
return r * (sin(b) / (cos(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(b) * cos(a)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / (Math.cos(b) * Math.cos(a)));
}
def code(r, a, b): return r * (math.sin(b) / (math.cos(b) * math.cos(a)))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(cos(b) * cos(a)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / (cos(b) * cos(a))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a}
\end{array}
Initial program 75.3%
+-commutative75.3%
Simplified75.3%
cos-sum99.5%
Applied egg-rr99.4%
sin-mult76.4%
div-sub76.4%
cos-diff76.5%
add-sqr-sqrt36.9%
sqrt-unprod75.4%
sqr-neg75.4%
sqrt-unprod38.6%
add-sqr-sqrt74.7%
cancel-sign-sub-inv74.7%
cos-sum76.2%
Applied egg-rr76.2%
+-inverses76.2%
Simplified76.2%
Final simplification76.2%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (* (cos b) (cos a))))
double code(double r, double a, double b) {
return (r * sin(b)) / (cos(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(b) * cos(a))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / (Math.cos(b) * Math.cos(a));
}
def code(r, a, b): return (r * math.sin(b)) / (math.cos(b) * math.cos(a))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(cos(b) * cos(a))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / (cos(b) * cos(a)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a}
\end{array}
Initial program 75.3%
associate-*r/75.3%
+-commutative75.3%
Simplified75.3%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult76.4%
div-sub76.4%
cos-diff76.5%
add-sqr-sqrt36.9%
sqrt-unprod75.4%
sqr-neg75.4%
sqrt-unprod38.6%
add-sqr-sqrt74.7%
cancel-sign-sub-inv74.7%
cos-sum76.2%
Applied egg-rr76.2%
+-inverses76.2%
Simplified76.2%
Final simplification76.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.9e-6) (not (<= b 7.8e-5))) (* r (/ (sin b) (cos b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.9e-6) || !(b <= 7.8e-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 <= (-2.9d-6)) .or. (.not. (b <= 7.8d-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 <= -2.9e-6) || !(b <= 7.8e-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 <= -2.9e-6) or not (b <= 7.8e-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 <= -2.9e-6) || !(b <= 7.8e-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 <= -2.9e-6) || ~((b <= 7.8e-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, -2.9e-6], N[Not[LessEqual[b, 7.8e-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 -2.9 \cdot 10^{-6} \lor \neg \left(b \leq 7.8 \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 < -2.9000000000000002e-6 or 7.7999999999999999e-5 < b Initial program 56.2%
+-commutative56.2%
Simplified56.2%
Taylor expanded in a around 0 56.6%
if -2.9000000000000002e-6 < b < 7.7999999999999999e-5Initial program 99.5%
associate-*r/99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in b around 0 99.5%
Final simplification75.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.9e-6) (not (<= b 5e-5))) (/ r (/ (cos b) (sin b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.9e-6) || !(b <= 5e-5)) {
tmp = r / (cos(b) / 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 <= (-2.9d-6)) .or. (.not. (b <= 5d-5))) then
tmp = r / (cos(b) / 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 <= -2.9e-6) || !(b <= 5e-5)) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.9e-6) or not (b <= 5e-5): tmp = r / (math.cos(b) / math.sin(b)) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.9e-6) || !(b <= 5e-5)) tmp = Float64(r / Float64(cos(b) / 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 <= -2.9e-6) || ~((b <= 5e-5))) tmp = r / (cos(b) / sin(b)); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.9e-6], N[Not[LessEqual[b, 5e-5]], $MachinePrecision]], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[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 -2.9 \cdot 10^{-6} \lor \neg \left(b \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -2.9000000000000002e-6 or 5.00000000000000024e-5 < b Initial program 56.2%
+-commutative56.2%
Simplified56.2%
clear-num56.1%
un-div-inv56.2%
Applied egg-rr56.2%
Taylor expanded in a around 0 56.7%
if -2.9000000000000002e-6 < b < 5.00000000000000024e-5Initial program 99.5%
associate-*r/99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in b around 0 99.5%
Final simplification75.6%
(FPCore (r a b) :precision binary64 (if (<= b -3.9e-5) (* (sin b) (/ r (cos b))) (if (<= b 4.8e-5) (/ (* r b) (cos (+ b a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -3.9e-5) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 4.8e-5) {
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 <= (-3.9d-5)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 4.8d-5) 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 <= -3.9e-5) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 4.8e-5) {
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 <= -3.9e-5: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 4.8e-5: 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 <= -3.9e-5) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 4.8e-5) 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 <= -3.9e-5) tmp = sin(b) * (r / cos(b)); elseif (b <= 4.8e-5) 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, -3.9e-5], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.8e-5], 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 -3.9 \cdot 10^{-5}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-5}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -3.8999999999999999e-5Initial program 58.0%
+-commutative58.0%
Simplified58.0%
Taylor expanded in a around 0 59.4%
*-commutative59.4%
associate-/l*59.4%
Simplified59.4%
if -3.8999999999999999e-5 < b < 4.8000000000000001e-5Initial program 99.5%
associate-*r/99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in b around 0 99.5%
if 4.8000000000000001e-5 < b Initial program 54.4%
+-commutative54.4%
Simplified54.4%
Taylor expanded in a around 0 54.0%
Final simplification75.6%
(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 75.3%
Final simplification75.3%
(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 75.3%
associate-*r/75.3%
+-commutative75.3%
Simplified75.3%
*-commutative75.3%
associate-/l*75.3%
Applied egg-rr75.3%
Final simplification75.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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 75.3%
associate-*r/75.3%
+-commutative75.3%
Simplified75.3%
Final simplification75.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 75.3%
+-commutative75.3%
Simplified75.3%
Taylor expanded in b around 0 49.8%
Final simplification49.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -720000000.0) (not (<= b 1.35))) (* r (sin b)) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -720000000.0) || !(b <= 1.35)) {
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 <= (-720000000.0d0)) .or. (.not. (b <= 1.35d0))) 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 <= -720000000.0) || !(b <= 1.35)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -720000000.0) or not (b <= 1.35): 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 <= -720000000.0) || !(b <= 1.35)) 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 <= -720000000.0) || ~((b <= 1.35))) tmp = r * sin(b); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -720000000.0], N[Not[LessEqual[b, 1.35]], $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 -720000000 \lor \neg \left(b \leq 1.35\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -7.2e8 or 1.3500000000000001 < b Initial program 55.6%
+-commutative55.6%
Simplified55.6%
add-sqr-sqrt21.9%
sqrt-unprod26.3%
pow226.3%
Applied egg-rr26.3%
Taylor expanded in b around 0 10.8%
Taylor expanded in a around 0 10.3%
if -7.2e8 < b < 1.3500000000000001Initial program 99.5%
associate-*r/99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in b around 0 98.5%
Final simplification49.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.15) (not (<= b 11.0))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.15) || !(b <= 11.0)) {
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.15d0)) .or. (.not. (b <= 11.0d0))) 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.15) || !(b <= 11.0)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.15) or not (b <= 11.0): 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.15) || !(b <= 11.0)) 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.15) || ~((b <= 11.0))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.15], N[Not[LessEqual[b, 11.0]], $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.15 \lor \neg \left(b \leq 11\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.1499999999999999 or 11 < b Initial program 55.9%
+-commutative55.9%
Simplified55.9%
add-sqr-sqrt22.5%
sqrt-unprod26.8%
pow226.8%
Applied egg-rr26.8%
Taylor expanded in b around 0 10.8%
Taylor expanded in a around 0 10.3%
if -1.1499999999999999 < b < 11Initial program 99.5%
associate-*r/99.5%
+-commutative99.5%
Simplified99.5%
cos-sum99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 99.8%
sub-neg99.8%
+-commutative99.8%
mul-1-neg99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
mul-1-neg99.8%
*-commutative99.8%
fma-define99.8%
mul-1-neg99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 99.0%
associate-/l*99.0%
Simplified99.0%
Final simplification49.8%
(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 75.3%
+-commutative75.3%
Simplified75.3%
add-sqr-sqrt32.2%
sqrt-unprod35.4%
pow235.4%
Applied egg-rr35.4%
Taylor expanded in b around 0 26.5%
Taylor expanded in a around 0 33.8%
Final simplification33.8%
(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 75.3%
+-commutative75.3%
Simplified75.3%
Taylor expanded in b around 0 46.1%
Taylor expanded in a around 0 30.2%
Final simplification30.2%
herbie shell --seed 2024076
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))