Example from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 20.1s
Alternatives: 10
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 10 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.1× speedup?

\[\begin{array}{l} \\ \left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right| \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (fabs
  (+
   (* (* 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((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t)))))));
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    code = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t)))))))
end function
public static double code(double eh, double ew, double t) {
	return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))) + ((ew * Math.sin(t)) * Math.cos(Math.atan((eh / (ew * t)))))));
}
def code(eh, ew, t):
	return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + ((ew * math.sin(t)) * math.cos(math.atan((eh / (ew * t)))))))
function code(eh, ew, t)
	return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(Float64(ew * sin(t)) * cos(atan(Float64(eh / Float64(ew * t)))))))
end
function tmp = code(eh, ew, t)
	tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t)))))));
end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot 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. 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. lower-/.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. lower-*.f6499.2

      \[\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. Applied rewrites99.2%

    \[\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. Final simplification99.2%

    \[\leadsto \left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right| \]
  7. 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. Applied rewrites88.5%

    \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{ew}{\sqrt{\mathsf{fma}\left(eh \cdot eh, {\left(ew \cdot \tan t\right)}^{-2}, 1\right)}}, \sin t, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)}\right| \]
  4. 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| \]
  5. 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. lower-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. lower-*.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. lower-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. lower-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. lower-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. lower-/.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. lower-*.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. lower-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. lower-*.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. lower-sin.f6498.8

      \[\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| \]
  6. Applied rewrites98.8%

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

Alternative 4: 93.5% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left|ew \cdot \mathsf{fma}\left(\cos t, eh \cdot \frac{\sin \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.3333333333333333, eh \cdot \frac{t \cdot t}{ew}, \frac{eh}{ew}\right)}{t}\right)}{ew}, \sin t\right)\right|\\ \mathbf{if}\;ew \leq -5.3 \cdot 10^{-157}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;ew \leq 3.2 \cdot 10^{-47}:\\ \;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1
         (fabs
          (*
           ew
           (fma
            (cos t)
            (*
             eh
             (/
              (sin
               (atan
                (/
                 (fma -0.3333333333333333 (* eh (/ (* t t) ew)) (/ eh ew))
                 t)))
              ew))
            (sin t))))))
   (if (<= ew -5.3e-157)
     t_1
     (if (<= ew 3.2e-47)
       (fabs (* (* eh (cos t)) (sin (atan (/ eh (* ew (tan t)))))))
       t_1))))
double code(double eh, double ew, double t) {
	double t_1 = fabs((ew * fma(cos(t), (eh * (sin(atan((fma(-0.3333333333333333, (eh * ((t * t) / ew)), (eh / ew)) / t))) / ew)), sin(t))));
	double tmp;
	if (ew <= -5.3e-157) {
		tmp = t_1;
	} else if (ew <= 3.2e-47) {
		tmp = fabs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t)))))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(eh, ew, t)
	t_1 = abs(Float64(ew * fma(cos(t), Float64(eh * Float64(sin(atan(Float64(fma(-0.3333333333333333, Float64(eh * Float64(Float64(t * t) / ew)), Float64(eh / ew)) / t))) / ew)), sin(t))))
	tmp = 0.0
	if (ew <= -5.3e-157)
		tmp = t_1;
	elseif (ew <= 3.2e-47)
		tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(ew * tan(t)))))));
	else
		tmp = t_1;
	end
	return tmp
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[(N[Cos[t], $MachinePrecision] * N[(eh * N[(N[Sin[N[ArcTan[N[(N[(-0.3333333333333333 * N[(eh * N[(N[(t * t), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] + N[(eh / ew), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -5.3e-157], t$95$1, If[LessEqual[ew, 3.2e-47], 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]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left|ew \cdot \mathsf{fma}\left(\cos t, eh \cdot \frac{\sin \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.3333333333333333, eh \cdot \frac{t \cdot t}{ew}, \frac{eh}{ew}\right)}{t}\right)}{ew}, \sin t\right)\right|\\
\mathbf{if}\;ew \leq -5.3 \cdot 10^{-157}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;ew \leq 3.2 \cdot 10^{-47}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -5.3000000000000002e-157 or 3.1999999999999999e-47 < ew

    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. Applied rewrites89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|ew \cdot \left(eh \cdot \frac{\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}{ew} + \color{blue}{\sin t}\right)\right| \]
    8. Applied rewrites97.2%

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

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

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

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

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

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

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

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

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

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

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

    if -5.3000000000000002e-157 < ew < 3.1999999999999999e-47

    1. Initial program 99.9%

      \[\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 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)}\right| \]
    4. 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)}\right| \]
      2. lower-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{\color{blue}{ew \cdot \tan t}}\right)\right| \]
      9. lower-tan.f6494.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ew \leq -5.3 \cdot 10^{-157}:\\ \;\;\;\;\left|ew \cdot \mathsf{fma}\left(\cos t, eh \cdot \frac{\sin \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.3333333333333333, eh \cdot \frac{t \cdot t}{ew}, \frac{eh}{ew}\right)}{t}\right)}{ew}, \sin t\right)\right|\\ \mathbf{elif}\;ew \leq 3.2 \cdot 10^{-47}:\\ \;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew \cdot \mathsf{fma}\left(\cos t, eh \cdot \frac{\sin \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.3333333333333333, eh \cdot \frac{t \cdot t}{ew}, \frac{eh}{ew}\right)}{t}\right)}{ew}, \sin t\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 88.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left|ew \cdot \mathsf{fma}\left(\cos t, eh \cdot \frac{\sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)}{ew}, \sin t\right)\right|\\ \mathbf{if}\;ew \leq -3.8 \cdot 10^{-38}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;ew \leq 8.5 \cdot 10^{-8}:\\ \;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1
         (fabs
          (*
           ew
           (fma (cos t) (* eh (/ (sin (atan (/ eh (* ew t)))) ew)) (sin t))))))
   (if (<= ew -3.8e-38)
     t_1
     (if (<= ew 8.5e-8)
       (fabs (* (* eh (cos t)) (sin (atan (/ eh (* ew (tan t)))))))
       t_1))))
double code(double eh, double ew, double t) {
	double t_1 = fabs((ew * fma(cos(t), (eh * (sin(atan((eh / (ew * t)))) / ew)), sin(t))));
	double tmp;
	if (ew <= -3.8e-38) {
		tmp = t_1;
	} else if (ew <= 8.5e-8) {
		tmp = fabs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t)))))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(eh, ew, t)
	t_1 = abs(Float64(ew * fma(cos(t), Float64(eh * Float64(sin(atan(Float64(eh / Float64(ew * t)))) / ew)), sin(t))))
	tmp = 0.0
	if (ew <= -3.8e-38)
		tmp = t_1;
	elseif (ew <= 8.5e-8)
		tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(ew * tan(t)))))));
	else
		tmp = t_1;
	end
	return tmp
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[(N[Cos[t], $MachinePrecision] * N[(eh * N[(N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -3.8e-38], t$95$1, If[LessEqual[ew, 8.5e-8], 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]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left|ew \cdot \mathsf{fma}\left(\cos t, eh \cdot \frac{\sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)}{ew}, \sin t\right)\right|\\
\mathbf{if}\;ew \leq -3.8 \cdot 10^{-38}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;ew \leq 8.5 \cdot 10^{-8}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -3.8e-38 or 8.49999999999999935e-8 < ew

    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. Applied rewrites89.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.8e-38 < ew < 8.49999999999999935e-8

    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 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)}\right| \]
    4. 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)}\right| \]
      2. lower-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{\color{blue}{ew \cdot \tan t}}\right)\right| \]
      9. lower-tan.f6491.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ew \leq -3.8 \cdot 10^{-38}:\\ \;\;\;\;\left|ew \cdot \mathsf{fma}\left(\cos t, eh \cdot \frac{\sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)}{ew}, \sin t\right)\right|\\ \mathbf{elif}\;ew \leq 8.5 \cdot 10^{-8}:\\ \;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew \cdot \mathsf{fma}\left(\cos t, eh \cdot \frac{\sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)}{ew}, \sin t\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 76.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left|ew \cdot \sin t\right|\\ \mathbf{if}\;ew \leq -7.5 \cdot 10^{+105}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;ew \leq 2.6 \cdot 10^{+91}:\\ \;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (fabs (* ew (sin t)))))
   (if (<= ew -7.5e+105)
     t_1
     (if (<= ew 2.6e+91)
       (fabs (* (* eh (cos t)) (sin (atan (/ eh (* ew (tan t)))))))
       t_1))))
double code(double eh, double ew, double t) {
	double t_1 = fabs((ew * sin(t)));
	double tmp;
	if (ew <= -7.5e+105) {
		tmp = t_1;
	} else if (ew <= 2.6e+91) {
		tmp = fabs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t)))))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = abs((ew * sin(t)))
    if (ew <= (-7.5d+105)) then
        tmp = t_1
    else if (ew <= 2.6d+91) then
        tmp = abs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t)))))))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double t_1 = Math.abs((ew * Math.sin(t)));
	double tmp;
	if (ew <= -7.5e+105) {
		tmp = t_1;
	} else if (ew <= 2.6e+91) {
		tmp = Math.abs(((eh * Math.cos(t)) * Math.sin(Math.atan((eh / (ew * Math.tan(t)))))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(eh, ew, t):
	t_1 = math.fabs((ew * math.sin(t)))
	tmp = 0
	if ew <= -7.5e+105:
		tmp = t_1
	elif ew <= 2.6e+91:
		tmp = math.fabs(((eh * math.cos(t)) * math.sin(math.atan((eh / (ew * math.tan(t)))))))
	else:
		tmp = t_1
	return tmp
function code(eh, ew, t)
	t_1 = abs(Float64(ew * sin(t)))
	tmp = 0.0
	if (ew <= -7.5e+105)
		tmp = t_1;
	elseif (ew <= 2.6e+91)
		tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(ew * tan(t)))))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	t_1 = abs((ew * sin(t)));
	tmp = 0.0;
	if (ew <= -7.5e+105)
		tmp = t_1;
	elseif (ew <= 2.6e+91)
		tmp = abs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t)))))));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -7.5e+105], t$95$1, If[LessEqual[ew, 2.6e+91], 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]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left|ew \cdot \sin t\right|\\
\mathbf{if}\;ew \leq -7.5 \cdot 10^{+105}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;ew \leq 2.6 \cdot 10^{+91}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -7.5000000000000002e105 or 2.6e91 < ew

    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. Applied rewrites86.0%

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

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

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

        \[\leadsto \left|ew \cdot \color{blue}{\sin t}\right| \]
    6. Applied rewrites74.9%

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

    if -7.5000000000000002e105 < ew < 2.6e91

    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 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)}\right| \]
    4. 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)}\right| \]
      2. lower-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{\color{blue}{ew \cdot \tan t}}\right)\right| \]
      9. lower-tan.f6481.7

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

      \[\leadsto \left|\color{blue}{\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}\right| \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 69.0% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left|ew \cdot \sin t\right|\\ \mathbf{if}\;t \leq -900000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 0.00019:\\ \;\;\;\;\left|ew \cdot \mathsf{fma}\left(eh, \frac{\sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}{ew}, t\right)\right|\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (fabs (* ew (sin t)))))
   (if (<= t -900000000.0)
     t_1
     (if (<= t 0.00019)
       (fabs (* ew (fma eh (/ (sin (atan (/ eh (* ew (tan t))))) ew) t)))
       t_1))))
double code(double eh, double ew, double t) {
	double t_1 = fabs((ew * sin(t)));
	double tmp;
	if (t <= -900000000.0) {
		tmp = t_1;
	} else if (t <= 0.00019) {
		tmp = fabs((ew * fma(eh, (sin(atan((eh / (ew * tan(t))))) / ew), t)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(eh, ew, t)
	t_1 = abs(Float64(ew * sin(t)))
	tmp = 0.0
	if (t <= -900000000.0)
		tmp = t_1;
	elseif (t <= 0.00019)
		tmp = abs(Float64(ew * fma(eh, Float64(sin(atan(Float64(eh / Float64(ew * tan(t))))) / ew), t)));
	else
		tmp = t_1;
	end
	return tmp
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -900000000.0], t$95$1, If[LessEqual[t, 0.00019], N[Abs[N[(ew * N[(eh * N[(N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / ew), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left|ew \cdot \sin t\right|\\
\mathbf{if}\;t \leq -900000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 0.00019:\\
\;\;\;\;\left|ew \cdot \mathsf{fma}\left(eh, \frac{\sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}{ew}, t\right)\right|\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -9e8 or 1.9000000000000001e-4 < 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. Applied rewrites89.5%

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

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

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

        \[\leadsto \left|ew \cdot \color{blue}{\sin t}\right| \]
    6. Applied rewrites48.2%

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

    if -9e8 < t < 1.9000000000000001e-4

    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. Applied rewrites87.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 61.6% accurate, 7.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left|ew \cdot \sin t\right|\\ \mathbf{if}\;t \leq -900000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{-6}:\\ \;\;\;\;\left|eh\right|\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (fabs (* ew (sin t)))))
   (if (<= t -900000000.0) t_1 (if (<= t 2.2e-6) (fabs eh) t_1))))
double code(double eh, double ew, double t) {
	double t_1 = fabs((ew * sin(t)));
	double tmp;
	if (t <= -900000000.0) {
		tmp = t_1;
	} else if (t <= 2.2e-6) {
		tmp = fabs(eh);
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = abs((ew * sin(t)))
    if (t <= (-900000000.0d0)) then
        tmp = t_1
    else if (t <= 2.2d-6) then
        tmp = abs(eh)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double t_1 = Math.abs((ew * Math.sin(t)));
	double tmp;
	if (t <= -900000000.0) {
		tmp = t_1;
	} else if (t <= 2.2e-6) {
		tmp = Math.abs(eh);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(eh, ew, t):
	t_1 = math.fabs((ew * math.sin(t)))
	tmp = 0
	if t <= -900000000.0:
		tmp = t_1
	elif t <= 2.2e-6:
		tmp = math.fabs(eh)
	else:
		tmp = t_1
	return tmp
function code(eh, ew, t)
	t_1 = abs(Float64(ew * sin(t)))
	tmp = 0.0
	if (t <= -900000000.0)
		tmp = t_1;
	elseif (t <= 2.2e-6)
		tmp = abs(eh);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	t_1 = abs((ew * sin(t)));
	tmp = 0.0;
	if (t <= -900000000.0)
		tmp = t_1;
	elseif (t <= 2.2e-6)
		tmp = abs(eh);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -900000000.0], t$95$1, If[LessEqual[t, 2.2e-6], N[Abs[eh], $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left|ew \cdot \sin t\right|\\
\mathbf{if}\;t \leq -900000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 2.2 \cdot 10^{-6}:\\
\;\;\;\;\left|eh\right|\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -9e8 or 2.2000000000000001e-6 < 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. Applied rewrites89.5%

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

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

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

        \[\leadsto \left|ew \cdot \color{blue}{\sin t}\right| \]
    6. Applied rewrites48.2%

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

    if -9e8 < t < 2.2000000000000001e-6

    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|\color{blue}{eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}\right| \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

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

        \[\leadsto \left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{\color{blue}{ew \cdot \tan t}}\right)\right| \]
      6. lower-tan.f6472.8

        \[\leadsto \left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \color{blue}{\tan t}}\right)\right| \]
    5. Applied rewrites72.8%

      \[\leadsto \left|\color{blue}{eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}\right| \]
    6. Applied rewrites11.5%

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

      \[\leadsto \left|\color{blue}{-1 \cdot eh}\right| \]
    8. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \left|\color{blue}{\mathsf{neg}\left(eh\right)}\right| \]
      2. lower-neg.f6473.1

        \[\leadsto \left|\color{blue}{-eh}\right| \]
    9. Applied rewrites73.1%

      \[\leadsto \left|\color{blue}{-eh}\right| \]
    10. Step-by-step derivation
      1. fabs-negN/A

        \[\leadsto \color{blue}{\left|eh\right|} \]
      2. lower-fabs.f6473.1

        \[\leadsto \color{blue}{\left|eh\right|} \]
    11. Applied rewrites73.1%

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

Alternative 9: 45.6% accurate, 43.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;eh \leq -5.1 \cdot 10^{-202}:\\ \;\;\;\;\left|eh\right|\\ \mathbf{elif}\;eh \leq 3.8 \cdot 10^{-148}:\\ \;\;\;\;\left|ew \cdot t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|eh\right|\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (if (<= eh -5.1e-202)
   (fabs eh)
   (if (<= eh 3.8e-148) (fabs (* ew t)) (fabs eh))))
double code(double eh, double ew, double t) {
	double tmp;
	if (eh <= -5.1e-202) {
		tmp = fabs(eh);
	} else if (eh <= 3.8e-148) {
		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 <= (-5.1d-202)) then
        tmp = abs(eh)
    else if (eh <= 3.8d-148) 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 <= -5.1e-202) {
		tmp = Math.abs(eh);
	} else if (eh <= 3.8e-148) {
		tmp = Math.abs((ew * t));
	} else {
		tmp = Math.abs(eh);
	}
	return tmp;
}
def code(eh, ew, t):
	tmp = 0
	if eh <= -5.1e-202:
		tmp = math.fabs(eh)
	elif eh <= 3.8e-148:
		tmp = math.fabs((ew * t))
	else:
		tmp = math.fabs(eh)
	return tmp
function code(eh, ew, t)
	tmp = 0.0
	if (eh <= -5.1e-202)
		tmp = abs(eh);
	elseif (eh <= 3.8e-148)
		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 <= -5.1e-202)
		tmp = abs(eh);
	elseif (eh <= 3.8e-148)
		tmp = abs((ew * t));
	else
		tmp = abs(eh);
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := If[LessEqual[eh, -5.1e-202], N[Abs[eh], $MachinePrecision], If[LessEqual[eh, 3.8e-148], N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision], N[Abs[eh], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;eh \leq -5.1 \cdot 10^{-202}:\\
\;\;\;\;\left|eh\right|\\

\mathbf{elif}\;eh \leq 3.8 \cdot 10^{-148}:\\
\;\;\;\;\left|ew \cdot t\right|\\

\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eh < -5.09999999999999996e-202 or 3.80000000000000014e-148 < 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. Taylor expanded in t around 0

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

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

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

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

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

        \[\leadsto \left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{\color{blue}{ew \cdot \tan t}}\right)\right| \]
      6. lower-tan.f6453.9

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

      \[\leadsto \left|\color{blue}{eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}\right| \]
    6. Applied rewrites10.3%

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

      \[\leadsto \left|\color{blue}{-1 \cdot eh}\right| \]
    8. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \left|\color{blue}{\mathsf{neg}\left(eh\right)}\right| \]
      2. lower-neg.f6454.2

        \[\leadsto \left|\color{blue}{-eh}\right| \]
    9. Applied rewrites54.2%

      \[\leadsto \left|\color{blue}{-eh}\right| \]
    10. Step-by-step derivation
      1. fabs-negN/A

        \[\leadsto \color{blue}{\left|eh\right|} \]
      2. lower-fabs.f6454.2

        \[\leadsto \color{blue}{\left|eh\right|} \]
    11. Applied rewrites54.2%

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

    if -5.09999999999999996e-202 < eh < 3.80000000000000014e-148

    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. Applied rewrites72.5%

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

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

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

        \[\leadsto \left|ew \cdot \color{blue}{\sin t}\right| \]
    6. Applied rewrites85.2%

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

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

        \[\leadsto \left|\color{blue}{t \cdot ew}\right| \]
      2. lower-*.f6442.4

        \[\leadsto \left|\color{blue}{t \cdot ew}\right| \]
    9. Applied rewrites42.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;eh \leq -5.1 \cdot 10^{-202}:\\ \;\;\;\;\left|eh\right|\\ \mathbf{elif}\;eh \leq 3.8 \cdot 10^{-148}:\\ \;\;\;\;\left|ew \cdot t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|eh\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 42.8% 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. Taylor expanded in t around 0

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

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

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

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

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

      \[\leadsto \left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{\color{blue}{ew \cdot \tan t}}\right)\right| \]
    6. lower-tan.f6447.5

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

    \[\leadsto \left|\color{blue}{eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}\right| \]
  6. Applied rewrites9.1%

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

    \[\leadsto \left|\color{blue}{-1 \cdot eh}\right| \]
  8. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \left|\color{blue}{\mathsf{neg}\left(eh\right)}\right| \]
    2. lower-neg.f6447.9

      \[\leadsto \left|\color{blue}{-eh}\right| \]
  9. Applied rewrites47.9%

    \[\leadsto \left|\color{blue}{-eh}\right| \]
  10. Step-by-step derivation
    1. fabs-negN/A

      \[\leadsto \color{blue}{\left|eh\right|} \]
    2. lower-fabs.f6447.9

      \[\leadsto \color{blue}{\left|eh\right|} \]
  11. Applied rewrites47.9%

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

Reproduce

?
herbie shell --seed 2024214 
(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))))))))