Example from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 20.2s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.8% accurate, 1.0× speedup?

\[\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}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\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}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 99.0% accurate, 1.2× speedup?

\[\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} \]
(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}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Add Preprocessing
  3. Taylor expanded in t around 0

    \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot t}\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot t}\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. *-commutativeN/A

      \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{\color{blue}{t \cdot ew}}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    3. *-lowering-*.f6499.3

      \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{\color{blue}{t \cdot ew}}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  5. Simplified99.3%

    \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \color{blue}{\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| \]
  6. Taylor expanded in ew around 0

    \[\leadsto \left|\color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right) + ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)}\right| \]
  7. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \left|\color{blue}{\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)} + ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right| \]
    2. accelerator-lowering-fma.f64N/A

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)}\right| \]
    3. *-lowering-*.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(\color{blue}{eh \cdot \cos t}, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \color{blue}{\cos t}, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
    5. sin-lowering-sin.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \color{blue}{\sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
    6. atan-lowering-atan.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \color{blue}{\tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
    7. /-lowering-/.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
    8. *-lowering-*.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{\color{blue}{ew \cdot \tan t}}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
    9. tan-lowering-tan.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \color{blue}{\tan t}}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
    10. *-lowering-*.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)}\right)\right| \]
    11. *-lowering-*.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \color{blue}{\left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)}\right)\right| \]
  8. Simplified99.3%

    \[\leadsto \left|\color{blue}{\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)}\right| \]
  9. Final simplification99.3%

    \[\leadsto \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| \]
  10. Add Preprocessing

Alternative 3: 98.5% accurate, 1.6× speedup?

\[\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} \]
(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}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

      \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. *-commutativeN/A

      \[\leadsto \left|\color{blue}{\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    3. accelerator-lowering-fma.f64N/A

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
  4. Applied egg-rr85.7%

    \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
  5. Taylor expanded in eh around 0

    \[\leadsto \left|\color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right) + ew \cdot \sin t}\right| \]
  6. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \left|\color{blue}{\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)} + ew \cdot \sin t\right| \]
    2. accelerator-lowering-fma.f64N/A

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \sin t\right)}\right| \]
    3. *-lowering-*.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(\color{blue}{eh \cdot \cos t}, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \sin t\right)\right| \]
    4. cos-lowering-cos.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \color{blue}{\cos t}, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \sin t\right)\right| \]
    5. sin-lowering-sin.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \color{blue}{\sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \sin t\right)\right| \]
    6. atan-lowering-atan.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \color{blue}{\tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \sin t\right)\right| \]
    7. /-lowering-/.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \sin t\right)\right| \]
    8. *-lowering-*.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{\color{blue}{ew \cdot \tan t}}\right), ew \cdot \sin t\right)\right| \]
    9. tan-lowering-tan.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \color{blue}{\tan t}}\right), ew \cdot \sin t\right)\right| \]
    10. *-lowering-*.f64N/A

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{ew \cdot \sin t}\right)\right| \]
    11. sin-lowering-sin.f6498.6

      \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \color{blue}{\sin t}\right)\right| \]
  7. Simplified98.6%

    \[\leadsto \left|\color{blue}{\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \sin t\right)}\right| \]
  8. Add Preprocessing

Alternative 4: 75.5% accurate, 1.8× speedup?

\[\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} \]
(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}
Derivation
  1. Split input into 3 regimes
  2. if t < -1.16e182 or 7.60000000000000001e143 < t

    1. Initial program 99.6%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
    4. Applied egg-rr88.8%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
    5. Step-by-step derivation
      1. sin-atanN/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{\frac{eh}{ew \cdot \tan t}}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}}}}\right)\right| \]
      2. associate-/l/N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{eh}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}} \cdot \left(ew \cdot \tan t\right)}}\right)\right| \]
    6. Applied egg-rr43.1%

      \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{eh}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)} \cdot \left(ew \cdot \tan t\right)}}\right)\right| \]
    7. Taylor expanded in eh around inf

      \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]
    8. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]
      2. cos-lowering-cos.f6464.1

        \[\leadsto \left|eh \cdot \color{blue}{\cos t}\right| \]
    9. Simplified64.1%

      \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]

    if -1.16e182 < t < -3.2000000000000001e-7 or 6.9999999999999994e-5 < t < 7.60000000000000001e143

    1. Initial program 99.6%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
    4. Applied egg-rr85.9%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
    5. Taylor expanded in eh around 0

      \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
      2. sin-lowering-sin.f6474.7

        \[\leadsto \left|ew \cdot \color{blue}{\sin t}\right| \]
    7. Simplified74.7%

      \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]

    if -3.2000000000000001e-7 < t < 6.9999999999999994e-5

    1. Initial program 100.0%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

      \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot t}\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot t}\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. *-commutativeN/A

        \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{\color{blue}{t \cdot ew}}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      3. *-lowering-*.f6499.9

        \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{\color{blue}{t \cdot ew}}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    5. Simplified99.9%

      \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \color{blue}{\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| \]
    6. Taylor expanded in ew around 0

      \[\leadsto \left|\color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right) + ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)}\right| \]
    7. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left|\color{blue}{\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)} + ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right| \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)}\right| \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\color{blue}{eh \cdot \cos t}, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh \cdot \color{blue}{\cos t}, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
      5. sin-lowering-sin.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \color{blue}{\sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
      6. atan-lowering-atan.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \color{blue}{\tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
      7. /-lowering-/.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
      8. *-lowering-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{\color{blue}{ew \cdot \tan t}}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
      9. tan-lowering-tan.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \color{blue}{\tan t}}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)\right| \]
      10. *-lowering-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)}\right)\right| \]
      11. *-lowering-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \color{blue}{\left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)}\right)\right| \]
    8. Simplified99.9%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(eh \cdot \cos t, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \sin t\right)\right)}\right| \]
    9. Taylor expanded in t around 0

      \[\leadsto \left|\color{blue}{eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right) + ew \cdot \left(t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)}\right| \]
    10. Step-by-step derivation
      1. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), ew \cdot \left(t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right)}\right| \]
      2. sin-lowering-sin.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \color{blue}{\sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \left(t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right)\right| \]
      3. atan-lowering-atan.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \color{blue}{\tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \left(t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right)\right| \]
      4. /-lowering-/.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, ew \cdot \left(t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right)\right| \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{\color{blue}{ew \cdot \tan t}}\right), ew \cdot \left(t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right)\right| \]
      6. tan-lowering-tan.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \color{blue}{\tan t}}\right), ew \cdot \left(t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right)\right| \]
      7. associate-*r*N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{\left(ew \cdot t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)}\right)\right| \]
      8. *-lowering-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{\left(ew \cdot t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)}\right)\right| \]
      9. *-commutativeN/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{\left(t \cdot ew\right)} \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right| \]
      10. *-lowering-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{\left(t \cdot ew\right)} \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right| \]
      11. cos-lowering-cos.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \left(t \cdot ew\right) \cdot \color{blue}{\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)}\right)\right| \]
      12. atan-lowering-atan.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \left(t \cdot ew\right) \cdot \cos \color{blue}{\tan^{-1} \left(\frac{eh}{ew \cdot t}\right)}\right)\right| \]
      13. /-lowering-/.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot t}\right)}\right)\right| \]
      14. *-commutativeN/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{\color{blue}{t \cdot ew}}\right)\right)\right| \]
      15. *-lowering-*.f6499.9

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{\color{blue}{t \cdot ew}}\right)\right)\right| \]
    11. Simplified99.9%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)}\right| \]
    12. Taylor expanded in t around 0

      \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{\color{blue}{t \cdot \left(ew + \frac{1}{3} \cdot \left(ew \cdot {t}^{2}\right)\right)}}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
    13. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{\color{blue}{t \cdot \left(ew + \frac{1}{3} \cdot \left(ew \cdot {t}^{2}\right)\right)}}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
      2. +-commutativeN/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{t \cdot \color{blue}{\left(\frac{1}{3} \cdot \left(ew \cdot {t}^{2}\right) + ew\right)}}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
      3. associate-*r*N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{t \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot ew\right) \cdot {t}^{2}} + ew\right)}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
      4. *-commutativeN/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{t \cdot \left(\color{blue}{\left(ew \cdot \frac{1}{3}\right)} \cdot {t}^{2} + ew\right)}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
      5. associate-*l*N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{t \cdot \left(\color{blue}{ew \cdot \left(\frac{1}{3} \cdot {t}^{2}\right)} + ew\right)}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{t \cdot \color{blue}{\mathsf{fma}\left(ew, \frac{1}{3} \cdot {t}^{2}, ew\right)}}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
      7. *-lowering-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{t \cdot \mathsf{fma}\left(ew, \color{blue}{\frac{1}{3} \cdot {t}^{2}}, ew\right)}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
      8. unpow2N/A

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{t \cdot \mathsf{fma}\left(ew, \frac{1}{3} \cdot \color{blue}{\left(t \cdot t\right)}, ew\right)}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
      9. *-lowering-*.f6499.9

        \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{t \cdot \mathsf{fma}\left(ew, 0.3333333333333333 \cdot \color{blue}{\left(t \cdot t\right)}, ew\right)}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
    14. Simplified99.9%

      \[\leadsto \left|\mathsf{fma}\left(eh, \sin \tan^{-1} \left(\frac{eh}{\color{blue}{t \cdot \mathsf{fma}\left(ew, 0.3333333333333333 \cdot \left(t \cdot t\right), ew\right)}}\right), \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right| \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.16 \cdot 10^{+182}:\\ \;\;\;\;\left|eh \cdot \cos t\right|\\ \mathbf{elif}\;t \leq -3.2 \cdot 10^{-7}:\\ \;\;\;\;\left|ew \cdot \sin t\right|\\ \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}:\\ \;\;\;\;\left|ew \cdot \sin t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|eh \cdot \cos t\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 75.1% accurate, 7.2× speedup?

\[\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} \]
(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}
Derivation
  1. Split input into 2 regimes
  2. if eh < -9.00000000000000001e-60 or 1.19999999999999996e-20 < eh

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
    4. Applied egg-rr92.1%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
    5. Step-by-step derivation
      1. sin-atanN/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{\frac{eh}{ew \cdot \tan t}}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}}}}\right)\right| \]
      2. associate-/l/N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{eh}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}} \cdot \left(ew \cdot \tan t\right)}}\right)\right| \]
    6. Applied egg-rr29.1%

      \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{eh}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)} \cdot \left(ew \cdot \tan t\right)}}\right)\right| \]
    7. Taylor expanded in eh around inf

      \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]
    8. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]
      2. cos-lowering-cos.f6480.9

        \[\leadsto \left|eh \cdot \color{blue}{\cos t}\right| \]
    9. Simplified80.9%

      \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]

    if -9.00000000000000001e-60 < eh < 1.19999999999999996e-20

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
    4. Applied egg-rr77.7%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
    5. Taylor expanded in eh around 0

      \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
      2. sin-lowering-sin.f6476.6

        \[\leadsto \left|ew \cdot \color{blue}{\sin t}\right| \]
    7. Simplified76.6%

      \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 64.8% accurate, 7.2× speedup?

\[\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} \]
(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}
Derivation
  1. Split input into 2 regimes
  2. if eh < -1.10000000000000007e-186 or 3.9999999999999999e-200 < eh

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
    4. Applied egg-rr89.5%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
    5. Step-by-step derivation
      1. sin-atanN/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{\frac{eh}{ew \cdot \tan t}}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}}}}\right)\right| \]
      2. associate-/l/N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{eh}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}} \cdot \left(ew \cdot \tan t\right)}}\right)\right| \]
    6. Applied egg-rr39.8%

      \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{eh}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)} \cdot \left(ew \cdot \tan t\right)}}\right)\right| \]
    7. Taylor expanded in eh around inf

      \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]
    8. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]
      2. cos-lowering-cos.f6469.2

        \[\leadsto \left|eh \cdot \color{blue}{\cos t}\right| \]
    9. Simplified69.2%

      \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]

    if -1.10000000000000007e-186 < eh < 3.9999999999999999e-200

    1. Initial program 99.7%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
    4. Applied egg-rr71.4%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
    5. Taylor expanded in eh around 0

      \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
      2. sin-lowering-sin.f6491.1

        \[\leadsto \left|ew \cdot \color{blue}{\sin t}\right| \]
    7. Simplified91.1%

      \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
    8. Taylor expanded in t around 0

      \[\leadsto \left|\color{blue}{ew \cdot t}\right| \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left|\color{blue}{t \cdot ew}\right| \]
      2. *-lowering-*.f6435.1

        \[\leadsto \left|\color{blue}{t \cdot ew}\right| \]
    10. Simplified35.1%

      \[\leadsto \left|\color{blue}{t \cdot ew}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;eh \leq -1.1 \cdot 10^{-186}:\\ \;\;\;\;\left|eh \cdot \cos t\right|\\ \mathbf{elif}\;eh \leq 4 \cdot 10^{-200}:\\ \;\;\;\;\left|ew \cdot t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|eh \cdot \cos t\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 45.2% accurate, 43.4× speedup?

\[\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} \]
(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}
Derivation
  1. Split input into 2 regimes
  2. if eh < -1.15e-184 or 2.9e-130 < eh

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
    4. Applied egg-rr92.2%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
    5. Step-by-step derivation
      1. sin-atanN/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{\frac{eh}{ew \cdot \tan t}}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}}}}\right)\right| \]
      2. associate-/l/N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{eh}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}} \cdot \left(ew \cdot \tan t\right)}}\right)\right| \]
    6. Applied egg-rr38.2%

      \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{eh}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)} \cdot \left(ew \cdot \tan t\right)}}\right)\right| \]
    7. Taylor expanded in t around 0

      \[\leadsto \left|\color{blue}{eh}\right| \]
    8. Step-by-step derivation
      1. Simplified47.8%

        \[\leadsto \left|\color{blue}{eh}\right| \]

      if -1.15e-184 < eh < 2.9e-130

      1. Initial program 99.7%

        \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. associate-*l*N/A

          \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
        2. *-commutativeN/A

          \[\leadsto \left|\color{blue}{\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
        3. accelerator-lowering-fma.f64N/A

          \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
      4. Applied egg-rr68.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
      5. Taylor expanded in eh around 0

        \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
      6. Step-by-step derivation
        1. *-lowering-*.f64N/A

          \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
        2. sin-lowering-sin.f6484.2

          \[\leadsto \left|ew \cdot \color{blue}{\sin t}\right| \]
      7. Simplified84.2%

        \[\leadsto \left|\color{blue}{ew \cdot \sin t}\right| \]
      8. Taylor expanded in t around 0

        \[\leadsto \left|\color{blue}{ew \cdot t}\right| \]
      9. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \left|\color{blue}{t \cdot ew}\right| \]
        2. *-lowering-*.f6435.8

          \[\leadsto \left|\color{blue}{t \cdot ew}\right| \]
      10. Simplified35.8%

        \[\leadsto \left|\color{blue}{t \cdot ew}\right| \]
    9. Recombined 2 regimes into one program.
    10. Final simplification44.5%

      \[\leadsto \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} \]
    11. Add Preprocessing

    Alternative 8: 42.4% accurate, 290.0× speedup?

    \[\begin{array}{l} \\ \left|eh\right| \end{array} \]
    (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}
    
    Derivation
    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
    4. Applied egg-rr85.7%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
    5. Step-by-step derivation
      1. sin-atanN/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{\frac{eh}{ew \cdot \tan t}}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}}}}\right)\right| \]
      2. associate-/l/N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{eh}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}} \cdot \left(ew \cdot \tan t\right)}}\right)\right| \]
    6. Applied egg-rr46.3%

      \[\leadsto \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, ew, \left(eh \cdot \cos t\right) \cdot \color{blue}{\frac{eh}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)} \cdot \left(ew \cdot \tan t\right)}}\right)\right| \]
    7. Taylor expanded in t around 0

      \[\leadsto \left|\color{blue}{eh}\right| \]
    8. Step-by-step derivation
      1. Simplified39.0%

        \[\leadsto \left|\color{blue}{eh}\right| \]
      2. Add Preprocessing

      Reproduce

      ?
      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))))))))