
(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 (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%
+-commutative75.5%
Simplified75.5%
cos-sum99.6%
cancel-sign-sub-inv99.6%
fma-define99.6%
Applied egg-rr99.6%
Final simplification99.6%
(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 75.5%
associate-/l*75.5%
remove-double-neg75.5%
remove-double-neg75.5%
+-commutative75.5%
Simplified75.5%
cos-sum99.6%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a))));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 75.5%
+-commutative75.5%
Simplified75.5%
cos-sum99.6%
Applied egg-rr99.6%
Taylor expanded in r around 0 99.6%
associate-/l*99.5%
/-rgt-identity99.5%
*-commutative99.5%
*-commutative99.5%
*-rgt-identity99.5%
cancel-sign-sub-inv99.5%
distribute-lft-neg-in99.5%
fma-undefine99.5%
times-frac99.6%
*-commutative99.6%
times-frac99.6%
/-rgt-identity99.6%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos b) (cos a)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 75.5%
+-commutative75.5%
Simplified75.5%
cos-sum99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (if (<= b -2.25e-8) (* r (tan b)) (if (<= b 2.6) (* (sin b) (/ r (cos a))) (/ 1.0 (/ (/ 1.0 r) (tan b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.25e-8) {
tmp = r * tan(b);
} else if (b <= 2.6) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = 1.0 / ((1.0 / r) / tan(b));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-2.25d-8)) then
tmp = r * tan(b)
else if (b <= 2.6d0) then
tmp = sin(b) * (r / cos(a))
else
tmp = 1.0d0 / ((1.0d0 / r) / tan(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2.25e-8) {
tmp = r * Math.tan(b);
} else if (b <= 2.6) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = 1.0 / ((1.0 / r) / Math.tan(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.25e-8: tmp = r * math.tan(b) elif b <= 2.6: tmp = math.sin(b) * (r / math.cos(a)) else: tmp = 1.0 / ((1.0 / r) / math.tan(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2.25e-8) tmp = Float64(r * tan(b)); elseif (b <= 2.6) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(1.0 / Float64(Float64(1.0 / r) / tan(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2.25e-8) tmp = r * tan(b); elseif (b <= 2.6) tmp = sin(b) * (r / cos(a)); else tmp = 1.0 / ((1.0 / r) / tan(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.25e-8], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.6], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(1.0 / r), $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.25 \cdot 10^{-8}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{elif}\;b \leq 2.6:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{1}{r}}{\tan b}}\\
\end{array}
\end{array}
if b < -2.24999999999999996e-8Initial program 60.2%
associate-/l*60.1%
remove-double-neg60.1%
remove-double-neg60.1%
+-commutative60.1%
Simplified60.1%
associate-*r/60.2%
clear-num60.0%
Applied egg-rr60.0%
Taylor expanded in a around 0 60.0%
div-inv60.0%
Applied egg-rr60.0%
associate-*r/60.0%
*-rgt-identity60.0%
associate-/r*60.0%
Simplified60.0%
associate-/l/60.0%
*-commutative60.0%
clear-num60.2%
associate-/l*60.1%
quot-tan60.2%
Applied egg-rr60.2%
if -2.24999999999999996e-8 < b < 2.60000000000000009Initial program 98.5%
+-commutative98.5%
Simplified98.5%
cos-sum99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 99.8%
associate-/l*99.8%
/-rgt-identity99.8%
*-commutative99.8%
*-commutative99.8%
*-rgt-identity99.8%
cancel-sign-sub-inv99.8%
distribute-lft-neg-in99.8%
fma-undefine99.8%
times-frac99.8%
*-commutative99.8%
times-frac99.8%
/-rgt-identity99.8%
Simplified99.8%
Taylor expanded in b around 0 98.4%
if 2.60000000000000009 < b Initial program 47.9%
associate-/l*47.9%
remove-double-neg47.9%
remove-double-neg47.9%
+-commutative47.9%
Simplified47.9%
associate-*r/47.9%
clear-num48.0%
Applied egg-rr48.0%
Taylor expanded in a around 0 48.6%
div-inv48.6%
Applied egg-rr48.6%
associate-*r/48.6%
*-rgt-identity48.6%
associate-/r*48.5%
Simplified48.5%
div-inv48.5%
*-un-lft-identity48.5%
div-inv48.5%
associate-/l/48.6%
*-commutative48.6%
clear-num48.5%
associate-/l*48.5%
quot-tan48.5%
Applied egg-rr48.5%
*-lft-identity48.5%
associate-/r*48.5%
Simplified48.5%
Final simplification75.6%
(FPCore (r a b) :precision binary64 (if (<= b -2.25e-8) (* (sin b) (/ r (cos b))) (if (<= b 2.6) (* (sin b) (/ r (cos a))) (/ 1.0 (/ (/ 1.0 r) (tan b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.25e-8) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 2.6) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = 1.0 / ((1.0 / r) / tan(b));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-2.25d-8)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 2.6d0) then
tmp = sin(b) * (r / cos(a))
else
tmp = 1.0d0 / ((1.0d0 / r) / tan(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2.25e-8) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 2.6) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = 1.0 / ((1.0 / r) / Math.tan(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.25e-8: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 2.6: tmp = math.sin(b) * (r / math.cos(a)) else: tmp = 1.0 / ((1.0 / r) / math.tan(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2.25e-8) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 2.6) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(1.0 / Float64(Float64(1.0 / r) / tan(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2.25e-8) tmp = sin(b) * (r / cos(b)); elseif (b <= 2.6) tmp = sin(b) * (r / cos(a)); else tmp = 1.0 / ((1.0 / r) / tan(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.25e-8], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.6], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(1.0 / r), $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.25 \cdot 10^{-8}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 2.6:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{1}{r}}{\tan b}}\\
\end{array}
\end{array}
if b < -2.24999999999999996e-8Initial program 60.2%
associate-/l*60.1%
remove-double-neg60.1%
remove-double-neg60.1%
+-commutative60.1%
Simplified60.1%
associate-*r/60.2%
clear-num60.0%
Applied egg-rr60.0%
Taylor expanded in a around 0 60.0%
div-inv60.0%
Applied egg-rr60.0%
associate-*r/60.0%
*-rgt-identity60.0%
associate-/r*60.0%
Simplified60.0%
associate-/r/60.0%
clear-num60.2%
Applied egg-rr60.2%
if -2.24999999999999996e-8 < b < 2.60000000000000009Initial program 98.5%
+-commutative98.5%
Simplified98.5%
cos-sum99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 99.8%
associate-/l*99.8%
/-rgt-identity99.8%
*-commutative99.8%
*-commutative99.8%
*-rgt-identity99.8%
cancel-sign-sub-inv99.8%
distribute-lft-neg-in99.8%
fma-undefine99.8%
times-frac99.8%
*-commutative99.8%
times-frac99.8%
/-rgt-identity99.8%
Simplified99.8%
Taylor expanded in b around 0 98.4%
if 2.60000000000000009 < b Initial program 47.9%
associate-/l*47.9%
remove-double-neg47.9%
remove-double-neg47.9%
+-commutative47.9%
Simplified47.9%
associate-*r/47.9%
clear-num48.0%
Applied egg-rr48.0%
Taylor expanded in a around 0 48.6%
div-inv48.6%
Applied egg-rr48.6%
associate-*r/48.6%
*-rgt-identity48.6%
associate-/r*48.5%
Simplified48.5%
div-inv48.5%
*-un-lft-identity48.5%
div-inv48.5%
associate-/l/48.6%
*-commutative48.6%
clear-num48.5%
associate-/l*48.5%
quot-tan48.5%
Applied egg-rr48.5%
*-lft-identity48.5%
associate-/r*48.5%
Simplified48.5%
Final simplification75.6%
(FPCore (r a b) :precision binary64 (if (<= b -2.25e-8) (* (sin b) (/ r (cos b))) (if (<= b 2.6) (* (sin b) (/ r (cos a))) (/ (sin b) (/ (cos b) r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.25e-8) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 2.6) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = sin(b) / (cos(b) / r);
}
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.25d-8)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 2.6d0) then
tmp = sin(b) * (r / cos(a))
else
tmp = sin(b) / (cos(b) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2.25e-8) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 2.6) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = Math.sin(b) / (Math.cos(b) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.25e-8: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 2.6: tmp = math.sin(b) * (r / math.cos(a)) else: tmp = math.sin(b) / (math.cos(b) / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2.25e-8) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 2.6) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(sin(b) / Float64(cos(b) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2.25e-8) tmp = sin(b) * (r / cos(b)); elseif (b <= 2.6) tmp = sin(b) * (r / cos(a)); else tmp = sin(b) / (cos(b) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.25e-8], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.6], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.25 \cdot 10^{-8}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 2.6:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\end{array}
\end{array}
if b < -2.24999999999999996e-8Initial program 60.2%
associate-/l*60.1%
remove-double-neg60.1%
remove-double-neg60.1%
+-commutative60.1%
Simplified60.1%
associate-*r/60.2%
clear-num60.0%
Applied egg-rr60.0%
Taylor expanded in a around 0 60.0%
div-inv60.0%
Applied egg-rr60.0%
associate-*r/60.0%
*-rgt-identity60.0%
associate-/r*60.0%
Simplified60.0%
associate-/r/60.0%
clear-num60.2%
Applied egg-rr60.2%
if -2.24999999999999996e-8 < b < 2.60000000000000009Initial program 98.5%
+-commutative98.5%
Simplified98.5%
cos-sum99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 99.8%
associate-/l*99.8%
/-rgt-identity99.8%
*-commutative99.8%
*-commutative99.8%
*-rgt-identity99.8%
cancel-sign-sub-inv99.8%
distribute-lft-neg-in99.8%
fma-undefine99.8%
times-frac99.8%
*-commutative99.8%
times-frac99.8%
/-rgt-identity99.8%
Simplified99.8%
Taylor expanded in b around 0 98.4%
if 2.60000000000000009 < b Initial program 47.9%
associate-/l*47.9%
remove-double-neg47.9%
remove-double-neg47.9%
+-commutative47.9%
Simplified47.9%
associate-*r/47.9%
clear-num48.0%
Applied egg-rr48.0%
Taylor expanded in a around 0 48.6%
add-cube-cbrt47.9%
pow348.0%
clear-num48.0%
Applied egg-rr48.0%
rem-cube-cbrt48.5%
clear-num48.6%
*-commutative48.6%
associate-/l/48.5%
clear-num48.6%
Applied egg-rr48.6%
Final simplification75.7%
(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.5%
associate-/l*75.5%
remove-double-neg75.5%
remove-double-neg75.5%
+-commutative75.5%
Simplified75.5%
Final simplification75.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ b a)))))
double code(double r, double a, double b) {
return sin(b) * (r / cos((b + a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((b + a)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((b + a)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((b + a))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(b + a\right)}
\end{array}
Initial program 75.5%
+-commutative75.5%
Simplified75.5%
*-commutative75.5%
associate-/l*75.6%
Applied egg-rr75.6%
Final simplification75.6%
(FPCore (r a b) :precision binary64 (if (<= b -2.25e-8) (* r (tan b)) (if (<= b 2.6) (* b (/ r (cos a))) (/ 1.0 (/ (/ 1.0 r) (tan b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.25e-8) {
tmp = r * tan(b);
} else if (b <= 2.6) {
tmp = b * (r / cos(a));
} else {
tmp = 1.0 / ((1.0 / r) / tan(b));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-2.25d-8)) then
tmp = r * tan(b)
else if (b <= 2.6d0) then
tmp = b * (r / cos(a))
else
tmp = 1.0d0 / ((1.0d0 / r) / tan(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2.25e-8) {
tmp = r * Math.tan(b);
} else if (b <= 2.6) {
tmp = b * (r / Math.cos(a));
} else {
tmp = 1.0 / ((1.0 / r) / Math.tan(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.25e-8: tmp = r * math.tan(b) elif b <= 2.6: tmp = b * (r / math.cos(a)) else: tmp = 1.0 / ((1.0 / r) / math.tan(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2.25e-8) tmp = Float64(r * tan(b)); elseif (b <= 2.6) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(1.0 / Float64(Float64(1.0 / r) / tan(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2.25e-8) tmp = r * tan(b); elseif (b <= 2.6) tmp = b * (r / cos(a)); else tmp = 1.0 / ((1.0 / r) / tan(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.25e-8], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.6], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(1.0 / r), $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.25 \cdot 10^{-8}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{elif}\;b \leq 2.6:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{1}{r}}{\tan b}}\\
\end{array}
\end{array}
if b < -2.24999999999999996e-8Initial program 60.2%
associate-/l*60.1%
remove-double-neg60.1%
remove-double-neg60.1%
+-commutative60.1%
Simplified60.1%
associate-*r/60.2%
clear-num60.0%
Applied egg-rr60.0%
Taylor expanded in a around 0 60.0%
div-inv60.0%
Applied egg-rr60.0%
associate-*r/60.0%
*-rgt-identity60.0%
associate-/r*60.0%
Simplified60.0%
associate-/l/60.0%
*-commutative60.0%
clear-num60.2%
associate-/l*60.1%
quot-tan60.2%
Applied egg-rr60.2%
if -2.24999999999999996e-8 < b < 2.60000000000000009Initial program 98.5%
associate-/l*98.5%
remove-double-neg98.5%
remove-double-neg98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.4%
associate-/l*98.4%
Simplified98.4%
if 2.60000000000000009 < b Initial program 47.9%
associate-/l*47.9%
remove-double-neg47.9%
remove-double-neg47.9%
+-commutative47.9%
Simplified47.9%
associate-*r/47.9%
clear-num48.0%
Applied egg-rr48.0%
Taylor expanded in a around 0 48.6%
div-inv48.6%
Applied egg-rr48.6%
associate-*r/48.6%
*-rgt-identity48.6%
associate-/r*48.5%
Simplified48.5%
div-inv48.5%
*-un-lft-identity48.5%
div-inv48.5%
associate-/l/48.6%
*-commutative48.6%
clear-num48.5%
associate-/l*48.5%
quot-tan48.5%
Applied egg-rr48.5%
*-lft-identity48.5%
associate-/r*48.5%
Simplified48.5%
Final simplification75.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.25e-8) (not (<= b 2.6))) (* r (tan b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.25e-8) || !(b <= 2.6)) {
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 <= (-2.25d-8)) .or. (.not. (b <= 2.6d0))) 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 <= -2.25e-8) || !(b <= 2.6)) {
tmp = r * Math.tan(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.25e-8) or not (b <= 2.6): tmp = r * math.tan(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.25e-8) || !(b <= 2.6)) tmp = Float64(r * tan(b)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2.25e-8) || ~((b <= 2.6))) tmp = r * tan(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.25e-8], N[Not[LessEqual[b, 2.6]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.25 \cdot 10^{-8} \lor \neg \left(b \leq 2.6\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -2.24999999999999996e-8 or 2.60000000000000009 < b Initial program 53.9%
associate-/l*53.9%
remove-double-neg53.9%
remove-double-neg53.9%
+-commutative53.9%
Simplified53.9%
associate-*r/53.9%
clear-num53.9%
Applied egg-rr53.9%
Taylor expanded in a around 0 54.2%
div-inv54.2%
Applied egg-rr54.2%
associate-*r/54.2%
*-rgt-identity54.2%
associate-/r*54.2%
Simplified54.2%
associate-/l/54.2%
*-commutative54.2%
clear-num54.3%
associate-/l*54.2%
quot-tan54.2%
Applied egg-rr54.2%
if -2.24999999999999996e-8 < b < 2.60000000000000009Initial program 98.5%
associate-/l*98.5%
remove-double-neg98.5%
remove-double-neg98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.4%
associate-/l*98.4%
Simplified98.4%
Final simplification75.6%
(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 75.5%
associate-/l*75.5%
remove-double-neg75.5%
remove-double-neg75.5%
+-commutative75.5%
Simplified75.5%
associate-*r/75.5%
clear-num75.1%
Applied egg-rr75.1%
Taylor expanded in a around 0 60.2%
div-inv60.2%
Applied egg-rr60.2%
associate-*r/60.2%
*-rgt-identity60.2%
associate-/r*60.1%
Simplified60.1%
associate-/l/60.2%
*-commutative60.2%
clear-num60.6%
associate-/l*60.6%
quot-tan60.6%
Applied egg-rr60.6%
Final simplification60.6%
(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.5%
associate-/l*75.5%
remove-double-neg75.5%
remove-double-neg75.5%
+-commutative75.5%
Simplified75.5%
Taylor expanded in b around 0 50.2%
associate-/l*50.2%
Simplified50.2%
Taylor expanded in a around 0 35.2%
*-commutative35.2%
Simplified35.2%
Final simplification35.2%
herbie shell --seed 2024069
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))