
(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(-Float64(sin(b) * 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 \sin a\right)} \cdot r
\end{array}
Initial program 81.4%
associate-/l*81.4%
remove-double-neg81.4%
sin-neg81.4%
neg-mul-181.4%
associate-/r*81.4%
associate-/l*81.4%
*-commutative81.4%
associate-*l/81.5%
associate-/l*81.5%
sin-neg81.5%
distribute-lft-neg-in81.5%
distribute-rgt-neg-in81.5%
associate-/l*81.5%
metadata-eval81.5%
/-rgt-identity81.5%
+-commutative81.5%
Simplified81.5%
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 81.4%
associate-/l*81.4%
+-commutative81.4%
Simplified81.4%
associate-/r/81.5%
Applied egg-rr81.5%
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 81.4%
associate-/l*81.4%
remove-double-neg81.4%
sin-neg81.4%
neg-mul-181.4%
associate-/r*81.4%
associate-/l*81.4%
*-commutative81.4%
associate-*l/81.5%
associate-/l*81.5%
sin-neg81.5%
distribute-lft-neg-in81.5%
distribute-rgt-neg-in81.5%
associate-/l*81.5%
metadata-eval81.5%
/-rgt-identity81.5%
+-commutative81.5%
Simplified81.5%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (* (cos b) (cos a)))))
double code(double r, double a, double b) {
return sin(b) * (r / (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 = sin(b) * (r / (cos(b) * cos(a)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / (Math.cos(b) * Math.cos(a)));
}
def code(r, a, b): return math.sin(b) * (r / (math.cos(b) * math.cos(a)))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(cos(b) * cos(a)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / (cos(b) * cos(a))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos b \cdot \cos a}
\end{array}
Initial program 81.4%
associate-/l*81.4%
+-commutative81.4%
Simplified81.4%
associate-/r/81.5%
Applied egg-rr81.5%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult82.4%
div-sub82.4%
cos-diff82.1%
add-sqr-sqrt47.7%
sqrt-unprod81.7%
sqr-neg81.7%
sqrt-unprod47.3%
add-sqr-sqrt81.4%
sub-neg81.4%
cos-sum82.3%
Applied egg-rr82.3%
+-inverses82.3%
Simplified82.3%
Final simplification82.3%
(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 81.4%
associate-/l*81.4%
remove-double-neg81.4%
sin-neg81.4%
neg-mul-181.4%
associate-/r*81.4%
associate-/l*81.4%
*-commutative81.4%
associate-*l/81.5%
associate-/l*81.5%
sin-neg81.5%
distribute-lft-neg-in81.5%
distribute-rgt-neg-in81.5%
associate-/l*81.5%
metadata-eval81.5%
/-rgt-identity81.5%
+-commutative81.5%
Simplified81.5%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult82.4%
div-sub82.4%
cos-diff82.1%
add-sqr-sqrt47.7%
sqrt-unprod81.7%
sqr-neg81.7%
sqrt-unprod47.3%
add-sqr-sqrt81.4%
sub-neg81.4%
cos-sum82.3%
Applied egg-rr82.4%
+-inverses82.3%
Simplified82.4%
Final simplification82.4%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.000215) (not (<= a 2.7e-6))) (* (sin b) (/ r (cos a))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.000215) || !(a <= 2.7e-6)) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = 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 ((a <= (-0.000215d0)) .or. (.not. (a <= 2.7d-6))) then
tmp = sin(b) * (r / cos(a))
else
tmp = r * tan(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.000215) || !(a <= 2.7e-6)) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.000215) or not (a <= 2.7e-6): tmp = math.sin(b) * (r / math.cos(a)) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.000215) || !(a <= 2.7e-6)) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.000215) || ~((a <= 2.7e-6))) tmp = sin(b) * (r / cos(a)); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.000215], N[Not[LessEqual[a, 2.7e-6]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000215 \lor \neg \left(a \leq 2.7 \cdot 10^{-6}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if a < -2.14999999999999995e-4 or 2.69999999999999998e-6 < a Initial program 63.5%
associate-/l*63.5%
+-commutative63.5%
Simplified63.5%
associate-/r/63.5%
Applied egg-rr63.5%
cos-sum99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 64.4%
if -2.14999999999999995e-4 < a < 2.69999999999999998e-6Initial program 99.4%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
clear-num99.0%
associate-/r/99.3%
clear-num99.4%
quot-tan99.6%
Applied egg-rr99.6%
Final simplification82.0%
(FPCore (r a b) :precision binary64 (if (<= a -0.00085) (* (sin b) (/ r (cos a))) (if (<= a 2.8e-6) (* r (tan b)) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.00085) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 2.8e-6) {
tmp = r * tan(b);
} else {
tmp = r * (sin(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 (a <= (-0.00085d0)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 2.8d-6) then
tmp = r * tan(b)
else
tmp = r * (sin(b) / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.00085) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 2.8e-6) {
tmp = r * Math.tan(b);
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.00085: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 2.8e-6: tmp = r * math.tan(b) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.00085) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 2.8e-6) tmp = Float64(r * tan(b)); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.00085) tmp = sin(b) * (r / cos(a)); elseif (a <= 2.8e-6) tmp = r * tan(b); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.00085], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.8e-6], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00085:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 2.8 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -8.49999999999999953e-4Initial program 67.2%
associate-/l*67.3%
+-commutative67.3%
Simplified67.3%
associate-/r/67.3%
Applied egg-rr67.3%
cos-sum99.4%
Applied egg-rr99.4%
Taylor expanded in b around 0 68.0%
if -8.49999999999999953e-4 < a < 2.79999999999999987e-6Initial program 99.4%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
clear-num99.0%
associate-/r/99.3%
clear-num99.4%
quot-tan99.6%
Applied egg-rr99.6%
if 2.79999999999999987e-6 < a Initial program 58.8%
associate-/l*58.8%
remove-double-neg58.8%
sin-neg58.8%
neg-mul-158.8%
associate-/r*58.8%
associate-/l*58.8%
*-commutative58.8%
associate-*l/58.9%
associate-/l*58.9%
sin-neg58.9%
distribute-lft-neg-in58.9%
distribute-rgt-neg-in58.9%
associate-/l*58.9%
metadata-eval58.9%
/-rgt-identity58.9%
+-commutative58.9%
Simplified58.9%
Taylor expanded in b around 0 60.0%
Final simplification82.0%
(FPCore (r a b) :precision binary64 (if (<= a -5.2e-6) (/ r (/ (cos a) (sin b))) (if (<= a 3.7e-6) (* r (tan b)) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -5.2e-6) {
tmp = r / (cos(a) / sin(b));
} else if (a <= 3.7e-6) {
tmp = r * tan(b);
} else {
tmp = r * (sin(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 (a <= (-5.2d-6)) then
tmp = r / (cos(a) / sin(b))
else if (a <= 3.7d-6) then
tmp = r * tan(b)
else
tmp = r * (sin(b) / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -5.2e-6) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else if (a <= 3.7e-6) {
tmp = r * Math.tan(b);
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -5.2e-6: tmp = r / (math.cos(a) / math.sin(b)) elif a <= 3.7e-6: tmp = r * math.tan(b) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -5.2e-6) tmp = Float64(r / Float64(cos(a) / sin(b))); elseif (a <= 3.7e-6) tmp = Float64(r * tan(b)); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -5.2e-6) tmp = r / (cos(a) / sin(b)); elseif (a <= 3.7e-6) tmp = r * tan(b); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -5.2e-6], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.7e-6], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.2 \cdot 10^{-6}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{elif}\;a \leq 3.7 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -5.20000000000000019e-6Initial program 67.2%
associate-/l*67.3%
+-commutative67.3%
Simplified67.3%
Taylor expanded in b around 0 68.0%
if -5.20000000000000019e-6 < a < 3.7000000000000002e-6Initial program 99.4%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
clear-num99.0%
associate-/r/99.3%
clear-num99.4%
quot-tan99.6%
Applied egg-rr99.6%
if 3.7000000000000002e-6 < a Initial program 58.8%
associate-/l*58.8%
remove-double-neg58.8%
sin-neg58.8%
neg-mul-158.8%
associate-/r*58.8%
associate-/l*58.8%
*-commutative58.8%
associate-*l/58.9%
associate-/l*58.9%
sin-neg58.9%
distribute-lft-neg-in58.9%
distribute-rgt-neg-in58.9%
associate-/l*58.9%
metadata-eval58.9%
/-rgt-identity58.9%
+-commutative58.9%
Simplified58.9%
Taylor expanded in b around 0 60.0%
Final simplification82.0%
(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 81.4%
associate-/l*81.4%
+-commutative81.4%
Simplified81.4%
associate-/r/81.5%
Applied egg-rr81.5%
Final simplification81.5%
(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 81.4%
associate-/l*81.4%
remove-double-neg81.4%
sin-neg81.4%
neg-mul-181.4%
associate-/r*81.4%
associate-/l*81.4%
*-commutative81.4%
associate-*l/81.5%
associate-/l*81.5%
sin-neg81.5%
distribute-lft-neg-in81.5%
distribute-rgt-neg-in81.5%
associate-/l*81.5%
metadata-eval81.5%
/-rgt-identity81.5%
+-commutative81.5%
Simplified81.5%
Final simplification81.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.000125) (not (<= b 0.000106))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000125) || !(b <= 0.000106)) {
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.000125d0)) .or. (.not. (b <= 0.000106d0))) 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.000125) || !(b <= 0.000106)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.000125) or not (b <= 0.000106): 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.000125) || !(b <= 0.000106)) 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.000125) || ~((b <= 0.000106))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.000125], N[Not[LessEqual[b, 0.000106]], $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.000125 \lor \neg \left(b \leq 0.000106\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.25e-4 or 1.06e-4 < b Initial program 60.1%
associate-/l*60.2%
+-commutative60.2%
Simplified60.2%
Taylor expanded in a around 0 59.8%
clear-num59.8%
associate-/r/59.9%
clear-num59.9%
quot-tan60.0%
Applied egg-rr60.0%
if -1.25e-4 < b < 1.06e-4Initial program 98.8%
associate-/l*98.7%
remove-double-neg98.7%
sin-neg98.7%
neg-mul-198.7%
associate-/r*98.7%
associate-/l*98.8%
*-commutative98.8%
associate-*l/98.9%
associate-/l*98.9%
sin-neg98.9%
distribute-lft-neg-in98.9%
distribute-rgt-neg-in98.9%
associate-/l*98.9%
metadata-eval98.9%
/-rgt-identity98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.9%
Final simplification81.4%
(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 81.4%
associate-/l*81.4%
+-commutative81.4%
Simplified81.4%
Taylor expanded in a around 0 63.8%
clear-num63.6%
associate-/r/63.8%
clear-num63.8%
quot-tan63.9%
Applied egg-rr63.9%
Final simplification63.9%
(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 81.4%
associate-/l*81.4%
+-commutative81.4%
Simplified81.4%
Taylor expanded in a around 0 63.8%
Taylor expanded in b around 0 39.1%
Final simplification39.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 81.4%
associate-/l*81.4%
remove-double-neg81.4%
sin-neg81.4%
neg-mul-181.4%
associate-/r*81.4%
associate-/l*81.4%
*-commutative81.4%
associate-*l/81.5%
associate-/l*81.5%
sin-neg81.5%
distribute-lft-neg-in81.5%
distribute-rgt-neg-in81.5%
associate-/l*81.5%
metadata-eval81.5%
/-rgt-identity81.5%
+-commutative81.5%
Simplified81.5%
Taylor expanded in b around 0 56.2%
Taylor expanded in a around 0 38.5%
Final simplification38.5%
herbie shell --seed 2024024
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))