
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(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 (- 0.0 (sin b)) (sin a) (* (cos a) (cos b))))))
double code(double r, double a, double b) {
return sin(b) * (r / fma((0.0 - sin(b)), sin(a), (cos(a) * cos(b))));
}
function code(r, a, b) return Float64(sin(b) * Float64(r / fma(Float64(0.0 - sin(b)), sin(a), Float64(cos(a) * cos(b))))) end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[(0.0 - N[Sin[b], $MachinePrecision]), $MachinePrecision] * N[Sin[a], $MachinePrecision] + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 74.1%
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6474.1
Applied egg-rr74.1%
cos-sumN/A
*-commutativeN/A
cancel-sign-sub-invN/A
sub0-negN/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.6
Applied egg-rr99.6%
sub0-negN/A
neg-lowering-neg.f64N/A
sin-lowering-sin.f6499.6
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (r / ((cos(a) * cos(b)) - (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(a) * cos(b)) - (sin(b) * sin(a))))
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(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 74.1%
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6474.1
Applied egg-rr74.1%
cos-sumN/A
*-commutativeN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f6499.5
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b)
:precision binary64
(if (<= b -0.076)
(* (sin b) (/ r (cos b)))
(if (<= b 0.07)
(*
r
(/
(*
b
(fma
(* b b)
(fma
b
(* b (fma (* b b) -0.0001984126984126984 0.008333333333333333))
-0.16666666666666666)
1.0))
(cos (+ b a))))
(/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.076) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 0.07) {
tmp = r * ((b * fma((b * b), fma(b, (b * fma((b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos((b + a)));
} else {
tmp = (r * sin(b)) / cos(b);
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if (b <= -0.076) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 0.07) tmp = Float64(r * Float64(Float64(b * fma(Float64(b * b), fma(b, Float64(b * fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos(Float64(b + a)))); else tmp = Float64(Float64(r * sin(b)) / cos(b)); end return tmp end
code[r_, a_, b_] := If[LessEqual[b, -0.076], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.07], N[(r * N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.076:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 0.07:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\end{array}
\end{array}
if b < -0.0759999999999999981Initial program 56.6%
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6456.7
Applied egg-rr56.7%
Taylor expanded in a around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6458.2
Simplified58.2%
if -0.0759999999999999981 < b < 0.070000000000000007Initial program 97.5%
cos-sumN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-sub0N/A
--lowering--.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.8
Applied egg-rr99.8%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6499.8
Simplified99.8%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr97.6%
if 0.070000000000000007 < b Initial program 41.9%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6441.7
Simplified41.7%
Final simplification74.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* (sin b) (/ r (cos b)))))
(if (<= b -0.235)
t_0
(if (<= b 0.095)
(*
r
(/
(*
b
(fma
(* b b)
(fma
b
(* b (fma (* b b) -0.0001984126984126984 0.008333333333333333))
-0.16666666666666666)
1.0))
(cos (+ b a))))
t_0))))
double code(double r, double a, double b) {
double t_0 = sin(b) * (r / cos(b));
double tmp;
if (b <= -0.235) {
tmp = t_0;
} else if (b <= 0.095) {
tmp = r * ((b * fma((b * b), fma(b, (b * fma((b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos((b + a)));
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(sin(b) * Float64(r / cos(b))) tmp = 0.0 if (b <= -0.235) tmp = t_0; elseif (b <= 0.095) tmp = Float64(r * Float64(Float64(b * fma(Float64(b * b), fma(b, Float64(b * fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos(Float64(b + a)))); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.235], t$95$0, If[LessEqual[b, 0.095], N[(r * N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot \frac{r}{\cos b}\\
\mathbf{if}\;b \leq -0.235:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.095:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -0.23499999999999999 or 0.095000000000000001 < b Initial program 49.9%
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6449.9
Applied egg-rr49.9%
Taylor expanded in a around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6450.6
Simplified50.6%
if -0.23499999999999999 < b < 0.095000000000000001Initial program 97.5%
cos-sumN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-sub0N/A
--lowering--.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.8
Applied egg-rr99.8%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6499.8
Simplified99.8%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr97.6%
Final simplification74.5%
(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 74.1%
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6474.1
Applied egg-rr74.1%
Final simplification74.1%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos a))))
double code(double r, double a, double b) {
return sin(b) * (r / 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 = sin(b) * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos(a));
}
def code(r, a, b): return math.sin(b) * (r / math.cos(a))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos(a)); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a}
\end{array}
Initial program 74.1%
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6474.1
Applied egg-rr74.1%
Taylor expanded in b around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6454.6
Simplified54.6%
Final simplification54.6%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (sin b))))
(if (<= b -5.2)
t_0
(if (<= b 0.69)
(*
r
(/
(*
b
(fma
(* b b)
(fma
b
(* b (fma (* b b) -0.0001984126984126984 0.008333333333333333))
-0.16666666666666666)
1.0))
(cos (+ b a))))
t_0))))
double code(double r, double a, double b) {
double t_0 = r * sin(b);
double tmp;
if (b <= -5.2) {
tmp = t_0;
} else if (b <= 0.69) {
tmp = r * ((b * fma((b * b), fma(b, (b * fma((b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos((b + a)));
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(r * sin(b)) tmp = 0.0 if (b <= -5.2) tmp = t_0; elseif (b <= 0.69) tmp = Float64(r * Float64(Float64(b * fma(Float64(b * b), fma(b, Float64(b * fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos(Float64(b + a)))); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5.2], t$95$0, If[LessEqual[b, 0.69], N[(r * N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \sin b\\
\mathbf{if}\;b \leq -5.2:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.69:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -5.20000000000000018 or 0.68999999999999995 < b Initial program 49.5%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f646.5
Simplified6.5%
Taylor expanded in a around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6411.4
Simplified11.4%
if -5.20000000000000018 < b < 0.68999999999999995Initial program 97.5%
cos-sumN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-sub0N/A
--lowering--.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.8
Applied egg-rr99.8%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6499.5
Simplified99.5%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr97.4%
Final simplification55.4%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (sin b))))
(if (<= b -4.6)
t_0
(if (<= b 0.69)
(*
(/ r (cos (+ b a)))
(*
b
(fma
(* b b)
(fma
(* b b)
(fma (* b b) -0.0001984126984126984 0.008333333333333333)
-0.16666666666666666)
1.0)))
t_0))))
double code(double r, double a, double b) {
double t_0 = r * sin(b);
double tmp;
if (b <= -4.6) {
tmp = t_0;
} else if (b <= 0.69) {
tmp = (r / cos((b + a))) * (b * fma((b * b), fma((b * b), fma((b * b), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666), 1.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(r * sin(b)) tmp = 0.0 if (b <= -4.6) tmp = t_0; elseif (b <= 0.69) tmp = Float64(Float64(r / cos(Float64(b + a))) * Float64(b * fma(Float64(b * b), fma(Float64(b * b), fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666), 1.0))); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4.6], t$95$0, If[LessEqual[b, 0.69], N[(N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(b * N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \sin b\\
\mathbf{if}\;b \leq -4.6:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.69:\\
\;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -4.5999999999999996 or 0.68999999999999995 < b Initial program 49.5%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f646.5
Simplified6.5%
Taylor expanded in a around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6411.4
Simplified11.4%
if -4.5999999999999996 < b < 0.68999999999999995Initial program 97.5%
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6497.6
Applied egg-rr97.6%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6497.4
Simplified97.4%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (sin b))))
(if (<= b -4.2)
t_0
(if (<= b 0.69)
(*
r
(/
(*
b
(fma
b
(* b (fma (* b b) 0.008333333333333333 -0.16666666666666666))
1.0))
(cos (+ b a))))
t_0))))
double code(double r, double a, double b) {
double t_0 = r * sin(b);
double tmp;
if (b <= -4.2) {
tmp = t_0;
} else if (b <= 0.69) {
tmp = r * ((b * fma(b, (b * fma((b * b), 0.008333333333333333, -0.16666666666666666)), 1.0)) / cos((b + a)));
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(r * sin(b)) tmp = 0.0 if (b <= -4.2) tmp = t_0; elseif (b <= 0.69) tmp = Float64(r * Float64(Float64(b * fma(b, Float64(b * fma(Float64(b * b), 0.008333333333333333, -0.16666666666666666)), 1.0)) / cos(Float64(b + a)))); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4.2], t$95$0, If[LessEqual[b, 0.69], N[(r * N[(N[(b * N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \sin b\\
\mathbf{if}\;b \leq -4.2:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.69:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, 0.008333333333333333, -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -4.20000000000000018 or 0.68999999999999995 < b Initial program 49.5%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f646.5
Simplified6.5%
Taylor expanded in a around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6411.4
Simplified11.4%
if -4.20000000000000018 < b < 0.68999999999999995Initial program 97.5%
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6497.6
Applied egg-rr97.6%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f6497.2
Simplified97.2%
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6497.2
Applied egg-rr97.2%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (sin b))))
(if (<= b -3.5)
t_0
(if (<= b 0.69)
(* (/ r (cos (+ b a))) (* b (fma b (* b -0.16666666666666666) 1.0)))
t_0))))
double code(double r, double a, double b) {
double t_0 = r * sin(b);
double tmp;
if (b <= -3.5) {
tmp = t_0;
} else if (b <= 0.69) {
tmp = (r / cos((b + a))) * (b * fma(b, (b * -0.16666666666666666), 1.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(r * sin(b)) tmp = 0.0 if (b <= -3.5) tmp = t_0; elseif (b <= 0.69) tmp = Float64(Float64(r / cos(Float64(b + a))) * Float64(b * fma(b, Float64(b * -0.16666666666666666), 1.0))); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.5], t$95$0, If[LessEqual[b, 0.69], N[(N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(b * N[(b * N[(b * -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \sin b\\
\mathbf{if}\;b \leq -3.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.69:\\
\;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \mathsf{fma}\left(b, b \cdot -0.16666666666666666, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -3.5 or 0.68999999999999995 < b Initial program 49.5%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f646.5
Simplified6.5%
Taylor expanded in a around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6411.4
Simplified11.4%
if -3.5 < b < 0.68999999999999995Initial program 97.5%
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6497.6
Applied egg-rr97.6%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f6496.8
Simplified96.8%
(FPCore (r a b) :precision binary64 (if (<= b -4.5) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -4.5) {
tmp = r * sin(b);
} else {
tmp = b * (r / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-4.5d0)) then
tmp = r * sin(b)
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -4.5) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -4.5: tmp = r * math.sin(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -4.5) tmp = Float64(r * sin(b)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -4.5) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -4.5], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -4.5Initial program 56.0%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f646.5
Simplified6.5%
Taylor expanded in a around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6412.2
Simplified12.2%
if -4.5 < b Initial program 80.5%
Taylor expanded in b around 0
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f6468.0
Simplified68.0%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6468.1
Applied egg-rr68.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 74.1%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f6453.0
Simplified53.0%
Taylor expanded in a around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6439.5
Simplified39.5%
(FPCore (r a b) :precision binary64 (* b (* r (/ 1.0 (fma b (* b -0.5) 1.0)))))
double code(double r, double a, double b) {
return b * (r * (1.0 / fma(b, (b * -0.5), 1.0)));
}
function code(r, a, b) return Float64(b * Float64(r * Float64(1.0 / fma(b, Float64(b * -0.5), 1.0)))) end
code[r_, a_, b_] := N[(b * N[(r * N[(1.0 / N[(b * N[(b * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \left(r \cdot \frac{1}{\mathsf{fma}\left(b, b \cdot -0.5, 1\right)}\right)
\end{array}
Initial program 74.1%
Taylor expanded in b around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
--lowering--.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6452.5
Simplified52.5%
Taylor expanded in b around 0
Simplified52.0%
Taylor expanded in a around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f6436.1
Simplified36.1%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6436.1
Applied egg-rr36.1%
Final simplification36.1%
(FPCore (r a b) :precision binary64 (* b (/ r (fma b (* b -0.5) 1.0))))
double code(double r, double a, double b) {
return b * (r / fma(b, (b * -0.5), 1.0));
}
function code(r, a, b) return Float64(b * Float64(r / fma(b, Float64(b * -0.5), 1.0))) end
code[r_, a_, b_] := N[(b * N[(r / N[(b * N[(b * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{r}{\mathsf{fma}\left(b, b \cdot -0.5, 1\right)}
\end{array}
Initial program 74.1%
Taylor expanded in b around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
--lowering--.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6452.5
Simplified52.5%
Taylor expanded in b around 0
Simplified52.0%
Taylor expanded in a around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f6436.1
Simplified36.1%
(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 74.1%
Taylor expanded in b around 0
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f6451.2
Simplified51.2%
Taylor expanded in a around 0
*-commutativeN/A
*-lowering-*.f6436.0
Simplified36.0%
herbie shell --seed 2024199
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))