
(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 8 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 (+ (* (* 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}
Initial program 99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* eh (cos t)) (sin (atan (/ eh (* ew (tan t))))) (* ew (* (sin t) (cos (atan (/ eh (* ew t)))))))))
double code(double eh, double ew, double t) {
return fabs(fma((eh * cos(t)), sin(atan((eh / (ew * tan(t))))), (ew * (sin(t) * cos(atan((eh / (ew * t))))))));
}
function code(eh, ew, t) return abs(fma(Float64(eh * cos(t)), sin(atan(Float64(eh / Float64(ew * tan(t))))), Float64(ew * Float64(sin(t) * cos(atan(Float64(eh / Float64(ew * t)))))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6499.3
Simplified99.3%
Taylor expanded in ew around 0
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
sin-lowering-sin.f64N/A
atan-lowering-atan.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
Simplified99.3%
Final simplification99.3%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* eh (cos t)) (sin (atan (/ eh (* ew (tan t))))) (* ew (sin t)))))
double code(double eh, double ew, double t) {
return fabs(fma((eh * cos(t)), sin(atan((eh / (ew * tan(t))))), (ew * sin(t))));
}
function code(eh, ew, t) return abs(fma(Float64(eh * cos(t)), sin(atan(Float64(eh / Float64(ew * tan(t))))), Float64(ew * sin(t)))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \sin t\right)\right|
\end{array}
Initial program 99.8%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr85.7%
Taylor expanded in eh around 0
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
sin-lowering-sin.f64N/A
atan-lowering-atan.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f6498.6
Simplified98.6%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* eh (cos t)))) (t_2 (fabs (* ew (sin t)))))
(if (<= t -1.16e+182)
t_1
(if (<= t -3.2e-7)
t_2
(if (<= t 7e-5)
(fabs
(fma
eh
(sin (atan (/ eh (* t (fma ew (* 0.3333333333333333 (* t t)) ew)))))
(* (* ew t) (cos (atan (/ eh (* ew t)))))))
(if (<= t 7.6e+143) t_2 t_1))))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * cos(t)));
double t_2 = fabs((ew * sin(t)));
double tmp;
if (t <= -1.16e+182) {
tmp = t_1;
} else if (t <= -3.2e-7) {
tmp = t_2;
} else if (t <= 7e-5) {
tmp = fabs(fma(eh, sin(atan((eh / (t * fma(ew, (0.3333333333333333 * (t * t)), ew))))), ((ew * t) * cos(atan((eh / (ew * t)))))));
} else if (t <= 7.6e+143) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(eh * cos(t))) t_2 = abs(Float64(ew * sin(t))) tmp = 0.0 if (t <= -1.16e+182) tmp = t_1; elseif (t <= -3.2e-7) tmp = t_2; elseif (t <= 7e-5) tmp = abs(fma(eh, sin(atan(Float64(eh / Float64(t * fma(ew, Float64(0.3333333333333333 * Float64(t * t)), ew))))), Float64(Float64(ew * t) * cos(atan(Float64(eh / Float64(ew * t))))))); elseif (t <= 7.6e+143) tmp = t_2; 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]}, Block[{t$95$2 = N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -1.16e+182], t$95$1, If[LessEqual[t, -3.2e-7], t$95$2, If[LessEqual[t, 7e-5], N[Abs[N[(eh * N[Sin[N[ArcTan[N[(eh / N[(t * N[(ew * N[(0.3333333333333333 * N[(t * t), $MachinePrecision]), $MachinePrecision] + ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(N[(ew * t), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 7.6e+143], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \cos t\right|\\
t_2 := \left|ew \cdot \sin t\right|\\
\mathbf{if}\;t \leq -1.16 \cdot 10^{+182}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq -3.2 \cdot 10^{-7}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t \leq 7 \cdot 10^{-5}:\\
\;\;\;\;\left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{t \cdot \mathsf{fma}\left(ew, 0.3333333333333333 \cdot \left(t \cdot t\right), ew\right)}\right), \left(ew \cdot t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right|\\
\mathbf{elif}\;t \leq 7.6 \cdot 10^{+143}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.16e182 or 7.60000000000000001e143 < t Initial program 99.6%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr88.8%
sin-atanN/A
associate-/l/N/A
Applied egg-rr43.1%
Taylor expanded in eh around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6464.1
Simplified64.1%
if -1.16e182 < t < -3.2000000000000001e-7 or 6.9999999999999994e-5 < t < 7.60000000000000001e143Initial program 99.6%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr85.9%
Taylor expanded in eh around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6474.7
Simplified74.7%
if -3.2000000000000001e-7 < t < 6.9999999999999994e-5Initial program 100.0%
Taylor expanded in t around 0
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6499.9
Simplified99.9%
Taylor expanded in ew around 0
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
sin-lowering-sin.f64N/A
atan-lowering-atan.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
Simplified99.9%
Taylor expanded in t around 0
accelerator-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
atan-lowering-atan.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
atan-lowering-atan.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6499.9
Simplified99.9%
Taylor expanded in t around 0
*-lowering-*.f64N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6499.9
Simplified99.9%
Final simplification83.1%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* eh (cos t))))) (if (<= eh -9e-60) t_1 (if (<= eh 1.2e-20) (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 <= -9e-60) {
tmp = t_1;
} else if (eh <= 1.2e-20) {
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 <= (-9d-60)) then
tmp = t_1
else if (eh <= 1.2d-20) 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 <= -9e-60) {
tmp = t_1;
} else if (eh <= 1.2e-20) {
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 <= -9e-60: tmp = t_1 elif eh <= 1.2e-20: 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 <= -9e-60) tmp = t_1; elseif (eh <= 1.2e-20) 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 <= -9e-60) tmp = t_1; elseif (eh <= 1.2e-20) 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, -9e-60], t$95$1, If[LessEqual[eh, 1.2e-20], 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 -9 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 1.2 \cdot 10^{-20}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -9.00000000000000001e-60 or 1.19999999999999996e-20 < eh Initial program 99.8%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr92.1%
sin-atanN/A
associate-/l/N/A
Applied egg-rr29.1%
Taylor expanded in eh around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6480.9
Simplified80.9%
if -9.00000000000000001e-60 < eh < 1.19999999999999996e-20Initial program 99.8%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr77.7%
Taylor expanded in eh around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6476.6
Simplified76.6%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* eh (cos t))))) (if (<= eh -1.1e-186) t_1 (if (<= eh 4e-200) (fabs (* ew t)) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * cos(t)));
double tmp;
if (eh <= -1.1e-186) {
tmp = t_1;
} else if (eh <= 4e-200) {
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 <= (-1.1d-186)) then
tmp = t_1
else if (eh <= 4d-200) 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 <= -1.1e-186) {
tmp = t_1;
} else if (eh <= 4e-200) {
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 <= -1.1e-186: tmp = t_1 elif eh <= 4e-200: 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 <= -1.1e-186) tmp = t_1; elseif (eh <= 4e-200) 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 <= -1.1e-186) tmp = t_1; elseif (eh <= 4e-200) 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, -1.1e-186], t$95$1, If[LessEqual[eh, 4e-200], 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 -1.1 \cdot 10^{-186}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 4 \cdot 10^{-200}:\\
\;\;\;\;\left|ew \cdot t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -1.10000000000000007e-186 or 3.9999999999999999e-200 < eh Initial program 99.8%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr89.5%
sin-atanN/A
associate-/l/N/A
Applied egg-rr39.8%
Taylor expanded in eh around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6469.2
Simplified69.2%
if -1.10000000000000007e-186 < eh < 3.9999999999999999e-200Initial program 99.7%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr71.4%
Taylor expanded in eh around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6491.1
Simplified91.1%
Taylor expanded in t around 0
*-commutativeN/A
*-lowering-*.f6435.1
Simplified35.1%
Final simplification62.1%
(FPCore (eh ew t) :precision binary64 (if (<= eh -1.15e-184) (fabs eh) (if (<= eh 2.9e-130) (fabs (* ew t)) (fabs eh))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -1.15e-184) {
tmp = fabs(eh);
} else if (eh <= 2.9e-130) {
tmp = fabs((ew * t));
} else {
tmp = fabs(eh);
}
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) :: tmp
if (eh <= (-1.15d-184)) then
tmp = abs(eh)
else if (eh <= 2.9d-130) then
tmp = abs((ew * t))
else
tmp = abs(eh)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= -1.15e-184) {
tmp = Math.abs(eh);
} else if (eh <= 2.9e-130) {
tmp = Math.abs((ew * t));
} else {
tmp = Math.abs(eh);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= -1.15e-184: tmp = math.fabs(eh) elif eh <= 2.9e-130: tmp = math.fabs((ew * t)) else: tmp = math.fabs(eh) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= -1.15e-184) tmp = abs(eh); elseif (eh <= 2.9e-130) tmp = abs(Float64(ew * t)); else tmp = abs(eh); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= -1.15e-184) tmp = abs(eh); elseif (eh <= 2.9e-130) tmp = abs((ew * t)); else tmp = abs(eh); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -1.15e-184], N[Abs[eh], $MachinePrecision], If[LessEqual[eh, 2.9e-130], N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision], N[Abs[eh], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -1.15 \cdot 10^{-184}:\\
\;\;\;\;\left|eh\right|\\
\mathbf{elif}\;eh \leq 2.9 \cdot 10^{-130}:\\
\;\;\;\;\left|ew \cdot t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\
\end{array}
\end{array}
if eh < -1.15e-184 or 2.9e-130 < eh Initial program 99.8%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr92.2%
sin-atanN/A
associate-/l/N/A
Applied egg-rr38.2%
Taylor expanded in t around 0
Simplified47.8%
if -1.15e-184 < eh < 2.9e-130Initial program 99.7%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr68.8%
Taylor expanded in eh around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6484.2
Simplified84.2%
Taylor expanded in t around 0
*-commutativeN/A
*-lowering-*.f6435.8
Simplified35.8%
Final simplification44.5%
(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.8%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr85.7%
sin-atanN/A
associate-/l/N/A
Applied egg-rr46.3%
Taylor expanded in t around 0
Simplified39.0%
herbie shell --seed 2024204
(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))))))))