
(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 11 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) (- (* (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 76.3%
+-commutative76.3%
Simplified76.3%
cos-sum99.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* r (/ (sin b) (cos a))))) (if (<= a -0.00023) t_0 (if (<= a 66000000.0) (* (tan b) r) t_0))))
double code(double r, double a, double b) {
double t_0 = r * (sin(b) / cos(a));
double tmp;
if (a <= -0.00023) {
tmp = t_0;
} else if (a <= 66000000.0) {
tmp = tan(b) * r;
} 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(a))
if (a <= (-0.00023d0)) then
tmp = t_0
else if (a <= 66000000.0d0) then
tmp = tan(b) * r
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(a));
double tmp;
if (a <= -0.00023) {
tmp = t_0;
} else if (a <= 66000000.0) {
tmp = Math.tan(b) * r;
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * (math.sin(b) / math.cos(a)) tmp = 0 if a <= -0.00023: tmp = t_0 elif a <= 66000000.0: tmp = math.tan(b) * r else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * Float64(sin(b) / cos(a))) tmp = 0.0 if (a <= -0.00023) tmp = t_0; elseif (a <= 66000000.0) tmp = Float64(tan(b) * r); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * (sin(b) / cos(a)); tmp = 0.0; if (a <= -0.00023) tmp = t_0; elseif (a <= 66000000.0) tmp = tan(b) * r; 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[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.00023], t$95$0, If[LessEqual[a, 66000000.0], N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \frac{\sin b}{\cos a}\\
\mathbf{if}\;a \leq -0.00023:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 66000000:\\
\;\;\;\;\tan b \cdot r\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -2.3000000000000001e-4 or 6.6e7 < a Initial program 55.5%
+-commutative55.5%
Simplified55.5%
Taylor expanded in b around 0 55.7%
if -2.3000000000000001e-4 < a < 6.6e7Initial program 97.4%
associate-*r/97.4%
+-commutative97.4%
Simplified97.4%
add-log-exp97.2%
Applied egg-rr97.2%
rem-log-exp97.4%
expm1-log1p-u97.4%
expm1-define97.2%
log1p-undefine97.1%
rem-exp-log97.1%
+-commutative97.1%
Applied egg-rr97.1%
Taylor expanded in a around 0 97.1%
associate--l+97.4%
metadata-eval97.4%
+-rgt-identity97.4%
associate-/l*97.4%
*-commutative97.4%
quot-tan97.6%
Applied egg-rr97.6%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (sin b) (/ r (cos a))))) (if (<= a -0.00024) t_0 (if (<= a 66000000.0) (* (tan b) r) t_0))))
double code(double r, double a, double b) {
double t_0 = sin(b) * (r / cos(a));
double tmp;
if (a <= -0.00024) {
tmp = t_0;
} else if (a <= 66000000.0) {
tmp = tan(b) * r;
} 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(a))
if (a <= (-0.00024d0)) then
tmp = t_0
else if (a <= 66000000.0d0) then
tmp = tan(b) * r
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(a));
double tmp;
if (a <= -0.00024) {
tmp = t_0;
} else if (a <= 66000000.0) {
tmp = Math.tan(b) * r;
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) * (r / math.cos(a)) tmp = 0 if a <= -0.00024: tmp = t_0 elif a <= 66000000.0: tmp = math.tan(b) * r else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(sin(b) * Float64(r / cos(a))) tmp = 0.0 if (a <= -0.00024) tmp = t_0; elseif (a <= 66000000.0) tmp = Float64(tan(b) * r); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) * (r / cos(a)); tmp = 0.0; if (a <= -0.00024) tmp = t_0; elseif (a <= 66000000.0) tmp = tan(b) * r; 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[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.00024], t$95$0, If[LessEqual[a, 66000000.0], N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot \frac{r}{\cos a}\\
\mathbf{if}\;a \leq -0.00024:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 66000000:\\
\;\;\;\;\tan b \cdot r\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -2.40000000000000006e-4 or 6.6e7 < a Initial program 55.5%
associate-*r/55.5%
+-commutative55.5%
Simplified55.5%
associate-*r/55.5%
*-commutative55.5%
div-inv55.4%
associate-*l*55.5%
Applied egg-rr55.5%
Taylor expanded in b around 0 55.8%
if -2.40000000000000006e-4 < a < 6.6e7Initial program 97.4%
associate-*r/97.4%
+-commutative97.4%
Simplified97.4%
add-log-exp97.2%
Applied egg-rr97.2%
rem-log-exp97.4%
expm1-log1p-u97.4%
expm1-define97.2%
log1p-undefine97.1%
rem-exp-log97.1%
+-commutative97.1%
Applied egg-rr97.1%
Taylor expanded in a around 0 97.1%
associate--l+97.4%
metadata-eval97.4%
+-rgt-identity97.4%
associate-/l*97.4%
*-commutative97.4%
quot-tan97.6%
Applied egg-rr97.6%
(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}
Initial program 76.3%
(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 76.3%
associate-*r/76.3%
+-commutative76.3%
Simplified76.3%
*-commutative76.3%
associate-/l*76.3%
Applied egg-rr76.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(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 76.3%
associate-*r/76.3%
+-commutative76.3%
Simplified76.3%
add-log-exp76.1%
Applied egg-rr76.1%
cos-sum99.3%
add-log-exp99.5%
fma-neg99.5%
distribute-rgt-neg-in99.5%
Applied egg-rr99.5%
fma-undefine99.5%
add-sqr-sqrt48.6%
sqrt-unprod88.6%
sqr-neg88.6%
sqrt-unprod40.0%
add-sqr-sqrt76.5%
cos-diff76.4%
Applied egg-rr76.4%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (tan b) r))) (if (<= b -1.75e-6) t_0 (if (<= b 0.00045) (/ (* b r) (cos (+ b a))) t_0))))
double code(double r, double a, double b) {
double t_0 = tan(b) * r;
double tmp;
if (b <= -1.75e-6) {
tmp = t_0;
} else if (b <= 0.00045) {
tmp = (b * r) / 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 = tan(b) * r
if (b <= (-1.75d-6)) then
tmp = t_0
else if (b <= 0.00045d0) then
tmp = (b * r) / 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 = Math.tan(b) * r;
double tmp;
if (b <= -1.75e-6) {
tmp = t_0;
} else if (b <= 0.00045) {
tmp = (b * r) / Math.cos((b + a));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = math.tan(b) * r tmp = 0 if b <= -1.75e-6: tmp = t_0 elif b <= 0.00045: tmp = (b * r) / math.cos((b + a)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(tan(b) * r) tmp = 0.0 if (b <= -1.75e-6) tmp = t_0; elseif (b <= 0.00045) tmp = Float64(Float64(b * r) / cos(Float64(b + a))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = tan(b) * r; tmp = 0.0; if (b <= -1.75e-6) tmp = t_0; elseif (b <= 0.00045) tmp = (b * r) / cos((b + a)); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -1.75e-6], t$95$0, If[LessEqual[b, 0.00045], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan b \cdot r\\
\mathbf{if}\;b \leq -1.75 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.00045:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -1.74999999999999997e-6 or 4.4999999999999999e-4 < b Initial program 52.3%
associate-*r/52.3%
+-commutative52.3%
Simplified52.3%
add-log-exp52.1%
Applied egg-rr52.1%
rem-log-exp52.3%
expm1-log1p-u52.3%
expm1-define52.1%
log1p-undefine52.0%
rem-exp-log52.0%
+-commutative52.0%
Applied egg-rr52.0%
Taylor expanded in a around 0 52.2%
associate--l+52.5%
metadata-eval52.5%
+-rgt-identity52.5%
associate-/l*52.5%
*-commutative52.5%
quot-tan52.6%
Applied egg-rr52.6%
if -1.74999999999999997e-6 < b < 4.4999999999999999e-4Initial program 99.1%
associate-*r/99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in b around 0 99.2%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (tan b) r))) (if (<= b -1.75e-6) t_0 (if (<= b 2.1e-5) (* r (/ b (cos a))) t_0))))
double code(double r, double a, double b) {
double t_0 = tan(b) * r;
double tmp;
if (b <= -1.75e-6) {
tmp = t_0;
} else if (b <= 2.1e-5) {
tmp = r * (b / 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 = tan(b) * r
if (b <= (-1.75d-6)) then
tmp = t_0
else if (b <= 2.1d-5) then
tmp = r * (b / 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.tan(b) * r;
double tmp;
if (b <= -1.75e-6) {
tmp = t_0;
} else if (b <= 2.1e-5) {
tmp = r * (b / Math.cos(a));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = math.tan(b) * r tmp = 0 if b <= -1.75e-6: tmp = t_0 elif b <= 2.1e-5: tmp = r * (b / math.cos(a)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(tan(b) * r) tmp = 0.0 if (b <= -1.75e-6) tmp = t_0; elseif (b <= 2.1e-5) tmp = Float64(r * Float64(b / cos(a))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = tan(b) * r; tmp = 0.0; if (b <= -1.75e-6) tmp = t_0; elseif (b <= 2.1e-5) tmp = r * (b / cos(a)); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -1.75e-6], t$95$0, If[LessEqual[b, 2.1e-5], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan b \cdot r\\
\mathbf{if}\;b \leq -1.75 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -1.74999999999999997e-6 or 2.09999999999999988e-5 < b Initial program 52.3%
associate-*r/52.3%
+-commutative52.3%
Simplified52.3%
add-log-exp52.1%
Applied egg-rr52.1%
rem-log-exp52.3%
expm1-log1p-u52.3%
expm1-define52.1%
log1p-undefine52.0%
rem-exp-log52.0%
+-commutative52.0%
Applied egg-rr52.0%
Taylor expanded in a around 0 52.2%
associate--l+52.5%
metadata-eval52.5%
+-rgt-identity52.5%
associate-/l*52.5%
*-commutative52.5%
quot-tan52.6%
Applied egg-rr52.6%
if -1.74999999999999997e-6 < b < 2.09999999999999988e-5Initial program 99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in b around 0 99.1%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (tan b) r))) (if (<= b -1.25e-6) t_0 (if (<= b 0.000112) (/ (* b r) (cos a)) t_0))))
double code(double r, double a, double b) {
double t_0 = tan(b) * r;
double tmp;
if (b <= -1.25e-6) {
tmp = t_0;
} else if (b <= 0.000112) {
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 = tan(b) * r
if (b <= (-1.25d-6)) then
tmp = t_0
else if (b <= 0.000112d0) 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.tan(b) * r;
double tmp;
if (b <= -1.25e-6) {
tmp = t_0;
} else if (b <= 0.000112) {
tmp = (b * r) / Math.cos(a);
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = math.tan(b) * r tmp = 0 if b <= -1.25e-6: tmp = t_0 elif b <= 0.000112: tmp = (b * r) / math.cos(a) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(tan(b) * r) tmp = 0.0 if (b <= -1.25e-6) tmp = t_0; elseif (b <= 0.000112) tmp = Float64(Float64(b * r) / cos(a)); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = tan(b) * r; tmp = 0.0; if (b <= -1.25e-6) tmp = t_0; elseif (b <= 0.000112) tmp = (b * r) / cos(a); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -1.25e-6], t$95$0, If[LessEqual[b, 0.000112], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan b \cdot r\\
\mathbf{if}\;b \leq -1.25 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.000112:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -1.2500000000000001e-6 or 1.11999999999999998e-4 < b Initial program 52.3%
associate-*r/52.3%
+-commutative52.3%
Simplified52.3%
add-log-exp52.1%
Applied egg-rr52.1%
rem-log-exp52.3%
expm1-log1p-u52.3%
expm1-define52.1%
log1p-undefine52.0%
rem-exp-log52.0%
+-commutative52.0%
Applied egg-rr52.0%
Taylor expanded in a around 0 52.2%
associate--l+52.5%
metadata-eval52.5%
+-rgt-identity52.5%
associate-/l*52.5%
*-commutative52.5%
quot-tan52.6%
Applied egg-rr52.6%
if -1.2500000000000001e-6 < b < 1.11999999999999998e-4Initial program 99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in b around 0 99.2%
(FPCore (r a b) :precision binary64 (* (tan b) r))
double code(double r, double a, double b) {
return tan(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 = tan(b) * r
end function
public static double code(double r, double a, double b) {
return Math.tan(b) * r;
}
def code(r, a, b): return math.tan(b) * r
function code(r, a, b) return Float64(tan(b) * r) end
function tmp = code(r, a, b) tmp = tan(b) * r; end
code[r_, a_, b_] := N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\tan b \cdot r
\end{array}
Initial program 76.3%
associate-*r/76.3%
+-commutative76.3%
Simplified76.3%
add-log-exp76.1%
Applied egg-rr76.1%
rem-log-exp76.3%
expm1-log1p-u76.2%
expm1-define76.0%
log1p-undefine76.0%
rem-exp-log76.0%
+-commutative76.0%
Applied egg-rr76.0%
Taylor expanded in a around 0 60.5%
associate--l+60.6%
metadata-eval60.6%
+-rgt-identity60.6%
associate-/l*60.6%
*-commutative60.6%
quot-tan60.7%
Applied egg-rr60.7%
(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 76.3%
+-commutative76.3%
Simplified76.3%
Taylor expanded in b around 0 53.0%
Taylor expanded in a around 0 37.3%
herbie shell --seed 2024052 -o generate:simplify
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))