
(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 15 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))))
(fma (- (sin b)) (sin 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))) + fma(-sin(b), sin(a), (sin(b) * sin(a)))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a)))) + fma(Float64(-sin(b)), sin(a), Float64(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] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right) + \mathsf{fma}\left(-\sin b, \sin a, \sin b \cdot \sin a\right)}
\end{array}
Initial program 73.8%
associate-/l*73.7%
remove-double-neg73.7%
remove-double-neg73.7%
+-commutative73.7%
Simplified73.7%
cos-sum99.5%
*-un-lft-identity99.5%
prod-diff99.5%
Applied egg-rr99.5%
fmm-undef99.5%
*-commutative99.5%
*-rgt-identity99.5%
*-commutative99.5%
fma-undefine99.5%
*-rgt-identity99.5%
distribute-lft-neg-in99.5%
*-rgt-identity99.5%
fma-undefine99.5%
*-commutative99.5%
Simplified99.5%
cancel-sign-sub-inv99.5%
*-commutative99.5%
fma-define99.6%
Applied egg-rr99.6%
Final simplification99.6%
(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(sin(b) * Float64(-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 \left(-\sin a\right)\right)}
\end{array}
Initial program 73.8%
associate-/l*73.7%
remove-double-neg73.7%
remove-double-neg73.7%
+-commutative73.7%
Simplified73.7%
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 73.8%
associate-/l*73.7%
remove-double-neg73.7%
remove-double-neg73.7%
+-commutative73.7%
Simplified73.7%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ 1.0 (- (* (cos b) (/ (cos a) (* r (sin b)))) (/ (sin a) r))))
double code(double r, double a, double b) {
return 1.0 / ((cos(b) * (cos(a) / (r * 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 = 1.0d0 / ((cos(b) * (cos(a) / (r * sin(b)))) - (sin(a) / r))
end function
public static double code(double r, double a, double b) {
return 1.0 / ((Math.cos(b) * (Math.cos(a) / (r * Math.sin(b)))) - (Math.sin(a) / r));
}
def code(r, a, b): return 1.0 / ((math.cos(b) * (math.cos(a) / (r * math.sin(b)))) - (math.sin(a) / r))
function code(r, a, b) return Float64(1.0 / Float64(Float64(cos(b) * Float64(cos(a) / Float64(r * sin(b)))) - Float64(sin(a) / r))) end
function tmp = code(r, a, b) tmp = 1.0 / ((cos(b) * (cos(a) / (r * sin(b)))) - (sin(a) / r)); end
code[r_, a_, b_] := N[(1.0 / N[(N[(N[Cos[b], $MachinePrecision] * N[(N[Cos[a], $MachinePrecision] / N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\cos b \cdot \frac{\cos a}{r \cdot \sin b} - \frac{\sin a}{r}}
\end{array}
Initial program 73.8%
associate-/l*73.7%
remove-double-neg73.7%
remove-double-neg73.7%
+-commutative73.7%
Simplified73.7%
associate-*r/73.8%
clear-num72.9%
*-commutative72.9%
Applied egg-rr72.9%
cos-sum98.6%
div-sub93.9%
Applied egg-rr93.9%
associate-/l*93.9%
remove-double-neg93.9%
neg-mul-193.9%
*-commutative93.9%
distribute-rgt-neg-in93.9%
distribute-frac-neg93.9%
associate-*r*93.9%
*-commutative93.9%
neg-mul-193.9%
distribute-neg-frac93.9%
times-frac98.6%
*-inverses98.6%
distribute-lft-neg-in98.6%
metadata-eval98.6%
associate-*r/98.6%
Simplified98.6%
Final simplification98.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.5e-8) (not (<= b 0.035))) (* r (/ (sin b) (cos b))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.5e-8) || !(b <= 0.035)) {
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 <= (-4.5d-8)) .or. (.not. (b <= 0.035d0))) 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 <= -4.5e-8) || !(b <= 0.035)) {
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 <= -4.5e-8) or not (b <= 0.035): 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 <= -4.5e-8) || !(b <= 0.035)) 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 <= -4.5e-8) || ~((b <= 0.035))) 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, -4.5e-8], N[Not[LessEqual[b, 0.035]], $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 -4.5 \cdot 10^{-8} \lor \neg \left(b \leq 0.035\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -4.49999999999999993e-8 or 0.035000000000000003 < b Initial program 51.7%
associate-/l*51.6%
remove-double-neg51.6%
remove-double-neg51.6%
+-commutative51.6%
Simplified51.6%
Taylor expanded in a around 0 50.6%
if -4.49999999999999993e-8 < b < 0.035000000000000003Initial program 99.2%
associate-/l*99.2%
remove-double-neg99.2%
remove-double-neg99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in b around 0 99.2%
Final simplification73.2%
(FPCore (r a b) :precision binary64 (if (<= b -4.5e-8) (* (sin b) (/ r (cos b))) (if (<= b 0.035) (* r (/ b (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -4.5e-8) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 0.035) {
tmp = r * (b / cos(a));
} else {
tmp = r * (sin(b) / 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.5d-8)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 0.035d0) then
tmp = r * (b / cos(a))
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -4.5e-8) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 0.035) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -4.5e-8: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 0.035: tmp = r * (b / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -4.5e-8) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 0.035) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -4.5e-8) tmp = sin(b) * (r / cos(b)); elseif (b <= 0.035) tmp = r * (b / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -4.5e-8], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.035], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-8}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 0.035:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -4.49999999999999993e-8Initial program 57.2%
associate-/l*57.0%
remove-double-neg57.0%
remove-double-neg57.0%
+-commutative57.0%
Simplified57.0%
Taylor expanded in a around 0 57.3%
*-commutative57.3%
associate-/l*57.2%
Simplified57.2%
if -4.49999999999999993e-8 < b < 0.035000000000000003Initial program 99.2%
associate-/l*99.2%
remove-double-neg99.2%
remove-double-neg99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in b around 0 99.2%
if 0.035000000000000003 < b Initial program 47.9%
associate-/l*47.9%
remove-double-neg47.9%
remove-double-neg47.9%
+-commutative47.9%
Simplified47.9%
Taylor expanded in a around 0 46.1%
Final simplification73.2%
(FPCore (r a b) :precision binary64 (if (<= b -4.5e-8) (/ (sin b) (/ (cos b) r)) (if (<= b 0.035) (* r (/ b (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -4.5e-8) {
tmp = sin(b) / (cos(b) / r);
} else if (b <= 0.035) {
tmp = r * (b / cos(a));
} else {
tmp = r * (sin(b) / 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.5d-8)) then
tmp = sin(b) / (cos(b) / r)
else if (b <= 0.035d0) then
tmp = r * (b / cos(a))
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -4.5e-8) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else if (b <= 0.035) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -4.5e-8: tmp = math.sin(b) / (math.cos(b) / r) elif b <= 0.035: tmp = r * (b / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -4.5e-8) tmp = Float64(sin(b) / Float64(cos(b) / r)); elseif (b <= 0.035) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -4.5e-8) tmp = sin(b) / (cos(b) / r); elseif (b <= 0.035) tmp = r * (b / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -4.5e-8], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.035], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{elif}\;b \leq 0.035:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -4.49999999999999993e-8Initial program 57.2%
associate-/l*57.0%
remove-double-neg57.0%
remove-double-neg57.0%
+-commutative57.0%
Simplified57.0%
cos-sum99.2%
cancel-sign-sub-inv99.2%
fma-define99.2%
Applied egg-rr99.2%
associate-*r/99.3%
*-commutative99.3%
distribute-lft-neg-out99.3%
fmm-def99.3%
cos-sum57.2%
associate-*r/57.1%
clear-num57.1%
un-div-inv57.1%
Applied egg-rr57.1%
Taylor expanded in a around 0 57.2%
if -4.49999999999999993e-8 < b < 0.035000000000000003Initial program 99.2%
associate-/l*99.2%
remove-double-neg99.2%
remove-double-neg99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in b around 0 99.2%
if 0.035000000000000003 < b Initial program 47.9%
associate-/l*47.9%
remove-double-neg47.9%
remove-double-neg47.9%
+-commutative47.9%
Simplified47.9%
Taylor expanded in a around 0 46.1%
Final simplification73.2%
(FPCore (r a b) :precision binary64 (if (<= b -4.5e-8) (/ (* r (sin b)) (cos b)) (if (<= b 0.035) (* r (/ b (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -4.5e-8) {
tmp = (r * sin(b)) / cos(b);
} else if (b <= 0.035) {
tmp = r * (b / cos(a));
} else {
tmp = r * (sin(b) / 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.5d-8)) then
tmp = (r * sin(b)) / cos(b)
else if (b <= 0.035d0) then
tmp = r * (b / cos(a))
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -4.5e-8) {
tmp = (r * Math.sin(b)) / Math.cos(b);
} else if (b <= 0.035) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -4.5e-8: tmp = (r * math.sin(b)) / math.cos(b) elif b <= 0.035: tmp = r * (b / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -4.5e-8) tmp = Float64(Float64(r * sin(b)) / cos(b)); elseif (b <= 0.035) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -4.5e-8) tmp = (r * sin(b)) / cos(b); elseif (b <= 0.035) tmp = r * (b / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -4.5e-8], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.035], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{elif}\;b \leq 0.035:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -4.49999999999999993e-8Initial program 57.2%
associate-/l*57.0%
remove-double-neg57.0%
remove-double-neg57.0%
+-commutative57.0%
Simplified57.0%
Taylor expanded in a around 0 57.3%
*-commutative57.3%
Simplified57.3%
if -4.49999999999999993e-8 < b < 0.035000000000000003Initial program 99.2%
associate-/l*99.2%
remove-double-neg99.2%
remove-double-neg99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in b around 0 99.2%
if 0.035000000000000003 < b Initial program 47.9%
associate-/l*47.9%
remove-double-neg47.9%
remove-double-neg47.9%
+-commutative47.9%
Simplified47.9%
Taylor expanded in a around 0 46.1%
Final simplification73.2%
(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 73.8%
associate-/l*73.7%
remove-double-neg73.7%
remove-double-neg73.7%
+-commutative73.7%
Simplified73.7%
Final simplification73.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(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 73.8%
Final simplification73.8%
(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 73.8%
associate-/l*73.7%
remove-double-neg73.7%
remove-double-neg73.7%
+-commutative73.7%
Simplified73.7%
Taylor expanded in b around 0 52.5%
Final simplification52.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -24.0) (not (<= b 11.0))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -24.0) || !(b <= 11.0)) {
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 <= (-24.0d0)) .or. (.not. (b <= 11.0d0))) 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 <= -24.0) || !(b <= 11.0)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -24.0) or not (b <= 11.0): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -24.0) || !(b <= 11.0)) 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 <= -24.0) || ~((b <= 11.0))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -24.0], N[Not[LessEqual[b, 11.0]], $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 -24 \lor \neg \left(b \leq 11\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -24 or 11 < b Initial program 50.6%
+-commutative50.6%
Simplified50.6%
Taylor expanded in b around 0 11.2%
Taylor expanded in a around 0 10.9%
*-commutative10.9%
Simplified10.9%
if -24 < b < 11Initial program 99.2%
associate-/l*99.2%
remove-double-neg99.2%
remove-double-neg99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in b around 0 97.9%
Final simplification52.4%
(FPCore (r a b) :precision binary64 (if (<= b 340000.0) (/ (* r b) (cos (+ b a))) (* r (sin b))))
double code(double r, double a, double b) {
double tmp;
if (b <= 340000.0) {
tmp = (r * b) / cos((b + 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 <= 340000.0d0) then
tmp = (r * b) / cos((b + 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 <= 340000.0) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = r * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 340000.0: tmp = (r * b) / math.cos((b + a)) else: tmp = r * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 340000.0) tmp = Float64(Float64(r * b) / cos(Float64(b + a))); else tmp = Float64(r * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 340000.0) tmp = (r * b) / cos((b + a)); else tmp = r * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 340000.0], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 340000:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \sin b\\
\end{array}
\end{array}
if b < 3.4e5Initial program 85.9%
+-commutative85.9%
Simplified85.9%
Taylor expanded in b around 0 68.9%
if 3.4e5 < b Initial program 46.6%
+-commutative46.6%
Simplified46.6%
Taylor expanded in b around 0 11.6%
Taylor expanded in a around 0 10.9%
*-commutative10.9%
Simplified10.9%
Final simplification51.0%
(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 73.8%
+-commutative73.8%
Simplified73.8%
Taylor expanded in b around 0 52.5%
Taylor expanded in a around 0 37.3%
*-commutative37.3%
Simplified37.3%
Final simplification37.3%
(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 73.8%
associate-/l*73.7%
remove-double-neg73.7%
remove-double-neg73.7%
+-commutative73.7%
Simplified73.7%
Taylor expanded in b around 0 48.6%
Taylor expanded in a around 0 33.6%
Final simplification33.6%
herbie shell --seed 2024115
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))