
(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 (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
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
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
Simplified99.8%
(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.8%
Taylor expanded in t around 0
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6499.5
Simplified99.5%
(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%
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
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
Simplified99.8%
Taylor expanded in eh around inf
*-lowering-*.f64N/A
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
Simplified90.2%
Applied egg-rr86.5%
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
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f6499.1
Simplified99.1%
Final simplification99.1%
(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 -1.65e+22)
t_3
(if (<= eh -2e-151)
t_4
(if (<= eh 2e-112) (fabs t_1) (if (<= eh 2.75e+68) 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 <= -1.65e+22) {
tmp = t_3;
} else if (eh <= -2e-151) {
tmp = t_4;
} else if (eh <= 2e-112) {
tmp = fabs(t_1);
} else if (eh <= 2.75e+68) {
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 <= -1.65e+22) tmp = t_3; elseif (eh <= -2e-151) tmp = t_4; elseif (eh <= 2e-112) tmp = abs(t_1); elseif (eh <= 2.75e+68) 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, -1.65e+22], t$95$3, If[LessEqual[eh, -2e-151], t$95$4, If[LessEqual[eh, 2e-112], N[Abs[t$95$1], $MachinePrecision], If[LessEqual[eh, 2.75e+68], 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 -1.65 \cdot 10^{+22}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;eh \leq -2 \cdot 10^{-151}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;eh \leq 2 \cdot 10^{-112}:\\
\;\;\;\;\left|t\_1\right|\\
\mathbf{elif}\;eh \leq 2.75 \cdot 10^{+68}:\\
\;\;\;\;t\_4\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if eh < -1.6499999999999999e22 or 2.7500000000000002e68 < eh Initial program 99.9%
+-commutativeN/A
sin-atanN/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr19.7%
Taylor expanded in eh around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6487.0
Simplified87.0%
if -1.6499999999999999e22 < eh < -1.9999999999999999e-151 or 1.9999999999999999e-112 < eh < 2.7500000000000002e68Initial program 99.8%
+-commutativeN/A
sin-atanN/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr56.7%
Taylor expanded in t around 0
/-lowering-/.f6490.5
Simplified90.5%
if -1.9999999999999999e-151 < eh < 1.9999999999999999e-112Initial program 99.7%
+-commutativeN/A
sin-atanN/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr58.5%
Taylor expanded in eh around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6472.6
Simplified72.6%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* ew (sin t))))) (if (<= ew -5.4e+109) t_1 (if (<= ew 1.3e+47) (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 <= -5.4e+109) {
tmp = t_1;
} else if (ew <= 1.3e+47) {
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 <= (-5.4d+109)) then
tmp = t_1
else if (ew <= 1.3d+47) 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 <= -5.4e+109) {
tmp = t_1;
} else if (ew <= 1.3e+47) {
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 <= -5.4e+109: tmp = t_1 elif ew <= 1.3e+47: 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 <= -5.4e+109) tmp = t_1; elseif (ew <= 1.3e+47) 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 <= -5.4e+109) tmp = t_1; elseif (ew <= 1.3e+47) 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, -5.4e+109], t$95$1, If[LessEqual[ew, 1.3e+47], 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 -5.4 \cdot 10^{+109}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 1.3 \cdot 10^{+47}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -5.40000000000000003e109 or 1.30000000000000002e47 < ew Initial program 99.8%
+-commutativeN/A
sin-atanN/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr76.4%
Taylor expanded in eh around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6476.7
Simplified76.7%
if -5.40000000000000003e109 < ew < 1.30000000000000002e47Initial program 99.8%
+-commutativeN/A
sin-atanN/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr20.4%
Taylor expanded in eh around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6483.4
Simplified83.4%
(FPCore (eh ew t) :precision binary64 (fabs (* eh (cos t))))
double code(double eh, double ew, double t) {
return fabs((eh * cos(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((eh * cos(t)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((eh * Math.cos(t)));
}
def code(eh, ew, t): return math.fabs((eh * math.cos(t)))
function code(eh, ew, t) return abs(Float64(eh * cos(t))) end
function tmp = code(eh, ew, t) tmp = abs((eh * cos(t))); end
code[eh_, ew_, t_] := N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \cos t\right|
\end{array}
Initial program 99.8%
+-commutativeN/A
sin-atanN/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr41.6%
Taylor expanded in eh around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6461.9
Simplified61.9%
(FPCore (eh ew t) :precision binary64 (if (<= ew 5e+68) (fabs eh) (fabs (* t ew))))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= 5e+68) {
tmp = fabs(eh);
} else {
tmp = fabs((t * ew));
}
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 (ew <= 5d+68) then
tmp = abs(eh)
else
tmp = abs((t * ew))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (ew <= 5e+68) {
tmp = Math.abs(eh);
} else {
tmp = Math.abs((t * ew));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if ew <= 5e+68: tmp = math.fabs(eh) else: tmp = math.fabs((t * ew)) return tmp
function code(eh, ew, t) tmp = 0.0 if (ew <= 5e+68) tmp = abs(eh); else tmp = abs(Float64(t * ew)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (ew <= 5e+68) tmp = abs(eh); else tmp = abs((t * ew)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[ew, 5e+68], N[Abs[eh], $MachinePrecision], N[Abs[N[(t * ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq 5 \cdot 10^{+68}:\\
\;\;\;\;\left|eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t \cdot ew\right|\\
\end{array}
\end{array}
if ew < 5.0000000000000004e68Initial program 99.8%
+-commutativeN/A
sin-atanN/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr33.2%
Taylor expanded in t around 0
Simplified43.2%
if 5.0000000000000004e68 < ew Initial program 99.8%
Applied egg-rr11.6%
Taylor expanded in ew around inf
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
associate-/l*N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
cancel-sign-sub-invN/A
+-lowering-+.f64N/A
metadata-evalN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f6444.9
Simplified44.9%
Taylor expanded in t around 0
*-commutativeN/A
*-lowering-*.f6434.6
Simplified34.6%
(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%
+-commutativeN/A
sin-atanN/A
div-invN/A
associate-/l*N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr41.6%
Taylor expanded in t around 0
Simplified39.1%
herbie shell --seed 2024198
(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))))))))