
(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 (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{eh \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}
Initial program 99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (- (* eh (/ (tan t) ew)))))
(fabs
(fma
(/ (cos t) (sqrt (+ 1.0 (pow t_1 2.0))))
ew
(* (sin (atan t_1)) (- (* eh (sin t))))))))
double code(double eh, double ew, double t) {
double t_1 = -(eh * (tan(t) / ew));
return fabs(fma((cos(t) / sqrt((1.0 + pow(t_1, 2.0)))), ew, (sin(atan(t_1)) * -(eh * sin(t)))));
}
function code(eh, ew, t) t_1 = Float64(-Float64(eh * Float64(tan(t) / ew))) return abs(fma(Float64(cos(t) / sqrt(Float64(1.0 + (t_1 ^ 2.0)))), ew, Float64(sin(atan(t_1)) * Float64(-Float64(eh * sin(t)))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = (-N[(eh * N[(N[Tan[t], $MachinePrecision] / 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[(N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision] * (-N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -eh \cdot \frac{\tan t}{ew}\\
\left|\mathsf{fma}\left(\frac{\cos t}{\sqrt{1 + {t\_1}^{2}}}, ew, \sin \tan^{-1} t\_1 \cdot \left(-eh \cdot \sin t\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (cos t) ew (* (sin (atan (- (* eh (/ (tan t) ew))))) (- (* eh (sin t)))))))
double code(double eh, double ew, double t) {
return fabs(fma(cos(t), ew, (sin(atan(-(eh * (tan(t) / ew)))) * -(eh * sin(t)))));
}
function code(eh, ew, t) return abs(fma(cos(t), ew, Float64(sin(atan(Float64(-Float64(eh * Float64(tan(t) / ew))))) * Float64(-Float64(eh * sin(t)))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[Cos[t], $MachinePrecision] * ew + N[(N[Sin[N[ArcTan[(-N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]], $MachinePrecision] * (-N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\cos t, ew, \sin \tan^{-1} \left(-eh \cdot \frac{\tan t}{ew}\right) \cdot \left(-eh \cdot \sin t\right)\right)\right|
\end{array}
Initial program 99.8%
Applied egg-rr99.8%
Taylor expanded in eh around 0
lower-cos.f6497.6
Simplified97.6%
Final simplification97.6%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (* eh 0.5) (* (sin t) (/ (tan t) ew)))))
(if (<= ew -1.6e-89)
(fabs (fma t_1 eh (* ew (cos t))))
(if (<= ew 1.2e-36)
(fabs (* eh (sin t)))
(fabs (fma (cos t) ew (* eh t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh * 0.5) * (sin(t) * (tan(t) / ew));
double tmp;
if (ew <= -1.6e-89) {
tmp = fabs(fma(t_1, eh, (ew * cos(t))));
} else if (ew <= 1.2e-36) {
tmp = fabs((eh * sin(t)));
} else {
tmp = fabs(fma(cos(t), ew, (eh * t_1)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(eh * 0.5) * Float64(sin(t) * Float64(tan(t) / ew))) tmp = 0.0 if (ew <= -1.6e-89) tmp = abs(fma(t_1, eh, Float64(ew * cos(t)))); elseif (ew <= 1.2e-36) tmp = abs(Float64(eh * sin(t))); else tmp = abs(fma(cos(t), ew, Float64(eh * t_1))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh * 0.5), $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, -1.6e-89], N[Abs[N[(t$95$1 * eh + N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 1.2e-36], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Cos[t], $MachinePrecision] * ew + N[(eh * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(eh \cdot 0.5\right) \cdot \left(\sin t \cdot \frac{\tan t}{ew}\right)\\
\mathbf{if}\;ew \leq -1.6 \cdot 10^{-89}:\\
\;\;\;\;\left|\mathsf{fma}\left(t\_1, eh, ew \cdot \cos t\right)\right|\\
\mathbf{elif}\;ew \leq 1.2 \cdot 10^{-36}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(\cos t, ew, eh \cdot t\_1\right)\right|\\
\end{array}
\end{array}
if ew < -1.59999999999999999e-89Initial program 99.8%
Applied egg-rr89.6%
Taylor expanded in eh around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/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.f6471.0
Simplified71.0%
lift-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied egg-rr80.8%
if -1.59999999999999999e-89 < ew < 1.2e-36Initial program 99.7%
Applied egg-rr62.4%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6472.2
Simplified72.2%
if 1.2e-36 < ew Initial program 99.8%
Applied egg-rr91.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
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.f6474.7
Simplified74.7%
lift-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied egg-rr86.5%
Final simplification79.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(fma (cos t) ew (* eh (* (* eh 0.5) (* (sin t) (/ (tan t) ew))))))))
(if (<= ew -1.6e-89) t_1 (if (<= ew 1.2e-36) (fabs (* eh (sin t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs(fma(cos(t), ew, (eh * ((eh * 0.5) * (sin(t) * (tan(t) / ew))))));
double tmp;
if (ew <= -1.6e-89) {
tmp = t_1;
} else if (ew <= 1.2e-36) {
tmp = fabs((eh * sin(t)));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(fma(cos(t), ew, Float64(eh * Float64(Float64(eh * 0.5) * Float64(sin(t) * Float64(tan(t) / ew)))))) tmp = 0.0 if (ew <= -1.6e-89) tmp = t_1; elseif (ew <= 1.2e-36) tmp = abs(Float64(eh * sin(t))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[Cos[t], $MachinePrecision] * ew + N[(eh * N[(N[(eh * 0.5), $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -1.6e-89], t$95$1, If[LessEqual[ew, 1.2e-36], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\mathsf{fma}\left(\cos t, ew, eh \cdot \left(\left(eh \cdot 0.5\right) \cdot \left(\sin t \cdot \frac{\tan t}{ew}\right)\right)\right)\right|\\
\mathbf{if}\;ew \leq -1.6 \cdot 10^{-89}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 1.2 \cdot 10^{-36}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -1.59999999999999999e-89 or 1.2e-36 < ew Initial program 99.8%
Applied egg-rr90.5%
Taylor expanded in eh around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/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.f6472.9
Simplified72.9%
lift-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
Applied egg-rr83.7%
if -1.59999999999999999e-89 < ew < 1.2e-36Initial program 99.7%
Applied egg-rr62.4%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6472.2
Simplified72.2%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* ew (cos t))))) (if (<= ew -1.6e-89) t_1 (if (<= ew 4.2e-36) (fabs (* eh (sin t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * cos(t)));
double tmp;
if (ew <= -1.6e-89) {
tmp = t_1;
} else if (ew <= 4.2e-36) {
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((ew * cos(t)))
if (ew <= (-1.6d-89)) then
tmp = t_1
else if (ew <= 4.2d-36) 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((ew * Math.cos(t)));
double tmp;
if (ew <= -1.6e-89) {
tmp = t_1;
} else if (ew <= 4.2e-36) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((ew * math.cos(t))) tmp = 0 if ew <= -1.6e-89: tmp = t_1 elif ew <= 4.2e-36: tmp = math.fabs((eh * math.sin(t))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(ew * cos(t))) tmp = 0.0 if (ew <= -1.6e-89) tmp = t_1; elseif (ew <= 4.2e-36) tmp = abs(Float64(eh * sin(t))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((ew * cos(t))); tmp = 0.0; if (ew <= -1.6e-89) tmp = t_1; elseif (ew <= 4.2e-36) 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[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -1.6e-89], t$95$1, If[LessEqual[ew, 4.2e-36], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \cos t\right|\\
\mathbf{if}\;ew \leq -1.6 \cdot 10^{-89}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 4.2 \cdot 10^{-36}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -1.59999999999999999e-89 or 4.19999999999999982e-36 < ew Initial program 99.8%
Applied egg-rr99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6483.2
Simplified83.2%
if -1.59999999999999999e-89 < ew < 4.19999999999999982e-36Initial program 99.7%
Applied egg-rr62.4%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6472.2
Simplified72.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* eh (sin t)))))
(if (<= t -5e-6)
t_1
(if (<= t 1.5e-43) (fabs (fma (* t (* ew -0.5)) t ew)) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * sin(t)));
double tmp;
if (t <= -5e-6) {
tmp = t_1;
} else if (t <= 1.5e-43) {
tmp = fabs(fma((t * (ew * -0.5)), t, ew));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(eh * sin(t))) tmp = 0.0 if (t <= -5e-6) tmp = t_1; elseif (t <= 1.5e-43) tmp = abs(fma(Float64(t * Float64(ew * -0.5)), t, ew)); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -5e-6], t$95$1, If[LessEqual[t, 1.5e-43], N[Abs[N[(N[(t * N[(ew * -0.5), $MachinePrecision]), $MachinePrecision] * t + ew), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \sin t\right|\\
\mathbf{if}\;t \leq -5 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.5 \cdot 10^{-43}:\\
\;\;\;\;\left|\mathsf{fma}\left(t \cdot \left(ew \cdot -0.5\right), t, ew\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -5.00000000000000041e-6 or 1.50000000000000002e-43 < t Initial program 99.6%
Applied egg-rr69.7%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6451.8
Simplified51.8%
if -5.00000000000000041e-6 < t < 1.50000000000000002e-43Initial program 100.0%
Applied egg-rr90.8%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6466.0
Simplified66.0%
Taylor expanded in ew around inf
lower-*.f6476.5
Simplified76.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6476.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.5
Applied egg-rr76.5%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* t (* ew -0.5)) t ew)))
double code(double eh, double ew, double t) {
return fabs(fma((t * (ew * -0.5)), t, ew));
}
function code(eh, ew, t) return abs(fma(Float64(t * Float64(ew * -0.5)), t, ew)) end
code[eh_, ew_, t_] := N[Abs[N[(N[(t * N[(ew * -0.5), $MachinePrecision]), $MachinePrecision] * t + ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(t \cdot \left(ew \cdot -0.5\right), t, ew\right)\right|
\end{array}
Initial program 99.8%
Applied egg-rr79.4%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6433.0
Simplified33.0%
Taylor expanded in ew around inf
lower-*.f6439.1
Simplified39.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6439.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6439.3
Applied egg-rr39.3%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* t t) (* ew -0.5) ew)))
double code(double eh, double ew, double t) {
return fabs(fma((t * t), (ew * -0.5), ew));
}
function code(eh, ew, t) return abs(fma(Float64(t * t), Float64(ew * -0.5), ew)) end
code[eh_, ew_, t_] := N[Abs[N[(N[(t * t), $MachinePrecision] * N[(ew * -0.5), $MachinePrecision] + ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(t \cdot t, ew \cdot -0.5, ew\right)\right|
\end{array}
Initial program 99.8%
Applied egg-rr79.4%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6433.0
Simplified33.0%
Taylor expanded in ew around inf
lower-*.f6439.1
Simplified39.1%
Final simplification39.1%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (* -0.5 (* t t)))))
double code(double eh, double ew, double t) {
return fabs((ew * (-0.5 * (t * 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 * ((-0.5d0) * (t * t))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * (-0.5 * (t * t))));
}
def code(eh, ew, t): return math.fabs((ew * (-0.5 * (t * t))))
function code(eh, ew, t) return abs(Float64(ew * Float64(-0.5 * Float64(t * t)))) end
function tmp = code(eh, ew, t) tmp = abs((ew * (-0.5 * (t * t)))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(-0.5 * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \left(-0.5 \cdot \left(t \cdot t\right)\right)\right|
\end{array}
Initial program 99.8%
Applied egg-rr79.4%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6433.0
Simplified33.0%
Taylor expanded in ew around inf
lower-*.f6439.1
Simplified39.1%
Taylor expanded in t around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f644.9
Simplified4.9%
herbie shell --seed 2024208
(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)))))))