
(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 16 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 (/ (* (sin b) r) (fma (cos b) (cos a) (* (sin a) (- (sin b))))))
double code(double r, double a, double b) {
return (sin(b) * r) / fma(cos(b), cos(a), (sin(a) * -sin(b)));
}
function code(r, a, b) return Float64(Float64(sin(b) * r) / fma(cos(b), cos(a), Float64(sin(a) * Float64(-sin(b))))) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $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{\sin b \cdot r}{\mathsf{fma}\left(\cos b, \cos a, \sin a \cdot \left(-\sin b\right)\right)}
\end{array}
Initial program 77.7%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (- (* (cos a) (cos b)) (* (sin a) (sin b)))))
double code(double r, double a, double b) {
return (sin(b) * r) / ((cos(a) * cos(b)) - (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 = (sin(b) * r) / ((cos(a) * cos(b)) - (sin(a) * sin(b)))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(a) * Math.sin(b)));
}
def code(r, a, b): return (math.sin(b) * r) / ((math.cos(a) * math.cos(b)) - (math.sin(a) * math.sin(b)))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(a) * sin(b)))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / ((cos(a) * cos(b)) - (sin(a) * sin(b))); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos a \cdot \cos b - \sin a \cdot \sin b}
\end{array}
Initial program 77.7%
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.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (* (/ (sin b) (fma (cos b) (cos a) (* (sin a) (- (sin b))))) r))
double code(double r, double a, double b) {
return (sin(b) / fma(cos(b), cos(a), (sin(a) * -sin(b)))) * r;
}
function code(r, a, b) return Float64(Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(a) * Float64(-sin(b))))) * r) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin a \cdot \left(-\sin b\right)\right)} \cdot r
\end{array}
Initial program 77.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6477.7
Applied rewrites77.7%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (* (/ r (fma (sin a) (- (sin b)) (* (cos a) (cos b)))) (sin b)))
double code(double r, double a, double b) {
return (r / fma(sin(a), -sin(b), (cos(a) * cos(b)))) * sin(b);
}
function code(r, a, b) return Float64(Float64(r / fma(sin(a), Float64(-sin(b)), Float64(cos(a) * cos(b)))) * sin(b)) end
code[r_, a_, b_] := N[(N[(r / N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \cos b\right)} \cdot \sin b
\end{array}
Initial program 77.7%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
lift-neg.f64N/A
neg-mul-1N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
lift-neg.f64N/A
lower-/.f64N/A
metadata-evalN/A
lift-neg.f64N/A
frac-2negN/A
lower-/.f6499.6
Applied rewrites99.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.5
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
*-lft-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
metadata-evalN/A
neg-mul-1N/A
Applied rewrites99.5%
Final simplification99.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ (* (sin b) r) (cos b))))
(if (<= b -0.036)
t_0
(if (<= b 0.022)
(/
(*
(fma
(* (fma 0.008333333333333333 (* b b) -0.16666666666666666) r)
(* b b)
r)
b)
(cos (+ a b)))
t_0))))
double code(double r, double a, double b) {
double t_0 = (sin(b) * r) / cos(b);
double tmp;
if (b <= -0.036) {
tmp = t_0;
} else if (b <= 0.022) {
tmp = (fma((fma(0.008333333333333333, (b * b), -0.16666666666666666) * r), (b * b), r) * b) / cos((a + b));
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(Float64(sin(b) * r) / cos(b)) tmp = 0.0 if (b <= -0.036) tmp = t_0; elseif (b <= 0.022) tmp = Float64(Float64(fma(Float64(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666) * r), Float64(b * b), r) * b) / cos(Float64(a + b))); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.036], t$95$0, If[LessEqual[b, 0.022], 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], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b \cdot r}{\cos b}\\
\mathbf{if}\;b \leq -0.036:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.022:\\
\;\;\;\;\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)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -0.0359999999999999973 or 0.021999999999999999 < b Initial program 54.5%
Taylor expanded in a around 0
lower-cos.f6453.8
Applied rewrites53.8%
if -0.0359999999999999973 < b < 0.021999999999999999Initial program 99.5%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Final simplification77.4%
(FPCore (r a b)
:precision binary64
(if (<= b -0.036)
(* (/ (sin b) (cos b)) r)
(if (<= b 0.022)
(/
(*
(fma
(* (fma 0.008333333333333333 (* b b) -0.16666666666666666) r)
(* b b)
r)
b)
(cos (+ a b)))
(* (/ r (cos b)) (sin b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.036) {
tmp = (sin(b) / cos(b)) * r;
} else if (b <= 0.022) {
tmp = (fma((fma(0.008333333333333333, (b * b), -0.16666666666666666) * r), (b * b), r) * b) / cos((a + b));
} else {
tmp = (r / cos(b)) * sin(b);
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if (b <= -0.036) tmp = Float64(Float64(sin(b) / cos(b)) * r); elseif (b <= 0.022) tmp = Float64(Float64(fma(Float64(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666) * r), Float64(b * b), r) * b) / cos(Float64(a + b))); else tmp = Float64(Float64(r / cos(b)) * sin(b)); end return tmp end
code[r_, a_, b_] := If[LessEqual[b, -0.036], N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision], If[LessEqual[b, 0.022], 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], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.036:\\
\;\;\;\;\frac{\sin b}{\cos b} \cdot r\\
\mathbf{elif}\;b \leq 0.022:\\
\;\;\;\;\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)}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\end{array}
\end{array}
if b < -0.0359999999999999973Initial program 50.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6450.3
Applied rewrites50.3%
Taylor expanded in a around 0
lower-cos.f6449.9
Applied rewrites49.9%
if -0.0359999999999999973 < b < 0.021999999999999999Initial program 99.5%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
if 0.021999999999999999 < b Initial program 58.1%
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.f6457.0
Applied rewrites57.0%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* (/ r (cos b)) (sin b))))
(if (<= b -0.036)
t_0
(if (<= b 0.022)
(/
(*
(fma
(* (fma 0.008333333333333333 (* b b) -0.16666666666666666) r)
(* b b)
r)
b)
(cos (+ a b)))
t_0))))
double code(double r, double a, double b) {
double t_0 = (r / cos(b)) * sin(b);
double tmp;
if (b <= -0.036) {
tmp = t_0;
} else if (b <= 0.022) {
tmp = (fma((fma(0.008333333333333333, (b * b), -0.16666666666666666) * r), (b * b), r) * b) / cos((a + b));
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(Float64(r / cos(b)) * sin(b)) tmp = 0.0 if (b <= -0.036) tmp = t_0; elseif (b <= 0.022) tmp = Float64(Float64(fma(Float64(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666) * r), Float64(b * b), r) * b) / cos(Float64(a + b))); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.036], t$95$0, If[LessEqual[b, 0.022], 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], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{r}{\cos b} \cdot \sin b\\
\mathbf{if}\;b \leq -0.036:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.022:\\
\;\;\;\;\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)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -0.0359999999999999973 or 0.021999999999999999 < b Initial program 54.5%
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.f6453.7
Applied rewrites53.7%
if -0.0359999999999999973 < b < 0.021999999999999999Initial program 99.5%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (cos (+ a b))))
double code(double r, double a, double b) {
return (sin(b) * r) / 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 = (sin(b) * r) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / Math.cos((a + b));
}
def code(r, a, b): return (math.sin(b) * r) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(sin(b) * r) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos \left(a + b\right)}
\end{array}
Initial program 77.7%
Final simplification77.7%
(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 77.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6477.7
Applied rewrites77.7%
(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 77.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6477.6
Applied rewrites77.6%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ r (/ 1.0 (sin b)))))
(if (<= b -8.5e+18)
t_0
(if (<= b 4.0)
(/
(*
(fma
(* (fma 0.008333333333333333 (* b b) -0.16666666666666666) r)
(* b b)
r)
b)
(cos (+ a b)))
t_0))))
double code(double r, double a, double b) {
double t_0 = r / (1.0 / sin(b));
double tmp;
if (b <= -8.5e+18) {
tmp = t_0;
} else if (b <= 4.0) {
tmp = (fma((fma(0.008333333333333333, (b * b), -0.16666666666666666) * r), (b * b), r) * b) / cos((a + b));
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(r / Float64(1.0 / sin(b))) tmp = 0.0 if (b <= -8.5e+18) tmp = t_0; elseif (b <= 4.0) tmp = Float64(Float64(fma(Float64(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666) * r), Float64(b * b), r) * b) / cos(Float64(a + b))); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(r / N[(1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -8.5e+18], t$95$0, If[LessEqual[b, 4.0], 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], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{r}{\frac{1}{\sin b}}\\
\mathbf{if}\;b \leq -8.5 \cdot 10^{+18}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 4:\\
\;\;\;\;\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)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -8.5e18 or 4 < b Initial program 54.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6454.6
Applied rewrites54.6%
Taylor expanded in b around 0
lower-cos.f6411.2
Applied rewrites11.2%
Taylor expanded in a around 0
Applied rewrites10.8%
if -8.5e18 < b < 4Initial program 98.8%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.1%
(FPCore (r a b) :precision binary64 (if (<= b -1.2e+21) (/ r (/ 1.0 (sin b))) (/ (* b r) (cos (+ a b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.2e+21) {
tmp = r / (1.0 / sin(b));
} 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 <= (-1.2d+21)) then
tmp = r / (1.0d0 / sin(b))
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 <= -1.2e+21) {
tmp = r / (1.0 / Math.sin(b));
} else {
tmp = (b * r) / Math.cos((a + b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.2e+21: tmp = r / (1.0 / math.sin(b)) else: tmp = (b * r) / math.cos((a + b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.2e+21) tmp = Float64(r / Float64(1.0 / sin(b))); 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 <= -1.2e+21) tmp = r / (1.0 / sin(b)); else tmp = (b * r) / cos((a + b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.2e+21], N[(r / N[(1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.2 \cdot 10^{+21}:\\
\;\;\;\;\frac{r}{\frac{1}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -1.2e21Initial program 50.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6450.3
Applied rewrites50.3%
Taylor expanded in b around 0
lower-cos.f6412.0
Applied rewrites12.0%
Taylor expanded in a around 0
Applied rewrites12.1%
if -1.2e21 < b Initial program 85.2%
Taylor expanded in b around 0
lower-*.f6466.4
Applied rewrites66.4%
(FPCore (r a b) :precision binary64 (if (<= b -1.2e+21) (/ (* (sin b) r) 1.0) (/ (* b r) (cos (+ a b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.2e+21) {
tmp = (sin(b) * r) / 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 <= (-1.2d+21)) then
tmp = (sin(b) * r) / 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 <= -1.2e+21) {
tmp = (Math.sin(b) * r) / 1.0;
} else {
tmp = (b * r) / Math.cos((a + b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.2e+21: tmp = (math.sin(b) * r) / 1.0 else: tmp = (b * r) / math.cos((a + b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.2e+21) tmp = Float64(Float64(sin(b) * r) / 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 <= -1.2e+21) tmp = (sin(b) * r) / 1.0; else tmp = (b * r) / cos((a + b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.2e+21], N[(N[(N[Sin[b], $MachinePrecision] * r), $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 -1.2 \cdot 10^{+21}:\\
\;\;\;\;\frac{\sin b \cdot r}{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -1.2e21Initial program 50.3%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
flip--N/A
cos-diffN/A
lower-/.f64N/A
Applied rewrites50.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6447.2
Applied rewrites47.2%
Taylor expanded in b around 0
Applied rewrites12.1%
if -1.2e21 < b Initial program 85.2%
Taylor expanded in b around 0
lower-*.f6466.4
Applied rewrites66.4%
Final simplification54.7%
(FPCore (r a b) :precision binary64 (if (<= b -17.0) (/ (* (sin b) r) 1.0) (* (/ b (cos a)) r)))
double code(double r, double a, double b) {
double tmp;
if (b <= -17.0) {
tmp = (sin(b) * r) / 1.0;
} else {
tmp = (b / cos(a)) * r;
}
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 <= (-17.0d0)) then
tmp = (sin(b) * r) / 1.0d0
else
tmp = (b / cos(a)) * r
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -17.0) {
tmp = (Math.sin(b) * r) / 1.0;
} else {
tmp = (b / Math.cos(a)) * r;
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -17.0: tmp = (math.sin(b) * r) / 1.0 else: tmp = (b / math.cos(a)) * r return tmp
function code(r, a, b) tmp = 0.0 if (b <= -17.0) tmp = Float64(Float64(sin(b) * r) / 1.0); else tmp = Float64(Float64(b / cos(a)) * r); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -17.0) tmp = (sin(b) * r) / 1.0; else tmp = (b / cos(a)) * r; end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -17.0], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / 1.0), $MachinePrecision], N[(N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -17:\\
\;\;\;\;\frac{\sin b \cdot r}{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\cos a} \cdot r\\
\end{array}
\end{array}
if b < -17Initial program 50.3%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
flip--N/A
cos-diffN/A
lower-/.f64N/A
Applied rewrites50.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6447.4
Applied rewrites47.4%
Taylor expanded in b around 0
Applied rewrites11.7%
if -17 < b Initial program 85.6%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6466.9
Applied rewrites66.9%
Applied rewrites67.0%
Final simplification54.7%
(FPCore (r a b) :precision binary64 (* (/ b (cos a)) r))
double code(double r, double a, double b) {
return (b / cos(a)) * 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 / cos(a)) * r
end function
public static double code(double r, double a, double b) {
return (b / Math.cos(a)) * r;
}
def code(r, a, b): return (b / math.cos(a)) * r
function code(r, a, b) return Float64(Float64(b / cos(a)) * r) end
function tmp = code(r, a, b) tmp = (b / cos(a)) * r; end
code[r_, a_, b_] := N[(N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{\cos a} \cdot r
\end{array}
Initial program 77.7%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6452.7
Applied rewrites52.7%
Applied rewrites52.8%
Final simplification52.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 77.7%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6452.7
Applied rewrites52.7%
Taylor expanded in a around 0
Applied rewrites37.3%
herbie shell --seed 2024244
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))