
(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 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(r * Float64(sin(b) / cos(Float64(a + b)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos((a + b))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (/ (* (sin b) 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(Float64(sin(b) * r) / fma(sin(b), Float64(-sin(a)), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\mathsf{fma}\left(\sin b, -\sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 76.4%
+-commutative76.4%
Simplified76.4%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-def99.5%
Applied egg-rr99.5%
Taylor expanded in r around 0 99.5%
+-commutative99.5%
mul-1-neg99.5%
*-commutative99.5%
sub-neg99.5%
*-commutative99.5%
Simplified99.5%
sub-neg99.5%
*-commutative99.5%
distribute-rgt-neg-in99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-def99.5%
Simplified99.5%
Final simplification99.5%
(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(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a)))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 76.4%
+-commutative76.4%
Simplified76.4%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-def99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(a) * cos(b)) - (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(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 76.4%
+-commutative76.4%
Simplified76.4%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (- (* (cos a) (cos b)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (sin(b) * r) / ((cos(a) * cos(b)) - (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(a) * cos(b)) - (sin(b) * sin(a)))
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(b) * Math.sin(a)));
}
def code(r, a, b): return (math.sin(b) * r) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / ((cos(a) * cos(b)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 76.4%
associate-*r/76.4%
+-commutative76.4%
Simplified76.4%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.0146) (not (<= a 8.5e-5))) (/ (sin b) (/ (cos a) r)) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0146) || !(a <= 8.5e-5)) {
tmp = sin(b) / (cos(a) / r);
} 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 ((a <= (-0.0146d0)) .or. (.not. (a <= 8.5d-5))) then
tmp = sin(b) / (cos(a) / r)
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 ((a <= -0.0146) || !(a <= 8.5e-5)) {
tmp = Math.sin(b) / (Math.cos(a) / r);
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.0146) or not (a <= 8.5e-5): tmp = math.sin(b) / (math.cos(a) / r) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.0146) || !(a <= 8.5e-5)) tmp = Float64(sin(b) / Float64(cos(a) / r)); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.0146) || ~((a <= 8.5e-5))) tmp = sin(b) / (cos(a) / r); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.0146], N[Not[LessEqual[a, 8.5e-5]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0146 \lor \neg \left(a \leq 8.5 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -0.0146000000000000001 or 8.500000000000001e-5 < a Initial program 55.3%
*-commutative55.3%
associate-/r/55.2%
+-commutative55.2%
Simplified55.2%
Taylor expanded in b around 0 55.5%
if -0.0146000000000000001 < a < 8.500000000000001e-5Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in a around 0 97.9%
Final simplification76.5%
(FPCore (r a b) :precision binary64 (if (<= b -0.012) (* r (tan b)) (if (<= b 9.2e-12) (/ (* b r) (cos (+ b a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.012) {
tmp = r * tan(b);
} else if (b <= 9.2e-12) {
tmp = (b * r) / cos((b + 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 <= (-0.012d0)) then
tmp = r * tan(b)
else if (b <= 9.2d-12) then
tmp = (b * r) / cos((b + 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 <= -0.012) {
tmp = r * Math.tan(b);
} else if (b <= 9.2e-12) {
tmp = (b * r) / Math.cos((b + a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.012: tmp = r * math.tan(b) elif b <= 9.2e-12: tmp = (b * r) / math.cos((b + a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.012) tmp = Float64(r * tan(b)); elseif (b <= 9.2e-12) tmp = Float64(Float64(b * r) / cos(Float64(b + a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.012) tmp = r * tan(b); elseif (b <= 9.2e-12) tmp = (b * r) / cos((b + a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.012], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.2e-12], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.012:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{elif}\;b \leq 9.2 \cdot 10^{-12}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -0.012Initial program 56.4%
+-commutative56.4%
Simplified56.4%
cos-sum99.2%
cancel-sign-sub-inv99.2%
fma-def99.3%
Applied egg-rr99.3%
distribute-lft-neg-out99.3%
fma-neg99.2%
cos-sum56.4%
add-log-exp56.0%
add-cube-cbrt54.7%
log-prod54.8%
pow254.8%
Applied egg-rr54.8%
log-pow54.8%
distribute-lft1-in54.8%
metadata-eval54.8%
Simplified54.8%
Taylor expanded in a around 0 55.6%
log-pow56.2%
rem-log-exp56.6%
Simplified56.6%
expm1-log1p-u39.7%
expm1-udef15.7%
associate-*r*15.7%
metadata-eval15.7%
*-un-lft-identity15.7%
quot-tan15.7%
Applied egg-rr15.7%
expm1-def39.8%
expm1-log1p56.7%
Simplified56.7%
if -0.012 < b < 9.19999999999999957e-12Initial program 98.9%
associate-*r/98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.9%
if 9.19999999999999957e-12 < b Initial program 52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in a around 0 51.5%
Final simplification76.2%
(FPCore (r a b) :precision binary64 (if (<= a -0.018) (/ (sin b) (/ (cos a) r)) (if (<= a 2.1e-5) (* r (/ (sin b) (cos b))) (/ (* (sin b) r) (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.018) {
tmp = sin(b) / (cos(a) / r);
} else if (a <= 2.1e-5) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = (sin(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 (a <= (-0.018d0)) then
tmp = sin(b) / (cos(a) / r)
else if (a <= 2.1d-5) then
tmp = r * (sin(b) / cos(b))
else
tmp = (sin(b) * r) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.018) {
tmp = Math.sin(b) / (Math.cos(a) / r);
} else if (a <= 2.1e-5) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = (Math.sin(b) * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.018: tmp = math.sin(b) / (math.cos(a) / r) elif a <= 2.1e-5: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = (math.sin(b) * r) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.018) tmp = Float64(sin(b) / Float64(cos(a) / r)); elseif (a <= 2.1e-5) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(Float64(sin(b) * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.018) tmp = sin(b) / (cos(a) / r); elseif (a <= 2.1e-5) tmp = r * (sin(b) / cos(b)); else tmp = (sin(b) * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.018], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.1e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.018:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\mathbf{elif}\;a \leq 2.1 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos a}\\
\end{array}
\end{array}
if a < -0.0179999999999999986Initial program 48.4%
*-commutative48.4%
associate-/r/48.4%
+-commutative48.4%
Simplified48.4%
Taylor expanded in b around 0 48.9%
if -0.0179999999999999986 < a < 2.09999999999999988e-5Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in a around 0 97.9%
if 2.09999999999999988e-5 < a Initial program 61.5%
associate-*r/61.6%
+-commutative61.6%
Simplified61.6%
Taylor expanded in b around 0 61.5%
Final simplification76.6%
(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 76.4%
Final simplification76.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.012) (not (<= b 9.2e-12))) (* r (tan b)) (/ (* b r) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.012) || !(b <= 9.2e-12)) {
tmp = r * tan(b);
} else {
tmp = (b * r) / cos((b + 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 <= (-0.012d0)) .or. (.not. (b <= 9.2d-12))) then
tmp = r * tan(b)
else
tmp = (b * r) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.012) || !(b <= 9.2e-12)) {
tmp = r * Math.tan(b);
} else {
tmp = (b * r) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.012) or not (b <= 9.2e-12): tmp = r * math.tan(b) else: tmp = (b * r) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.012) || !(b <= 9.2e-12)) tmp = Float64(r * tan(b)); else tmp = Float64(Float64(b * r) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.012) || ~((b <= 9.2e-12))) tmp = r * tan(b); else tmp = (b * r) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.012], N[Not[LessEqual[b, 9.2e-12]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.012 \lor \neg \left(b \leq 9.2 \cdot 10^{-12}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -0.012 or 9.19999999999999957e-12 < b Initial program 54.3%
+-commutative54.3%
Simplified54.3%
cos-sum99.1%
cancel-sign-sub-inv99.1%
fma-def99.2%
Applied egg-rr99.2%
distribute-lft-neg-out99.2%
fma-neg99.1%
cos-sum54.3%
add-log-exp54.0%
add-cube-cbrt52.9%
log-prod52.9%
pow252.9%
Applied egg-rr52.9%
log-pow52.8%
distribute-lft1-in52.8%
metadata-eval52.8%
Simplified52.8%
Taylor expanded in a around 0 53.0%
log-pow53.6%
rem-log-exp53.9%
Simplified53.9%
expm1-log1p-u37.7%
expm1-udef13.3%
associate-*r*13.3%
metadata-eval13.3%
*-un-lft-identity13.3%
quot-tan13.3%
Applied egg-rr13.3%
expm1-def37.8%
expm1-log1p54.0%
Simplified54.0%
if -0.012 < b < 9.19999999999999957e-12Initial program 98.9%
associate-*r/98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.9%
Final simplification76.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.012) (not (<= b 9.2e-12))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.012) || !(b <= 9.2e-12)) {
tmp = r * tan(b);
} else {
tmp = r * (b / 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 <= (-0.012d0)) .or. (.not. (b <= 9.2d-12))) then
tmp = r * tan(b)
else
tmp = r * (b / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.012) || !(b <= 9.2e-12)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.012) or not (b <= 9.2e-12): tmp = r * math.tan(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.012) || !(b <= 9.2e-12)) tmp = Float64(r * tan(b)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.012) || ~((b <= 9.2e-12))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.012], N[Not[LessEqual[b, 9.2e-12]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.012 \lor \neg \left(b \leq 9.2 \cdot 10^{-12}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -0.012 or 9.19999999999999957e-12 < b Initial program 54.3%
+-commutative54.3%
Simplified54.3%
cos-sum99.1%
cancel-sign-sub-inv99.1%
fma-def99.2%
Applied egg-rr99.2%
distribute-lft-neg-out99.2%
fma-neg99.1%
cos-sum54.3%
add-log-exp54.0%
add-cube-cbrt52.9%
log-prod52.9%
pow252.9%
Applied egg-rr52.9%
log-pow52.8%
distribute-lft1-in52.8%
metadata-eval52.8%
Simplified52.8%
Taylor expanded in a around 0 53.0%
log-pow53.6%
rem-log-exp53.9%
Simplified53.9%
expm1-log1p-u37.7%
expm1-udef13.3%
associate-*r*13.3%
metadata-eval13.3%
*-un-lft-identity13.3%
quot-tan13.3%
Applied egg-rr13.3%
expm1-def37.8%
expm1-log1p54.0%
Simplified54.0%
if -0.012 < b < 9.19999999999999957e-12Initial program 98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.8%
Final simplification76.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.012) (not (<= b 9.2e-12))) (* r (tan b)) (/ (* b r) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.012) || !(b <= 9.2e-12)) {
tmp = r * tan(b);
} 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 <= (-0.012d0)) .or. (.not. (b <= 9.2d-12))) then
tmp = r * tan(b)
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 <= -0.012) || !(b <= 9.2e-12)) {
tmp = r * Math.tan(b);
} else {
tmp = (b * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.012) or not (b <= 9.2e-12): tmp = r * math.tan(b) else: tmp = (b * r) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.012) || !(b <= 9.2e-12)) tmp = Float64(r * tan(b)); else tmp = Float64(Float64(b * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.012) || ~((b <= 9.2e-12))) tmp = r * tan(b); else tmp = (b * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.012], N[Not[LessEqual[b, 9.2e-12]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.012 \lor \neg \left(b \leq 9.2 \cdot 10^{-12}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\end{array}
\end{array}
if b < -0.012 or 9.19999999999999957e-12 < b Initial program 54.3%
+-commutative54.3%
Simplified54.3%
cos-sum99.1%
cancel-sign-sub-inv99.1%
fma-def99.2%
Applied egg-rr99.2%
distribute-lft-neg-out99.2%
fma-neg99.1%
cos-sum54.3%
add-log-exp54.0%
add-cube-cbrt52.9%
log-prod52.9%
pow252.9%
Applied egg-rr52.9%
log-pow52.8%
distribute-lft1-in52.8%
metadata-eval52.8%
Simplified52.8%
Taylor expanded in a around 0 53.0%
log-pow53.6%
rem-log-exp53.9%
Simplified53.9%
expm1-log1p-u37.7%
expm1-udef13.3%
associate-*r*13.3%
metadata-eval13.3%
*-un-lft-identity13.3%
quot-tan13.3%
Applied egg-rr13.3%
expm1-def37.8%
expm1-log1p54.0%
Simplified54.0%
if -0.012 < b < 9.19999999999999957e-12Initial program 98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.8%
Final simplification76.2%
(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 76.4%
+-commutative76.4%
Simplified76.4%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-def99.5%
Applied egg-rr99.5%
distribute-lft-neg-out99.5%
fma-neg99.4%
cos-sum76.4%
add-log-exp76.1%
add-cube-cbrt74.4%
log-prod74.4%
pow274.4%
Applied egg-rr74.4%
log-pow74.4%
distribute-lft1-in74.4%
metadata-eval74.4%
Simplified74.4%
Taylor expanded in a around 0 58.7%
log-pow59.0%
rem-log-exp59.2%
Simplified59.2%
expm1-log1p-u46.7%
expm1-udef21.7%
associate-*r*21.7%
metadata-eval21.7%
*-un-lft-identity21.7%
quot-tan21.7%
Applied egg-rr21.7%
expm1-def46.7%
expm1-log1p59.2%
Simplified59.2%
Final simplification59.2%
(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 76.4%
+-commutative76.4%
Simplified76.4%
Taylor expanded in b around 0 51.9%
Taylor expanded in a around 0 34.9%
Final simplification34.9%
herbie shell --seed 2023187
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))