
(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 12 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) (- 0.0 -1.0)) (/ r (fma (sin b) (- 0.0 (sin a)) (* (cos b) (cos a))))))
double code(double r, double a, double b) {
return (sin(b) / (0.0 - -1.0)) * (r / fma(sin(b), (0.0 - sin(a)), (cos(b) * cos(a))));
}
function code(r, a, b) return Float64(Float64(sin(b) / Float64(0.0 - -1.0)) * Float64(r / fma(sin(b), Float64(0.0 - sin(a)), Float64(cos(b) * cos(a))))) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[(0.0 - -1.0), $MachinePrecision]), $MachinePrecision] * N[(r / N[(N[Sin[b], $MachinePrecision] * N[(0.0 - N[Sin[a], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{0 - -1} \cdot \frac{r}{\mathsf{fma}\left(\sin b, 0 - \sin a, \cos b \cdot \cos a\right)}
\end{array}
Initial program 79.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.4
Applied egg-rr99.4%
sub0-negN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.4
Applied egg-rr99.4%
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
sub0-negN/A
--lowering--.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f6499.4
Applied egg-rr99.4%
*-commutativeN/A
frac-2negN/A
associate-*l/N/A
neg-mul-1N/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sub0-negN/A
--lowering--.f64N/A
sin-lowering-sin.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ (sin b) (cos (+ b a)))))
(if (<= t_0 -0.01)
(/ r (/ 1.0 (tan b)))
(if (<= t_0 5e-13) (* r (* b (/ 1.0 (cos a)))) (* r (tan b))))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((b + a));
double tmp;
if (t_0 <= -0.01) {
tmp = r / (1.0 / tan(b));
} else if (t_0 <= 5e-13) {
tmp = r * (b * (1.0 / cos(a)));
} else {
tmp = r * tan(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) :: t_0
real(8) :: tmp
t_0 = sin(b) / cos((b + a))
if (t_0 <= (-0.01d0)) then
tmp = r / (1.0d0 / tan(b))
else if (t_0 <= 5d-13) then
tmp = r * (b * (1.0d0 / cos(a)))
else
tmp = r * tan(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.sin(b) / Math.cos((b + a));
double tmp;
if (t_0 <= -0.01) {
tmp = r / (1.0 / Math.tan(b));
} else if (t_0 <= 5e-13) {
tmp = r * (b * (1.0 / Math.cos(a)));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((b + a)) tmp = 0 if t_0 <= -0.01: tmp = r / (1.0 / math.tan(b)) elif t_0 <= 5e-13: tmp = r * (b * (1.0 / math.cos(a))) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(b + a))) tmp = 0.0 if (t_0 <= -0.01) tmp = Float64(r / Float64(1.0 / tan(b))); elseif (t_0 <= 5e-13) tmp = Float64(r * Float64(b * Float64(1.0 / cos(a)))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) / cos((b + a)); tmp = 0.0; if (t_0 <= -0.01) tmp = r / (1.0 / tan(b)); elseif (t_0 <= 5e-13) tmp = r * (b * (1.0 / cos(a))); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.01], N[(r / N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-13], N[(r * N[(b * N[(1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(b + a\right)}\\
\mathbf{if}\;t\_0 \leq -0.01:\\
\;\;\;\;\frac{r}{\frac{1}{\tan b}}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;r \cdot \left(b \cdot \frac{1}{\cos a}\right)\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0100000000000000002Initial program 69.5%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6469.6
Simplified69.6%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
/-lowering-/.f64N/A
quot-tanN/A
tan-lowering-tan.f6469.8
Applied egg-rr69.8%
if -0.0100000000000000002 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 4.9999999999999999e-13Initial program 99.6%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6499.5
Simplified99.5%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6499.6
Applied egg-rr99.6%
if 4.9999999999999999e-13 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 57.4%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6456.2
Simplified56.2%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6456.4
Applied egg-rr56.4%
Final simplification79.3%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ (sin b) (cos (+ b a)))) (t_1 (* r (tan b))))
(if (<= t_0 -0.01)
t_1
(if (<= t_0 5e-13) (* r (* b (/ 1.0 (cos a)))) t_1))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((b + a));
double t_1 = r * tan(b);
double tmp;
if (t_0 <= -0.01) {
tmp = t_1;
} else if (t_0 <= 5e-13) {
tmp = r * (b * (1.0 / cos(a)));
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(b) / cos((b + a))
t_1 = r * tan(b)
if (t_0 <= (-0.01d0)) then
tmp = t_1
else if (t_0 <= 5d-13) then
tmp = r * (b * (1.0d0 / cos(a)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.sin(b) / Math.cos((b + a));
double t_1 = r * Math.tan(b);
double tmp;
if (t_0 <= -0.01) {
tmp = t_1;
} else if (t_0 <= 5e-13) {
tmp = r * (b * (1.0 / Math.cos(a)));
} else {
tmp = t_1;
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((b + a)) t_1 = r * math.tan(b) tmp = 0 if t_0 <= -0.01: tmp = t_1 elif t_0 <= 5e-13: tmp = r * (b * (1.0 / math.cos(a))) else: tmp = t_1 return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(b + a))) t_1 = Float64(r * tan(b)) tmp = 0.0 if (t_0 <= -0.01) tmp = t_1; elseif (t_0 <= 5e-13) tmp = Float64(r * Float64(b * Float64(1.0 / cos(a)))); else tmp = t_1; end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) / cos((b + a)); t_1 = r * tan(b); tmp = 0.0; if (t_0 <= -0.01) tmp = t_1; elseif (t_0 <= 5e-13) tmp = r * (b * (1.0 / cos(a))); else tmp = t_1; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.01], t$95$1, If[LessEqual[t$95$0, 5e-13], N[(r * N[(b * N[(1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(b + a\right)}\\
t_1 := r \cdot \tan b\\
\mathbf{if}\;t\_0 \leq -0.01:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;r \cdot \left(b \cdot \frac{1}{\cos a}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0100000000000000002 or 4.9999999999999999e-13 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 63.4%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6462.8
Simplified62.8%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6463.0
Applied egg-rr63.0%
if -0.0100000000000000002 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 4.9999999999999999e-13Initial program 99.6%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6499.5
Simplified99.5%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6499.6
Applied egg-rr99.6%
Final simplification79.3%
(FPCore (r a b) :precision binary64 (let* ((t_0 (/ (sin b) (cos (+ b a)))) (t_1 (* r (tan b)))) (if (<= t_0 -0.01) t_1 (if (<= t_0 5e-13) (* r (/ b (cos a))) t_1))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((b + a));
double t_1 = r * tan(b);
double tmp;
if (t_0 <= -0.01) {
tmp = t_1;
} else if (t_0 <= 5e-13) {
tmp = r * (b / cos(a));
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(b) / cos((b + a))
t_1 = r * tan(b)
if (t_0 <= (-0.01d0)) then
tmp = t_1
else if (t_0 <= 5d-13) then
tmp = r * (b / cos(a))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.sin(b) / Math.cos((b + a));
double t_1 = r * Math.tan(b);
double tmp;
if (t_0 <= -0.01) {
tmp = t_1;
} else if (t_0 <= 5e-13) {
tmp = r * (b / Math.cos(a));
} else {
tmp = t_1;
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((b + a)) t_1 = r * math.tan(b) tmp = 0 if t_0 <= -0.01: tmp = t_1 elif t_0 <= 5e-13: tmp = r * (b / math.cos(a)) else: tmp = t_1 return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(b + a))) t_1 = Float64(r * tan(b)) tmp = 0.0 if (t_0 <= -0.01) tmp = t_1; elseif (t_0 <= 5e-13) tmp = Float64(r * Float64(b / cos(a))); else tmp = t_1; end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) / cos((b + a)); t_1 = r * tan(b); tmp = 0.0; if (t_0 <= -0.01) tmp = t_1; elseif (t_0 <= 5e-13) tmp = r * (b / cos(a)); else tmp = t_1; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.01], t$95$1, If[LessEqual[t$95$0, 5e-13], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(b + a\right)}\\
t_1 := r \cdot \tan b\\
\mathbf{if}\;t\_0 \leq -0.01:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0100000000000000002 or 4.9999999999999999e-13 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 63.4%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6462.8
Simplified62.8%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6463.0
Applied egg-rr63.0%
if -0.0100000000000000002 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 4.9999999999999999e-13Initial program 99.6%
Taylor expanded in b around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6499.6
Simplified99.6%
Final simplification79.3%
(FPCore (r a b) :precision binary64 (let* ((t_0 (/ (sin b) (cos (+ b a)))) (t_1 (* r (tan b)))) (if (<= t_0 -0.01) t_1 (if (<= t_0 5e-13) (* b (/ r (cos a))) t_1))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((b + a));
double t_1 = r * tan(b);
double tmp;
if (t_0 <= -0.01) {
tmp = t_1;
} else if (t_0 <= 5e-13) {
tmp = b * (r / cos(a));
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(b) / cos((b + a))
t_1 = r * tan(b)
if (t_0 <= (-0.01d0)) then
tmp = t_1
else if (t_0 <= 5d-13) then
tmp = b * (r / cos(a))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.sin(b) / Math.cos((b + a));
double t_1 = r * Math.tan(b);
double tmp;
if (t_0 <= -0.01) {
tmp = t_1;
} else if (t_0 <= 5e-13) {
tmp = b * (r / Math.cos(a));
} else {
tmp = t_1;
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((b + a)) t_1 = r * math.tan(b) tmp = 0 if t_0 <= -0.01: tmp = t_1 elif t_0 <= 5e-13: tmp = b * (r / math.cos(a)) else: tmp = t_1 return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(b + a))) t_1 = Float64(r * tan(b)) tmp = 0.0 if (t_0 <= -0.01) tmp = t_1; elseif (t_0 <= 5e-13) tmp = Float64(b * Float64(r / cos(a))); else tmp = t_1; end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) / cos((b + a)); t_1 = r * tan(b); tmp = 0.0; if (t_0 <= -0.01) tmp = t_1; elseif (t_0 <= 5e-13) tmp = b * (r / cos(a)); else tmp = t_1; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.01], t$95$1, If[LessEqual[t$95$0, 5e-13], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(b + a\right)}\\
t_1 := r \cdot \tan b\\
\mathbf{if}\;t\_0 \leq -0.01:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0100000000000000002 or 4.9999999999999999e-13 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 63.4%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6462.8
Simplified62.8%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6463.0
Applied egg-rr63.0%
if -0.0100000000000000002 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 4.9999999999999999e-13Initial program 99.6%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6499.5
Simplified99.5%
Final simplification79.3%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (fma (sin b) (- 0.0 (sin a)) (* (cos b) (cos a))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(sin(b), (0.0 - sin(a)), (cos(b) * cos(a))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(sin(b), Float64(0.0 - sin(a)), Float64(cos(b) * cos(a))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] * N[(0.0 - N[Sin[a], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin b, 0 - \sin a, \cos b \cdot \cos a\right)}
\end{array}
Initial program 79.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.4
Applied egg-rr99.4%
sub0-negN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.4
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (fma (cos b) (cos a) (* (sin b) (- 0.0 (sin a)))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(cos(b), cos(a), (sin(b) * (0.0 - sin(a)))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(b) * Float64(0.0 - sin(a)))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * N[(0.0 - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(0 - \sin a\right)\right)}
\end{array}
Initial program 79.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.4
Applied egg-rr99.4%
sub0-negN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.4
Applied egg-rr99.4%
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
sub0-negN/A
--lowering--.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f6499.4
Applied egg-rr99.4%
sub0-negN/A
distribute-lft-neg-inN/A
neg-lowering-neg.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f6499.4
Applied egg-rr99.4%
Final simplification99.4%
(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 79.5%
cos-sumN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f6499.4
Applied egg-rr99.4%
Final simplification99.4%
(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 79.5%
Final simplification79.5%
(FPCore (r a b) :precision binary64 (* r (tan b)))
double code(double r, double a, double b) {
return r * tan(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 * tan(b)
end function
public static double code(double r, double a, double b) {
return r * Math.tan(b);
}
def code(r, a, b): return r * math.tan(b)
function code(r, a, b) return Float64(r * tan(b)) end
function tmp = code(r, a, b) tmp = r * tan(b); end
code[r_, a_, b_] := N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \tan b
\end{array}
Initial program 79.5%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6460.7
Simplified60.7%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6460.8
Applied egg-rr60.8%
Final simplification60.8%
(FPCore (r a b) :precision binary64 (/ r (/ (fma (* b b) -0.3333333333333333 1.0) b)))
double code(double r, double a, double b) {
return r / (fma((b * b), -0.3333333333333333, 1.0) / b);
}
function code(r, a, b) return Float64(r / Float64(fma(Float64(b * b), -0.3333333333333333, 1.0) / b)) end
code[r_, a_, b_] := N[(r / N[(N[(N[(b * b), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\mathsf{fma}\left(b \cdot b, -0.3333333333333333, 1\right)}{b}}
\end{array}
Initial program 79.5%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6460.7
Simplified60.7%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
/-lowering-/.f64N/A
quot-tanN/A
tan-lowering-tan.f6460.7
Applied egg-rr60.7%
Taylor expanded in b around 0
/-lowering-/.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6429.1
Simplified29.1%
(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 79.5%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6447.1
Simplified47.1%
Taylor expanded in a around 0
Simplified28.7%
herbie shell --seed 2024195
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))