
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ eh (* ew (tan t)))))) (fabs (fma (* eh (cos t)) (sin t_1) (* (* ew (sin t)) (cos t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (ew * tan(t))));
return fabs(fma((eh * cos(t)), sin(t_1), ((ew * sin(t)) * cos(t_1))));
}
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(ew * tan(t)))) return abs(fma(Float64(eh * cos(t)), sin(t_1), Float64(Float64(ew * sin(t)) * cos(t_1)))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
\left|\mathsf{fma}\left(eh \cdot \cos t, \sin t\_1, \left(ew \cdot \sin t\right) \cdot \cos t\_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Taylor expanded in ew around 0
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-tan.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ eh (* ew (tan t)))))
(t_2
(/
1.0
(fabs
(/
1.0
(fma
eh
(* (cos t) (sin t_1))
(/
(* ew (sin t))
(sqrt
(fma (pow (tan t) -2.0) (* (/ eh ew) (/ eh ew)) 1.0)))))))))
(if (<= t -0.0003)
t_2
(if (<= t 0.005)
(fabs
(+
(* t (* (cos t_1) (fma ew (* (* t t) -0.16666666666666666) ew)))
(*
(fma
(* t t)
(fma (* eh (* t t)) 0.041666666666666664 (* eh -0.5))
eh)
(sin (atan (/ (/ eh ew) (tan t)))))))
t_2))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (ew * tan(t))));
double t_2 = 1.0 / fabs((1.0 / fma(eh, (cos(t) * sin(t_1)), ((ew * sin(t)) / sqrt(fma(pow(tan(t), -2.0), ((eh / ew) * (eh / ew)), 1.0))))));
double tmp;
if (t <= -0.0003) {
tmp = t_2;
} else if (t <= 0.005) {
tmp = fabs(((t * (cos(t_1) * fma(ew, ((t * t) * -0.16666666666666666), ew))) + (fma((t * t), fma((eh * (t * t)), 0.041666666666666664, (eh * -0.5)), eh) * sin(atan(((eh / ew) / tan(t)))))));
} else {
tmp = t_2;
}
return tmp;
}
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(ew * tan(t)))) t_2 = Float64(1.0 / abs(Float64(1.0 / fma(eh, Float64(cos(t) * sin(t_1)), Float64(Float64(ew * sin(t)) / sqrt(fma((tan(t) ^ -2.0), Float64(Float64(eh / ew) * Float64(eh / ew)), 1.0))))))) tmp = 0.0 if (t <= -0.0003) tmp = t_2; elseif (t <= 0.005) tmp = abs(Float64(Float64(t * Float64(cos(t_1) * fma(ew, Float64(Float64(t * t) * -0.16666666666666666), ew))) + Float64(fma(Float64(t * t), fma(Float64(eh * Float64(t * t)), 0.041666666666666664, Float64(eh * -0.5)), eh) * sin(atan(Float64(Float64(eh / ew) / tan(t))))))); else tmp = t_2; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[Abs[N[(1.0 / N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Tan[t], $MachinePrecision], -2.0], $MachinePrecision] * N[(N[(eh / ew), $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -0.0003], t$95$2, If[LessEqual[t, 0.005], N[Abs[N[(N[(t * N[(N[Cos[t$95$1], $MachinePrecision] * N[(ew * N[(N[(t * t), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] + ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t * t), $MachinePrecision] * N[(N[(eh * N[(t * t), $MachinePrecision]), $MachinePrecision] * 0.041666666666666664 + N[(eh * -0.5), $MachinePrecision]), $MachinePrecision] + eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
t_2 := \frac{1}{\left|\frac{1}{\mathsf{fma}\left(eh, \cos t \cdot \sin t\_1, \frac{ew \cdot \sin t}{\sqrt{\mathsf{fma}\left({\tan t}^{-2}, \frac{eh}{ew} \cdot \frac{eh}{ew}, 1\right)}}\right)}\right|}\\
\mathbf{if}\;t \leq -0.0003:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t \leq 0.005:\\
\;\;\;\;\left|t \cdot \left(\cos t\_1 \cdot \mathsf{fma}\left(ew, \left(t \cdot t\right) \cdot -0.16666666666666666, ew\right)\right) + \mathsf{fma}\left(t \cdot t, \mathsf{fma}\left(eh \cdot \left(t \cdot t\right), 0.041666666666666664, eh \cdot -0.5\right), eh\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if t < -2.99999999999999974e-4 or 0.0050000000000000001 < t Initial program 99.6%
Applied rewrites87.1%
lift-fma.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
Applied rewrites99.5%
if -2.99999999999999974e-4 < t < 0.0050000000000000001Initial program 100.0%
Taylor expanded in t around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
+-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
Applied rewrites100.0%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (sin (atan (/ eh (* ew (tan t))))))
(t_2
(fabs
(*
eh
(*
ew
(fma
(cos t)
(/ t_1 ew)
(* (cos (atan (/ eh (* ew t)))) (/ (sin t) eh))))))))
(if (<= eh -1.52e-12)
t_2
(if (<= eh 1.85e-91)
(/ 1.0 (fabs (/ 1.0 (* ew (fma eh (/ (* (cos t) t_1) ew) (sin t))))))
t_2))))
double code(double eh, double ew, double t) {
double t_1 = sin(atan((eh / (ew * tan(t)))));
double t_2 = fabs((eh * (ew * fma(cos(t), (t_1 / ew), (cos(atan((eh / (ew * t)))) * (sin(t) / eh))))));
double tmp;
if (eh <= -1.52e-12) {
tmp = t_2;
} else if (eh <= 1.85e-91) {
tmp = 1.0 / fabs((1.0 / (ew * fma(eh, ((cos(t) * t_1) / ew), sin(t)))));
} else {
tmp = t_2;
}
return tmp;
}
function code(eh, ew, t) t_1 = sin(atan(Float64(eh / Float64(ew * tan(t))))) t_2 = abs(Float64(eh * Float64(ew * fma(cos(t), Float64(t_1 / ew), Float64(cos(atan(Float64(eh / Float64(ew * t)))) * Float64(sin(t) / eh)))))) tmp = 0.0 if (eh <= -1.52e-12) tmp = t_2; elseif (eh <= 1.85e-91) tmp = Float64(1.0 / abs(Float64(1.0 / Float64(ew * fma(eh, Float64(Float64(cos(t) * t_1) / ew), sin(t)))))); else tmp = t_2; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(eh * N[(ew * N[(N[Cos[t], $MachinePrecision] * N[(t$95$1 / ew), $MachinePrecision] + N[(N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] / eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -1.52e-12], t$95$2, If[LessEqual[eh, 1.85e-91], N[(1.0 / N[Abs[N[(1.0 / N[(ew * N[(eh * N[(N[(N[Cos[t], $MachinePrecision] * t$95$1), $MachinePrecision] / ew), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
t_2 := \left|eh \cdot \left(ew \cdot \mathsf{fma}\left(\cos t, \frac{t\_1}{ew}, \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \frac{\sin t}{eh}\right)\right)\right|\\
\mathbf{if}\;eh \leq -1.52 \cdot 10^{-12}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;eh \leq 1.85 \cdot 10^{-91}:\\
\;\;\;\;\frac{1}{\left|\frac{1}{ew \cdot \mathsf{fma}\left(eh, \frac{\cos t \cdot t\_1}{ew}, \sin t\right)}\right|}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if eh < -1.52e-12 or 1.8500000000000001e-91 < eh Initial program 99.8%
Taylor expanded in ew around 0
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-tan.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in eh around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in ew around inf
Applied rewrites99.6%
Taylor expanded in t around 0
Applied rewrites99.6%
if -1.52e-12 < eh < 1.8500000000000001e-91Initial program 99.8%
Applied rewrites79.2%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites98.4%
Final simplification99.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(/
1.0
(fabs
(/
1.0
(*
ew
(fma
eh
(/ (* (cos t) (sin (atan (/ eh (* ew (tan t)))))) ew)
(sin t))))))))
(if (<= ew -4.2e-45) t_1 (if (<= ew 6.6e-110) (fabs (* eh (cos t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = 1.0 / fabs((1.0 / (ew * fma(eh, ((cos(t) * sin(atan((eh / (ew * tan(t)))))) / ew), sin(t)))));
double tmp;
if (ew <= -4.2e-45) {
tmp = t_1;
} else if (ew <= 6.6e-110) {
tmp = fabs((eh * cos(t)));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(1.0 / abs(Float64(1.0 / Float64(ew * fma(eh, Float64(Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t)))))) / ew), sin(t)))))) tmp = 0.0 if (ew <= -4.2e-45) tmp = t_1; elseif (ew <= 6.6e-110) tmp = abs(Float64(eh * cos(t))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(1.0 / N[Abs[N[(1.0 / N[(ew * N[(eh * N[(N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, -4.2e-45], t$95$1, If[LessEqual[ew, 6.6e-110], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{\left|\frac{1}{ew \cdot \mathsf{fma}\left(eh, \frac{\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}{ew}, \sin t\right)}\right|}\\
\mathbf{if}\;ew \leq -4.2 \cdot 10^{-45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 6.6 \cdot 10^{-110}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -4.1999999999999999e-45 or 6.5999999999999998e-110 < ew Initial program 99.8%
Applied rewrites90.3%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites96.2%
if -4.1999999999999999e-45 < ew < 6.5999999999999998e-110Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
lift-/.f64N/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
Applied rewrites6.8%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6492.2
Applied rewrites92.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (sin t)))
(t_2 (* eh (cos t)))
(t_3 (fabs t_2))
(t_4
(fabs
(fma
(* t_2 (/ eh ew))
(/ 1.0 (/ eh ew))
(/ t_1 (sqrt (fma (* eh eh) (pow (* ew (tan t)) -2.0) 1.0)))))))
(if (<= eh -9e+64)
t_3
(if (<= eh -2.55e-160)
t_4
(if (<= eh 2.3e-136) (fabs t_1) (if (<= eh 1.75e+34) t_4 t_3))))))
double code(double eh, double ew, double t) {
double t_1 = ew * sin(t);
double t_2 = eh * cos(t);
double t_3 = fabs(t_2);
double t_4 = fabs(fma((t_2 * (eh / ew)), (1.0 / (eh / ew)), (t_1 / sqrt(fma((eh * eh), pow((ew * tan(t)), -2.0), 1.0)))));
double tmp;
if (eh <= -9e+64) {
tmp = t_3;
} else if (eh <= -2.55e-160) {
tmp = t_4;
} else if (eh <= 2.3e-136) {
tmp = fabs(t_1);
} else if (eh <= 1.75e+34) {
tmp = t_4;
} else {
tmp = t_3;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(ew * sin(t)) t_2 = Float64(eh * cos(t)) t_3 = abs(t_2) t_4 = abs(fma(Float64(t_2 * Float64(eh / ew)), Float64(1.0 / Float64(eh / ew)), Float64(t_1 / sqrt(fma(Float64(eh * eh), (Float64(ew * tan(t)) ^ -2.0), 1.0))))) tmp = 0.0 if (eh <= -9e+64) tmp = t_3; elseif (eh <= -2.55e-160) tmp = t_4; elseif (eh <= 2.3e-136) tmp = abs(t_1); elseif (eh <= 1.75e+34) tmp = t_4; else tmp = t_3; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Abs[t$95$2], $MachinePrecision]}, Block[{t$95$4 = N[Abs[N[(N[(t$95$2 * N[(eh / ew), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(eh / ew), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 / N[Sqrt[N[(N[(eh * eh), $MachinePrecision] * N[Power[N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -9e+64], t$95$3, If[LessEqual[eh, -2.55e-160], t$95$4, If[LessEqual[eh, 2.3e-136], N[Abs[t$95$1], $MachinePrecision], If[LessEqual[eh, 1.75e+34], t$95$4, t$95$3]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \sin t\\
t_2 := eh \cdot \cos t\\
t_3 := \left|t\_2\right|\\
t_4 := \left|\mathsf{fma}\left(t\_2 \cdot \frac{eh}{ew}, \frac{1}{\frac{eh}{ew}}, \frac{t\_1}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}\right)\right|\\
\mathbf{if}\;eh \leq -9 \cdot 10^{+64}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;eh \leq -2.55 \cdot 10^{-160}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;eh \leq 2.3 \cdot 10^{-136}:\\
\;\;\;\;\left|t\_1\right|\\
\mathbf{elif}\;eh \leq 1.75 \cdot 10^{+34}:\\
\;\;\;\;t\_4\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if eh < -8.99999999999999946e64 or 1.74999999999999999e34 < eh Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
lift-/.f64N/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
Applied rewrites17.8%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6486.6
Applied rewrites86.6%
if -8.99999999999999946e64 < eh < -2.55e-160 or 2.29999999999999998e-136 < eh < 1.74999999999999999e34Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
lift-/.f64N/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
Applied rewrites54.9%
Taylor expanded in t around 0
lower-/.f6489.2
Applied rewrites89.2%
if -2.55e-160 < eh < 2.29999999999999998e-136Initial program 99.8%
Applied rewrites19.5%
Taylor expanded in ew around inf
lower-*.f64N/A
lower-sin.f6474.6
Applied rewrites74.6%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* ew (sin t))))) (if (<= ew -6.8e+25) t_1 (if (<= ew 3.4e+39) (fabs (* eh (cos t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * sin(t)));
double tmp;
if (ew <= -6.8e+25) {
tmp = t_1;
} else if (ew <= 3.4e+39) {
tmp = fabs((eh * cos(t)));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = abs((ew * sin(t)))
if (ew <= (-6.8d+25)) then
tmp = t_1
else if (ew <= 3.4d+39) then
tmp = abs((eh * cos(t)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.abs((ew * Math.sin(t)));
double tmp;
if (ew <= -6.8e+25) {
tmp = t_1;
} else if (ew <= 3.4e+39) {
tmp = Math.abs((eh * Math.cos(t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((ew * math.sin(t))) tmp = 0 if ew <= -6.8e+25: tmp = t_1 elif ew <= 3.4e+39: tmp = math.fabs((eh * math.cos(t))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(ew * sin(t))) tmp = 0.0 if (ew <= -6.8e+25) tmp = t_1; elseif (ew <= 3.4e+39) tmp = abs(Float64(eh * cos(t))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((ew * sin(t))); tmp = 0.0; if (ew <= -6.8e+25) tmp = t_1; elseif (ew <= 3.4e+39) tmp = abs((eh * cos(t))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -6.8e+25], t$95$1, If[LessEqual[ew, 3.4e+39], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \sin t\right|\\
\mathbf{if}\;ew \leq -6.8 \cdot 10^{+25}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 3.4 \cdot 10^{+39}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -6.79999999999999967e25 or 3.3999999999999999e39 < ew Initial program 99.8%
Applied rewrites33.3%
Taylor expanded in ew around inf
lower-*.f64N/A
lower-sin.f6469.7
Applied rewrites69.7%
if -6.79999999999999967e25 < ew < 3.3999999999999999e39Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
lift-/.f64N/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
Applied rewrites18.6%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6485.0
Applied rewrites85.0%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* eh (cos t))))) (if (<= eh -2.05e-181) t_1 (if (<= eh 2.9e-147) (fabs (* ew t)) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * cos(t)));
double tmp;
if (eh <= -2.05e-181) {
tmp = t_1;
} else if (eh <= 2.9e-147) {
tmp = fabs((ew * t));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = abs((eh * cos(t)))
if (eh <= (-2.05d-181)) then
tmp = t_1
else if (eh <= 2.9d-147) then
tmp = abs((ew * t))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.abs((eh * Math.cos(t)));
double tmp;
if (eh <= -2.05e-181) {
tmp = t_1;
} else if (eh <= 2.9e-147) {
tmp = Math.abs((ew * t));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((eh * math.cos(t))) tmp = 0 if eh <= -2.05e-181: tmp = t_1 elif eh <= 2.9e-147: tmp = math.fabs((ew * t)) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(eh * cos(t))) tmp = 0.0 if (eh <= -2.05e-181) tmp = t_1; elseif (eh <= 2.9e-147) tmp = abs(Float64(ew * t)); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((eh * cos(t))); tmp = 0.0; if (eh <= -2.05e-181) tmp = t_1; elseif (eh <= 2.9e-147) tmp = abs((ew * t)); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -2.05e-181], t$95$1, If[LessEqual[eh, 2.9e-147], N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \cos t\right|\\
\mathbf{if}\;eh \leq -2.05 \cdot 10^{-181}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 2.9 \cdot 10^{-147}:\\
\;\;\;\;\left|ew \cdot t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -2.0500000000000001e-181 or 2.9000000000000001e-147 < eh Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
lift-/.f64N/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
Applied rewrites37.7%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6472.4
Applied rewrites72.4%
if -2.0500000000000001e-181 < eh < 2.9000000000000001e-147Initial program 99.8%
Applied rewrites21.3%
Taylor expanded in ew around inf
lower-*.f64N/A
lower-sin.f6478.8
Applied rewrites78.8%
Taylor expanded in t around 0
Applied rewrites48.2%
Final simplification67.5%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* eh 1.0)))) (if (<= eh -1.22e-170) t_1 (if (<= eh 3.4e-147) (fabs (* ew t)) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * 1.0));
double tmp;
if (eh <= -1.22e-170) {
tmp = t_1;
} else if (eh <= 3.4e-147) {
tmp = fabs((ew * t));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = abs((eh * 1.0d0))
if (eh <= (-1.22d-170)) then
tmp = t_1
else if (eh <= 3.4d-147) then
tmp = abs((ew * t))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.abs((eh * 1.0));
double tmp;
if (eh <= -1.22e-170) {
tmp = t_1;
} else if (eh <= 3.4e-147) {
tmp = Math.abs((ew * t));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((eh * 1.0)) tmp = 0 if eh <= -1.22e-170: tmp = t_1 elif eh <= 3.4e-147: tmp = math.fabs((ew * t)) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(eh * 1.0)) tmp = 0.0 if (eh <= -1.22e-170) tmp = t_1; elseif (eh <= 3.4e-147) tmp = abs(Float64(ew * t)); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((eh * 1.0)); tmp = 0.0; if (eh <= -1.22e-170) tmp = t_1; elseif (eh <= 3.4e-147) tmp = abs((ew * t)); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -1.22e-170], t$95$1, If[LessEqual[eh, 3.4e-147], N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot 1\right|\\
\mathbf{if}\;eh \leq -1.22 \cdot 10^{-170}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 3.4 \cdot 10^{-147}:\\
\;\;\;\;\left|ew \cdot t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -1.22e-170 or 3.39999999999999996e-147 < eh Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
lift-/.f64N/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
Applied rewrites37.4%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6473.3
Applied rewrites73.3%
Taylor expanded in t around 0
Applied rewrites49.7%
if -1.22e-170 < eh < 3.39999999999999996e-147Initial program 99.8%
Applied rewrites21.5%
Taylor expanded in ew around inf
lower-*.f64N/A
lower-sin.f6478.6
Applied rewrites78.6%
Taylor expanded in t around 0
Applied rewrites46.9%
Final simplification49.1%
(FPCore (eh ew t) :precision binary64 (fabs (* eh 1.0)))
double code(double eh, double ew, double t) {
return fabs((eh * 1.0));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((eh * 1.0d0))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((eh * 1.0));
}
def code(eh, ew, t): return math.fabs((eh * 1.0))
function code(eh, ew, t) return abs(Float64(eh * 1.0)) end
function tmp = code(eh, ew, t) tmp = abs((eh * 1.0)); end
code[eh_, ew_, t_] := N[Abs[N[(eh * 1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot 1\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
lift-/.f64N/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
Applied rewrites42.5%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6462.8
Applied rewrites62.8%
Taylor expanded in t around 0
Applied rewrites43.2%
herbie shell --seed 2024234
(FPCore (eh ew t)
:name "Example from Robby"
:precision binary64
(fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))