
(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 18 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 (sin a) (- (sin b)) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(sin(a), -sin(b), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(sin(a), Float64(-sin(b)), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \cos b\right)}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.4%
sub-neg99.4%
Applied egg-rr99.4%
+-commutative99.4%
distribute-lft-neg-in99.4%
*-commutative99.4%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(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(sin(b) * Float64(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[Sin[b], $MachinePrecision] * N[(r / 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}
\\
\sin b \cdot \frac{r}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
associate-/l*77.3%
+-commutative77.3%
Simplified77.3%
associate-/r/77.0%
Applied egg-rr77.0%
cos-sum99.0%
Applied egg-rr99.0%
Final simplification99.0%
(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 77.4%
associate-/l*77.3%
remove-double-neg77.3%
sin-neg77.3%
neg-mul-177.3%
associate-/r*77.3%
associate-/l*77.4%
*-commutative77.4%
associate-*l/77.3%
associate-/l*77.3%
sin-neg77.3%
distribute-lft-neg-in77.3%
distribute-rgt-neg-in77.3%
associate-/l*77.3%
metadata-eval77.3%
/-rgt-identity77.3%
+-commutative77.3%
Simplified77.3%
cos-sum99.0%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (sin b) (/ (- (* (cos a) (cos b)) (* (sin b) (sin a))) r)))
double code(double r, double a, double b) {
return sin(b) / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / r);
}
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) / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / r)
end function
public static double code(double r, double a, double b) {
return Math.sin(b) / (((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))) / r);
}
def code(r, a, b): return math.sin(b) / (((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))) / r)
function code(r, a, b) return Float64(sin(b) / Float64(Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))) / r)) end
function tmp = code(r, a, b) tmp = sin(b) / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / r); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\frac{\cos a \cdot \cos b - \sin b \cdot \sin a}{r}}
\end{array}
Initial program 77.4%
associate-/l*77.3%
remove-double-neg77.3%
sin-neg77.3%
neg-mul-177.3%
associate-/r*77.3%
associate-/l*77.4%
*-commutative77.4%
associate-*l/77.3%
associate-/l*77.3%
sin-neg77.3%
distribute-lft-neg-in77.3%
distribute-rgt-neg-in77.3%
associate-/l*77.3%
metadata-eval77.3%
/-rgt-identity77.3%
+-commutative77.3%
Simplified77.3%
associate-*l/77.4%
associate-/l*77.3%
Applied egg-rr77.3%
cos-sum99.0%
Applied egg-rr99.4%
Final simplification99.4%
(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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $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{r \cdot \sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.0%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -6.5e-6) (not (<= b 4e-6))) (* (sin b) (/ r (cos b))) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -6.5e-6) || !(b <= 4e-6)) {
tmp = sin(b) * (r / 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 <= 4d-6))) then
tmp = sin(b) * (r / 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 <= 4e-6)) {
tmp = Math.sin(b) * (r / 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 <= 4e-6): tmp = math.sin(b) * (r / 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 <= 4e-6)) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -6.5e-6) || ~((b <= 4e-6))) tmp = sin(b) * (r / 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, 4e-6]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-6} \lor \neg \left(b \leq 4 \cdot 10^{-6}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -6.4999999999999996e-6 or 3.99999999999999982e-6 < b Initial program 56.1%
associate-/l*56.1%
+-commutative56.1%
Simplified56.1%
associate-/r/56.1%
Applied egg-rr56.1%
Taylor expanded in a around 0 55.1%
if -6.4999999999999996e-6 < b < 3.99999999999999982e-6Initial program 98.6%
associate-/l*98.5%
remove-double-neg98.5%
sin-neg98.5%
neg-mul-198.5%
associate-/r*98.5%
associate-/l*98.6%
*-commutative98.6%
associate-*l/98.5%
associate-/l*98.5%
sin-neg98.5%
distribute-lft-neg-in98.5%
distribute-rgt-neg-in98.5%
associate-/l*98.5%
metadata-eval98.5%
/-rgt-identity98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.6%
Final simplification76.8%
(FPCore (r a b) :precision binary64 (if (<= b -2.5e-6) (* r (/ (sin b) (cos b))) (if (<= b 3.8e-6) (/ (* r b) (cos a)) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.5e-6) {
tmp = r * (sin(b) / cos(b));
} else if (b <= 3.8e-6) {
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 <= (-2.5d-6)) then
tmp = r * (sin(b) / cos(b))
else if (b <= 3.8d-6) 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 <= -2.5e-6) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else if (b <= 3.8e-6) {
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 <= -2.5e-6: tmp = r * (math.sin(b) / math.cos(b)) elif b <= 3.8e-6: 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 <= -2.5e-6) tmp = Float64(r * Float64(sin(b) / cos(b))); elseif (b <= 3.8e-6) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(sin(b) * Float64(r / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2.5e-6) tmp = r * (sin(b) / cos(b)); elseif (b <= 3.8e-6) tmp = (r * b) / cos(a); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.5e-6], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.8e-6], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -2.5000000000000002e-6Initial program 54.8%
associate-/l*54.8%
remove-double-neg54.8%
sin-neg54.8%
neg-mul-154.8%
associate-/r*54.8%
associate-/l*54.8%
*-commutative54.8%
associate-*l/54.9%
associate-/l*54.9%
sin-neg54.9%
distribute-lft-neg-in54.9%
distribute-rgt-neg-in54.9%
associate-/l*54.9%
metadata-eval54.9%
/-rgt-identity54.9%
+-commutative54.9%
Simplified54.9%
Taylor expanded in a around 0 52.3%
if -2.5000000000000002e-6 < b < 3.8e-6Initial program 98.6%
associate-/l*98.5%
remove-double-neg98.5%
sin-neg98.5%
neg-mul-198.5%
associate-/r*98.5%
associate-/l*98.6%
*-commutative98.6%
associate-*l/98.5%
associate-/l*98.5%
sin-neg98.5%
distribute-lft-neg-in98.5%
distribute-rgt-neg-in98.5%
associate-/l*98.5%
metadata-eval98.5%
/-rgt-identity98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.6%
if 3.8e-6 < b Initial program 57.1%
associate-/l*57.1%
+-commutative57.1%
Simplified57.1%
associate-/r/57.2%
Applied egg-rr57.2%
Taylor expanded in a around 0 57.3%
Final simplification76.9%
(FPCore (r a b) :precision binary64 (if (<= a -0.000152) (* r (/ (sin b) (cos a))) (if (<= a 0.00052) (* r (/ (sin b) (cos b))) (/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.000152) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 0.00052) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = r / (cos(a) / 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 (a <= (-0.000152d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 0.00052d0) then
tmp = r * (sin(b) / cos(b))
else
tmp = r / (cos(a) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.000152) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 0.00052) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.000152: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 0.00052: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.000152) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 0.00052) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.000152) tmp = r * (sin(b) / cos(a)); elseif (a <= 0.00052) tmp = r * (sin(b) / cos(b)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.000152], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.00052], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000152:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 0.00052:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -1.5200000000000001e-4Initial program 47.7%
associate-/l*47.6%
remove-double-neg47.6%
sin-neg47.6%
neg-mul-147.6%
associate-/r*47.6%
associate-/l*47.7%
*-commutative47.7%
associate-*l/47.6%
associate-/l*47.6%
sin-neg47.6%
distribute-lft-neg-in47.6%
distribute-rgt-neg-in47.6%
associate-/l*47.6%
metadata-eval47.6%
/-rgt-identity47.6%
+-commutative47.6%
Simplified47.6%
Taylor expanded in b around 0 46.4%
if -1.5200000000000001e-4 < a < 5.19999999999999954e-4Initial program 99.3%
associate-/l*99.1%
remove-double-neg99.1%
sin-neg99.1%
neg-mul-199.1%
associate-/r*99.1%
associate-/l*99.3%
*-commutative99.3%
associate-*l/99.3%
associate-/l*99.3%
sin-neg99.3%
distribute-lft-neg-in99.3%
distribute-rgt-neg-in99.3%
associate-/l*99.3%
metadata-eval99.3%
/-rgt-identity99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
if 5.19999999999999954e-4 < a Initial program 62.5%
associate-/l*62.6%
+-commutative62.6%
Simplified62.6%
Taylor expanded in b around 0 61.7%
Final simplification76.9%
(FPCore (r a b) :precision binary64 (if (<= a -8.8e-6) (/ (sin b) (/ (cos a) r)) (if (<= a 2.65e-5) (* r (/ (sin b) (cos b))) (/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -8.8e-6) {
tmp = sin(b) / (cos(a) / r);
} else if (a <= 2.65e-5) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = r / (cos(a) / 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 (a <= (-8.8d-6)) then
tmp = sin(b) / (cos(a) / r)
else if (a <= 2.65d-5) then
tmp = r * (sin(b) / cos(b))
else
tmp = r / (cos(a) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -8.8e-6) {
tmp = Math.sin(b) / (Math.cos(a) / r);
} else if (a <= 2.65e-5) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -8.8e-6: tmp = math.sin(b) / (math.cos(a) / r) elif a <= 2.65e-5: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -8.8e-6) tmp = Float64(sin(b) / Float64(cos(a) / r)); elseif (a <= 2.65e-5) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -8.8e-6) tmp = sin(b) / (cos(a) / r); elseif (a <= 2.65e-5) tmp = r * (sin(b) / cos(b)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -8.8e-6], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.65e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\mathbf{elif}\;a \leq 2.65 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -8.8000000000000004e-6Initial program 47.7%
associate-/l*47.6%
remove-double-neg47.6%
sin-neg47.6%
neg-mul-147.6%
associate-/r*47.6%
associate-/l*47.7%
*-commutative47.7%
associate-*l/47.6%
associate-/l*47.6%
sin-neg47.6%
distribute-lft-neg-in47.6%
distribute-rgt-neg-in47.6%
associate-/l*47.6%
metadata-eval47.6%
/-rgt-identity47.6%
+-commutative47.6%
Simplified47.6%
associate-*l/47.7%
associate-/l*47.7%
Applied egg-rr47.7%
Taylor expanded in b around 0 46.6%
if -8.8000000000000004e-6 < a < 2.65e-5Initial program 99.3%
associate-/l*99.1%
remove-double-neg99.1%
sin-neg99.1%
neg-mul-199.1%
associate-/r*99.1%
associate-/l*99.3%
*-commutative99.3%
associate-*l/99.3%
associate-/l*99.3%
sin-neg99.3%
distribute-lft-neg-in99.3%
distribute-rgt-neg-in99.3%
associate-/l*99.3%
metadata-eval99.3%
/-rgt-identity99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
if 2.65e-5 < a Initial program 62.5%
associate-/l*62.6%
+-commutative62.6%
Simplified62.6%
Taylor expanded in b around 0 61.7%
Final simplification76.9%
(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.4%
associate-/l*77.3%
+-commutative77.3%
Simplified77.3%
associate-/r/77.0%
Applied egg-rr77.0%
Final simplification77.0%
(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.4%
associate-/l*77.3%
remove-double-neg77.3%
sin-neg77.3%
neg-mul-177.3%
associate-/r*77.3%
associate-/l*77.4%
*-commutative77.4%
associate-*l/77.3%
associate-/l*77.3%
sin-neg77.3%
distribute-lft-neg-in77.3%
distribute-rgt-neg-in77.3%
associate-/l*77.3%
metadata-eval77.3%
/-rgt-identity77.3%
+-commutative77.3%
Simplified77.3%
Final simplification77.3%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ b a))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((b + a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((b + a))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((b + a));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((b + a))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(b + a))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((b + a)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 77.4%
Final simplification77.4%
(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.4%
associate-/l*77.3%
+-commutative77.3%
Simplified77.3%
associate-/r/77.0%
Applied egg-rr77.0%
Taylor expanded in b around 0 55.4%
Final simplification55.4%
(FPCore (r a b) :precision binary64 (if (<= b 1.75) (* r (/ b (cos a))) (* r (sin b))))
double code(double r, double a, double b) {
double tmp;
if (b <= 1.75) {
tmp = r * (b / cos(a));
} else {
tmp = r * 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 <= 1.75d0) then
tmp = r * (b / cos(a))
else
tmp = r * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 1.75) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 1.75: tmp = r * (b / math.cos(a)) else: tmp = r * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 1.75) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(r * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 1.75) tmp = r * (b / cos(a)); else tmp = r * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 1.75], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.75:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \sin b\\
\end{array}
\end{array}
if b < 1.75Initial program 85.5%
associate-/l*85.4%
remove-double-neg85.4%
sin-neg85.4%
neg-mul-185.4%
associate-/r*85.4%
associate-/l*85.5%
*-commutative85.5%
associate-*l/85.5%
associate-/l*85.5%
sin-neg85.5%
distribute-lft-neg-in85.5%
distribute-rgt-neg-in85.5%
associate-/l*85.5%
metadata-eval85.5%
/-rgt-identity85.5%
+-commutative85.5%
Simplified85.5%
Taylor expanded in b around 0 70.2%
if 1.75 < b Initial program 55.3%
associate-/l*55.2%
remove-double-neg55.2%
sin-neg55.2%
neg-mul-155.2%
associate-/r*55.2%
associate-/l*55.3%
*-commutative55.3%
associate-*l/55.3%
associate-/l*55.3%
sin-neg55.3%
distribute-lft-neg-in55.3%
distribute-rgt-neg-in55.3%
associate-/l*55.3%
metadata-eval55.3%
/-rgt-identity55.3%
+-commutative55.3%
Simplified55.3%
Taylor expanded in b around 0 8.0%
mul-1-neg8.0%
unsub-neg8.0%
Simplified8.0%
Taylor expanded in a around 0 13.6%
Final simplification54.9%
(FPCore (r a b) :precision binary64 (if (<= b 1.7) (/ r (/ (cos a) b)) (* r (sin b))))
double code(double r, double a, double b) {
double tmp;
if (b <= 1.7) {
tmp = r / (cos(a) / b);
} else {
tmp = r * 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 <= 1.7d0) then
tmp = r / (cos(a) / b)
else
tmp = r * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 1.7) {
tmp = r / (Math.cos(a) / b);
} else {
tmp = r * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 1.7: tmp = r / (math.cos(a) / b) else: tmp = r * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 1.7) tmp = Float64(r / Float64(cos(a) / b)); else tmp = Float64(r * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 1.7) tmp = r / (cos(a) / b); else tmp = r * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 1.7], N[(r / N[(N[Cos[a], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7:\\
\;\;\;\;\frac{r}{\frac{\cos a}{b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \sin b\\
\end{array}
\end{array}
if b < 1.69999999999999996Initial program 85.5%
associate-/l*85.4%
+-commutative85.4%
Simplified85.4%
Taylor expanded in b around 0 70.2%
if 1.69999999999999996 < b Initial program 55.3%
associate-/l*55.2%
remove-double-neg55.2%
sin-neg55.2%
neg-mul-155.2%
associate-/r*55.2%
associate-/l*55.3%
*-commutative55.3%
associate-*l/55.3%
associate-/l*55.3%
sin-neg55.3%
distribute-lft-neg-in55.3%
distribute-rgt-neg-in55.3%
associate-/l*55.3%
metadata-eval55.3%
/-rgt-identity55.3%
+-commutative55.3%
Simplified55.3%
Taylor expanded in b around 0 8.0%
mul-1-neg8.0%
unsub-neg8.0%
Simplified8.0%
Taylor expanded in a around 0 13.6%
Final simplification54.9%
(FPCore (r a b) :precision binary64 (if (<= b 1.55) (/ (* r b) (cos a)) (* r (sin b))))
double code(double r, double a, double b) {
double tmp;
if (b <= 1.55) {
tmp = (r * b) / cos(a);
} else {
tmp = r * 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 <= 1.55d0) then
tmp = (r * b) / cos(a)
else
tmp = r * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 1.55) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = r * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 1.55: tmp = (r * b) / math.cos(a) else: tmp = r * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 1.55) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(r * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 1.55) tmp = (r * b) / cos(a); else tmp = r * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 1.55], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.55:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \sin b\\
\end{array}
\end{array}
if b < 1.55000000000000004Initial program 85.5%
associate-/l*85.4%
remove-double-neg85.4%
sin-neg85.4%
neg-mul-185.4%
associate-/r*85.4%
associate-/l*85.5%
*-commutative85.5%
associate-*l/85.5%
associate-/l*85.5%
sin-neg85.5%
distribute-lft-neg-in85.5%
distribute-rgt-neg-in85.5%
associate-/l*85.5%
metadata-eval85.5%
/-rgt-identity85.5%
+-commutative85.5%
Simplified85.5%
Taylor expanded in b around 0 70.2%
if 1.55000000000000004 < b Initial program 55.3%
associate-/l*55.2%
remove-double-neg55.2%
sin-neg55.2%
neg-mul-155.2%
associate-/r*55.2%
associate-/l*55.3%
*-commutative55.3%
associate-*l/55.3%
associate-/l*55.3%
sin-neg55.3%
distribute-lft-neg-in55.3%
distribute-rgt-neg-in55.3%
associate-/l*55.3%
metadata-eval55.3%
/-rgt-identity55.3%
+-commutative55.3%
Simplified55.3%
Taylor expanded in b around 0 8.0%
mul-1-neg8.0%
unsub-neg8.0%
Simplified8.0%
Taylor expanded in a around 0 13.6%
Final simplification54.9%
(FPCore (r a b) :precision binary64 (* r (sin b)))
double code(double r, double a, double b) {
return r * 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 * sin(b)
end function
public static double code(double r, double a, double b) {
return r * Math.sin(b);
}
def code(r, a, b): return r * math.sin(b)
function code(r, a, b) return Float64(r * sin(b)) end
function tmp = code(r, a, b) tmp = r * sin(b); end
code[r_, a_, b_] := N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \sin b
\end{array}
Initial program 77.4%
associate-/l*77.3%
remove-double-neg77.3%
sin-neg77.3%
neg-mul-177.3%
associate-/r*77.3%
associate-/l*77.4%
*-commutative77.4%
associate-*l/77.3%
associate-/l*77.3%
sin-neg77.3%
distribute-lft-neg-in77.3%
distribute-rgt-neg-in77.3%
associate-/l*77.3%
metadata-eval77.3%
/-rgt-identity77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in b around 0 53.9%
mul-1-neg53.9%
unsub-neg53.9%
Simplified53.9%
Taylor expanded in a around 0 39.4%
Final simplification39.4%
(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 77.4%
associate-/l*77.3%
remove-double-neg77.3%
sin-neg77.3%
neg-mul-177.3%
associate-/r*77.3%
associate-/l*77.4%
*-commutative77.4%
associate-*l/77.3%
associate-/l*77.3%
sin-neg77.3%
distribute-lft-neg-in77.3%
distribute-rgt-neg-in77.3%
associate-/l*77.3%
metadata-eval77.3%
/-rgt-identity77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in b around 0 52.0%
Taylor expanded in a around 0 35.4%
*-commutative35.4%
Simplified35.4%
Final simplification35.4%
herbie shell --seed 2024011
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))