
(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 (* (sin b) (/ r (fma (cos b) (cos a) (* (sin b) (- (sin a)))))))
double code(double r, double a, double b) {
return sin(b) * (r / fma(cos(b), cos(a), (sin(b) * -sin(a))));
}
function code(r, a, b) return Float64(sin(b) * Float64(r / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a)))))) end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 72.0%
associate-*r/72.0%
/-rgt-identity72.0%
metadata-eval72.0%
associate-/l/72.0%
associate-*l/72.1%
associate-/l/72.1%
metadata-eval72.1%
metadata-eval72.1%
metadata-eval72.1%
/-rgt-identity72.1%
+-commutative72.1%
Simplified72.1%
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 72.0%
+-commutative72.0%
Simplified72.0%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (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 = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / 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}
\\
\sin b \cdot \frac{r}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 72.0%
associate-*r/72.0%
/-rgt-identity72.0%
metadata-eval72.0%
associate-/l/72.0%
associate-*l/72.1%
associate-/l/72.1%
metadata-eval72.1%
metadata-eval72.1%
metadata-eval72.1%
/-rgt-identity72.1%
+-commutative72.1%
Simplified72.1%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -2.9e+16) (not (<= a 0.08))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -2.9e+16) || !(a <= 0.08)) {
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 <= (-2.9d+16)) .or. (.not. (a <= 0.08d0))) 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 <= -2.9e+16) || !(a <= 0.08)) {
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 <= -2.9e+16) or not (a <= 0.08): 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 <= -2.9e+16) || !(a <= 0.08)) 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 <= -2.9e+16) || ~((a <= 0.08))) 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, -2.9e+16], N[Not[LessEqual[a, 0.08]], $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 -2.9 \cdot 10^{+16} \lor \neg \left(a \leq 0.08\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -2.9e16 or 0.0800000000000000017 < a Initial program 48.5%
+-commutative48.5%
Simplified48.5%
Taylor expanded in b around 0 48.8%
if -2.9e16 < a < 0.0800000000000000017Initial program 97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in a around 0 97.3%
Final simplification72.3%
(FPCore (r a b) :precision binary64 (if (<= a -2.9e+16) (* (sin b) (/ r (cos a))) (if (<= a 0.075) (* r (/ (sin b) (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -2.9e+16) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 0.075) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = r * (sin(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 (a <= (-2.9d+16)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 0.075d0) then
tmp = r * (sin(b) / cos(b))
else
tmp = r * (sin(b) / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -2.9e+16) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 0.075) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -2.9e+16: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 0.075: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -2.9e+16) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 0.075) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -2.9e+16) tmp = sin(b) * (r / cos(a)); elseif (a <= 0.075) tmp = r * (sin(b) / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -2.9e+16], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.075], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.9 \cdot 10^{+16}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 0.075:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -2.9e16Initial program 46.0%
associate-*r/46.0%
/-rgt-identity46.0%
metadata-eval46.0%
associate-/l/46.0%
associate-*l/46.1%
associate-/l/46.1%
metadata-eval46.1%
metadata-eval46.1%
metadata-eval46.1%
/-rgt-identity46.1%
+-commutative46.1%
Simplified46.1%
Taylor expanded in b around 0 46.1%
if -2.9e16 < a < 0.0749999999999999972Initial program 97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in a around 0 97.3%
if 0.0749999999999999972 < a Initial program 51.5%
+-commutative51.5%
Simplified51.5%
Taylor expanded in b around 0 52.2%
Final simplification72.3%
(FPCore (r a b) :precision binary64 (if (<= a -2.9e+16) (* (sin b) (/ r (cos a))) (if (<= a 0.075) (* (sin b) (/ r (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -2.9e+16) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 0.075) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = r * (sin(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 (a <= (-2.9d+16)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 0.075d0) then
tmp = sin(b) * (r / cos(b))
else
tmp = r * (sin(b) / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -2.9e+16) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 0.075) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -2.9e+16: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 0.075: tmp = math.sin(b) * (r / math.cos(b)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -2.9e+16) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 0.075) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -2.9e+16) tmp = sin(b) * (r / cos(a)); elseif (a <= 0.075) tmp = sin(b) * (r / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -2.9e+16], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.075], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.9 \cdot 10^{+16}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 0.075:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -2.9e16Initial program 46.0%
associate-*r/46.0%
/-rgt-identity46.0%
metadata-eval46.0%
associate-/l/46.0%
associate-*l/46.1%
associate-/l/46.1%
metadata-eval46.1%
metadata-eval46.1%
metadata-eval46.1%
/-rgt-identity46.1%
+-commutative46.1%
Simplified46.1%
Taylor expanded in b around 0 46.1%
if -2.9e16 < a < 0.0749999999999999972Initial program 97.1%
associate-*r/97.1%
/-rgt-identity97.1%
metadata-eval97.1%
associate-/l/97.1%
associate-*l/97.2%
associate-/l/97.2%
metadata-eval97.2%
metadata-eval97.2%
metadata-eval97.2%
/-rgt-identity97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in a around 0 97.4%
if 0.0749999999999999972 < a Initial program 51.5%
+-commutative51.5%
Simplified51.5%
Taylor expanded in b around 0 52.2%
Final simplification72.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 72.0%
Final simplification72.0%
(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 72.0%
associate-*r/72.0%
/-rgt-identity72.0%
metadata-eval72.0%
associate-/l/72.0%
associate-*l/72.1%
associate-/l/72.1%
metadata-eval72.1%
metadata-eval72.1%
metadata-eval72.1%
/-rgt-identity72.1%
+-commutative72.1%
Simplified72.1%
Final simplification72.1%
(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 72.0%
+-commutative72.0%
Simplified72.0%
Taylor expanded in b around 0 52.2%
Final simplification52.2%
(FPCore (r a b) :precision binary64 (if (<= b -960.0) (* r (sin b)) (if (<= b 18000.0) (* r (/ b (cos a))) (* r (- (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -960.0) {
tmp = r * sin(b);
} else if (b <= 18000.0) {
tmp = r * (b / cos(a));
} else {
tmp = r * -sin(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 <= (-960.0d0)) then
tmp = r * sin(b)
else if (b <= 18000.0d0) then
tmp = r * (b / cos(a))
else
tmp = r * -sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -960.0) {
tmp = r * Math.sin(b);
} else if (b <= 18000.0) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * -Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -960.0: tmp = r * math.sin(b) elif b <= 18000.0: tmp = r * (b / math.cos(a)) else: tmp = r * -math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -960.0) tmp = Float64(r * sin(b)); elseif (b <= 18000.0) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(r * Float64(-sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -960.0) tmp = r * sin(b); elseif (b <= 18000.0) tmp = r * (b / cos(a)); else tmp = r * -sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -960.0], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 18000.0], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * (-N[Sin[b], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -960:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{elif}\;b \leq 18000:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \left(-\sin b\right)\\
\end{array}
\end{array}
if b < -960Initial program 55.1%
associate-*r/55.0%
/-rgt-identity55.0%
metadata-eval55.0%
associate-/l/55.0%
associate-*l/55.2%
associate-/l/55.2%
metadata-eval55.2%
metadata-eval55.2%
metadata-eval55.2%
/-rgt-identity55.2%
+-commutative55.2%
Simplified55.2%
cos-sum99.3%
cancel-sign-sub-inv99.3%
fma-def99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 7.6%
mul-1-neg7.6%
unsub-neg7.6%
*-commutative7.6%
Simplified7.6%
Taylor expanded in a around 0 13.6%
Simplified13.6%
if -960 < b < 18000Initial program 97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in b around 0 96.8%
if 18000 < b Initial program 41.3%
+-commutative41.3%
Simplified41.3%
associate-*r/41.4%
clear-num41.4%
*-commutative41.4%
Applied egg-rr41.4%
Taylor expanded in a around 0 41.2%
associate-/r*41.3%
Simplified41.3%
frac-2neg41.3%
metadata-eval41.3%
div-inv41.3%
distribute-neg-frac41.3%
add-sqr-sqrt25.1%
sqrt-unprod28.9%
sqr-neg28.9%
sqrt-unprod3.7%
add-sqr-sqrt7.4%
frac-2neg7.4%
clear-num7.4%
div-inv7.4%
clear-num7.4%
Applied egg-rr7.4%
Taylor expanded in b around 0 11.6%
Final simplification53.1%
(FPCore (r a b) :precision binary64 (if (<= b -960.0) (* r (sin b)) (if (<= b 18000.0) (/ (* r b) (cos a)) (* r (- (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -960.0) {
tmp = r * sin(b);
} else if (b <= 18000.0) {
tmp = (r * b) / cos(a);
} else {
tmp = r * -sin(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 <= (-960.0d0)) then
tmp = r * sin(b)
else if (b <= 18000.0d0) then
tmp = (r * b) / cos(a)
else
tmp = r * -sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -960.0) {
tmp = r * Math.sin(b);
} else if (b <= 18000.0) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = r * -Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -960.0: tmp = r * math.sin(b) elif b <= 18000.0: tmp = (r * b) / math.cos(a) else: tmp = r * -math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -960.0) tmp = Float64(r * sin(b)); elseif (b <= 18000.0) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(r * Float64(-sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -960.0) tmp = r * sin(b); elseif (b <= 18000.0) tmp = (r * b) / cos(a); else tmp = r * -sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -960.0], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 18000.0], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * (-N[Sin[b], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -960:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{elif}\;b \leq 18000:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \left(-\sin b\right)\\
\end{array}
\end{array}
if b < -960Initial program 55.1%
associate-*r/55.0%
/-rgt-identity55.0%
metadata-eval55.0%
associate-/l/55.0%
associate-*l/55.2%
associate-/l/55.2%
metadata-eval55.2%
metadata-eval55.2%
metadata-eval55.2%
/-rgt-identity55.2%
+-commutative55.2%
Simplified55.2%
cos-sum99.3%
cancel-sign-sub-inv99.3%
fma-def99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 7.6%
mul-1-neg7.6%
unsub-neg7.6%
*-commutative7.6%
Simplified7.6%
Taylor expanded in a around 0 13.6%
Simplified13.6%
if -960 < b < 18000Initial program 97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in b around 0 96.9%
if 18000 < b Initial program 41.3%
+-commutative41.3%
Simplified41.3%
associate-*r/41.4%
clear-num41.4%
*-commutative41.4%
Applied egg-rr41.4%
Taylor expanded in a around 0 41.2%
associate-/r*41.3%
Simplified41.3%
frac-2neg41.3%
metadata-eval41.3%
div-inv41.3%
distribute-neg-frac41.3%
add-sqr-sqrt25.1%
sqrt-unprod28.9%
sqr-neg28.9%
sqrt-unprod3.7%
add-sqr-sqrt7.4%
frac-2neg7.4%
clear-num7.4%
div-inv7.4%
clear-num7.4%
Applied egg-rr7.4%
Taylor expanded in b around 0 11.6%
Final simplification53.1%
(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 72.0%
associate-*r/72.0%
/-rgt-identity72.0%
metadata-eval72.0%
associate-/l/72.0%
associate-*l/72.1%
associate-/l/72.1%
metadata-eval72.1%
metadata-eval72.1%
metadata-eval72.1%
/-rgt-identity72.1%
+-commutative72.1%
Simplified72.1%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.5%
Applied egg-rr99.5%
Taylor expanded in b around 0 49.9%
mul-1-neg49.9%
unsub-neg49.9%
*-commutative49.9%
Simplified49.9%
Taylor expanded in a around 0 37.1%
Simplified37.1%
Final simplification37.1%
(FPCore (r a b) :precision binary64 (/ 1.0 (+ (* -0.3333333333333333 (/ b r)) (/ 1.0 (* r b)))))
double code(double r, double a, double b) {
return 1.0 / ((-0.3333333333333333 * (b / r)) + (1.0 / (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 / (((-0.3333333333333333d0) * (b / r)) + (1.0d0 / (r * b)))
end function
public static double code(double r, double a, double b) {
return 1.0 / ((-0.3333333333333333 * (b / r)) + (1.0 / (r * b)));
}
def code(r, a, b): return 1.0 / ((-0.3333333333333333 * (b / r)) + (1.0 / (r * b)))
function code(r, a, b) return Float64(1.0 / Float64(Float64(-0.3333333333333333 * Float64(b / r)) + Float64(1.0 / Float64(r * b)))) end
function tmp = code(r, a, b) tmp = 1.0 / ((-0.3333333333333333 * (b / r)) + (1.0 / (r * b))); end
code[r_, a_, b_] := N[(1.0 / N[(N[(-0.3333333333333333 * N[(b / r), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(r * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{-0.3333333333333333 \cdot \frac{b}{r} + \frac{1}{r \cdot b}}
\end{array}
Initial program 72.0%
+-commutative72.0%
Simplified72.0%
associate-*r/72.0%
clear-num71.5%
*-commutative71.5%
Applied egg-rr71.5%
Taylor expanded in a around 0 55.9%
associate-/r*55.9%
Simplified55.9%
Taylor expanded in b around 0 32.8%
Final simplification32.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 72.0%
+-commutative72.0%
Simplified72.0%
Taylor expanded in b around 0 48.3%
Taylor expanded in a around 0 32.8%
Final simplification32.8%
herbie shell --seed 2023332
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))