
(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 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (* (/ r (fma (sin (- b)) (sin a) (* (cos a) (cos b)))) (sin b)))
double code(double r, double a, double b) {
return (r / fma(sin(-b), sin(a), (cos(a) * cos(b)))) * sin(b);
}
function code(r, a, b) return Float64(Float64(r / fma(sin(Float64(-b)), sin(a), Float64(cos(a) * cos(b)))) * sin(b)) end
code[r_, a_, b_] := N[(N[(r / N[(N[Sin[(-b)], $MachinePrecision] * N[Sin[a], $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 \left(-b\right), \sin a, \cos a \cdot \cos b\right)} \cdot \sin b
\end{array}
Initial program 75.8%
lift-sin.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6475.9
Applied egg-rr75.9%
cos-sumN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cancel-sign-sub-invN/A
lift-sin.f64N/A
sin-negN/A
lift-neg.f64N/A
lift-sin.f64N/A
+-commutativeN/A
lift-fma.f6499.5
Applied egg-rr99.5%
(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(sin(b) * Float64(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[Sin[b], $MachinePrecision] * N[(r / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a \cdot \cos b - \sin a \cdot \sin b}
\end{array}
Initial program 75.8%
lift-sin.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6475.9
Applied egg-rr75.9%
cos-sumN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower--.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-*.f6499.5
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (* (- a b) (/ (+ b a) (- a b)))))))
double code(double r, double a, double b) {
return sin(b) * (r / cos(((a - b) * ((b + a) / (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) * ((b + a) / (a - b)))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos(((a - b) * ((b + a) / (a - b)))));
}
def code(r, a, b): return math.sin(b) * (r / math.cos(((a - b) * ((b + a) / (a - b)))))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(Float64(a - b) * Float64(Float64(b + a) / Float64(a - b)))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos(((a - b) * ((b + a) / (a - b))))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(N[(a - b), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] / N[(a - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(\left(a - b\right) \cdot \frac{b + a}{a - b}\right)}
\end{array}
Initial program 75.8%
lift-sin.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6475.9
Applied egg-rr75.9%
+-commutativeN/A
flip-+N/A
lift--.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6475.9
Applied egg-rr75.9%
Final simplification75.9%
(FPCore (r a b) :precision binary64 (if (<= b -2.7e-5) (* r (/ (sin b) (cos b))) (if (<= b 2.2e-36) (* b (/ r (cos a))) (/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.7e-5) {
tmp = r * (sin(b) / cos(b));
} else if (b <= 2.2e-36) {
tmp = b * (r / cos(a));
} else {
tmp = (r * sin(b)) / cos(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 <= (-2.7d-5)) then
tmp = r * (sin(b) / cos(b))
else if (b <= 2.2d-36) then
tmp = b * (r / cos(a))
else
tmp = (r * sin(b)) / cos(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2.7e-5) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else if (b <= 2.2e-36) {
tmp = b * (r / Math.cos(a));
} else {
tmp = (r * Math.sin(b)) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.7e-5: tmp = r * (math.sin(b) / math.cos(b)) elif b <= 2.2e-36: tmp = b * (r / math.cos(a)) else: tmp = (r * math.sin(b)) / math.cos(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2.7e-5) tmp = Float64(r * Float64(sin(b) / cos(b))); elseif (b <= 2.2e-36) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(Float64(r * sin(b)) / cos(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2.7e-5) tmp = r * (sin(b) / cos(b)); elseif (b <= 2.2e-36) tmp = b * (r / cos(a)); else tmp = (r * sin(b)) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.7e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.2e-36], N[(b * N[(r / N[Cos[a], $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 -2.7 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-36}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\end{array}
\end{array}
if b < -2.6999999999999999e-5Initial program 44.6%
lift-sin.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6444.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6444.6
Applied egg-rr44.6%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6445.6
Simplified45.6%
if -2.6999999999999999e-5 < b < 2.1999999999999999e-36Initial program 99.5%
Taylor expanded in b around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6499.5
Simplified99.5%
*-commutativeN/A
lift-cos.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.5
Applied egg-rr99.5%
if 2.1999999999999999e-36 < b Initial program 63.6%
Taylor expanded in a around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6464.3
Simplified64.3%
Final simplification76.3%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* r (/ (sin b) (cos b))))) (if (<= b -2.7e-5) t_0 (if (<= b 2.2e-36) (* b (/ r (cos a))) t_0))))
double code(double r, double a, double b) {
double t_0 = r * (sin(b) / cos(b));
double tmp;
if (b <= -2.7e-5) {
tmp = t_0;
} else if (b <= 2.2e-36) {
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 * (sin(b) / cos(b))
if (b <= (-2.7d-5)) then
tmp = t_0
else if (b <= 2.2d-36) 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.sin(b) / Math.cos(b));
double tmp;
if (b <= -2.7e-5) {
tmp = t_0;
} else if (b <= 2.2e-36) {
tmp = b * (r / Math.cos(a));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * (math.sin(b) / math.cos(b)) tmp = 0 if b <= -2.7e-5: tmp = t_0 elif b <= 2.2e-36: tmp = b * (r / math.cos(a)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * Float64(sin(b) / cos(b))) tmp = 0.0 if (b <= -2.7e-5) tmp = t_0; elseif (b <= 2.2e-36) 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 * (sin(b) / cos(b)); tmp = 0.0; if (b <= -2.7e-5) tmp = t_0; elseif (b <= 2.2e-36) 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[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.7e-5], t$95$0, If[LessEqual[b, 2.2e-36], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \frac{\sin b}{\cos b}\\
\mathbf{if}\;b \leq -2.7 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-36}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -2.6999999999999999e-5 or 2.1999999999999999e-36 < b Initial program 55.6%
lift-sin.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6455.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6455.6
Applied egg-rr55.6%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6456.4
Simplified56.4%
if -2.6999999999999999e-5 < b < 2.1999999999999999e-36Initial program 99.5%
Taylor expanded in b around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6499.5
Simplified99.5%
*-commutativeN/A
lift-cos.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.5
Applied egg-rr99.5%
Final simplification76.3%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (sin b) (/ r (cos b))))) (if (<= b -2.5e-5) t_0 (if (<= b 2.2e-36) (* b (/ r (cos a))) t_0))))
double code(double r, double a, double b) {
double t_0 = sin(b) * (r / cos(b));
double tmp;
if (b <= -2.5e-5) {
tmp = t_0;
} else if (b <= 2.2e-36) {
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 = sin(b) * (r / cos(b))
if (b <= (-2.5d-5)) then
tmp = t_0
else if (b <= 2.2d-36) 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 = Math.sin(b) * (r / Math.cos(b));
double tmp;
if (b <= -2.5e-5) {
tmp = t_0;
} else if (b <= 2.2e-36) {
tmp = b * (r / Math.cos(a));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) * (r / math.cos(b)) tmp = 0 if b <= -2.5e-5: tmp = t_0 elif b <= 2.2e-36: tmp = b * (r / math.cos(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 <= -2.5e-5) tmp = t_0; elseif (b <= 2.2e-36) tmp = Float64(b * Float64(r / cos(a))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) * (r / cos(b)); tmp = 0.0; if (b <= -2.5e-5) tmp = t_0; elseif (b <= 2.2e-36) tmp = b * (r / cos(a)); else tmp = t_0; end tmp_2 = 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, -2.5e-5], t$95$0, If[LessEqual[b, 2.2e-36], N[(b * N[(r / N[Cos[a], $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 -2.5 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-36}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -2.50000000000000012e-5 or 2.1999999999999999e-36 < b Initial program 55.6%
lift-sin.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6455.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6455.6
Applied egg-rr55.6%
Taylor expanded in a around 0
lower-/.f64N/A
lower-cos.f6456.4
Simplified56.4%
if -2.50000000000000012e-5 < b < 2.1999999999999999e-36Initial program 99.5%
Taylor expanded in b around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6499.5
Simplified99.5%
*-commutativeN/A
lift-cos.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.5
Applied egg-rr99.5%
Final simplification76.3%
(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 75.8%
lift-sin.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6475.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6475.9
Applied egg-rr75.9%
Final simplification75.9%
(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 75.8%
lift-sin.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6475.9
Applied egg-rr75.9%
Final simplification75.9%
(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 75.8%
lift-sin.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6475.9
Applied egg-rr75.9%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6455.2
Simplified55.2%
Final simplification55.2%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (- (/ r (sin a)))))
(if (<= b -5000000.0)
t_0
(if (<= b 55000000000.0)
(* (/ r (cos (+ b a))) (fma b (* -0.16666666666666666 (* b b)) b))
t_0))))
double code(double r, double a, double b) {
double t_0 = -(r / sin(a));
double tmp;
if (b <= -5000000.0) {
tmp = t_0;
} else if (b <= 55000000000.0) {
tmp = (r / cos((b + a))) * fma(b, (-0.16666666666666666 * (b * b)), b);
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(-Float64(r / sin(a))) tmp = 0.0 if (b <= -5000000.0) tmp = t_0; elseif (b <= 55000000000.0) tmp = Float64(Float64(r / cos(Float64(b + a))) * fma(b, Float64(-0.16666666666666666 * Float64(b * b)), b)); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = (-N[(r / N[Sin[a], $MachinePrecision]), $MachinePrecision])}, If[LessEqual[b, -5000000.0], t$95$0, If[LessEqual[b, 55000000000.0], N[(N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(b * N[(-0.16666666666666666 * N[(b * b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{r}{\sin a}\\
\mathbf{if}\;b \leq -5000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 55000000000:\\
\;\;\;\;\frac{r}{\cos \left(b + a\right)} \cdot \mathsf{fma}\left(b, -0.16666666666666666 \cdot \left(b \cdot b\right), b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -5e6 or 5.5e10 < b Initial program 51.4%
lift-sin.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
clear-numN/A
inv-powN/A
frac-2negN/A
neg-mul-1N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
times-fracN/A
unpow-prod-downN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
Applied egg-rr51.4%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6410.2
Simplified10.2%
Taylor expanded in b around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-sin.f649.9
Simplified9.9%
if -5e6 < b < 5.5e10Initial program 98.7%
lift-sin.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6498.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.8
Applied egg-rr98.8%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.3
Simplified95.3%
(FPCore (r a b) :precision binary64 (if (<= b 4600000000.0) (* b (/ r (cos a))) (- (/ r (sin a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= 4600000000.0) {
tmp = b * (r / cos(a));
} else {
tmp = -(r / sin(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 <= 4600000000.0d0) then
tmp = b * (r / cos(a))
else
tmp = -(r / sin(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 4600000000.0) {
tmp = b * (r / Math.cos(a));
} else {
tmp = -(r / Math.sin(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 4600000000.0: tmp = b * (r / math.cos(a)) else: tmp = -(r / math.sin(a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 4600000000.0) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(-Float64(r / sin(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 4600000000.0) tmp = b * (r / cos(a)); else tmp = -(r / sin(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 4600000000.0], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(r / N[Sin[a], $MachinePrecision]), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4600000000:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{r}{\sin a}\\
\end{array}
\end{array}
if b < 4.6e9Initial program 82.3%
Taylor expanded in b around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6468.9
Simplified68.9%
*-commutativeN/A
lift-cos.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6468.9
Applied egg-rr68.9%
if 4.6e9 < b Initial program 59.0%
lift-sin.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
clear-numN/A
inv-powN/A
frac-2negN/A
neg-mul-1N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
times-fracN/A
unpow-prod-downN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
Applied egg-rr58.9%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f649.0
Simplified9.0%
Taylor expanded in b around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-sin.f648.9
Simplified8.9%
(FPCore (r a b) :precision binary64 (if (<= b 4200000000.0) (* r b) (- (/ r (sin a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= 4200000000.0) {
tmp = r * b;
} else {
tmp = -(r / sin(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 <= 4200000000.0d0) then
tmp = r * b
else
tmp = -(r / sin(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 4200000000.0) {
tmp = r * b;
} else {
tmp = -(r / Math.sin(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 4200000000.0: tmp = r * b else: tmp = -(r / math.sin(a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 4200000000.0) tmp = Float64(r * b); else tmp = Float64(-Float64(r / sin(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 4200000000.0) tmp = r * b; else tmp = -(r / sin(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 4200000000.0], N[(r * b), $MachinePrecision], (-N[(r / N[Sin[a], $MachinePrecision]), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4200000000:\\
\;\;\;\;r \cdot b\\
\mathbf{else}:\\
\;\;\;\;-\frac{r}{\sin a}\\
\end{array}
\end{array}
if b < 4.2e9Initial program 82.3%
Taylor expanded in b around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6468.9
Simplified68.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f6449.9
Simplified49.9%
if 4.2e9 < b Initial program 59.0%
lift-sin.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
clear-numN/A
inv-powN/A
frac-2negN/A
neg-mul-1N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
times-fracN/A
unpow-prod-downN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
Applied egg-rr58.9%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f649.0
Simplified9.0%
Taylor expanded in b around inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-sin.f648.9
Simplified8.9%
(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 75.8%
Taylor expanded in b around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6450.6
Simplified50.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f6436.8
Simplified36.8%
herbie shell --seed 2024207
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))