
(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 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(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 (/ (* r (sin b)) (fma (- 0.0 (sin a)) (sin b) (* (cos b) (cos a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma((0.0 - sin(a)), sin(b), (cos(b) * cos(a)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(Float64(0.0 - sin(a)), sin(b), Float64(cos(b) * cos(a)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(0.0 - N[Sin[a], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision] + N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(0 - \sin a, \sin b, \cos b \cdot \cos a\right)}
\end{array}
Initial program 77.4%
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f6477.5%
Simplified77.5%
cos-sumN/A
fmm-defN/A
*-commutativeN/A
fma-lowering-fma.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
neg-sub0N/A
--lowering--.f64N/A
sin-lowering-sin.f6499.5%
Applied egg-rr99.5%
+-commutativeN/A
*-commutativeN/A
fma-defineN/A
fma-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.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (fma (cos b) (cos a) (* (sin b) (- 0.0 (sin a)))))))
double code(double r, double a, double b) {
return sin(b) * (r / fma(cos(b), cos(a), (sin(b) * (0.0 - sin(a)))));
}
function code(r, a, b) return Float64(sin(b) * Float64(r / fma(cos(b), cos(a), Float64(sin(b) * Float64(0.0 - sin(a)))))) end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * N[(0.0 - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(0 - \sin a\right)\right)}
\end{array}
Initial program 77.4%
clear-numN/A
un-div-invN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6477.4%
Applied egg-rr77.4%
cos-sumN/A
fmm-defN/A
distribute-rgt-neg-outN/A
sub0-negN/A
fma-lowering-fma.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
*-commutativeN/A
sub0-negN/A
distribute-lft-neg-outN/A
neg-lowering-neg.f64N/A
*-commutativeN/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 (/ (* 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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f6477.5%
Simplified77.5%
+-commutativeN/A
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.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a))));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
clear-numN/A
un-div-invN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6477.4%
Applied egg-rr77.4%
cos-sumN/A
*-commutativeN/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.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a))));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
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.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b)
:precision binary64
(if (<= b -0.003)
(/ (* r (sin b)) (cos b))
(if (<= b 0.0082)
(* (/ r (cos (+ b a))) (* b (+ 1.0 (* -0.16666666666666666 (* b b)))))
(* r (tan b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.003) {
tmp = (r * sin(b)) / cos(b);
} else if (b <= 0.0082) {
tmp = (r / cos((b + a))) * (b * (1.0 + (-0.16666666666666666 * (b * b))));
} 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) :: tmp
if (b <= (-0.003d0)) then
tmp = (r * sin(b)) / cos(b)
else if (b <= 0.0082d0) then
tmp = (r / cos((b + a))) * (b * (1.0d0 + ((-0.16666666666666666d0) * (b * b))))
else
tmp = r * tan(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -0.003) {
tmp = (r * Math.sin(b)) / Math.cos(b);
} else if (b <= 0.0082) {
tmp = (r / Math.cos((b + a))) * (b * (1.0 + (-0.16666666666666666 * (b * b))));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.003: tmp = (r * math.sin(b)) / math.cos(b) elif b <= 0.0082: tmp = (r / math.cos((b + a))) * (b * (1.0 + (-0.16666666666666666 * (b * b)))) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.003) tmp = Float64(Float64(r * sin(b)) / cos(b)); elseif (b <= 0.0082) tmp = Float64(Float64(r / cos(Float64(b + a))) * Float64(b * Float64(1.0 + Float64(-0.16666666666666666 * Float64(b * b))))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.003) tmp = (r * sin(b)) / cos(b); elseif (b <= 0.0082) tmp = (r / cos((b + a))) * (b * (1.0 + (-0.16666666666666666 * (b * b)))); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.003], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.0082], N[(N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(b * N[(1.0 + N[(-0.16666666666666666 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.003:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{elif}\;b \leq 0.0082:\\
\;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + -0.16666666666666666 \cdot \left(b \cdot b\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if b < -0.0030000000000000001Initial program 55.9%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6455.5%
Simplified55.5%
if -0.0030000000000000001 < b < 0.00820000000000000069Initial program 98.5%
clear-numN/A
un-div-invN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6498.5%
Applied egg-rr98.5%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.5%
Simplified98.5%
if 0.00820000000000000069 < b Initial program 53.6%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6453.5%
Simplified53.5%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6453.7%
Applied egg-rr53.7%
Final simplification77.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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 77.4%
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f6477.5%
Simplified77.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 77.4%
clear-numN/A
un-div-invN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6477.4%
Applied egg-rr77.4%
Final simplification77.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 77.4%
Final simplification77.4%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (tan b))))
(if (<= b -0.0065)
t_0
(if (<= b 0.0028)
(* (/ r (cos (+ b a))) (* b (+ 1.0 (* -0.16666666666666666 (* b b)))))
t_0))))
double code(double r, double a, double b) {
double t_0 = r * tan(b);
double tmp;
if (b <= -0.0065) {
tmp = t_0;
} else if (b <= 0.0028) {
tmp = (r / cos((b + a))) * (b * (1.0 + (-0.16666666666666666 * (b * b))));
} else {
tmp = t_0;
}
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 = r * tan(b)
if (b <= (-0.0065d0)) then
tmp = t_0
else if (b <= 0.0028d0) then
tmp = (r / cos((b + a))) * (b * (1.0d0 + ((-0.16666666666666666d0) * (b * b))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = r * Math.tan(b);
double tmp;
if (b <= -0.0065) {
tmp = t_0;
} else if (b <= 0.0028) {
tmp = (r / Math.cos((b + a))) * (b * (1.0 + (-0.16666666666666666 * (b * b))));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * math.tan(b) tmp = 0 if b <= -0.0065: tmp = t_0 elif b <= 0.0028: tmp = (r / math.cos((b + a))) * (b * (1.0 + (-0.16666666666666666 * (b * b)))) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * tan(b)) tmp = 0.0 if (b <= -0.0065) tmp = t_0; elseif (b <= 0.0028) tmp = Float64(Float64(r / cos(Float64(b + a))) * Float64(b * Float64(1.0 + Float64(-0.16666666666666666 * Float64(b * b))))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * tan(b); tmp = 0.0; if (b <= -0.0065) tmp = t_0; elseif (b <= 0.0028) tmp = (r / cos((b + a))) * (b * (1.0 + (-0.16666666666666666 * (b * b)))); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.0065], t$95$0, If[LessEqual[b, 0.0028], N[(N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(b * N[(1.0 + N[(-0.16666666666666666 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -0.0065:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.0028:\\
\;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \left(b \cdot \left(1 + -0.16666666666666666 \cdot \left(b \cdot b\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -0.0064999999999999997 or 0.00279999999999999997 < b Initial program 54.7%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6454.5%
Simplified54.5%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6454.5%
Applied egg-rr54.5%
if -0.0064999999999999997 < b < 0.00279999999999999997Initial program 98.5%
clear-numN/A
un-div-invN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6498.5%
Applied egg-rr98.5%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.5%
Simplified98.5%
Final simplification77.4%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* r (tan b)))) (if (<= b -5.9e-5) t_0 (if (<= b 8.6e-6) (* r (/ b (cos (+ b a)))) t_0))))
double code(double r, double a, double b) {
double t_0 = r * tan(b);
double tmp;
if (b <= -5.9e-5) {
tmp = t_0;
} else if (b <= 8.6e-6) {
tmp = r * (b / cos((b + a)));
} else {
tmp = t_0;
}
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 = r * tan(b)
if (b <= (-5.9d-5)) then
tmp = t_0
else if (b <= 8.6d-6) then
tmp = r * (b / cos((b + a)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = r * Math.tan(b);
double tmp;
if (b <= -5.9e-5) {
tmp = t_0;
} else if (b <= 8.6e-6) {
tmp = r * (b / Math.cos((b + a)));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * math.tan(b) tmp = 0 if b <= -5.9e-5: tmp = t_0 elif b <= 8.6e-6: tmp = r * (b / math.cos((b + a))) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * tan(b)) tmp = 0.0 if (b <= -5.9e-5) tmp = t_0; elseif (b <= 8.6e-6) tmp = Float64(r * Float64(b / cos(Float64(b + a)))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * tan(b); tmp = 0.0; if (b <= -5.9e-5) tmp = t_0; elseif (b <= 8.6e-6) tmp = r * (b / cos((b + a))); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5.9e-5], t$95$0, If[LessEqual[b, 8.6e-6], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -5.9 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -5.8999999999999998e-5 or 8.60000000000000067e-6 < b Initial program 55.5%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6454.7%
Simplified54.7%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6454.8%
Applied egg-rr54.8%
if -5.8999999999999998e-5 < b < 8.60000000000000067e-6Initial program 99.0%
Taylor expanded in b around 0
Simplified98.7%
Final simplification76.9%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* r (tan b)))) (if (<= b -5.8e-5) t_0 (if (<= b 5.3e-6) (* b (/ r (cos a))) t_0))))
double code(double r, double a, double b) {
double t_0 = r * tan(b);
double tmp;
if (b <= -5.8e-5) {
tmp = t_0;
} else if (b <= 5.3e-6) {
tmp = b * (r / cos(a));
} else {
tmp = t_0;
}
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 = r * tan(b)
if (b <= (-5.8d-5)) then
tmp = t_0
else if (b <= 5.3d-6) then
tmp = b * (r / cos(a))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = r * Math.tan(b);
double tmp;
if (b <= -5.8e-5) {
tmp = t_0;
} else if (b <= 5.3e-6) {
tmp = b * (r / Math.cos(a));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * math.tan(b) tmp = 0 if b <= -5.8e-5: tmp = t_0 elif b <= 5.3e-6: tmp = b * (r / math.cos(a)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * tan(b)) tmp = 0.0 if (b <= -5.8e-5) tmp = t_0; elseif (b <= 5.3e-6) tmp = Float64(b * Float64(r / cos(a))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * tan(b); tmp = 0.0; if (b <= -5.8e-5) tmp = t_0; elseif (b <= 5.3e-6) tmp = b * (r / cos(a)); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5.8e-5], t$95$0, If[LessEqual[b, 5.3e-6], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -5.8 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 5.3 \cdot 10^{-6}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -5.8e-5 or 5.3000000000000001e-6 < b Initial program 55.5%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6454.7%
Simplified54.7%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6454.8%
Applied egg-rr54.8%
if -5.8e-5 < b < 5.3000000000000001e-6Initial program 99.0%
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f6498.9%
Simplified98.9%
cos-sumN/A
fmm-defN/A
*-commutativeN/A
fma-lowering-fma.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
neg-sub0N/A
--lowering--.f64N/A
sin-lowering-sin.f6499.8%
Applied egg-rr99.8%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6498.6%
Simplified98.6%
Final simplification76.8%
(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 77.4%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6460.9%
Simplified60.9%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6460.9%
Applied egg-rr60.9%
Final simplification60.9%
(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 77.4%
Taylor expanded in b around 0
cos-lowering-cos.f6455.7%
Simplified55.7%
Taylor expanded in a around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6439.5%
Simplified39.5%
(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 77.4%
Taylor expanded in b around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6452.3%
Simplified52.3%
Taylor expanded in a around 0
*-commutativeN/A
*-lowering-*.f6436.3%
Simplified36.3%
herbie shell --seed 2024155
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))