
(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(r * Float64(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[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 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(r * Float64(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[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (fma (- 0.0 (sin b)) (sin a) (* (cos a) (cos b))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma((0.0 - sin(b)), sin(a), (cos(a) * cos(b))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(Float64(0.0 - sin(b)), sin(a), Float64(cos(a) * cos(b))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(0.0 - N[Sin[b], $MachinePrecision]), $MachinePrecision] * N[Sin[a], $MachinePrecision] + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(0 - \sin b, \sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 75.8%
cos-sumN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f6499.5%
Applied egg-rr99.5%
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
fma-defineN/A
fma-lowering-fma.f64N/A
sub0-negN/A
--lowering--.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a))));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 75.8%
cos-sumN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f6499.5%
Applied egg-rr99.5%
(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 75.8%
clear-numN/A
un-div-invN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6475.8%
Applied egg-rr75.8%
Final simplification75.8%
(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 75.8%
Final simplification75.8%
(FPCore (r a b)
:precision binary64
(if (<= b -0.062)
(/ 1.0 (/ (/ 1.0 r) (tan b)))
(if (<= b 0.036)
(*
r
(/
(*
b
(+
1.0
(*
b
(* b (+ -0.16666666666666666 (* (* b b) 0.008333333333333333))))))
(cos (+ b a))))
(* r (tan b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.062) {
tmp = 1.0 / ((1.0 / r) / tan(b));
} else if (b <= 0.036) {
tmp = r * ((b * (1.0 + (b * (b * (-0.16666666666666666 + ((b * b) * 0.008333333333333333)))))) / cos((b + 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 (b <= (-0.062d0)) then
tmp = 1.0d0 / ((1.0d0 / r) / tan(b))
else if (b <= 0.036d0) then
tmp = r * ((b * (1.0d0 + (b * (b * ((-0.16666666666666666d0) + ((b * b) * 0.008333333333333333d0)))))) / cos((b + 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 (b <= -0.062) {
tmp = 1.0 / ((1.0 / r) / Math.tan(b));
} else if (b <= 0.036) {
tmp = r * ((b * (1.0 + (b * (b * (-0.16666666666666666 + ((b * b) * 0.008333333333333333)))))) / Math.cos((b + a)));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.062: tmp = 1.0 / ((1.0 / r) / math.tan(b)) elif b <= 0.036: tmp = r * ((b * (1.0 + (b * (b * (-0.16666666666666666 + ((b * b) * 0.008333333333333333)))))) / math.cos((b + a))) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.062) tmp = Float64(1.0 / Float64(Float64(1.0 / r) / tan(b))); elseif (b <= 0.036) tmp = Float64(r * Float64(Float64(b * Float64(1.0 + Float64(b * Float64(b * Float64(-0.16666666666666666 + Float64(Float64(b * b) * 0.008333333333333333)))))) / cos(Float64(b + a)))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.062) tmp = 1.0 / ((1.0 / r) / tan(b)); elseif (b <= 0.036) tmp = r * ((b * (1.0 + (b * (b * (-0.16666666666666666 + ((b * b) * 0.008333333333333333)))))) / cos((b + a))); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.062], N[(1.0 / N[(N[(1.0 / r), $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.036], N[(r * N[(N[(b * N[(1.0 + N[(b * N[(b * N[(-0.16666666666666666 + N[(N[(b * b), $MachinePrecision] * 0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.062:\\
\;\;\;\;\frac{1}{\frac{\frac{1}{r}}{\tan b}}\\
\mathbf{elif}\;b \leq 0.036:\\
\;\;\;\;r \cdot \frac{b \cdot \left(1 + b \cdot \left(b \cdot \left(-0.16666666666666666 + \left(b \cdot b\right) \cdot 0.008333333333333333\right)\right)\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if b < -0.062Initial program 60.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6460.3%
Simplified60.3%
clear-numN/A
un-div-invN/A
clear-numN/A
metadata-evalN/A
/-lowering-/.f64N/A
metadata-evalN/A
/-lowering-/.f64N/A
clear-numN/A
metadata-evalN/A
/-lowering-/.f64N/A
metadata-evalN/A
quot-tanN/A
tan-lowering-tan.f6460.4%
Applied egg-rr60.4%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
tan-lowering-tan.f6460.5%
Applied egg-rr60.5%
if -0.062 < b < 0.0359999999999999973Initial program 98.2%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.2%
Simplified98.2%
if 0.0359999999999999973 < b Initial program 53.4%
Taylor expanded in a around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6452.4%
Simplified52.4%
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6452.6%
Applied egg-rr52.6%
Final simplification75.7%
(FPCore (r a b)
:precision binary64
(if (<= b -0.062)
(/ 1.0 (/ (/ 1.0 r) (tan b)))
(if (<= b 0.0052)
(* r (/ (* b (+ 1.0 (* -0.16666666666666666 (* b b)))) (cos (+ b a))))
(* r (tan b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.062) {
tmp = 1.0 / ((1.0 / r) / tan(b));
} else if (b <= 0.0052) {
tmp = r * ((b * (1.0 + (-0.16666666666666666 * (b * b)))) / cos((b + 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 (b <= (-0.062d0)) then
tmp = 1.0d0 / ((1.0d0 / r) / tan(b))
else if (b <= 0.0052d0) then
tmp = r * ((b * (1.0d0 + ((-0.16666666666666666d0) * (b * b)))) / cos((b + 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 (b <= -0.062) {
tmp = 1.0 / ((1.0 / r) / Math.tan(b));
} else if (b <= 0.0052) {
tmp = r * ((b * (1.0 + (-0.16666666666666666 * (b * b)))) / Math.cos((b + a)));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.062: tmp = 1.0 / ((1.0 / r) / math.tan(b)) elif b <= 0.0052: tmp = r * ((b * (1.0 + (-0.16666666666666666 * (b * b)))) / math.cos((b + a))) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.062) tmp = Float64(1.0 / Float64(Float64(1.0 / r) / tan(b))); elseif (b <= 0.0052) tmp = Float64(r * Float64(Float64(b * Float64(1.0 + Float64(-0.16666666666666666 * Float64(b * b)))) / cos(Float64(b + a)))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.062) tmp = 1.0 / ((1.0 / r) / tan(b)); elseif (b <= 0.0052) tmp = r * ((b * (1.0 + (-0.16666666666666666 * (b * b)))) / cos((b + a))); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.062], N[(1.0 / N[(N[(1.0 / r), $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.0052], N[(r * N[(N[(b * N[(1.0 + N[(-0.16666666666666666 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.062:\\
\;\;\;\;\frac{1}{\frac{\frac{1}{r}}{\tan b}}\\
\mathbf{elif}\;b \leq 0.0052:\\
\;\;\;\;r \cdot \frac{b \cdot \left(1 + -0.16666666666666666 \cdot \left(b \cdot b\right)\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if b < -0.062Initial program 60.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6460.3%
Simplified60.3%
clear-numN/A
un-div-invN/A
clear-numN/A
metadata-evalN/A
/-lowering-/.f64N/A
metadata-evalN/A
/-lowering-/.f64N/A
clear-numN/A
metadata-evalN/A
/-lowering-/.f64N/A
metadata-evalN/A
quot-tanN/A
tan-lowering-tan.f6460.4%
Applied egg-rr60.4%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
tan-lowering-tan.f6460.5%
Applied egg-rr60.5%
if -0.062 < b < 0.0051999999999999998Initial program 98.2%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.2%
Simplified98.2%
if 0.0051999999999999998 < b Initial program 53.4%
Taylor expanded in a around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6452.4%
Simplified52.4%
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6452.6%
Applied egg-rr52.6%
Final simplification75.7%
(FPCore (r a b) :precision binary64 (if (<= b -0.062) (/ 1.0 (/ (/ 1.0 r) (tan b))) (if (<= b 0.00037) (* r (/ b (cos (+ b a)))) (* r (tan b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.062) {
tmp = 1.0 / ((1.0 / r) / tan(b));
} else if (b <= 0.00037) {
tmp = r * (b / cos((b + 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 (b <= (-0.062d0)) then
tmp = 1.0d0 / ((1.0d0 / r) / tan(b))
else if (b <= 0.00037d0) then
tmp = r * (b / cos((b + 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 (b <= -0.062) {
tmp = 1.0 / ((1.0 / r) / Math.tan(b));
} else if (b <= 0.00037) {
tmp = r * (b / Math.cos((b + a)));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.062: tmp = 1.0 / ((1.0 / r) / math.tan(b)) elif b <= 0.00037: tmp = r * (b / math.cos((b + a))) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.062) tmp = Float64(1.0 / Float64(Float64(1.0 / r) / tan(b))); elseif (b <= 0.00037) tmp = Float64(r * Float64(b / cos(Float64(b + a)))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.062) tmp = 1.0 / ((1.0 / r) / tan(b)); elseif (b <= 0.00037) tmp = r * (b / cos((b + a))); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.062], N[(1.0 / N[(N[(1.0 / r), $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.00037], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.062:\\
\;\;\;\;\frac{1}{\frac{\frac{1}{r}}{\tan b}}\\
\mathbf{elif}\;b \leq 0.00037:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if b < -0.062Initial program 60.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6460.3%
Simplified60.3%
clear-numN/A
un-div-invN/A
clear-numN/A
metadata-evalN/A
/-lowering-/.f64N/A
metadata-evalN/A
/-lowering-/.f64N/A
clear-numN/A
metadata-evalN/A
/-lowering-/.f64N/A
metadata-evalN/A
quot-tanN/A
tan-lowering-tan.f6460.4%
Applied egg-rr60.4%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
tan-lowering-tan.f6460.5%
Applied egg-rr60.5%
if -0.062 < b < 3.6999999999999999e-4Initial program 98.2%
Taylor expanded in b around 0
Simplified98.0%
if 3.6999999999999999e-4 < b Initial program 53.4%
Taylor expanded in a around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6452.4%
Simplified52.4%
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6452.6%
Applied egg-rr52.6%
Final simplification75.7%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* r (tan b)))) (if (<= b -0.062) t_0 (if (<= b 9.5e-6) (* r (/ b (cos (+ b a)))) t_0))))
double code(double r, double a, double b) {
double t_0 = r * tan(b);
double tmp;
if (b <= -0.062) {
tmp = t_0;
} else if (b <= 9.5e-6) {
tmp = r * (b / cos((b + 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 = r * tan(b)
if (b <= (-0.062d0)) then
tmp = t_0
else if (b <= 9.5d-6) then
tmp = r * (b / cos((b + a)))
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.tan(b);
double tmp;
if (b <= -0.062) {
tmp = t_0;
} else if (b <= 9.5e-6) {
tmp = r * (b / Math.cos((b + a)));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * math.tan(b) tmp = 0 if b <= -0.062: tmp = t_0 elif b <= 9.5e-6: tmp = r * (b / math.cos((b + a))) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * tan(b)) tmp = 0.0 if (b <= -0.062) tmp = t_0; elseif (b <= 9.5e-6) tmp = Float64(r * Float64(b / cos(Float64(b + a)))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * tan(b); tmp = 0.0; if (b <= -0.062) tmp = t_0; elseif (b <= 9.5e-6) tmp = r * (b / cos((b + a))); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.062], t$95$0, If[LessEqual[b, 9.5e-6], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -0.062:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -0.062 or 9.5000000000000005e-6 < b Initial program 57.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6456.7%
Simplified56.7%
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6456.8%
Applied egg-rr56.8%
if -0.062 < b < 9.5000000000000005e-6Initial program 98.2%
Taylor expanded in b around 0
Simplified98.0%
Final simplification75.7%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* r (tan b)))) (if (<= b -0.062) t_0 (if (<= b 4e-5) (* b (/ r (cos a))) t_0))))
double code(double r, double a, double b) {
double t_0 = r * tan(b);
double tmp;
if (b <= -0.062) {
tmp = t_0;
} else if (b <= 4e-5) {
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 = r * tan(b)
if (b <= (-0.062d0)) then
tmp = t_0
else if (b <= 4d-5) 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 = r * Math.tan(b);
double tmp;
if (b <= -0.062) {
tmp = t_0;
} else if (b <= 4e-5) {
tmp = b * (r / Math.cos(a));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * math.tan(b) tmp = 0 if b <= -0.062: tmp = t_0 elif b <= 4e-5: tmp = b * (r / math.cos(a)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * tan(b)) tmp = 0.0 if (b <= -0.062) tmp = t_0; elseif (b <= 4e-5) tmp = Float64(b * Float64(r / cos(a))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * tan(b); tmp = 0.0; if (b <= -0.062) tmp = t_0; elseif (b <= 4e-5) tmp = b * (r / cos(a)); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.062], t$95$0, If[LessEqual[b, 4e-5], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -0.062:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-5}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -0.062 or 4.00000000000000033e-5 < b Initial program 57.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6456.7%
Simplified56.7%
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6456.8%
Applied egg-rr56.8%
if -0.062 < b < 4.00000000000000033e-5Initial program 98.2%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6498.0%
Simplified98.0%
Final simplification75.6%
(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 75.8%
Taylor expanded in a around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6460.6%
Simplified60.6%
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6460.7%
Applied egg-rr60.7%
Final simplification60.7%
(FPCore (r a b) :precision binary64 (* r (/ b (+ 1.0 (* b (* b -0.5))))))
double code(double r, double a, double b) {
return r * (b / (1.0 + (b * (b * -0.5))));
}
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 / (1.0d0 + (b * (b * (-0.5d0)))))
end function
public static double code(double r, double a, double b) {
return r * (b / (1.0 + (b * (b * -0.5))));
}
def code(r, a, b): return r * (b / (1.0 + (b * (b * -0.5))))
function code(r, a, b) return Float64(r * Float64(b / Float64(1.0 + Float64(b * Float64(b * -0.5))))) end
function tmp = code(r, a, b) tmp = r * (b / (1.0 + (b * (b * -0.5)))); end
code[r_, a_, b_] := N[(r * N[(b / N[(1.0 + N[(b * N[(b * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{1 + b \cdot \left(b \cdot -0.5\right)}
\end{array}
Initial program 75.8%
Taylor expanded in a around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6460.6%
Simplified60.6%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6432.2%
Simplified32.2%
Taylor expanded in b around 0
Simplified32.1%
(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 75.8%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6446.9%
Simplified46.9%
Taylor expanded in a around 0
*-commutativeN/A
*-lowering-*.f6432.1%
Simplified32.1%
herbie shell --seed 2024145
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))