
(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 18 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(sin(b) * Float64(-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 \left(-\sin a\right)\right)}
\end{array}
Initial program 76.7%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.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(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 76.7%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
Applied egg-rr99.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.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -200000.0) (not (<= a 4.9e-5))) (/ (* r (sin b)) (cos a)) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -200000.0) || !(a <= 4.9e-5)) {
tmp = (r * sin(b)) / 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 ((a <= (-200000.0d0)) .or. (.not. (a <= 4.9d-5))) then
tmp = (r * sin(b)) / 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 ((a <= -200000.0) || !(a <= 4.9e-5)) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -200000.0) or not (a <= 4.9e-5): tmp = (r * math.sin(b)) / math.cos(a) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -200000.0) || !(a <= 4.9e-5)) tmp = Float64(Float64(r * sin(b)) / cos(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 ((a <= -200000.0) || ~((a <= 4.9e-5))) tmp = (r * sin(b)) / cos(a); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -200000.0], N[Not[LessEqual[a, 4.9e-5]], $MachinePrecision]], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -200000 \lor \neg \left(a \leq 4.9 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -2e5 or 4.9e-5 < a Initial program 57.6%
associate-*r/57.7%
+-commutative57.7%
Simplified57.7%
Taylor expanded in b around 0 58.4%
if -2e5 < a < 4.9e-5Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in a around 0 97.9%
Final simplification77.1%
(FPCore (r a b) :precision binary64 (if (or (<= a -200000.0) (not (<= a 4.9e-5))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -200000.0) || !(a <= 4.9e-5)) {
tmp = r * (sin(b) / 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 ((a <= (-200000.0d0)) .or. (.not. (a <= 4.9d-5))) then
tmp = r * (sin(b) / 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 ((a <= -200000.0) || !(a <= 4.9e-5)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -200000.0) or not (a <= 4.9e-5): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -200000.0) || !(a <= 4.9e-5)) tmp = Float64(r * Float64(sin(b) / cos(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 ((a <= -200000.0) || ~((a <= 4.9e-5))) tmp = r * (sin(b) / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -200000.0], N[Not[LessEqual[a, 4.9e-5]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[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}\;a \leq -200000 \lor \neg \left(a \leq 4.9 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -2e5 or 4.9e-5 < a Initial program 57.6%
+-commutative57.6%
Simplified57.6%
Taylor expanded in b around 0 58.4%
if -2e5 < a < 4.9e-5Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in a around 0 97.9%
Final simplification77.1%
(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 76.7%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
(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 76.7%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
*-commutative76.7%
associate-/l*76.7%
Applied egg-rr76.7%
(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.7%
Final simplification76.7%
(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.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 55.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -118000000.0) (not (<= b 4.5))) (/ 1.0 (/ (/ 1.0 r) (sin b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -118000000.0) || !(b <= 4.5)) {
tmp = 1.0 / ((1.0 / 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 <= (-118000000.0d0)) .or. (.not. (b <= 4.5d0))) then
tmp = 1.0d0 / ((1.0d0 / 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 <= -118000000.0) || !(b <= 4.5)) {
tmp = 1.0 / ((1.0 / r) / Math.sin(b));
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -118000000.0) or not (b <= 4.5): tmp = 1.0 / ((1.0 / r) / math.sin(b)) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -118000000.0) || !(b <= 4.5)) tmp = Float64(1.0 / Float64(Float64(1.0 / 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 <= -118000000.0) || ~((b <= 4.5))) tmp = 1.0 / ((1.0 / r) / sin(b)); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -118000000.0], N[Not[LessEqual[b, 4.5]], $MachinePrecision]], N[(1.0 / N[(N[(1.0 / r), $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 -118000000 \lor \neg \left(b \leq 4.5\right):\\
\;\;\;\;\frac{1}{\frac{\frac{1}{r}}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -1.18e8 or 4.5 < b Initial program 54.1%
+-commutative54.1%
Simplified54.1%
associate-*r/54.1%
clear-num54.0%
*-commutative54.0%
Applied egg-rr54.0%
Taylor expanded in a around 0 53.9%
associate-/r*53.9%
Simplified53.9%
Taylor expanded in b around 0 11.1%
if -1.18e8 < b < 4.5Initial program 98.9%
associate-*r/98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.1%
Final simplification54.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -118000000.0) (not (<= b 7800.0))) (/ 1.0 (/ (/ 1.0 r) (sin b))) (* r (/ b (cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -118000000.0) || !(b <= 7800.0)) {
tmp = 1.0 / ((1.0 / 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 <= (-118000000.0d0)) .or. (.not. (b <= 7800.0d0))) then
tmp = 1.0d0 / ((1.0d0 / 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 <= -118000000.0) || !(b <= 7800.0)) {
tmp = 1.0 / ((1.0 / r) / Math.sin(b));
} else {
tmp = r * (b / Math.cos((b + a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -118000000.0) or not (b <= 7800.0): tmp = 1.0 / ((1.0 / r) / math.sin(b)) else: tmp = r * (b / math.cos((b + a))) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -118000000.0) || !(b <= 7800.0)) tmp = Float64(1.0 / Float64(Float64(1.0 / r) / sin(b))); else tmp = Float64(r * Float64(b / cos(Float64(b + a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -118000000.0) || ~((b <= 7800.0))) tmp = 1.0 / ((1.0 / r) / sin(b)); else tmp = r * (b / cos((b + a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -118000000.0], N[Not[LessEqual[b, 7800.0]], $MachinePrecision]], N[(1.0 / N[(N[(1.0 / r), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -118000000 \lor \neg \left(b \leq 7800\right):\\
\;\;\;\;\frac{1}{\frac{\frac{1}{r}}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -1.18e8 or 7800 < b Initial program 54.1%
+-commutative54.1%
Simplified54.1%
associate-*r/54.1%
clear-num54.0%
*-commutative54.0%
Applied egg-rr54.0%
Taylor expanded in a around 0 53.9%
associate-/r*53.9%
Simplified53.9%
Taylor expanded in b around 0 11.1%
if -1.18e8 < b < 7800Initial program 98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.0%
Final simplification54.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -5.6e+34) (not (<= b 640.0))) (/ r (- (sin a))) (* r (/ b (cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -5.6e+34) || !(b <= 640.0)) {
tmp = r / -sin(a);
} 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 <= (-5.6d+34)) .or. (.not. (b <= 640.0d0))) then
tmp = r / -sin(a)
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 <= -5.6e+34) || !(b <= 640.0)) {
tmp = r / -Math.sin(a);
} else {
tmp = r * (b / Math.cos((b + a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -5.6e+34) or not (b <= 640.0): tmp = r / -math.sin(a) else: tmp = r * (b / math.cos((b + a))) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -5.6e+34) || !(b <= 640.0)) tmp = Float64(r / Float64(-sin(a))); else tmp = Float64(r * Float64(b / cos(Float64(b + a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -5.6e+34) || ~((b <= 640.0))) tmp = r / -sin(a); else tmp = r * (b / cos((b + a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -5.6e+34], N[Not[LessEqual[b, 640.0]], $MachinePrecision]], N[(r / (-N[Sin[a], $MachinePrecision])), $MachinePrecision], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{+34} \lor \neg \left(b \leq 640\right):\\
\;\;\;\;\frac{r}{-\sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -5.60000000000000016e34 or 640 < b Initial program 53.3%
+-commutative53.3%
Simplified53.3%
associate-*r/53.3%
clear-num53.2%
*-commutative53.2%
Applied egg-rr53.2%
Taylor expanded in b around 0 8.6%
fma-define8.6%
associate-/l*8.5%
Simplified8.5%
Taylor expanded in b around inf 10.5%
associate-*r/10.5%
neg-mul-110.5%
Simplified10.5%
if -5.60000000000000016e34 < b < 640Initial program 97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in b around 0 92.7%
Final simplification54.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -1450000000000.0) (not (<= b 1.1))) (/ r (- (sin a))) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1450000000000.0) || !(b <= 1.1)) {
tmp = r / -sin(a);
} 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 <= (-1450000000000.0d0)) .or. (.not. (b <= 1.1d0))) then
tmp = r / -sin(a)
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 <= -1450000000000.0) || !(b <= 1.1)) {
tmp = r / -Math.sin(a);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1450000000000.0) or not (b <= 1.1): tmp = r / -math.sin(a) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1450000000000.0) || !(b <= 1.1)) tmp = Float64(r / Float64(-sin(a))); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1450000000000.0) || ~((b <= 1.1))) tmp = r / -sin(a); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1450000000000.0], N[Not[LessEqual[b, 1.1]], $MachinePrecision]], N[(r / (-N[Sin[a], $MachinePrecision])), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1450000000000 \lor \neg \left(b \leq 1.1\right):\\
\;\;\;\;\frac{r}{-\sin a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -1.45e12 or 1.1000000000000001 < b Initial program 54.7%
+-commutative54.7%
Simplified54.7%
associate-*r/54.7%
clear-num54.6%
*-commutative54.6%
Applied egg-rr54.6%
Taylor expanded in b around 0 8.3%
fma-define8.3%
associate-/l*8.3%
Simplified8.3%
Taylor expanded in b around inf 10.3%
associate-*r/10.3%
neg-mul-110.3%
Simplified10.3%
if -1.45e12 < b < 1.1000000000000001Initial program 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in b around 0 98.0%
Final simplification54.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -600000000000.0) (not (<= b 1.3))) (/ r (- (sin a))) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -600000000000.0) || !(b <= 1.3)) {
tmp = r / -sin(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 <= (-600000000000.0d0)) .or. (.not. (b <= 1.3d0))) then
tmp = r / -sin(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 <= -600000000000.0) || !(b <= 1.3)) {
tmp = r / -Math.sin(a);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -600000000000.0) or not (b <= 1.3): tmp = r / -math.sin(a) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -600000000000.0) || !(b <= 1.3)) tmp = Float64(r / Float64(-sin(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 <= -600000000000.0) || ~((b <= 1.3))) tmp = r / -sin(a); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -600000000000.0], N[Not[LessEqual[b, 1.3]], $MachinePrecision]], N[(r / (-N[Sin[a], $MachinePrecision])), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -600000000000 \lor \neg \left(b \leq 1.3\right):\\
\;\;\;\;\frac{r}{-\sin a}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -6e11 or 1.30000000000000004 < b Initial program 54.7%
+-commutative54.7%
Simplified54.7%
associate-*r/54.7%
clear-num54.6%
*-commutative54.6%
Applied egg-rr54.6%
Taylor expanded in b around 0 8.3%
fma-define8.3%
associate-/l*8.3%
Simplified8.3%
Taylor expanded in b around inf 10.3%
associate-*r/10.3%
neg-mul-110.3%
Simplified10.3%
if -6e11 < b < 1.30000000000000004Initial program 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in b around 0 98.0%
clear-num97.9%
un-div-inv97.8%
Applied egg-rr97.8%
associate-/r/98.0%
Simplified98.0%
Final simplification54.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -600000000000.0) (not (<= b 1.5))) (/ r (- (sin a))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -600000000000.0) || !(b <= 1.5)) {
tmp = r / -sin(a);
} 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 <= (-600000000000.0d0)) .or. (.not. (b <= 1.5d0))) then
tmp = r / -sin(a)
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 <= -600000000000.0) || !(b <= 1.5)) {
tmp = r / -Math.sin(a);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -600000000000.0) or not (b <= 1.5): tmp = r / -math.sin(a) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -600000000000.0) || !(b <= 1.5)) tmp = Float64(r / Float64(-sin(a))); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -600000000000.0) || ~((b <= 1.5))) tmp = r / -sin(a); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -600000000000.0], N[Not[LessEqual[b, 1.5]], $MachinePrecision]], N[(r / (-N[Sin[a], $MachinePrecision])), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -600000000000 \lor \neg \left(b \leq 1.5\right):\\
\;\;\;\;\frac{r}{-\sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -6e11 or 1.5 < b Initial program 54.7%
+-commutative54.7%
Simplified54.7%
associate-*r/54.7%
clear-num54.6%
*-commutative54.6%
Applied egg-rr54.6%
Taylor expanded in b around 0 8.3%
fma-define8.3%
associate-/l*8.3%
Simplified8.3%
Taylor expanded in b around inf 10.3%
associate-*r/10.3%
neg-mul-110.3%
Simplified10.3%
if -6e11 < b < 1.5Initial program 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in b around 0 98.0%
Final simplification54.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -3.8e+14) (not (<= b 1.4))) (/ r (- (sin a))) (* r b)))
double code(double r, double a, double b) {
double tmp;
if ((b <= -3.8e+14) || !(b <= 1.4)) {
tmp = r / -sin(a);
} else {
tmp = r * 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.8d+14)) .or. (.not. (b <= 1.4d0))) then
tmp = r / -sin(a)
else
tmp = r * b
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -3.8e+14) || !(b <= 1.4)) {
tmp = r / -Math.sin(a);
} else {
tmp = r * b;
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -3.8e+14) or not (b <= 1.4): tmp = r / -math.sin(a) else: tmp = r * b return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -3.8e+14) || !(b <= 1.4)) tmp = Float64(r / Float64(-sin(a))); else tmp = Float64(r * b); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -3.8e+14) || ~((b <= 1.4))) tmp = r / -sin(a); else tmp = r * b; end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -3.8e+14], N[Not[LessEqual[b, 1.4]], $MachinePrecision]], N[(r / (-N[Sin[a], $MachinePrecision])), $MachinePrecision], N[(r * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{+14} \lor \neg \left(b \leq 1.4\right):\\
\;\;\;\;\frac{r}{-\sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot b\\
\end{array}
\end{array}
if b < -3.8e14 or 1.3999999999999999 < b Initial program 55.1%
+-commutative55.1%
Simplified55.1%
associate-*r/55.1%
clear-num55.0%
*-commutative55.0%
Applied egg-rr55.0%
Taylor expanded in b around 0 8.3%
fma-define8.3%
associate-/l*8.3%
Simplified8.3%
Taylor expanded in b around inf 10.3%
associate-*r/10.3%
neg-mul-110.3%
Simplified10.3%
if -3.8e14 < b < 1.3999999999999999Initial program 97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in b around 0 97.3%
Taylor expanded in a around 0 61.7%
*-commutative61.7%
Simplified61.7%
Final simplification36.4%
(FPCore (r a b) :precision binary64 (/ 1.0 (/ (- (/ 1.0 r) (* a (/ b r))) b)))
double code(double r, double a, double b) {
return 1.0 / (((1.0 / r) - (a * (b / 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 = 1.0d0 / (((1.0d0 / r) - (a * (b / r))) / b)
end function
public static double code(double r, double a, double b) {
return 1.0 / (((1.0 / r) - (a * (b / r))) / b);
}
def code(r, a, b): return 1.0 / (((1.0 / r) - (a * (b / r))) / b)
function code(r, a, b) return Float64(1.0 / Float64(Float64(Float64(1.0 / r) - Float64(a * Float64(b / r))) / b)) end
function tmp = code(r, a, b) tmp = 1.0 / (((1.0 / r) - (a * (b / r))) / b); end
code[r_, a_, b_] := N[(1.0 / N[(N[(N[(1.0 / r), $MachinePrecision] - N[(a * N[(b / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{\frac{1}{r} - a \cdot \frac{b}{r}}{b}}
\end{array}
Initial program 76.7%
+-commutative76.7%
Simplified76.7%
associate-*r/76.7%
clear-num76.2%
*-commutative76.2%
Applied egg-rr76.2%
Taylor expanded in b around 0 53.2%
fma-define53.2%
associate-/l*53.2%
Simplified53.2%
Taylor expanded in a around 0 32.4%
+-commutative32.4%
mul-1-neg32.4%
unsub-neg32.4%
associate-/l*33.0%
Simplified33.0%
(FPCore (r a b) :precision binary64 (* r b))
double code(double r, double a, double b) {
return r * b;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * b
end function
public static double code(double r, double a, double b) {
return r * b;
}
def code(r, a, b): return r * b
function code(r, a, b) return Float64(r * b) end
function tmp = code(r, a, b) tmp = r * b; end
code[r_, a_, b_] := N[(r * b), $MachinePrecision]
\begin{array}{l}
\\
r \cdot b
\end{array}
Initial program 76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 51.0%
Taylor expanded in a around 0 32.9%
*-commutative32.9%
Simplified32.9%
herbie shell --seed 2024112
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))