
(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 11 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.7%
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.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* ew (sin t)) (cos (atan (/ eh (* t ew))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
return fabs((((ew * sin(t)) * cos(atan((eh / (t * ew))))) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((ew * sin(t)) * cos(atan((eh / (t * ew))))) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.sin(t)) * Math.cos(Math.atan((eh / (t * ew))))) + ((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t)))))));
}
def code(eh, ew, t): return math.fabs((((ew * math.sin(t)) * math.cos(math.atan((eh / (t * ew))))) + ((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(atan(Float64(eh / Float64(t * ew))))) + Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * sin(t)) * cos(atan((eh / (t * ew))))) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\end{array}
Initial program 99.7%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.1
Applied rewrites99.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (sin (atan (/ eh (* ew (tan t)))))))
(if (<= ew -1e+66)
(fabs (* ew (fma (* (cos t) t_1) (/ eh ew) (sin t))))
(if (<= ew 3e+43)
(fabs (* eh (fma (cos t) t_1 (/ (* ew (sin t)) eh))))
(fabs (* ew (fma eh (* (cos t) (/ t_1 ew)) (sin t))))))))
double code(double eh, double ew, double t) {
double t_1 = sin(atan((eh / (ew * tan(t)))));
double tmp;
if (ew <= -1e+66) {
tmp = fabs((ew * fma((cos(t) * t_1), (eh / ew), sin(t))));
} else if (ew <= 3e+43) {
tmp = fabs((eh * fma(cos(t), t_1, ((ew * sin(t)) / eh))));
} else {
tmp = fabs((ew * fma(eh, (cos(t) * (t_1 / ew)), sin(t))));
}
return tmp;
}
function code(eh, ew, t) t_1 = sin(atan(Float64(eh / Float64(ew * tan(t))))) tmp = 0.0 if (ew <= -1e+66) tmp = abs(Float64(ew * fma(Float64(cos(t) * t_1), Float64(eh / ew), sin(t)))); elseif (ew <= 3e+43) tmp = abs(Float64(eh * fma(cos(t), t_1, Float64(Float64(ew * sin(t)) / eh)))); else tmp = abs(Float64(ew * fma(eh, Float64(cos(t) * Float64(t_1 / ew)), sin(t)))); 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]}, If[LessEqual[ew, -1e+66], N[Abs[N[(ew * N[(N[(N[Cos[t], $MachinePrecision] * t$95$1), $MachinePrecision] * N[(eh / ew), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 3e+43], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * t$95$1 + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] / eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[(eh * N[(N[Cos[t], $MachinePrecision] * N[(t$95$1 / ew), $MachinePrecision]), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
\mathbf{if}\;ew \leq -1 \cdot 10^{+66}:\\
\;\;\;\;\left|ew \cdot \mathsf{fma}\left(\cos t \cdot t\_1, \frac{eh}{ew}, \sin t\right)\right|\\
\mathbf{elif}\;ew \leq 3 \cdot 10^{+43}:\\
\;\;\;\;\left|eh \cdot \mathsf{fma}\left(\cos t, t\_1, \frac{ew \cdot \sin t}{eh}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \mathsf{fma}\left(eh, \cos t \cdot \frac{t\_1}{ew}, \sin t\right)\right|\\
\end{array}
\end{array}
if ew < -9.99999999999999945e65Initial program 99.8%
Applied rewrites86.9%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.4%
lift-cos.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-atan.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
Applied rewrites99.5%
if -9.99999999999999945e65 < ew < 3.00000000000000017e43Initial program 99.7%
Applied rewrites88.7%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites77.8%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f6499.2
Applied rewrites99.2%
if 3.00000000000000017e43 < ew Initial program 99.8%
Applied rewrites93.6%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites98.1%
lift-cos.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-atan.f64N/A
lift-sin.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6498.1
Applied rewrites98.1%
Final simplification99.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (sin (atan (/ eh (* ew (tan t))))))
(t_2 (fabs (* ew (fma eh (* (cos t) (/ t_1 ew)) (sin t))))))
(if (<= ew -2.4e+66)
t_2
(if (<= ew 3e+43)
(fabs (* eh (fma (cos t) t_1 (/ (* ew (sin t)) eh))))
t_2))))
double code(double eh, double ew, double t) {
double t_1 = sin(atan((eh / (ew * tan(t)))));
double t_2 = fabs((ew * fma(eh, (cos(t) * (t_1 / ew)), sin(t))));
double tmp;
if (ew <= -2.4e+66) {
tmp = t_2;
} else if (ew <= 3e+43) {
tmp = fabs((eh * fma(cos(t), t_1, ((ew * sin(t)) / eh))));
} 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(ew * fma(eh, Float64(cos(t) * Float64(t_1 / ew)), sin(t)))) tmp = 0.0 if (ew <= -2.4e+66) tmp = t_2; elseif (ew <= 3e+43) tmp = abs(Float64(eh * fma(cos(t), t_1, Float64(Float64(ew * sin(t)) / eh)))); 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[(ew * N[(eh * N[(N[Cos[t], $MachinePrecision] * N[(t$95$1 / ew), $MachinePrecision]), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -2.4e+66], t$95$2, If[LessEqual[ew, 3e+43], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * t$95$1 + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] / eh), $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|ew \cdot \mathsf{fma}\left(eh, \cos t \cdot \frac{t\_1}{ew}, \sin t\right)\right|\\
\mathbf{if}\;ew \leq -2.4 \cdot 10^{+66}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;ew \leq 3 \cdot 10^{+43}:\\
\;\;\;\;\left|eh \cdot \mathsf{fma}\left(\cos t, t\_1, \frac{ew \cdot \sin t}{eh}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if ew < -2.4000000000000002e66 or 3.00000000000000017e43 < ew Initial program 99.8%
Applied rewrites90.0%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites98.8%
lift-cos.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-atan.f64N/A
lift-sin.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6498.8
Applied rewrites98.8%
if -2.4000000000000002e66 < ew < 3.00000000000000017e43Initial program 99.7%
Applied rewrites88.7%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites77.8%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f6499.2
Applied rewrites99.2%
Final simplification99.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
ew
(fma
eh
(/
(*
(cos t)
(sin
(atan
(/
(fma -0.3333333333333333 (/ (* eh (* t t)) ew) (/ eh ew))
t))))
ew)
(sin t))))))
(if (<= ew -2.4e+66)
t_1
(if (<= ew 2.8e+57)
(fabs
(*
eh
(fma
(cos t)
(sin (atan (/ eh (* ew (tan t)))))
(/ (* ew (sin t)) eh))))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * fma(eh, ((cos(t) * sin(atan((fma(-0.3333333333333333, ((eh * (t * t)) / ew), (eh / ew)) / t)))) / ew), sin(t))));
double tmp;
if (ew <= -2.4e+66) {
tmp = t_1;
} else if (ew <= 2.8e+57) {
tmp = fabs((eh * fma(cos(t), sin(atan((eh / (ew * tan(t))))), ((ew * sin(t)) / eh))));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(ew * fma(eh, Float64(Float64(cos(t) * sin(atan(Float64(fma(-0.3333333333333333, Float64(Float64(eh * Float64(t * t)) / ew), Float64(eh / ew)) / t)))) / ew), sin(t)))) tmp = 0.0 if (ew <= -2.4e+66) tmp = t_1; elseif (ew <= 2.8e+57) tmp = abs(Float64(eh * fma(cos(t), sin(atan(Float64(eh / Float64(ew * tan(t))))), Float64(Float64(ew * sin(t)) / eh)))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[(eh * N[(N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(-0.3333333333333333 * N[(N[(eh * N[(t * t), $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + N[(eh / ew), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -2.4e+66], t$95$1, If[LessEqual[ew, 2.8e+57], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] / eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \mathsf{fma}\left(eh, \frac{\cos t \cdot \sin \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.3333333333333333, \frac{eh \cdot \left(t \cdot t\right)}{ew}, \frac{eh}{ew}\right)}{t}\right)}{ew}, \sin t\right)\right|\\
\mathbf{if}\;ew \leq -2.4 \cdot 10^{+66}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 2.8 \cdot 10^{+57}:\\
\;\;\;\;\left|eh \cdot \mathsf{fma}\left(\cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \frac{ew \cdot \sin t}{eh}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -2.4000000000000002e66 or 2.8e57 < ew Initial program 99.8%
Applied rewrites89.7%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in t around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6499.3
Applied rewrites99.3%
if -2.4000000000000002e66 < ew < 2.8e57Initial program 99.7%
Applied rewrites88.9%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites77.7%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (cos t)))
(t_2
(fabs
(*
ew
(fma
eh
(/
(*
(cos t)
(sin
(atan
(/
(fma -0.3333333333333333 (/ (* eh (* t t)) ew) (/ eh ew))
t))))
ew)
(sin t))))))
(if (<= ew -2.1e-92)
t_2
(if (<= ew 7.2e-112)
(fabs (fma (* ew ew) (/ (* 0.5 (pow (sin t) 2.0)) t_1) t_1))
t_2))))
double code(double eh, double ew, double t) {
double t_1 = eh * cos(t);
double t_2 = fabs((ew * fma(eh, ((cos(t) * sin(atan((fma(-0.3333333333333333, ((eh * (t * t)) / ew), (eh / ew)) / t)))) / ew), sin(t))));
double tmp;
if (ew <= -2.1e-92) {
tmp = t_2;
} else if (ew <= 7.2e-112) {
tmp = fabs(fma((ew * ew), ((0.5 * pow(sin(t), 2.0)) / t_1), t_1));
} else {
tmp = t_2;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh * cos(t)) t_2 = abs(Float64(ew * fma(eh, Float64(Float64(cos(t) * sin(atan(Float64(fma(-0.3333333333333333, Float64(Float64(eh * Float64(t * t)) / ew), Float64(eh / ew)) / t)))) / ew), sin(t)))) tmp = 0.0 if (ew <= -2.1e-92) tmp = t_2; elseif (ew <= 7.2e-112) tmp = abs(fma(Float64(ew * ew), Float64(Float64(0.5 * (sin(t) ^ 2.0)) / t_1), t_1)); else tmp = t_2; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(ew * N[(eh * N[(N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(-0.3333333333333333 * N[(N[(eh * N[(t * t), $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + N[(eh / ew), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -2.1e-92], t$95$2, If[LessEqual[ew, 7.2e-112], N[Abs[N[(N[(ew * ew), $MachinePrecision] * N[(N[(0.5 * N[Power[N[Sin[t], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \cos t\\
t_2 := \left|ew \cdot \mathsf{fma}\left(eh, \frac{\cos t \cdot \sin \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.3333333333333333, \frac{eh \cdot \left(t \cdot t\right)}{ew}, \frac{eh}{ew}\right)}{t}\right)}{ew}, \sin t\right)\right|\\
\mathbf{if}\;ew \leq -2.1 \cdot 10^{-92}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;ew \leq 7.2 \cdot 10^{-112}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot ew, \frac{0.5 \cdot {\sin t}^{2}}{t\_1}, t\_1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if ew < -2.1e-92 or 7.2000000000000002e-112 < ew Initial program 99.8%
Applied rewrites91.0%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites97.6%
Taylor expanded in t around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6497.0
Applied rewrites97.0%
if -2.1e-92 < ew < 7.2000000000000002e-112Initial program 99.7%
Applied rewrites4.3%
Taylor expanded in ew around 0
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f6494.4
Applied rewrites94.4%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
ew
(fma eh (/ (* (cos t) (sin (atan (/ eh (* t ew))))) ew) (sin t)))))
(t_2 (* eh (cos t))))
(if (<= ew -1.6e-82)
t_1
(if (<= ew 9e-112)
(fabs (fma (* ew ew) (/ (* 0.5 (pow (sin t) 2.0)) t_2) t_2))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * fma(eh, ((cos(t) * sin(atan((eh / (t * ew))))) / ew), sin(t))));
double t_2 = eh * cos(t);
double tmp;
if (ew <= -1.6e-82) {
tmp = t_1;
} else if (ew <= 9e-112) {
tmp = fabs(fma((ew * ew), ((0.5 * pow(sin(t), 2.0)) / t_2), t_2));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(ew * fma(eh, Float64(Float64(cos(t) * sin(atan(Float64(eh / Float64(t * ew))))) / ew), sin(t)))) t_2 = Float64(eh * cos(t)) tmp = 0.0 if (ew <= -1.6e-82) tmp = t_1; elseif (ew <= 9e-112) tmp = abs(fma(Float64(ew * ew), Float64(Float64(0.5 * (sin(t) ^ 2.0)) / t_2), t_2)); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[(eh * N[(N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, -1.6e-82], t$95$1, If[LessEqual[ew, 9e-112], N[Abs[N[(N[(ew * ew), $MachinePrecision] * N[(N[(0.5 * N[Power[N[Sin[t], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \mathsf{fma}\left(eh, \frac{\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)}{ew}, \sin t\right)\right|\\
t_2 := eh \cdot \cos t\\
\mathbf{if}\;ew \leq -1.6 \cdot 10^{-82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 9 \cdot 10^{-112}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot ew, \frac{0.5 \cdot {\sin t}^{2}}{t\_2}, t\_2\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -1.6000000000000001e-82 or 9.00000000000000024e-112 < ew Initial program 99.8%
Applied rewrites91.5%
Taylor expanded in ew around inf
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites97.6%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6491.8
Applied rewrites91.8%
if -1.6000000000000001e-82 < ew < 9.00000000000000024e-112Initial program 99.7%
Applied rewrites5.3%
Taylor expanded in ew around 0
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f6494.6
Applied rewrites94.6%
Final simplification92.7%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* eh (cos t))))) (if (<= eh -8.5e-90) t_1 (if (<= eh 4.4e-116) (fabs (* ew (sin t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * cos(t)));
double tmp;
if (eh <= -8.5e-90) {
tmp = t_1;
} else if (eh <= 4.4e-116) {
tmp = fabs((ew * sin(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 <= (-8.5d-90)) then
tmp = t_1
else if (eh <= 4.4d-116) then
tmp = abs((ew * sin(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 <= -8.5e-90) {
tmp = t_1;
} else if (eh <= 4.4e-116) {
tmp = Math.abs((ew * Math.sin(t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((eh * math.cos(t))) tmp = 0 if eh <= -8.5e-90: tmp = t_1 elif eh <= 4.4e-116: tmp = math.fabs((ew * math.sin(t))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(eh * cos(t))) tmp = 0.0 if (eh <= -8.5e-90) tmp = t_1; elseif (eh <= 4.4e-116) tmp = abs(Float64(ew * sin(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 <= -8.5e-90) tmp = t_1; elseif (eh <= 4.4e-116) tmp = abs((ew * sin(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, -8.5e-90], t$95$1, If[LessEqual[eh, 4.4e-116], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \cos t\right|\\
\mathbf{if}\;eh \leq -8.5 \cdot 10^{-90}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 4.4 \cdot 10^{-116}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -8.5000000000000001e-90 or 4.4000000000000002e-116 < eh Initial program 99.7%
Applied rewrites31.2%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6480.4
Applied rewrites80.4%
if -8.5000000000000001e-90 < eh < 4.4000000000000002e-116Initial program 99.8%
Applied rewrites79.4%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6480.5
Applied rewrites80.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* eh (cos t)))))
(if (<= eh -2e-179)
t_1
(if (<= eh 7e-233)
(fabs
(/
(fma
t
(* t (fma (/ (* eh eh) ew) -0.4166666666666667 ew))
(/ (* 0.5 (* eh eh)) ew))
t))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * cos(t)));
double tmp;
if (eh <= -2e-179) {
tmp = t_1;
} else if (eh <= 7e-233) {
tmp = fabs((fma(t, (t * fma(((eh * eh) / ew), -0.4166666666666667, ew)), ((0.5 * (eh * eh)) / 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 <= -2e-179) tmp = t_1; elseif (eh <= 7e-233) tmp = abs(Float64(fma(t, Float64(t * fma(Float64(Float64(eh * eh) / ew), -0.4166666666666667, ew)), Float64(Float64(0.5 * Float64(eh * eh)) / ew)) / t)); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -2e-179], t$95$1, If[LessEqual[eh, 7e-233], N[Abs[N[(N[(t * N[(t * N[(N[(N[(eh * eh), $MachinePrecision] / ew), $MachinePrecision] * -0.4166666666666667 + ew), $MachinePrecision]), $MachinePrecision] + N[(N[(0.5 * N[(eh * eh), $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] / 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 \cdot 10^{-179}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 7 \cdot 10^{-233}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(t, t \cdot \mathsf{fma}\left(\frac{eh \cdot eh}{ew}, -0.4166666666666667, ew\right), \frac{0.5 \cdot \left(eh \cdot eh\right)}{ew}\right)}{t}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -2e-179 or 6.99999999999999982e-233 < eh Initial program 99.7%
Applied rewrites38.9%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6469.5
Applied rewrites69.5%
if -2e-179 < eh < 6.99999999999999982e-233Initial program 99.8%
Applied rewrites80.4%
Taylor expanded in eh around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sin.f6494.3
Applied rewrites94.3%
Taylor expanded in t around 0
lower-/.f64N/A
Applied rewrites34.4%
(FPCore (eh ew t)
:precision binary64
(if (<= eh -2.1e-179)
(fabs eh)
(if (<= eh 8e-233)
(fabs
(/
(fma
t
(* t (fma (/ (* eh eh) ew) -0.4166666666666667 ew))
(/ (* 0.5 (* eh eh)) ew))
t))
(fabs eh))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -2.1e-179) {
tmp = fabs(eh);
} else if (eh <= 8e-233) {
tmp = fabs((fma(t, (t * fma(((eh * eh) / ew), -0.4166666666666667, ew)), ((0.5 * (eh * eh)) / ew)) / t));
} else {
tmp = fabs(eh);
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (eh <= -2.1e-179) tmp = abs(eh); elseif (eh <= 8e-233) tmp = abs(Float64(fma(t, Float64(t * fma(Float64(Float64(eh * eh) / ew), -0.4166666666666667, ew)), Float64(Float64(0.5 * Float64(eh * eh)) / ew)) / t)); else tmp = abs(eh); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[eh, -2.1e-179], N[Abs[eh], $MachinePrecision], If[LessEqual[eh, 8e-233], N[Abs[N[(N[(t * N[(t * N[(N[(N[(eh * eh), $MachinePrecision] / ew), $MachinePrecision] * -0.4166666666666667 + ew), $MachinePrecision]), $MachinePrecision] + N[(N[(0.5 * N[(eh * eh), $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision], N[Abs[eh], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -2.1 \cdot 10^{-179}:\\
\;\;\;\;\left|eh\right|\\
\mathbf{elif}\;eh \leq 8 \cdot 10^{-233}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(t, t \cdot \mathsf{fma}\left(\frac{eh \cdot eh}{ew}, -0.4166666666666667, ew\right), \frac{0.5 \cdot \left(eh \cdot eh\right)}{ew}\right)}{t}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\
\end{array}
\end{array}
if eh < -2.0999999999999999e-179 or 7.99999999999999966e-233 < eh Initial program 99.7%
Applied rewrites38.9%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6469.5
Applied rewrites69.5%
Taylor expanded in t around 0
Applied rewrites48.2%
*-rgt-identity48.2
Applied rewrites48.2%
if -2.0999999999999999e-179 < eh < 7.99999999999999966e-233Initial program 99.8%
Applied rewrites80.4%
Taylor expanded in eh around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sin.f6494.3
Applied rewrites94.3%
Taylor expanded in t around 0
lower-/.f64N/A
Applied rewrites34.4%
(FPCore (eh ew t) :precision binary64 (fabs eh))
double code(double eh, double ew, double t) {
return fabs(eh);
}
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)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(eh);
}
def code(eh, ew, t): return math.fabs(eh)
function code(eh, ew, t) return abs(eh) end
function tmp = code(eh, ew, t) tmp = abs(eh); end
code[eh_, ew_, t_] := N[Abs[eh], $MachinePrecision]
\begin{array}{l}
\\
\left|eh\right|
\end{array}
Initial program 99.7%
Applied rewrites44.7%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6461.0
Applied rewrites61.0%
Taylor expanded in t around 0
Applied rewrites42.7%
*-rgt-identity42.7
Applied rewrites42.7%
herbie shell --seed 2024216
(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))))))))