
(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 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(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 (sin b)) (fma (cos b) (cos a) (* (- (sin b)) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), (-sin(b) * sin(a)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(Float64(-sin(b)) * sin(a)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}
\end{array}
Initial program 75.5%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (* (/ (sin b) (fma (- (sin b)) (sin a) (* (cos a) (cos b)))) r))
double code(double r, double a, double b) {
return (sin(b) / fma(-sin(b), sin(a), (cos(a) * cos(b)))) * r;
}
function code(r, a, b) return Float64(Float64(sin(b) / fma(Float64(-sin(b)), sin(a), Float64(cos(a) * cos(b)))) * r) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\mathsf{fma}\left(-\sin b, \sin a, \cos a \cdot \cos b\right)} \cdot r
\end{array}
Initial program 75.5%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.5
Applied rewrites99.5%
remove-double-divN/A
unpow-1N/A
lift-pow.f64N/A
clear-numN/A
inv-powN/A
lower-pow.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift-pow.f64N/A
unpow-1N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6499.5
Applied rewrites99.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (fma (- (sin b)) (sin a) (* (cos a) (cos b))))))
double code(double r, double a, double b) {
return sin(b) * (r / fma(-sin(b), sin(a), (cos(a) * cos(b))));
}
function code(r, a, b) return Float64(sin(b) * Float64(r / fma(Float64(-sin(b)), sin(a), Float64(cos(a) * cos(b))))) end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\mathsf{fma}\left(-\sin b, \sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 75.5%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.5
Applied rewrites99.5%
remove-double-divN/A
unpow-1N/A
lift-pow.f64N/A
clear-numN/A
inv-powN/A
lower-pow.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift-pow.f64N/A
unpow-1N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6499.5
Applied rewrites99.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.5
lift-fma.f64N/A
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (* (/ (* (sin b) r) (* (+ (cos (- (- (- b a) b) a)) (cos (- b (- a (+ a b))))) 0.5)) (cos (- b a))))
double code(double r, double a, double b) {
return ((sin(b) * r) / ((cos((((b - a) - b) - a)) + cos((b - (a - (a + b))))) * 0.5)) * 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) - b) - a)) + cos((b - (a - (a + b))))) * 0.5d0)) * cos((b - a))
end function
public static double code(double r, double a, double b) {
return ((Math.sin(b) * r) / ((Math.cos((((b - a) - b) - a)) + Math.cos((b - (a - (a + b))))) * 0.5)) * Math.cos((b - a));
}
def code(r, a, b): return ((math.sin(b) * r) / ((math.cos((((b - a) - b) - a)) + math.cos((b - (a - (a + b))))) * 0.5)) * math.cos((b - a))
function code(r, a, b) return Float64(Float64(Float64(sin(b) * r) / Float64(Float64(cos(Float64(Float64(Float64(b - a) - b) - a)) + cos(Float64(b - Float64(a - Float64(a + b))))) * 0.5)) * cos(Float64(b - a))) end
function tmp = code(r, a, b) tmp = ((sin(b) * r) / ((cos((((b - a) - b) - a)) + cos((b - (a - (a + b))))) * 0.5)) * cos((b - a)); end
code[r_, a_, b_] := N[(N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Cos[N[(N[(N[(b - a), $MachinePrecision] - b), $MachinePrecision] - a), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(b - N[(a - N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(b - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\left(\cos \left(\left(\left(b - a\right) - b\right) - a\right) + \cos \left(b - \left(a - \left(a + b\right)\right)\right)\right) \cdot 0.5} \cdot \cos \left(b - a\right)
\end{array}
Initial program 75.5%
lift-/.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
flip--N/A
cos-diffN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites75.4%
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
cos-multN/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites75.3%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f6475.8
Applied rewrites75.8%
(FPCore (r a b) :precision binary64 (* (/ (* (sin b) r) (* (+ (cos (* -2.0 a)) (cos (- b (- a (+ a b))))) 0.5)) (cos (- b a))))
double code(double r, double a, double b) {
return ((sin(b) * r) / ((cos((-2.0 * a)) + cos((b - (a - (a + b))))) * 0.5)) * 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(((-2.0d0) * a)) + cos((b - (a - (a + b))))) * 0.5d0)) * cos((b - a))
end function
public static double code(double r, double a, double b) {
return ((Math.sin(b) * r) / ((Math.cos((-2.0 * a)) + Math.cos((b - (a - (a + b))))) * 0.5)) * Math.cos((b - a));
}
def code(r, a, b): return ((math.sin(b) * r) / ((math.cos((-2.0 * a)) + math.cos((b - (a - (a + b))))) * 0.5)) * math.cos((b - a))
function code(r, a, b) return Float64(Float64(Float64(sin(b) * r) / Float64(Float64(cos(Float64(-2.0 * a)) + cos(Float64(b - Float64(a - Float64(a + b))))) * 0.5)) * cos(Float64(b - a))) end
function tmp = code(r, a, b) tmp = ((sin(b) * r) / ((cos((-2.0 * a)) + cos((b - (a - (a + b))))) * 0.5)) * cos((b - a)); end
code[r_, a_, b_] := N[(N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Cos[N[(-2.0 * a), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(b - N[(a - N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(b - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\left(\cos \left(-2 \cdot a\right) + \cos \left(b - \left(a - \left(a + b\right)\right)\right)\right) \cdot 0.5} \cdot \cos \left(b - a\right)
\end{array}
Initial program 75.5%
lift-/.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
flip--N/A
cos-diffN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites75.4%
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
cos-multN/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites75.3%
Taylor expanded in a around 0
lower-*.f6475.6
Applied rewrites75.6%
(FPCore (r a b) :precision binary64 (if (<= b -280000.0) (* (tan b) r) (if (<= b 1.08e-8) (/ (* b r) (cos (+ a b))) (* (/ r (cos b)) (sin b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -280000.0) {
tmp = tan(b) * r;
} else if (b <= 1.08e-8) {
tmp = (b * r) / cos((a + b));
} else {
tmp = (r / cos(b)) * sin(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 <= (-280000.0d0)) then
tmp = tan(b) * r
else if (b <= 1.08d-8) then
tmp = (b * r) / cos((a + b))
else
tmp = (r / cos(b)) * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -280000.0) {
tmp = Math.tan(b) * r;
} else if (b <= 1.08e-8) {
tmp = (b * r) / Math.cos((a + b));
} else {
tmp = (r / Math.cos(b)) * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -280000.0: tmp = math.tan(b) * r elif b <= 1.08e-8: tmp = (b * r) / math.cos((a + b)) else: tmp = (r / math.cos(b)) * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -280000.0) tmp = Float64(tan(b) * r); elseif (b <= 1.08e-8) tmp = Float64(Float64(b * r) / cos(Float64(a + b))); else tmp = Float64(Float64(r / cos(b)) * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -280000.0) tmp = tan(b) * r; elseif (b <= 1.08e-8) tmp = (b * r) / cos((a + b)); else tmp = (r / cos(b)) * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -280000.0], N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision], If[LessEqual[b, 1.08e-8], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -280000:\\
\;\;\;\;\tan b \cdot r\\
\mathbf{elif}\;b \leq 1.08 \cdot 10^{-8}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\end{array}
\end{array}
if b < -2.8e5Initial program 56.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6456.7
Applied rewrites56.7%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6454.8
Applied rewrites54.8%
Applied rewrites54.8%
if -2.8e5 < b < 1.0800000000000001e-8Initial program 96.7%
Taylor expanded in b around 0
lower-*.f6496.9
Applied rewrites96.9%
if 1.0800000000000001e-8 < b Initial program 53.3%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-sin.f6453.3
Applied rewrites53.3%
(FPCore (r a b) :precision binary64 (* (/ r (cos (+ a b))) (sin b)))
double code(double r, double a, double b) {
return (r / cos((a + b))) * 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 / cos((a + b))) * sin(b)
end function
public static double code(double r, double a, double b) {
return (r / Math.cos((a + b))) * Math.sin(b);
}
def code(r, a, b): return (r / math.cos((a + b))) * math.sin(b)
function code(r, a, b) return Float64(Float64(r / cos(Float64(a + b))) * sin(b)) end
function tmp = code(r, a, b) tmp = (r / cos((a + b))) * sin(b); end
code[r_, a_, b_] := N[(N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos \left(a + b\right)} \cdot \sin b
\end{array}
Initial program 75.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.5
Applied rewrites75.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -280000.0) (not (<= b 1.08e-8))) (* (tan b) r) (/ (* b r) (cos (+ a b)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -280000.0) || !(b <= 1.08e-8)) {
tmp = tan(b) * r;
} else {
tmp = (b * r) / cos((a + 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 <= (-280000.0d0)) .or. (.not. (b <= 1.08d-8))) then
tmp = tan(b) * r
else
tmp = (b * r) / cos((a + b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -280000.0) || !(b <= 1.08e-8)) {
tmp = Math.tan(b) * r;
} else {
tmp = (b * r) / Math.cos((a + b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -280000.0) or not (b <= 1.08e-8): tmp = math.tan(b) * r else: tmp = (b * r) / math.cos((a + b)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -280000.0) || !(b <= 1.08e-8)) tmp = Float64(tan(b) * r); else tmp = Float64(Float64(b * r) / cos(Float64(a + b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -280000.0) || ~((b <= 1.08e-8))) tmp = tan(b) * r; else tmp = (b * r) / cos((a + b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -280000.0], N[Not[LessEqual[b, 1.08e-8]], $MachinePrecision]], N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -280000 \lor \neg \left(b \leq 1.08 \cdot 10^{-8}\right):\\
\;\;\;\;\tan b \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -2.8e5 or 1.0800000000000001e-8 < b Initial program 54.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.9
Applied rewrites54.9%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6453.9
Applied rewrites53.9%
Applied rewrites54.0%
if -2.8e5 < b < 1.0800000000000001e-8Initial program 96.7%
Taylor expanded in b around 0
lower-*.f6496.9
Applied rewrites96.9%
Final simplification75.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -280000.0) (not (<= b 1.08e-8))) (* (tan b) r) (/ (* b r) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -280000.0) || !(b <= 1.08e-8)) {
tmp = tan(b) * r;
} else {
tmp = (b * r) / cos(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-280000.0d0)) .or. (.not. (b <= 1.08d-8))) then
tmp = tan(b) * r
else
tmp = (b * r) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -280000.0) || !(b <= 1.08e-8)) {
tmp = Math.tan(b) * r;
} else {
tmp = (b * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -280000.0) or not (b <= 1.08e-8): tmp = math.tan(b) * r else: tmp = (b * r) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -280000.0) || !(b <= 1.08e-8)) tmp = Float64(tan(b) * r); else tmp = Float64(Float64(b * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -280000.0) || ~((b <= 1.08e-8))) tmp = tan(b) * r; else tmp = (b * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -280000.0], N[Not[LessEqual[b, 1.08e-8]], $MachinePrecision]], N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -280000 \lor \neg \left(b \leq 1.08 \cdot 10^{-8}\right):\\
\;\;\;\;\tan b \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\end{array}
\end{array}
if b < -2.8e5 or 1.0800000000000001e-8 < b Initial program 54.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.9
Applied rewrites54.9%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6453.9
Applied rewrites53.9%
Applied rewrites54.0%
if -2.8e5 < b < 1.0800000000000001e-8Initial program 96.7%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6496.6
Applied rewrites96.6%
Applied rewrites96.7%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -280000.0) (not (<= b 1.08e-8))) (* (tan b) r) (* (/ r (cos a)) b)))
double code(double r, double a, double b) {
double tmp;
if ((b <= -280000.0) || !(b <= 1.08e-8)) {
tmp = tan(b) * r;
} else {
tmp = (r / cos(a)) * 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 <= (-280000.0d0)) .or. (.not. (b <= 1.08d-8))) then
tmp = tan(b) * r
else
tmp = (r / cos(a)) * b
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -280000.0) || !(b <= 1.08e-8)) {
tmp = Math.tan(b) * r;
} else {
tmp = (r / Math.cos(a)) * b;
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -280000.0) or not (b <= 1.08e-8): tmp = math.tan(b) * r else: tmp = (r / math.cos(a)) * b return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -280000.0) || !(b <= 1.08e-8)) tmp = Float64(tan(b) * r); else tmp = Float64(Float64(r / cos(a)) * b); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -280000.0) || ~((b <= 1.08e-8))) tmp = tan(b) * r; else tmp = (r / cos(a)) * b; end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -280000.0], N[Not[LessEqual[b, 1.08e-8]], $MachinePrecision]], N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision], N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -280000 \lor \neg \left(b \leq 1.08 \cdot 10^{-8}\right):\\
\;\;\;\;\tan b \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos a} \cdot b\\
\end{array}
\end{array}
if b < -2.8e5 or 1.0800000000000001e-8 < b Initial program 54.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.9
Applied rewrites54.9%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6453.9
Applied rewrites53.9%
Applied rewrites54.0%
if -2.8e5 < b < 1.0800000000000001e-8Initial program 96.7%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6496.6
Applied rewrites96.6%
Final simplification75.0%
(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 75.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.5
Applied rewrites75.5%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6459.4
Applied rewrites59.4%
Applied rewrites59.4%
(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 75.5%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6449.8
Applied rewrites49.8%
Taylor expanded in a around 0
Applied rewrites34.1%
herbie shell --seed 2024307
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))