
(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 (* r (/ (sin b) (fma (cos b) (cos a) (- (* (sin b) (sin a)))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(cos(b), cos(a), -(sin(b) * sin(a))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(-Float64(sin(b) * sin(a)))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + (-N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, -\sin b \cdot \sin a\right)}
\end{array}
Initial program 78.3%
associate-/l*78.3%
+-commutative78.3%
Simplified78.3%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.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 78.3%
associate-/l*78.3%
+-commutative78.3%
Simplified78.3%
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(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 78.3%
+-commutative78.3%
Simplified78.3%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (cos (+ b a)) (* (* (sin b) (sin a)) 2.0)))))
double code(double r, double a, double b) {
return r * (sin(b) / (cos((b + a)) - ((sin(b) * sin(a)) * 2.0)));
}
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)) - ((sin(b) * sin(a)) * 2.0d0)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / (Math.cos((b + a)) - ((Math.sin(b) * Math.sin(a)) * 2.0)));
}
def code(r, a, b): return r * (math.sin(b) / (math.cos((b + a)) - ((math.sin(b) * math.sin(a)) * 2.0)))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(cos(Float64(b + a)) - Float64(Float64(sin(b) * sin(a)) * 2.0)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / (cos((b + a)) - ((sin(b) * sin(a)) * 2.0))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] - N[(N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(b + a\right) - \left(\sin b \cdot \sin a\right) \cdot 2}
\end{array}
Initial program 78.3%
associate-/l*78.3%
+-commutative78.3%
Simplified78.3%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
distribute-lft-neg-out99.5%
fma-neg99.5%
add-sqr-sqrt50.5%
sqrt-unprod89.2%
sqr-neg89.2%
sqrt-unprod38.7%
add-sqr-sqrt78.7%
distribute-lft-neg-out78.7%
neg-mul-178.7%
add-sqr-sqrt40.0%
sqrt-unprod89.0%
sqr-neg89.0%
sqrt-unprod48.9%
add-sqr-sqrt99.5%
Applied egg-rr99.5%
fma-undefine99.5%
distribute-rgt-out99.5%
metadata-eval99.5%
add-sqr-sqrt56.0%
sqrt-unprod90.1%
*-un-lft-identity90.1%
metadata-eval90.1%
swap-sqr90.1%
*-commutative90.1%
*-commutative90.1%
sqrt-unprod41.5%
add-sqr-sqrt7.4%
sqrt-unprod41.3%
Applied egg-rr79.1%
Final simplification79.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -5.2e-5) (not (<= b 1.6e-14))) (* r (/ (sin b) (cos b))) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -5.2e-5) || !(b <= 1.6e-14)) {
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 <= (-5.2d-5)) .or. (.not. (b <= 1.6d-14))) 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 <= -5.2e-5) || !(b <= 1.6e-14)) {
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 <= -5.2e-5) or not (b <= 1.6e-14): 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 <= -5.2e-5) || !(b <= 1.6e-14)) tmp = Float64(r * Float64(sin(b) / 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 <= -5.2e-5) || ~((b <= 1.6e-14))) 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, -5.2e-5], N[Not[LessEqual[b, 1.6e-14]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / 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 -5.2 \cdot 10^{-5} \lor \neg \left(b \leq 1.6 \cdot 10^{-14}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -5.19999999999999968e-5 or 1.6000000000000001e-14 < b Initial program 58.1%
associate-/l*58.1%
+-commutative58.1%
Simplified58.1%
Taylor expanded in a around 0 59.0%
if -5.19999999999999968e-5 < b < 1.6000000000000001e-14Initial program 99.7%
associate-/l*99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in b around 0 99.7%
Final simplification78.7%
(FPCore (r a b) :precision binary64 (if (<= b -4.2e-5) (* r (/ (sin b) (cos b))) (if (<= b 1.6e-14) (/ (* r b) (cos a)) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -4.2e-5) {
tmp = r * (sin(b) / cos(b));
} else if (b <= 1.6e-14) {
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 <= (-4.2d-5)) then
tmp = r * (sin(b) / cos(b))
else if (b <= 1.6d-14) 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 <= -4.2e-5) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else if (b <= 1.6e-14) {
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 <= -4.2e-5: tmp = r * (math.sin(b) / math.cos(b)) elif b <= 1.6e-14: 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 <= -4.2e-5) tmp = Float64(r * Float64(sin(b) / cos(b))); elseif (b <= 1.6e-14) 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 <= -4.2e-5) tmp = r * (sin(b) / cos(b)); elseif (b <= 1.6e-14) tmp = (r * b) / cos(a); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -4.2e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.6e-14], 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 -4.2 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{-14}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -4.19999999999999977e-5Initial program 58.0%
associate-/l*58.1%
+-commutative58.1%
Simplified58.1%
Taylor expanded in a around 0 58.4%
if -4.19999999999999977e-5 < b < 1.6000000000000001e-14Initial program 99.7%
associate-/l*99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in b around 0 99.7%
if 1.6000000000000001e-14 < b Initial program 58.1%
associate-/l*58.1%
+-commutative58.1%
Simplified58.1%
Taylor expanded in a around 0 59.4%
*-commutative59.4%
associate-/l*59.4%
Simplified59.4%
Final simplification78.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 78.3%
associate-/l*78.3%
+-commutative78.3%
Simplified78.3%
Final simplification78.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 78.3%
Final simplification78.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 78.3%
associate-/l*78.3%
+-commutative78.3%
Simplified78.3%
Taylor expanded in b around 0 55.0%
Final simplification55.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -2450.0) (not (<= b 7.8e+37))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2450.0) || !(b <= 7.8e+37)) {
tmp = r * sin(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 <= (-2450.0d0)) .or. (.not. (b <= 7.8d+37))) then
tmp = r * sin(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 <= -2450.0) || !(b <= 7.8e+37)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2450.0) or not (b <= 7.8e+37): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2450.0) || !(b <= 7.8e+37)) tmp = Float64(r * sin(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 <= -2450.0) || ~((b <= 7.8e+37))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2450.0], N[Not[LessEqual[b, 7.8e+37]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2450 \lor \neg \left(b \leq 7.8 \cdot 10^{+37}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -2450 or 7.7999999999999997e37 < b Initial program 56.5%
+-commutative56.5%
Simplified56.5%
clear-num56.4%
associate-/r/56.5%
*-commutative56.5%
Applied egg-rr56.5%
Taylor expanded in a around 0 57.5%
Taylor expanded in b around 0 11.8%
if -2450 < b < 7.7999999999999997e37Initial program 98.4%
associate-/l*98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in b around 0 95.2%
Final simplification55.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -2200.0) (not (<= b 7.8e+37))) (* r (sin b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2200.0) || !(b <= 7.8e+37)) {
tmp = r * sin(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 <= (-2200.0d0)) .or. (.not. (b <= 7.8d+37))) then
tmp = r * sin(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 <= -2200.0) || !(b <= 7.8e+37)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2200.0) or not (b <= 7.8e+37): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2200.0) || !(b <= 7.8e+37)) tmp = Float64(r * sin(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 <= -2200.0) || ~((b <= 7.8e+37))) tmp = r * sin(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2200.0], N[Not[LessEqual[b, 7.8e+37]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2200 \lor \neg \left(b \leq 7.8 \cdot 10^{+37}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -2200 or 7.7999999999999997e37 < b Initial program 56.5%
+-commutative56.5%
Simplified56.5%
clear-num56.4%
associate-/r/56.5%
*-commutative56.5%
Applied egg-rr56.5%
Taylor expanded in a around 0 57.5%
Taylor expanded in b around 0 11.8%
if -2200 < b < 7.7999999999999997e37Initial program 98.4%
associate-/l*98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in b around 0 95.2%
Final simplification55.1%
(FPCore (r a b) :precision binary64 (if (<= b -2450.0) (* r (sin b)) (if (<= b 11.0) (/ (* r b) (cos a)) (* r (- (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2450.0) {
tmp = r * sin(b);
} else if (b <= 11.0) {
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 <= (-2450.0d0)) then
tmp = r * sin(b)
else if (b <= 11.0d0) 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 <= -2450.0) {
tmp = r * Math.sin(b);
} else if (b <= 11.0) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = r * -Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2450.0: tmp = r * math.sin(b) elif b <= 11.0: tmp = (r * b) / math.cos(a) else: tmp = r * -math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2450.0) tmp = Float64(r * sin(b)); elseif (b <= 11.0) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(r * Float64(-sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2450.0) tmp = r * sin(b); elseif (b <= 11.0) tmp = (r * b) / cos(a); else tmp = r * -sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2450.0], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 11.0], 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 -2450:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{elif}\;b \leq 11:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \left(-\sin b\right)\\
\end{array}
\end{array}
if b < -2450Initial program 57.1%
+-commutative57.1%
Simplified57.1%
clear-num57.1%
associate-/r/57.2%
*-commutative57.2%
Applied egg-rr57.2%
Taylor expanded in a around 0 57.5%
Taylor expanded in b around 0 12.1%
if -2450 < b < 11Initial program 99.7%
associate-/l*99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in b around 0 98.5%
if 11 < b Initial program 56.5%
+-commutative56.5%
Simplified56.5%
clear-num56.4%
associate-/r/56.5%
*-commutative56.5%
Applied egg-rr56.5%
Taylor expanded in a around 0 57.9%
Taylor expanded in b around 0 11.3%
*-commutative11.3%
add-sqr-sqrt4.2%
sqrt-unprod12.2%
sqr-neg12.2%
sqrt-unprod7.9%
add-sqr-sqrt13.0%
distribute-rgt-neg-in13.0%
neg-sub013.0%
*-commutative13.0%
Applied egg-rr13.0%
neg-sub013.0%
distribute-rgt-neg-in13.0%
Simplified13.0%
Final simplification55.6%
(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 78.3%
+-commutative78.3%
Simplified78.3%
clear-num77.8%
associate-/r/78.2%
*-commutative78.2%
Applied egg-rr78.2%
Taylor expanded in a around 0 59.5%
Taylor expanded in b around 0 35.8%
Final simplification35.8%
(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 78.3%
associate-/l*78.3%
+-commutative78.3%
Simplified78.3%
Taylor expanded in b around 0 51.1%
Taylor expanded in a around 0 31.9%
Final simplification31.9%
herbie shell --seed 2024080
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))