
(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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (sin b) (- (sin a)) (* (cos b) (cos a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(sin(b), -sin(a), (cos(b) * cos(a)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(sin(b), Float64(-sin(a)), Float64(cos(b) * cos(a)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision]) + N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\sin b, -\sin a, \cos b \cdot \cos a\right)}
\end{array}
Initial program 70.6%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.5
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (cos b) (cos a) (* (- (sin a)) (sin b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), (-sin(a) * sin(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(Float64(-sin(a)) * sin(b)))) 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[a], $MachinePrecision]) * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin a\right) \cdot \sin b\right)}
\end{array}
Initial program 70.6%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos b) (cos a)) (* (sin a) (sin b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(a)) - (sin(a) * 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)) / ((cos(b) * cos(a)) - (sin(a) * sin(b)))
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(a) * Math.sin(b)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(a) * math.sin(b)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(a) * sin(b)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(a) * sin(b))); 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[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin a \cdot \sin b}
\end{array}
Initial program 70.6%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (* (/ (* (sin b) r) (/ (+ (cos (- (- (- b a) b) a)) (cos (- b (- a (+ b a))))) 2.0)) (cos (- b a))))
double code(double r, double a, double b) {
return ((sin(b) * r) / ((cos((((b - a) - b) - a)) + cos((b - (a - (b + a))))) / 2.0)) * 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) - b) - a)) + cos((b - (a - (b + a))))) / 2.0d0)) * cos((b - a))
end function
public static double code(double r, double a, double b) {
return ((Math.sin(b) * r) / ((Math.cos((((b - a) - b) - a)) + Math.cos((b - (a - (b + a))))) / 2.0)) * Math.cos((b - a));
}
def code(r, a, b): return ((math.sin(b) * r) / ((math.cos((((b - a) - b) - a)) + math.cos((b - (a - (b + a))))) / 2.0)) * math.cos((b - a))
function code(r, a, b) return Float64(Float64(Float64(sin(b) * r) / Float64(Float64(cos(Float64(Float64(Float64(b - a) - b) - a)) + cos(Float64(b - Float64(a - Float64(b + a))))) / 2.0)) * cos(Float64(b - a))) end
function tmp = code(r, a, b) tmp = ((sin(b) * r) / ((cos((((b - a) - b) - a)) + cos((b - (a - (b + a))))) / 2.0)) * cos((b - a)); end
code[r_, a_, b_] := N[(N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Cos[N[(N[(N[(b - a), $MachinePrecision] - b), $MachinePrecision] - a), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(b - N[(a - N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(b - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\frac{\cos \left(\left(\left(b - a\right) - b\right) - a\right) + \cos \left(b - \left(a - \left(b + a\right)\right)\right)}{2}} \cdot \cos \left(b - a\right)
\end{array}
Initial program 70.6%
lift-/.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
flip--N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
cos-diff-revN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites70.5%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-sin.f64N/A
cos-+PI/2-revN/A
lift-sin.f64N/A
sin-diff-revN/A
lower-sin.f64N/A
lower--.f64N/A
Applied rewrites38.3%
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
Applied rewrites71.2%
(FPCore (r a b) :precision binary64 (* (/ (* (cos (- a b)) (* (sin b) r)) (+ (cos (- (- (- b a) a) b)) (cos (- b (- a (+ a b)))))) 2.0))
double code(double r, double a, double b) {
return ((cos((a - b)) * (sin(b) * r)) / (cos((((b - a) - a) - b)) + cos((b - (a - (a + b)))))) * 2.0;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((cos((a - b)) * (sin(b) * r)) / (cos((((b - a) - a) - b)) + cos((b - (a - (a + b)))))) * 2.0d0
end function
public static double code(double r, double a, double b) {
return ((Math.cos((a - b)) * (Math.sin(b) * r)) / (Math.cos((((b - a) - a) - b)) + Math.cos((b - (a - (a + b)))))) * 2.0;
}
def code(r, a, b): return ((math.cos((a - b)) * (math.sin(b) * r)) / (math.cos((((b - a) - a) - b)) + math.cos((b - (a - (a + b)))))) * 2.0
function code(r, a, b) return Float64(Float64(Float64(cos(Float64(a - b)) * Float64(sin(b) * r)) / Float64(cos(Float64(Float64(Float64(b - a) - a) - b)) + cos(Float64(b - Float64(a - Float64(a + b)))))) * 2.0) end
function tmp = code(r, a, b) tmp = ((cos((a - b)) * (sin(b) * r)) / (cos((((b - a) - a) - b)) + cos((b - (a - (a + b)))))) * 2.0; end
code[r_, a_, b_] := N[(N[(N[(N[Cos[N[(a - b), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(N[(N[(b - a), $MachinePrecision] - a), $MachinePrecision] - b), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(b - N[(a - N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(a - b\right) \cdot \left(\sin b \cdot r\right)}{\cos \left(\left(\left(b - a\right) - a\right) - b\right) + \cos \left(b - \left(a - \left(a + b\right)\right)\right)} \cdot 2
\end{array}
Initial program 70.6%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
Applied rewrites70.8%
(FPCore (r a b) :precision binary64 (if (or (<= a -740000.0) (not (<= a 6.5e-5))) (/ (* r (sin b)) (cos a)) (* (/ r (cos b)) (sin b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -740000.0) || !(a <= 6.5e-5)) {
tmp = (r * sin(b)) / cos(a);
} else {
tmp = (r / cos(b)) * 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 ((a <= (-740000.0d0)) .or. (.not. (a <= 6.5d-5))) then
tmp = (r * sin(b)) / cos(a)
else
tmp = (r / cos(b)) * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -740000.0) || !(a <= 6.5e-5)) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else {
tmp = (r / Math.cos(b)) * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -740000.0) or not (a <= 6.5e-5): tmp = (r * math.sin(b)) / math.cos(a) else: tmp = (r / math.cos(b)) * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -740000.0) || !(a <= 6.5e-5)) tmp = Float64(Float64(r * sin(b)) / cos(a)); else tmp = Float64(Float64(r / cos(b)) * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -740000.0) || ~((a <= 6.5e-5))) tmp = (r * sin(b)) / cos(a); else tmp = (r / cos(b)) * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -740000.0], N[Not[LessEqual[a, 6.5e-5]], $MachinePrecision]], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -740000 \lor \neg \left(a \leq 6.5 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\end{array}
\end{array}
if a < -7.4e5 or 6.49999999999999943e-5 < a Initial program 50.5%
Taylor expanded in b around 0
lower-cos.f6450.6
Applied rewrites50.6%
if -7.4e5 < a < 6.49999999999999943e-5Initial program 96.7%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-sin.f6496.8
Applied rewrites96.8%
Final simplification70.6%
(FPCore (r a b)
:precision binary64
(if (or (<= b -0.000105) (not (<= b 0.105)))
(* (/ r (cos b)) (sin b))
(/
(*
(fma
(* (fma 0.008333333333333333 (* b b) -0.16666666666666666) r)
(* b b)
r)
b)
(cos (+ a b)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000105) || !(b <= 0.105)) {
tmp = (r / cos(b)) * sin(b);
} else {
tmp = (fma((fma(0.008333333333333333, (b * b), -0.16666666666666666) * r), (b * b), r) * b) / cos((a + b));
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if ((b <= -0.000105) || !(b <= 0.105)) tmp = Float64(Float64(r / cos(b)) * sin(b)); else tmp = Float64(Float64(fma(Float64(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666) * r), Float64(b * b), r) * b) / cos(Float64(a + b))); end return tmp end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.000105], N[Not[LessEqual[b, 0.105]], $MachinePrecision]], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.008333333333333333 * N[(b * b), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * r), $MachinePrecision] * N[(b * b), $MachinePrecision] + r), $MachinePrecision] * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.000105 \lor \neg \left(b \leq 0.105\right):\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, b \cdot b, -0.16666666666666666\right) \cdot r, b \cdot b, r\right) \cdot b}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -1.05e-4 or 0.104999999999999996 < b Initial program 44.3%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-sin.f6443.9
Applied rewrites43.9%
if -1.05e-4 < b < 0.104999999999999996Initial program 98.5%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.5
Applied rewrites98.5%
Final simplification70.4%
(FPCore (r a b) :precision binary64 (* (/ (sin b) (cos (+ a b))) r))
double code(double r, double a, double b) {
return (sin(b) / cos((a + b))) * r;
}
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) / cos((a + b))) * r
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) / Math.cos((a + b))) * r;
}
def code(r, a, b): return (math.sin(b) / math.cos((a + b))) * r
function code(r, a, b) return Float64(Float64(sin(b) / cos(Float64(a + b))) * r) end
function tmp = code(r, a, b) tmp = (sin(b) / cos((a + b))) * r; end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\cos \left(a + b\right)} \cdot r
\end{array}
Initial program 70.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6470.6
Applied rewrites70.6%
(FPCore (r a b) :precision binary64 (* (/ r (cos (+ a b))) (sin b)))
double code(double r, double a, double b) {
return (r / cos((a + b))) * 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 / cos((a + b))) * sin(b)
end function
public static double code(double r, double a, double b) {
return (r / Math.cos((a + b))) * Math.sin(b);
}
def code(r, a, b): return (r / math.cos((a + b))) * math.sin(b)
function code(r, a, b) return Float64(Float64(r / cos(Float64(a + b))) * sin(b)) end
function tmp = code(r, a, b) tmp = (r / cos((a + b))) * sin(b); end
code[r_, a_, b_] := N[(N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos \left(a + b\right)} \cdot \sin b
\end{array}
Initial program 70.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6470.6
Applied rewrites70.6%
(FPCore (r a b)
:precision binary64
(if (or (<= b -4.6) (not (<= b 3.7)))
(/ (* r (sin b)) 1.0)
(/
(*
(fma
(* (fma 0.008333333333333333 (* b b) -0.16666666666666666) r)
(* b b)
r)
b)
(cos (+ a b)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.6) || !(b <= 3.7)) {
tmp = (r * sin(b)) / 1.0;
} else {
tmp = (fma((fma(0.008333333333333333, (b * b), -0.16666666666666666) * r), (b * b), r) * b) / cos((a + b));
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if ((b <= -4.6) || !(b <= 3.7)) tmp = Float64(Float64(r * sin(b)) / 1.0); else tmp = Float64(Float64(fma(Float64(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666) * r), Float64(b * b), r) * b) / cos(Float64(a + b))); end return tmp end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.6], N[Not[LessEqual[b, 3.7]], $MachinePrecision]], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision], N[(N[(N[(N[(N[(0.008333333333333333 * N[(b * b), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * r), $MachinePrecision] * N[(b * b), $MachinePrecision] + r), $MachinePrecision] * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \lor \neg \left(b \leq 3.7\right):\\
\;\;\;\;\frac{r \cdot \sin b}{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, b \cdot b, -0.16666666666666666\right) \cdot r, b \cdot b, r\right) \cdot b}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -4.5999999999999996 or 3.7000000000000002 < b Initial program 43.9%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6440.7
Applied rewrites40.7%
Taylor expanded in b around 0
Applied rewrites4.3%
Taylor expanded in b around 0
Applied rewrites12.7%
if -4.5999999999999996 < b < 3.7000000000000002Initial program 98.5%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.5
Applied rewrites98.5%
Final simplification54.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -3.9) (not (<= b 3.6))) (/ (* r (sin b)) 1.0) (/ (* b r) (cos (+ a b)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -3.9) || !(b <= 3.6)) {
tmp = (r * sin(b)) / 1.0;
} else {
tmp = (b * r) / cos((a + 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.9d0)) .or. (.not. (b <= 3.6d0))) then
tmp = (r * sin(b)) / 1.0d0
else
tmp = (b * r) / cos((a + b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -3.9) || !(b <= 3.6)) {
tmp = (r * Math.sin(b)) / 1.0;
} else {
tmp = (b * r) / Math.cos((a + b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -3.9) or not (b <= 3.6): tmp = (r * math.sin(b)) / 1.0 else: tmp = (b * r) / math.cos((a + b)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -3.9) || !(b <= 3.6)) tmp = Float64(Float64(r * sin(b)) / 1.0); else tmp = Float64(Float64(b * r) / cos(Float64(a + b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -3.9) || ~((b <= 3.6))) tmp = (r * sin(b)) / 1.0; else tmp = (b * r) / cos((a + b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -3.9], N[Not[LessEqual[b, 3.6]], $MachinePrecision]], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.9 \lor \neg \left(b \leq 3.6\right):\\
\;\;\;\;\frac{r \cdot \sin b}{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -3.89999999999999991 or 3.60000000000000009 < b Initial program 43.9%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6440.7
Applied rewrites40.7%
Taylor expanded in b around 0
Applied rewrites4.3%
Taylor expanded in b around 0
Applied rewrites12.7%
if -3.89999999999999991 < b < 3.60000000000000009Initial program 98.5%
Taylor expanded in b around 0
lower-*.f6498.0
Applied rewrites98.0%
Final simplification54.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.6) (not (<= b 1.6))) (/ (* r (sin b)) 1.0) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.6) || !(b <= 1.6)) {
tmp = (r * sin(b)) / 1.0;
} 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 <= (-4.6d0)) .or. (.not. (b <= 1.6d0))) then
tmp = (r * sin(b)) / 1.0d0
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 <= -4.6) || !(b <= 1.6)) {
tmp = (r * Math.sin(b)) / 1.0;
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.6) or not (b <= 1.6): tmp = (r * math.sin(b)) / 1.0 else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.6) || !(b <= 1.6)) tmp = Float64(Float64(r * sin(b)) / 1.0); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.6) || ~((b <= 1.6))) tmp = (r * sin(b)) / 1.0; else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.6], N[Not[LessEqual[b, 1.6]], $MachinePrecision]], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \lor \neg \left(b \leq 1.6\right):\\
\;\;\;\;\frac{r \cdot \sin b}{1}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -4.5999999999999996 or 1.6000000000000001 < b Initial program 43.9%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6440.7
Applied rewrites40.7%
Taylor expanded in b around 0
Applied rewrites4.3%
Taylor expanded in b around 0
Applied rewrites12.7%
if -4.5999999999999996 < b < 1.6000000000000001Initial program 98.5%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6497.9
Applied rewrites97.9%
Applied rewrites97.9%
Final simplification54.3%
(FPCore (r a b) :precision binary64 (* r (/ b (cos a))))
double code(double r, double a, double b) {
return r * (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 * (b / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos(a));
}
def code(r, a, b): return r * (b / math.cos(a))
function code(r, a, b) return Float64(r * Float64(b / cos(a))) end
function tmp = code(r, a, b) tmp = r * (b / cos(a)); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos a}
\end{array}
Initial program 70.6%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6449.8
Applied rewrites49.8%
Applied rewrites49.8%
(FPCore (r a b) :precision binary64 (* b r))
double code(double r, double a, double b) {
return b * r;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = b * r
end function
public static double code(double r, double a, double b) {
return b * r;
}
def code(r, a, b): return b * r
function code(r, a, b) return Float64(b * r) end
function tmp = code(r, a, b) tmp = b * r; end
code[r_, a_, b_] := N[(b * r), $MachinePrecision]
\begin{array}{l}
\\
b \cdot r
\end{array}
Initial program 70.6%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6449.8
Applied rewrites49.8%
Taylor expanded in a around 0
Applied rewrites31.8%
herbie shell --seed 2024340
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))