
(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 14 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 (* (/ (sin b) (fma (cos b) (cos a) (* (sin b) (- (sin a))))) r))
double code(double r, double a, double b) {
return (sin(b) / fma(cos(b), cos(a), (sin(b) * -sin(a)))) * r;
}
function code(r, a, b) return Float64(Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a))))) * r) end
code[r_, a_, b_] := N[(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] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)} \cdot r
\end{array}
Initial program 77.1%
associate-/l*77.0%
remove-double-neg77.0%
sin-neg77.0%
neg-mul-177.0%
associate-/r*77.0%
associate-/l*77.1%
*-commutative77.1%
associate-*l/77.2%
associate-/r/77.2%
*-commutative77.2%
associate-*r/77.2%
neg-mul-177.2%
sin-neg77.2%
remove-double-neg77.2%
+-commutative77.2%
Simplified77.2%
cos-sum99.5%
fma-neg99.6%
Applied egg-rr99.6%
Final simplification99.6%
(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 77.1%
associate-/l*77.0%
+-commutative77.0%
Simplified77.0%
associate-/r/77.1%
Applied egg-rr77.1%
cos-sum99.5%
Applied egg-rr99.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(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 77.1%
associate-/l*77.0%
remove-double-neg77.0%
sin-neg77.0%
neg-mul-177.0%
associate-/r*77.0%
associate-/l*77.1%
*-commutative77.1%
associate-*l/77.2%
associate-/r/77.2%
*-commutative77.2%
associate-*r/77.2%
neg-mul-177.2%
sin-neg77.2%
remove-double-neg77.2%
+-commutative77.2%
Simplified77.2%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (* (cos b) (cos a)))))
double code(double r, double a, double b) {
return r * (sin(b) / (cos(b) * cos(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / (cos(b) * cos(a)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / (Math.cos(b) * Math.cos(a)));
}
def code(r, a, b): return r * (math.sin(b) / (math.cos(b) * math.cos(a)))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(cos(b) * cos(a)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / (cos(b) * cos(a))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a}
\end{array}
Initial program 77.1%
associate-/l*77.0%
remove-double-neg77.0%
sin-neg77.0%
neg-mul-177.0%
associate-/r*77.0%
associate-/l*77.1%
*-commutative77.1%
associate-*l/77.2%
associate-/r/77.2%
*-commutative77.2%
associate-*r/77.2%
neg-mul-177.2%
sin-neg77.2%
remove-double-neg77.2%
+-commutative77.2%
Simplified77.2%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult78.3%
cos-sum78.7%
div-sub78.7%
sub-neg78.7%
add-sqr-sqrt49.4%
sqrt-unprod78.2%
sqr-neg78.2%
sqrt-unprod39.0%
add-sqr-sqrt77.7%
cos-diff78.2%
Applied egg-rr78.2%
+-inverses78.2%
Simplified78.2%
Final simplification78.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -6.5e-6) (not (<= b 54.0))) (* r (/ (sin b) (cos b))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -6.5e-6) || !(b <= 54.0)) {
tmp = r * (sin(b) / cos(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 <= (-6.5d-6)) .or. (.not. (b <= 54.0d0))) then
tmp = r * (sin(b) / cos(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 <= -6.5e-6) || !(b <= 54.0)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -6.5e-6) or not (b <= 54.0): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -6.5e-6) || !(b <= 54.0)) tmp = Float64(r * Float64(sin(b) / cos(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 <= -6.5e-6) || ~((b <= 54.0))) tmp = r * (sin(b) / cos(b)); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -6.5e-6], N[Not[LessEqual[b, 54.0]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-6} \lor \neg \left(b \leq 54\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -6.4999999999999996e-6 or 54 < b Initial program 54.0%
associate-/l*54.0%
remove-double-neg54.0%
sin-neg54.0%
neg-mul-154.0%
associate-/r*54.0%
associate-/l*54.0%
*-commutative54.0%
associate-*l/54.1%
associate-/r/54.1%
*-commutative54.1%
associate-*r/54.1%
neg-mul-154.1%
sin-neg54.1%
remove-double-neg54.1%
+-commutative54.1%
Simplified54.1%
Taylor expanded in a around 0 54.4%
if -6.4999999999999996e-6 < b < 54Initial program 98.9%
associate-/l*98.7%
remove-double-neg98.7%
sin-neg98.7%
neg-mul-198.7%
associate-/r*98.7%
associate-/l*98.9%
*-commutative98.9%
associate-*l/98.9%
associate-/r/98.9%
*-commutative98.9%
associate-*r/98.9%
neg-mul-198.9%
sin-neg98.9%
remove-double-neg98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 99.0%
Final simplification77.4%
(FPCore (r a b) :precision binary64 (if (<= b -6.8e-6) (* r (/ (sin b) (cos b))) (if (<= b 54.0) (* r (/ b (cos a))) (/ (sin b) (/ (cos b) r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -6.8e-6) {
tmp = r * (sin(b) / cos(b));
} else if (b <= 54.0) {
tmp = r * (b / 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 <= (-6.8d-6)) then
tmp = r * (sin(b) / cos(b))
else if (b <= 54.0d0) then
tmp = r * (b / 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 <= -6.8e-6) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else if (b <= 54.0) {
tmp = r * (b / Math.cos(a));
} else {
tmp = Math.sin(b) / (Math.cos(b) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -6.8e-6: tmp = r * (math.sin(b) / math.cos(b)) elif b <= 54.0: tmp = r * (b / math.cos(a)) else: tmp = math.sin(b) / (math.cos(b) / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -6.8e-6) tmp = Float64(r * Float64(sin(b) / cos(b))); elseif (b <= 54.0) tmp = Float64(r * Float64(b / 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 <= -6.8e-6) tmp = r * (sin(b) / cos(b)); elseif (b <= 54.0) tmp = r * (b / cos(a)); else tmp = sin(b) / (cos(b) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -6.8e-6], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 54.0], N[(r * N[(b / 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 -6.8 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{elif}\;b \leq 54:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\end{array}
\end{array}
if b < -6.80000000000000012e-6Initial program 59.6%
associate-/l*59.6%
remove-double-neg59.6%
sin-neg59.6%
neg-mul-159.6%
associate-/r*59.6%
associate-/l*59.6%
*-commutative59.6%
associate-*l/59.8%
associate-/r/59.8%
*-commutative59.8%
associate-*r/59.8%
neg-mul-159.8%
sin-neg59.8%
remove-double-neg59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in a around 0 59.7%
if -6.80000000000000012e-6 < b < 54Initial program 98.9%
associate-/l*98.7%
remove-double-neg98.7%
sin-neg98.7%
neg-mul-198.7%
associate-/r*98.7%
associate-/l*98.9%
*-commutative98.9%
associate-*l/98.9%
associate-/r/98.9%
*-commutative98.9%
associate-*r/98.9%
neg-mul-198.9%
sin-neg98.9%
remove-double-neg98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 99.0%
if 54 < b Initial program 48.7%
associate-/l*48.6%
remove-double-neg48.6%
sin-neg48.6%
neg-mul-148.6%
associate-/r*48.6%
associate-/l*48.7%
*-commutative48.7%
associate-*l/48.7%
associate-/r/48.7%
*-commutative48.7%
associate-*r/48.7%
neg-mul-148.7%
sin-neg48.7%
remove-double-neg48.7%
+-commutative48.7%
Simplified48.7%
associate-*l/48.7%
associate-/l*48.7%
Applied egg-rr48.7%
Taylor expanded in a around 0 49.5%
Final simplification77.4%
(FPCore (r a b) :precision binary64 (if (<= b -5.4e-6) (* r (/ (sin b) (cos b))) (if (<= b 54.0) (* r (/ b (cos a))) (/ (* (sin b) r) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -5.4e-6) {
tmp = r * (sin(b) / cos(b));
} else if (b <= 54.0) {
tmp = r * (b / cos(a));
} else {
tmp = (sin(b) * r) / 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 <= (-5.4d-6)) then
tmp = r * (sin(b) / cos(b))
else if (b <= 54.0d0) then
tmp = r * (b / cos(a))
else
tmp = (sin(b) * r) / cos(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -5.4e-6) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else if (b <= 54.0) {
tmp = r * (b / Math.cos(a));
} else {
tmp = (Math.sin(b) * r) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -5.4e-6: tmp = r * (math.sin(b) / math.cos(b)) elif b <= 54.0: tmp = r * (b / math.cos(a)) else: tmp = (math.sin(b) * r) / math.cos(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -5.4e-6) tmp = Float64(r * Float64(sin(b) / cos(b))); elseif (b <= 54.0) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(Float64(sin(b) * r) / cos(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -5.4e-6) tmp = r * (sin(b) / cos(b)); elseif (b <= 54.0) tmp = r * (b / cos(a)); else tmp = (sin(b) * r) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -5.4e-6], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 54.0], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.4 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{elif}\;b \leq 54:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos b}\\
\end{array}
\end{array}
if b < -5.39999999999999997e-6Initial program 59.6%
associate-/l*59.6%
remove-double-neg59.6%
sin-neg59.6%
neg-mul-159.6%
associate-/r*59.6%
associate-/l*59.6%
*-commutative59.6%
associate-*l/59.8%
associate-/r/59.8%
*-commutative59.8%
associate-*r/59.8%
neg-mul-159.8%
sin-neg59.8%
remove-double-neg59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in a around 0 59.7%
if -5.39999999999999997e-6 < b < 54Initial program 98.9%
associate-/l*98.7%
remove-double-neg98.7%
sin-neg98.7%
neg-mul-198.7%
associate-/r*98.7%
associate-/l*98.9%
*-commutative98.9%
associate-*l/98.9%
associate-/r/98.9%
*-commutative98.9%
associate-*r/98.9%
neg-mul-198.9%
sin-neg98.9%
remove-double-neg98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 99.0%
if 54 < b Initial program 48.7%
associate-/l*48.6%
remove-double-neg48.6%
sin-neg48.6%
neg-mul-148.6%
associate-/r*48.6%
associate-/l*48.7%
*-commutative48.7%
associate-*l/48.7%
associate-/r/48.7%
*-commutative48.7%
associate-*r/48.7%
neg-mul-148.7%
sin-neg48.7%
remove-double-neg48.7%
+-commutative48.7%
Simplified48.7%
Taylor expanded in a around 0 49.5%
*-commutative49.5%
Simplified49.5%
Final simplification77.4%
(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 77.1%
associate-/l*77.0%
+-commutative77.0%
Simplified77.0%
associate-/r/77.1%
Applied egg-rr77.1%
Final simplification77.1%
(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 77.1%
associate-/l*77.0%
remove-double-neg77.0%
sin-neg77.0%
neg-mul-177.0%
associate-/r*77.0%
associate-/l*77.1%
*-commutative77.1%
associate-*l/77.2%
associate-/r/77.2%
*-commutative77.2%
associate-*r/77.2%
neg-mul-177.2%
sin-neg77.2%
remove-double-neg77.2%
+-commutative77.2%
Simplified77.2%
Final simplification77.2%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos a))))
double code(double r, double a, double b) {
return sin(b) * (r / cos(a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos(a));
}
def code(r, a, b): return math.sin(b) * (r / math.cos(a))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos(a)); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a}
\end{array}
Initial program 77.1%
associate-/l*77.0%
+-commutative77.0%
Simplified77.0%
associate-/r/77.1%
Applied egg-rr77.1%
Taylor expanded in b around 0 57.3%
Final simplification57.3%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos a))))
double code(double r, double a, double b) {
return r * (sin(b) / cos(a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos(a));
}
def code(r, a, b): return r * (math.sin(b) / math.cos(a))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(a))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos(a)); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a}
\end{array}
Initial program 77.1%
associate-/l*77.0%
remove-double-neg77.0%
sin-neg77.0%
neg-mul-177.0%
associate-/r*77.0%
associate-/l*77.1%
*-commutative77.1%
associate-*l/77.2%
associate-/r/77.2%
*-commutative77.2%
associate-*r/77.2%
neg-mul-177.2%
sin-neg77.2%
remove-double-neg77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in b around 0 57.3%
Final simplification57.3%
(FPCore (r a b) :precision binary64 (* r (/ b (cos a))))
double code(double r, double a, double b) {
return r * (b / cos(a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (b / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos(a));
}
def code(r, a, b): return r * (b / math.cos(a))
function code(r, a, b) return Float64(r * Float64(b / cos(a))) end
function tmp = code(r, a, b) tmp = r * (b / cos(a)); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos a}
\end{array}
Initial program 77.1%
associate-/l*77.0%
remove-double-neg77.0%
sin-neg77.0%
neg-mul-177.0%
associate-/r*77.0%
associate-/l*77.1%
*-commutative77.1%
associate-*l/77.2%
associate-/r/77.2%
*-commutative77.2%
associate-*r/77.2%
neg-mul-177.2%
sin-neg77.2%
remove-double-neg77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in b around 0 53.6%
Final simplification53.6%
(FPCore (r a b) :precision binary64 (/ r (+ (* b -0.3333333333333333) (/ 1.0 b))))
double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / 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 * (-0.3333333333333333d0)) + (1.0d0 / b))
end function
public static double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / b));
}
def code(r, a, b): return r / ((b * -0.3333333333333333) + (1.0 / b))
function code(r, a, b) return Float64(r / Float64(Float64(b * -0.3333333333333333) + Float64(1.0 / b))) end
function tmp = code(r, a, b) tmp = r / ((b * -0.3333333333333333) + (1.0 / b)); end
code[r_, a_, b_] := N[(r / N[(N[(b * -0.3333333333333333), $MachinePrecision] + N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}}
\end{array}
Initial program 77.1%
associate-/l*77.0%
+-commutative77.0%
Simplified77.0%
Taylor expanded in b around 0 54.1%
+-commutative54.1%
neg-mul-154.1%
unsub-neg54.1%
fma-define54.1%
distribute-rgt-out--54.1%
metadata-eval54.1%
Simplified54.1%
Taylor expanded in a around 0 35.1%
Final simplification35.1%
(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 77.1%
associate-/l*77.0%
remove-double-neg77.0%
sin-neg77.0%
neg-mul-177.0%
associate-/r*77.0%
associate-/l*77.1%
*-commutative77.1%
associate-*l/77.2%
associate-/r/77.2%
*-commutative77.2%
associate-*r/77.2%
neg-mul-177.2%
sin-neg77.2%
remove-double-neg77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in b around 0 53.6%
Taylor expanded in a around 0 34.7%
Final simplification34.7%
herbie shell --seed 2024034
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))