
(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 11 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) r) (fma (cos b) (cos a) (* (sin a) (- (sin b))))))
double code(double r, double a, double b) {
return (sin(b) * r) / fma(cos(b), cos(a), (sin(a) * -sin(b)));
}
function code(r, a, b) return Float64(Float64(sin(b) * r) / fma(cos(b), cos(a), Float64(sin(a) * Float64(-sin(b))))) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\mathsf{fma}\left(\cos b, \cos a, \sin a \cdot \left(-\sin b\right)\right)}
\end{array}
Initial program 79.2%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (- (* (cos a) (cos b)) (* (sin a) (sin b)))))
double code(double r, double a, double b) {
return (sin(b) * r) / ((cos(a) * cos(b)) - (sin(a) * 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 = (sin(b) * r) / ((cos(a) * cos(b)) - (sin(a) * sin(b)))
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(a) * Math.sin(b)));
}
def code(r, a, b): return (math.sin(b) * r) / ((math.cos(a) * math.cos(b)) - (math.sin(a) * math.sin(b)))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(a) * sin(b)))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / ((cos(a) * cos(b)) - (sin(a) * sin(b))); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos a \cdot \cos b - \sin a \cdot \sin b}
\end{array}
Initial program 79.2%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (if (<= a -6.4e-6) (* (/ (sin b) (cos a)) r) (if (<= a 4.4e-9) (* (tan b) r) (/ (* (sin b) r) (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -6.4e-6) {
tmp = (sin(b) / cos(a)) * r;
} else if (a <= 4.4e-9) {
tmp = tan(b) * r;
} else {
tmp = (sin(b) * r) / 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 <= (-6.4d-6)) then
tmp = (sin(b) / cos(a)) * r
else if (a <= 4.4d-9) then
tmp = tan(b) * r
else
tmp = (sin(b) * r) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -6.4e-6) {
tmp = (Math.sin(b) / Math.cos(a)) * r;
} else if (a <= 4.4e-9) {
tmp = Math.tan(b) * r;
} else {
tmp = (Math.sin(b) * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -6.4e-6: tmp = (math.sin(b) / math.cos(a)) * r elif a <= 4.4e-9: tmp = math.tan(b) * r else: tmp = (math.sin(b) * r) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -6.4e-6) tmp = Float64(Float64(sin(b) / cos(a)) * r); elseif (a <= 4.4e-9) tmp = Float64(tan(b) * r); else tmp = Float64(Float64(sin(b) * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -6.4e-6) tmp = (sin(b) / cos(a)) * r; elseif (a <= 4.4e-9) tmp = tan(b) * r; else tmp = (sin(b) * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -6.4e-6], N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision], If[LessEqual[a, 4.4e-9], N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.4 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sin b}{\cos a} \cdot r\\
\mathbf{elif}\;a \leq 4.4 \cdot 10^{-9}:\\
\;\;\;\;\tan b \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos a}\\
\end{array}
\end{array}
if a < -6.3999999999999997e-6Initial program 61.5%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6461.5
Applied rewrites61.5%
Taylor expanded in b around 0
lower-cos.f6461.2
Applied rewrites61.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6461.2
Applied rewrites61.2%
if -6.3999999999999997e-6 < a < 4.3999999999999997e-9Initial program 99.5%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6499.4
Applied rewrites99.4%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6499.4
Applied rewrites99.4%
Applied rewrites99.5%
if 4.3999999999999997e-9 < a Initial program 48.7%
Taylor expanded in b around 0
lower-cos.f6448.8
Applied rewrites48.8%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (<= a -6.4e-6) (* (/ (sin b) (cos a)) r) (if (<= a 4.4e-9) (* (tan b) r) (* (/ r (cos a)) (sin b)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -6.4e-6) {
tmp = (sin(b) / cos(a)) * r;
} else if (a <= 4.4e-9) {
tmp = tan(b) * r;
} 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 <= (-6.4d-6)) then
tmp = (sin(b) / cos(a)) * r
else if (a <= 4.4d-9) then
tmp = tan(b) * r
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 <= -6.4e-6) {
tmp = (Math.sin(b) / Math.cos(a)) * r;
} else if (a <= 4.4e-9) {
tmp = Math.tan(b) * r;
} else {
tmp = (r / Math.cos(a)) * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -6.4e-6: tmp = (math.sin(b) / math.cos(a)) * r elif a <= 4.4e-9: tmp = math.tan(b) * r else: tmp = (r / math.cos(a)) * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -6.4e-6) tmp = Float64(Float64(sin(b) / cos(a)) * r); elseif (a <= 4.4e-9) tmp = Float64(tan(b) * r); else tmp = Float64(Float64(r / cos(a)) * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -6.4e-6) tmp = (sin(b) / cos(a)) * r; elseif (a <= 4.4e-9) tmp = tan(b) * r; else tmp = (r / cos(a)) * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -6.4e-6], N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision], If[LessEqual[a, 4.4e-9], N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision], N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.4 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sin b}{\cos a} \cdot r\\
\mathbf{elif}\;a \leq 4.4 \cdot 10^{-9}:\\
\;\;\;\;\tan b \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos a} \cdot \sin b\\
\end{array}
\end{array}
if a < -6.3999999999999997e-6Initial program 61.5%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6461.5
Applied rewrites61.5%
Taylor expanded in b around 0
lower-cos.f6461.2
Applied rewrites61.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6461.2
Applied rewrites61.2%
if -6.3999999999999997e-6 < a < 4.3999999999999997e-9Initial program 99.5%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6499.4
Applied rewrites99.4%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6499.4
Applied rewrites99.4%
Applied rewrites99.5%
if 4.3999999999999997e-9 < a Initial program 48.7%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6448.6
Applied rewrites48.6%
Taylor expanded in b around 0
lower-cos.f6448.8
Applied rewrites48.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6448.7
Applied rewrites48.7%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (/ r (cos a)) (sin b)))) (if (<= a -6.4e-6) t_0 (if (<= a 4.4e-9) (* (tan b) r) t_0))))
double code(double r, double a, double b) {
double t_0 = (r / cos(a)) * sin(b);
double tmp;
if (a <= -6.4e-6) {
tmp = t_0;
} else if (a <= 4.4e-9) {
tmp = tan(b) * r;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = (r / cos(a)) * sin(b)
if (a <= (-6.4d-6)) then
tmp = t_0
else if (a <= 4.4d-9) then
tmp = tan(b) * r
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = (r / Math.cos(a)) * Math.sin(b);
double tmp;
if (a <= -6.4e-6) {
tmp = t_0;
} else if (a <= 4.4e-9) {
tmp = Math.tan(b) * r;
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = (r / math.cos(a)) * math.sin(b) tmp = 0 if a <= -6.4e-6: tmp = t_0 elif a <= 4.4e-9: tmp = math.tan(b) * r else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(Float64(r / cos(a)) * sin(b)) tmp = 0.0 if (a <= -6.4e-6) tmp = t_0; elseif (a <= 4.4e-9) tmp = Float64(tan(b) * r); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = (r / cos(a)) * sin(b); tmp = 0.0; if (a <= -6.4e-6) tmp = t_0; elseif (a <= 4.4e-9) tmp = tan(b) * r; else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -6.4e-6], t$95$0, If[LessEqual[a, 4.4e-9], N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{r}{\cos a} \cdot \sin b\\
\mathbf{if}\;a \leq -6.4 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 4.4 \cdot 10^{-9}:\\
\;\;\;\;\tan b \cdot r\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -6.3999999999999997e-6 or 4.3999999999999997e-9 < a Initial program 55.9%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6455.9
Applied rewrites55.9%
Taylor expanded in b around 0
lower-cos.f6455.8
Applied rewrites55.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6455.7
Applied rewrites55.7%
if -6.3999999999999997e-6 < a < 4.3999999999999997e-9Initial program 99.5%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6499.4
Applied rewrites99.4%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6499.4
Applied rewrites99.4%
Applied rewrites99.5%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (cos (+ a b))))
double code(double r, double a, double b) {
return (sin(b) * r) / 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 = (sin(b) * r) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / Math.cos((a + b));
}
def code(r, a, b): return (math.sin(b) * r) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(sin(b) * r) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos \left(a + b\right)}
\end{array}
Initial program 79.2%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (* (/ r (cos (+ a b))) (sin b)))
double code(double r, double a, double b) {
return (r / cos((a + b))) * 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 / cos((a + b))) * sin(b)
end function
public static double code(double r, double a, double b) {
return (r / Math.cos((a + b))) * Math.sin(b);
}
def code(r, a, b): return (r / math.cos((a + b))) * math.sin(b)
function code(r, a, b) return Float64(Float64(r / cos(Float64(a + b))) * sin(b)) end
function tmp = code(r, a, b) tmp = (r / cos((a + b))) * sin(b); end
code[r_, a_, b_] := N[(N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos \left(a + b\right)} \cdot \sin b
\end{array}
Initial program 79.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6479.2
Applied rewrites79.2%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (tan b) r))) (if (<= b -6.2e-6) t_0 (if (<= b 3.9e-10) (/ (* b r) (cos a)) t_0))))
double code(double r, double a, double b) {
double t_0 = tan(b) * r;
double tmp;
if (b <= -6.2e-6) {
tmp = t_0;
} else if (b <= 3.9e-10) {
tmp = (b * r) / cos(a);
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = tan(b) * r
if (b <= (-6.2d-6)) then
tmp = t_0
else if (b <= 3.9d-10) then
tmp = (b * r) / cos(a)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.tan(b) * r;
double tmp;
if (b <= -6.2e-6) {
tmp = t_0;
} else if (b <= 3.9e-10) {
tmp = (b * r) / Math.cos(a);
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = math.tan(b) * r tmp = 0 if b <= -6.2e-6: tmp = t_0 elif b <= 3.9e-10: tmp = (b * r) / math.cos(a) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(tan(b) * r) tmp = 0.0 if (b <= -6.2e-6) tmp = t_0; elseif (b <= 3.9e-10) tmp = Float64(Float64(b * r) / cos(a)); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = tan(b) * r; tmp = 0.0; if (b <= -6.2e-6) tmp = t_0; elseif (b <= 3.9e-10) tmp = (b * r) / cos(a); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -6.2e-6], t$95$0, If[LessEqual[b, 3.9e-10], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan b \cdot r\\
\mathbf{if}\;b \leq -6.2 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 3.9 \cdot 10^{-10}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -6.1999999999999999e-6 or 3.9e-10 < b Initial program 61.0%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6460.9
Applied rewrites60.9%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6460.4
Applied rewrites60.4%
Applied rewrites60.5%
if -6.1999999999999999e-6 < b < 3.9e-10Initial program 99.9%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6499.8
Applied rewrites99.8%
Applied rewrites99.9%
Final simplification79.0%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (tan b) r))) (if (<= b -6.2e-6) t_0 (if (<= b 3.9e-10) (* (/ b (cos a)) r) t_0))))
double code(double r, double a, double b) {
double t_0 = tan(b) * r;
double tmp;
if (b <= -6.2e-6) {
tmp = t_0;
} else if (b <= 3.9e-10) {
tmp = (b / cos(a)) * r;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = tan(b) * r
if (b <= (-6.2d-6)) then
tmp = t_0
else if (b <= 3.9d-10) then
tmp = (b / cos(a)) * r
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.tan(b) * r;
double tmp;
if (b <= -6.2e-6) {
tmp = t_0;
} else if (b <= 3.9e-10) {
tmp = (b / Math.cos(a)) * r;
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = math.tan(b) * r tmp = 0 if b <= -6.2e-6: tmp = t_0 elif b <= 3.9e-10: tmp = (b / math.cos(a)) * r else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(tan(b) * r) tmp = 0.0 if (b <= -6.2e-6) tmp = t_0; elseif (b <= 3.9e-10) tmp = Float64(Float64(b / cos(a)) * r); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = tan(b) * r; tmp = 0.0; if (b <= -6.2e-6) tmp = t_0; elseif (b <= 3.9e-10) tmp = (b / cos(a)) * r; else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -6.2e-6], t$95$0, If[LessEqual[b, 3.9e-10], N[(N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan b \cdot r\\
\mathbf{if}\;b \leq -6.2 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 3.9 \cdot 10^{-10}:\\
\;\;\;\;\frac{b}{\cos a} \cdot r\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -6.1999999999999999e-6 or 3.9e-10 < b Initial program 61.0%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6460.9
Applied rewrites60.9%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6460.4
Applied rewrites60.4%
Applied rewrites60.5%
if -6.1999999999999999e-6 < b < 3.9e-10Initial program 99.9%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6499.8
Applied rewrites99.8%
Applied rewrites99.9%
Final simplification78.9%
(FPCore (r a b) :precision binary64 (* (tan b) r))
double code(double r, double a, double b) {
return tan(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 = tan(b) * r
end function
public static double code(double r, double a, double b) {
return Math.tan(b) * r;
}
def code(r, a, b): return math.tan(b) * r
function code(r, a, b) return Float64(tan(b) * r) end
function tmp = code(r, a, b) tmp = tan(b) * r; end
code[r_, a_, b_] := N[(N[Tan[b], $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\tan b \cdot r
\end{array}
Initial program 79.2%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6479.1
Applied rewrites79.1%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6465.4
Applied rewrites65.4%
Applied rewrites65.4%
Final simplification65.4%
(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 79.2%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6449.3
Applied rewrites49.3%
Taylor expanded in a around 0
Applied rewrites35.6%
herbie shell --seed 2024270
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))