
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (* eh (tan t)) (- 0.0 ew))))
(fabs
(fma
(/ (cos t) (sqrt (+ 1.0 (pow t_1 2.0))))
ew
(* eh (* (sin (atan t_1)) (- 0.0 (sin t))))))))
double code(double eh, double ew, double t) {
double t_1 = (eh * tan(t)) / (0.0 - ew);
return fabs(fma((cos(t) / sqrt((1.0 + pow(t_1, 2.0)))), ew, (eh * (sin(atan(t_1)) * (0.0 - sin(t))))));
}
function code(eh, ew, t) t_1 = Float64(Float64(eh * tan(t)) / Float64(0.0 - ew)) return abs(fma(Float64(cos(t) / sqrt(Float64(1.0 + (t_1 ^ 2.0)))), ew, Float64(eh * Float64(sin(atan(t_1)) * Float64(0.0 - sin(t)))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / N[(0.0 - ew), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[Cos[t], $MachinePrecision] / N[Sqrt[N[(1.0 + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * ew + N[(eh * N[(N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision] * N[(0.0 - N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh \cdot \tan t}{0 - ew}\\
\left|\mathsf{fma}\left(\frac{\cos t}{\sqrt{1 + {t\_1}^{2}}}, ew, eh \cdot \left(\sin \tan^{-1} t\_1 \cdot \left(0 - \sin t\right)\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
sub-negN/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (* eh (tan t)) (- 0.0 ew))))
(fabs
(fma
(sin t)
(* (- 0.0 eh) (sin (atan t_1)))
(/ (* (cos t) ew) (sqrt (+ 1.0 (pow t_1 2.0))))))))
double code(double eh, double ew, double t) {
double t_1 = (eh * tan(t)) / (0.0 - ew);
return fabs(fma(sin(t), ((0.0 - eh) * sin(atan(t_1))), ((cos(t) * ew) / sqrt((1.0 + pow(t_1, 2.0))))));
}
function code(eh, ew, t) t_1 = Float64(Float64(eh * tan(t)) / Float64(0.0 - ew)) return abs(fma(sin(t), Float64(Float64(0.0 - eh) * sin(atan(t_1))), Float64(Float64(cos(t) * ew) / sqrt(Float64(1.0 + (t_1 ^ 2.0)))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / N[(0.0 - ew), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[Sin[t], $MachinePrecision] * N[(N[(0.0 - eh), $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / N[Sqrt[N[(1.0 + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh \cdot \tan t}{0 - ew}\\
\left|\mathsf{fma}\left(\sin t, \left(0 - eh\right) \cdot \sin \tan^{-1} t\_1, \frac{\cos t \cdot ew}{\sqrt{1 + {t\_1}^{2}}}\right)\right|
\end{array}
\end{array}
Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (sin t) (* eh (* eh (/ -1.0 eh))) (/ (* (cos t) ew) (sqrt (+ 1.0 (pow (/ (* eh (tan t)) (- 0.0 ew)) 2.0)))))))
double code(double eh, double ew, double t) {
return fabs(fma(sin(t), (eh * (eh * (-1.0 / eh))), ((cos(t) * ew) / sqrt((1.0 + pow(((eh * tan(t)) / (0.0 - ew)), 2.0))))));
}
function code(eh, ew, t) return abs(fma(sin(t), Float64(eh * Float64(eh * Float64(-1.0 / eh))), Float64(Float64(cos(t) * ew) / sqrt(Float64(1.0 + (Float64(Float64(eh * tan(t)) / Float64(0.0 - ew)) ^ 2.0)))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[t], $MachinePrecision] * N[(eh * N[(eh * N[(-1.0 / eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / N[Sqrt[N[(1.0 + N[Power[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / N[(0.0 - ew), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\sin t, eh \cdot \left(eh \cdot \frac{-1}{eh}\right), \frac{\cos t \cdot ew}{\sqrt{1 + {\left(\frac{eh \cdot \tan t}{0 - ew}\right)}^{2}}}\right)\right|
\end{array}
Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
sin-atanN/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
+-rgt-identityN/A
*-commutativeN/A
associate-*r/N/A
+-rgt-identityN/A
+-rgt-identityN/A
+-rgt-identityN/A
Applied egg-rr84.1%
Taylor expanded in eh around -inf
/-lowering-/.f6497.8
Simplified97.8%
Final simplification97.8%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (- (cos t) (* eh (/ (sin t) ew))))))
double code(double eh, double ew, double t) {
return fabs((ew * (cos(t) - (eh * (sin(t) / ew)))));
}
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 * (cos(t) - (eh * (sin(t) / ew)))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * (Math.cos(t) - (eh * (Math.sin(t) / ew)))));
}
def code(eh, ew, t): return math.fabs((ew * (math.cos(t) - (eh * (math.sin(t) / ew)))))
function code(eh, ew, t) return abs(Float64(ew * Float64(cos(t) - Float64(eh * Float64(sin(t) / ew))))) end
function tmp = code(eh, ew, t) tmp = abs((ew * (cos(t) - (eh * (sin(t) / ew))))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(N[Cos[t], $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \left(\cos t - eh \cdot \frac{\sin t}{ew}\right)\right|
\end{array}
Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
sin-atanN/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
+-rgt-identityN/A
*-commutativeN/A
associate-*r/N/A
+-rgt-identityN/A
+-rgt-identityN/A
+-rgt-identityN/A
Applied egg-rr84.1%
Taylor expanded in eh around -inf
/-lowering-/.f6497.8
Simplified97.8%
Taylor expanded in ew around inf
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
cos-lowering-cos.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f6490.0
Simplified90.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* (cos t) ew))))
(if (<= ew -1.62e-93)
t_1
(if (<= ew 1.25e-101) (fabs (* eh (sin t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((cos(t) * ew));
double tmp;
if (ew <= -1.62e-93) {
tmp = t_1;
} else if (ew <= 1.25e-101) {
tmp = fabs((eh * 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((cos(t) * ew))
if (ew <= (-1.62d-93)) then
tmp = t_1
else if (ew <= 1.25d-101) then
tmp = abs((eh * 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((Math.cos(t) * ew));
double tmp;
if (ew <= -1.62e-93) {
tmp = t_1;
} else if (ew <= 1.25e-101) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((math.cos(t) * ew)) tmp = 0 if ew <= -1.62e-93: tmp = t_1 elif ew <= 1.25e-101: tmp = math.fabs((eh * math.sin(t))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(cos(t) * ew)) tmp = 0.0 if (ew <= -1.62e-93) tmp = t_1; elseif (ew <= 1.25e-101) tmp = abs(Float64(eh * sin(t))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((cos(t) * ew)); tmp = 0.0; if (ew <= -1.62e-93) tmp = t_1; elseif (ew <= 1.25e-101) tmp = abs((eh * sin(t))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -1.62e-93], t$95$1, If[LessEqual[ew, 1.25e-101], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\cos t \cdot ew\right|\\
\mathbf{if}\;ew \leq -1.62 \cdot 10^{-93}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 1.25 \cdot 10^{-101}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -1.6200000000000001e-93 or 1.25e-101 < ew Initial program 99.8%
sub-negN/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in eh around 0
*-lowering-*.f64N/A
cos-lowering-cos.f6481.6
Simplified81.6%
if -1.6200000000000001e-93 < ew < 1.25e-101Initial program 99.7%
neg-fabsN/A
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
Applied egg-rr58.0%
Taylor expanded in eh around -inf
*-lowering-*.f64N/A
sin-lowering-sin.f6471.1
Simplified71.1%
Final simplification78.5%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* eh (sin t))))) (if (<= t -0.00016) t_1 (if (<= t 2.4e-97) (fabs ew) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * sin(t)));
double tmp;
if (t <= -0.00016) {
tmp = t_1;
} else if (t <= 2.4e-97) {
tmp = fabs(ew);
} 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 * sin(t)))
if (t <= (-0.00016d0)) then
tmp = t_1
else if (t <= 2.4d-97) then
tmp = abs(ew)
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.sin(t)));
double tmp;
if (t <= -0.00016) {
tmp = t_1;
} else if (t <= 2.4e-97) {
tmp = Math.abs(ew);
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((eh * math.sin(t))) tmp = 0 if t <= -0.00016: tmp = t_1 elif t <= 2.4e-97: tmp = math.fabs(ew) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(eh * sin(t))) tmp = 0.0 if (t <= -0.00016) tmp = t_1; elseif (t <= 2.4e-97) tmp = abs(ew); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((eh * sin(t))); tmp = 0.0; if (t <= -0.00016) tmp = t_1; elseif (t <= 2.4e-97) tmp = abs(ew); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -0.00016], t$95$1, If[LessEqual[t, 2.4e-97], N[Abs[ew], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \sin t\right|\\
\mathbf{if}\;t \leq -0.00016:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.4 \cdot 10^{-97}:\\
\;\;\;\;\left|ew\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.60000000000000013e-4 or 2.4e-97 < t Initial program 99.6%
neg-fabsN/A
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
Applied egg-rr76.0%
Taylor expanded in eh around -inf
*-lowering-*.f64N/A
sin-lowering-sin.f6445.6
Simplified45.6%
if -1.60000000000000013e-4 < t < 2.4e-97Initial program 100.0%
sub-negN/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr100.0%
Taylor expanded in t around 0
Simplified79.4%
(FPCore (eh ew t)
:precision binary64
(if (<= ew -1.08e-148)
(fabs ew)
(if (<= ew 3.4e-221)
(fabs
(*
eh
(*
t
(fma
(* t t)
(fma (* t t) 0.008333333333333333 -0.16666666666666666)
1.0))))
(fabs ew))))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= -1.08e-148) {
tmp = fabs(ew);
} else if (ew <= 3.4e-221) {
tmp = fabs((eh * (t * fma((t * t), fma((t * t), 0.008333333333333333, -0.16666666666666666), 1.0))));
} else {
tmp = fabs(ew);
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (ew <= -1.08e-148) tmp = abs(ew); elseif (ew <= 3.4e-221) tmp = abs(Float64(eh * Float64(t * fma(Float64(t * t), fma(Float64(t * t), 0.008333333333333333, -0.16666666666666666), 1.0)))); else tmp = abs(ew); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[ew, -1.08e-148], N[Abs[ew], $MachinePrecision], If[LessEqual[ew, 3.4e-221], N[Abs[N[(eh * N[(t * N[(N[(t * t), $MachinePrecision] * N[(N[(t * t), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[ew], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.08 \cdot 10^{-148}:\\
\;\;\;\;\left|ew\right|\\
\mathbf{elif}\;ew \leq 3.4 \cdot 10^{-221}:\\
\;\;\;\;\left|eh \cdot \left(t \cdot \mathsf{fma}\left(t \cdot t, \mathsf{fma}\left(t \cdot t, 0.008333333333333333, -0.16666666666666666\right), 1\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if ew < -1.08000000000000006e-148 or 3.4000000000000001e-221 < ew Initial program 99.8%
sub-negN/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in t around 0
Simplified50.4%
if -1.08000000000000006e-148 < ew < 3.4000000000000001e-221Initial program 99.7%
neg-fabsN/A
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
Applied egg-rr48.1%
Taylor expanded in eh around -inf
*-lowering-*.f64N/A
sin-lowering-sin.f6481.1
Simplified81.1%
Taylor expanded in t around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6443.8
Simplified43.8%
(FPCore (eh ew t)
:precision binary64
(if (<= ew -4.4e-148)
(fabs ew)
(if (<= ew 7.8e-224)
(fabs (* t (fma -0.16666666666666666 (* eh (* t t)) eh)))
(fabs ew))))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= -4.4e-148) {
tmp = fabs(ew);
} else if (ew <= 7.8e-224) {
tmp = fabs((t * fma(-0.16666666666666666, (eh * (t * t)), eh)));
} else {
tmp = fabs(ew);
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (ew <= -4.4e-148) tmp = abs(ew); elseif (ew <= 7.8e-224) tmp = abs(Float64(t * fma(-0.16666666666666666, Float64(eh * Float64(t * t)), eh))); else tmp = abs(ew); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[ew, -4.4e-148], N[Abs[ew], $MachinePrecision], If[LessEqual[ew, 7.8e-224], N[Abs[N[(t * N[(-0.16666666666666666 * N[(eh * N[(t * t), $MachinePrecision]), $MachinePrecision] + eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[ew], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -4.4 \cdot 10^{-148}:\\
\;\;\;\;\left|ew\right|\\
\mathbf{elif}\;ew \leq 7.8 \cdot 10^{-224}:\\
\;\;\;\;\left|t \cdot \mathsf{fma}\left(-0.16666666666666666, eh \cdot \left(t \cdot t\right), eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if ew < -4.40000000000000034e-148 or 7.7999999999999996e-224 < ew Initial program 99.8%
sub-negN/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in t around 0
Simplified50.4%
if -4.40000000000000034e-148 < ew < 7.7999999999999996e-224Initial program 99.7%
neg-fabsN/A
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
Applied egg-rr48.1%
Taylor expanded in eh around -inf
*-lowering-*.f64N/A
sin-lowering-sin.f6481.1
Simplified81.1%
Taylor expanded in t around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6443.6
Simplified43.6%
(FPCore (eh ew t) :precision binary64 (if (<= ew -4.8e-147) (fabs ew) (if (<= ew 1.15e-221) (fabs (* t eh)) (fabs ew))))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= -4.8e-147) {
tmp = fabs(ew);
} else if (ew <= 1.15e-221) {
tmp = fabs((t * eh));
} else {
tmp = fabs(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 <= (-4.8d-147)) then
tmp = abs(ew)
else if (ew <= 1.15d-221) then
tmp = abs((t * eh))
else
tmp = abs(ew)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (ew <= -4.8e-147) {
tmp = Math.abs(ew);
} else if (ew <= 1.15e-221) {
tmp = Math.abs((t * eh));
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if ew <= -4.8e-147: tmp = math.fabs(ew) elif ew <= 1.15e-221: tmp = math.fabs((t * eh)) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if (ew <= -4.8e-147) tmp = abs(ew); elseif (ew <= 1.15e-221) tmp = abs(Float64(t * eh)); else tmp = abs(ew); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (ew <= -4.8e-147) tmp = abs(ew); elseif (ew <= 1.15e-221) tmp = abs((t * eh)); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[ew, -4.8e-147], N[Abs[ew], $MachinePrecision], If[LessEqual[ew, 1.15e-221], N[Abs[N[(t * eh), $MachinePrecision]], $MachinePrecision], N[Abs[ew], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -4.8 \cdot 10^{-147}:\\
\;\;\;\;\left|ew\right|\\
\mathbf{elif}\;ew \leq 1.15 \cdot 10^{-221}:\\
\;\;\;\;\left|t \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if ew < -4.79999999999999997e-147 or 1.15e-221 < ew Initial program 99.8%
sub-negN/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in t around 0
Simplified50.4%
if -4.79999999999999997e-147 < ew < 1.15e-221Initial program 99.7%
neg-fabsN/A
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
Applied egg-rr48.1%
Taylor expanded in eh around -inf
*-lowering-*.f64N/A
sin-lowering-sin.f6481.1
Simplified81.1%
Taylor expanded in t around 0
Simplified43.5%
Final simplification49.2%
(FPCore (eh ew t) :precision binary64 (fabs ew))
double code(double eh, double ew, double t) {
return fabs(ew);
}
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)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(ew);
}
def code(eh, ew, t): return math.fabs(ew)
function code(eh, ew, t) return abs(ew) end
function tmp = code(eh, ew, t) tmp = abs(ew); end
code[eh_, ew_, t_] := N[Abs[ew], $MachinePrecision]
\begin{array}{l}
\\
\left|ew\right|
\end{array}
Initial program 99.8%
sub-negN/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in t around 0
Simplified44.8%
herbie shell --seed 2024196
(FPCore (eh ew t)
:name "Example 2 from Robby"
:precision binary64
(fabs (- (* (* ew (cos t)) (cos (atan (/ (* (- eh) (tan t)) ew)))) (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))