Example from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 24.4s
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.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{eh}{ew \cdot t}\\ \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(t\_1, t\_1, 1\right)}}, ew, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right| \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (/ eh (* ew t))))
   (fabs
    (fma
     (/ (sin t) (sqrt (fma t_1 t_1 1.0)))
     ew
     (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t)))))))))))
double code(double eh, double ew, double t) {
	double t_1 = eh / (ew * t);
	return fabs(fma((sin(t) / sqrt(fma(t_1, t_1, 1.0))), ew, (eh * (cos(t) * sin(atan((eh / (ew * tan(t)))))))));
}
function code(eh, ew, t)
	t_1 = Float64(eh / Float64(ew * t))
	return abs(fma(Float64(sin(t) / sqrt(fma(t_1, t_1, 1.0))), ew, Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t)))))))))
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[Sin[t], $MachinePrecision] / N[Sqrt[N[(t$95$1 * t$95$1 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * ew + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{eh}{ew \cdot t}\\
\left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(t\_1, t\_1, 1\right)}}, ew, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\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. 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.1

      \[\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.1%

    \[\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. Step-by-step derivation
    1. lift-+.f64N/A

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

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

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

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

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

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

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

Alternative 3: 91.8% accurate, 1.6× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left|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|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 8.19999999999999959e99

    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 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. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.19999999999999959e99 < 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. lift-+.f64N/A

        \[\leadsto \left|\color{blue}{\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. +-commutativeN/A

        \[\leadsto \left|\color{blue}{\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{\frac{eh}{ew}}{\tan t}\right)}\right| \]
      3. lift-*.f64N/A

        \[\leadsto \left|\color{blue}{\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{\frac{eh}{ew}}{\tan t}\right)\right| \]
      4. lift-*.f64N/A

        \[\leadsto \left|\color{blue}{\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{\frac{eh}{ew}}{\tan t}\right)\right| \]
      5. associate-*l*N/A

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

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

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

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

      \[\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| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification94.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 8.2 \cdot 10^{+99}:\\ \;\;\;\;\left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(\frac{eh}{ew \cdot t}, \frac{eh}{ew \cdot t}, 1\right)}}, ew, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|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|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 89.6% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{eh}{ew \cdot t}\\ \left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(t\_1, t\_1, 1\right)}}, ew, eh \cdot \left(\cos t \cdot \sin \tan^{-1} t\_1\right)\right)\right| \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (/ eh (* ew t))))
   (fabs
    (fma
     (/ (sin t) (sqrt (fma t_1 t_1 1.0)))
     ew
     (* eh (* (cos t) (sin (atan t_1))))))))
double code(double eh, double ew, double t) {
	double t_1 = eh / (ew * t);
	return fabs(fma((sin(t) / sqrt(fma(t_1, t_1, 1.0))), ew, (eh * (cos(t) * sin(atan(t_1))))));
}
function code(eh, ew, t)
	t_1 = Float64(eh / Float64(ew * t))
	return abs(fma(Float64(sin(t) / sqrt(fma(t_1, t_1, 1.0))), ew, Float64(eh * Float64(cos(t) * sin(atan(t_1))))))
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[Sin[t], $MachinePrecision] / N[Sqrt[N[(t$95$1 * t$95$1 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * ew + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{eh}{ew \cdot t}\\
\left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{\mathsf{fma}\left(t\_1, t\_1, 1\right)}}, ew, eh \cdot \left(\cos t \cdot \sin \tan^{-1} t\_1\right)\right)\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. 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.1

      \[\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.1%

    \[\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. Step-by-step derivation
    1. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 73.1% accurate, 3.6× speedup?

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

\\
\begin{array}{l}
t_1 := ew \cdot \sin t\\
\mathbf{if}\;ew \leq -2.2 \cdot 10^{+140}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{0.5}{t\_1}, eh \cdot eh, t\_1\right)\right|\\

\mathbf{elif}\;ew \leq 1.25 \cdot 10^{+97}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\

\mathbf{else}:\\
\;\;\;\;\left|t\_1\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ew < -2.1999999999999998e140

    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. Applied rewrites79.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t, \left(eh \cdot eh\right) \cdot \left(0.5 \cdot \frac{{\cos t}^{2}}{ew \cdot \sin t}\right)\right)}\right| \]
    7. Step-by-step derivation
      1. Applied rewrites75.9%

        \[\leadsto \left|\mathsf{fma}\left(\frac{\mathsf{fma}\left(\cos \left(t + t\right), 0.25, 0.25\right)}{\sin t \cdot ew}, \color{blue}{eh \cdot eh}, \sin t \cdot ew\right)\right| \]
      2. Taylor expanded in t around 0

        \[\leadsto \left|\mathsf{fma}\left(\frac{\frac{1}{2}}{\sin t \cdot ew}, eh \cdot eh, \sin t \cdot ew\right)\right| \]
      3. Step-by-step derivation
        1. Applied rewrites75.9%

          \[\leadsto \left|\mathsf{fma}\left(\frac{0.5}{\sin t \cdot ew}, eh \cdot eh, \sin t \cdot ew\right)\right| \]

        if -2.1999999999999998e140 < ew < 1.25e97

        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 rewrites30.4%

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

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

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

            \[\leadsto \left|eh \cdot \color{blue}{\cos t}\right| \]
        6. Applied rewrites80.6%

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

        if 1.25e97 < ew

        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. Applied rewrites80.2%

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

          \[\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.f6478.7

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;ew \leq -2.2 \cdot 10^{+140}:\\ \;\;\;\;\left|\mathsf{fma}\left(\frac{0.5}{ew \cdot \sin t}, eh \cdot eh, ew \cdot \sin t\right)\right|\\ \mathbf{elif}\;ew \leq 1.25 \cdot 10^{+97}:\\ \;\;\;\;\left|eh \cdot \cos t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew \cdot \sin t\right|\\ \end{array} \]
      6. Add Preprocessing

      Alternative 6: 73.7% accurate, 7.2× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_1 := \left|ew \cdot \sin t\right|\\ \mathbf{if}\;ew \leq -2.2 \cdot 10^{+140}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;ew \leq 1.25 \cdot 10^{+97}:\\ \;\;\;\;\left|eh \cdot \cos t\right|\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
      (FPCore (eh ew t)
       :precision binary64
       (let* ((t_1 (fabs (* ew (sin t)))))
         (if (<= ew -2.2e+140) t_1 (if (<= ew 1.25e+97) (fabs (* eh (cos t))) t_1))))
      double code(double eh, double ew, double t) {
      	double t_1 = fabs((ew * sin(t)));
      	double tmp;
      	if (ew <= -2.2e+140) {
      		tmp = t_1;
      	} else if (ew <= 1.25e+97) {
      		tmp = fabs((eh * cos(t)));
      	} else {
      		tmp = t_1;
      	}
      	return tmp;
      }
      
      real(8) function code(eh, ew, t)
          real(8), intent (in) :: eh
          real(8), intent (in) :: ew
          real(8), intent (in) :: t
          real(8) :: t_1
          real(8) :: tmp
          t_1 = abs((ew * sin(t)))
          if (ew <= (-2.2d+140)) then
              tmp = t_1
          else if (ew <= 1.25d+97) then
              tmp = abs((eh * cos(t)))
          else
              tmp = t_1
          end if
          code = tmp
      end function
      
      public static double code(double eh, double ew, double t) {
      	double t_1 = Math.abs((ew * Math.sin(t)));
      	double tmp;
      	if (ew <= -2.2e+140) {
      		tmp = t_1;
      	} else if (ew <= 1.25e+97) {
      		tmp = Math.abs((eh * Math.cos(t)));
      	} else {
      		tmp = t_1;
      	}
      	return tmp;
      }
      
      def code(eh, ew, t):
      	t_1 = math.fabs((ew * math.sin(t)))
      	tmp = 0
      	if ew <= -2.2e+140:
      		tmp = t_1
      	elif ew <= 1.25e+97:
      		tmp = math.fabs((eh * math.cos(t)))
      	else:
      		tmp = t_1
      	return tmp
      
      function code(eh, ew, t)
      	t_1 = abs(Float64(ew * sin(t)))
      	tmp = 0.0
      	if (ew <= -2.2e+140)
      		tmp = t_1;
      	elseif (ew <= 1.25e+97)
      		tmp = abs(Float64(eh * cos(t)));
      	else
      		tmp = t_1;
      	end
      	return tmp
      end
      
      function tmp_2 = code(eh, ew, t)
      	t_1 = abs((ew * sin(t)));
      	tmp = 0.0;
      	if (ew <= -2.2e+140)
      		tmp = t_1;
      	elseif (ew <= 1.25e+97)
      		tmp = abs((eh * cos(t)));
      	else
      		tmp = t_1;
      	end
      	tmp_2 = tmp;
      end
      
      code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -2.2e+140], t$95$1, If[LessEqual[ew, 1.25e+97], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_1 := \left|ew \cdot \sin t\right|\\
      \mathbf{if}\;ew \leq -2.2 \cdot 10^{+140}:\\
      \;\;\;\;t\_1\\
      
      \mathbf{elif}\;ew \leq 1.25 \cdot 10^{+97}:\\
      \;\;\;\;\left|eh \cdot \cos t\right|\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if ew < -2.1999999999999998e140 or 1.25e97 < 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 rewrites79.8%

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

          \[\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.f6477.2

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

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

        if -2.1999999999999998e140 < ew < 1.25e97

        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 rewrites30.4%

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

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

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

            \[\leadsto \left|eh \cdot \color{blue}{\cos t}\right| \]
        6. Applied rewrites80.6%

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

      Alternative 7: 61.9% accurate, 8.1× speedup?

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

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

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

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

          \[\leadsto \left|eh \cdot \color{blue}{\cos t}\right| \]
      6. Applied rewrites63.1%

        \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]
      7. Add Preprocessing

      Alternative 8: 41.7% accurate, 108.8× speedup?

      \[\begin{array}{l} \\ \left|eh \cdot 1\right| \end{array} \]
      (FPCore (eh ew t) :precision binary64 (fabs (* eh 1.0)))
      double code(double eh, double ew, double t) {
      	return fabs((eh * 1.0));
      }
      
      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 * 1.0d0))
      end function
      
      public static double code(double eh, double ew, double t) {
      	return Math.abs((eh * 1.0));
      }
      
      def code(eh, ew, t):
      	return math.fabs((eh * 1.0))
      
      function code(eh, ew, t)
      	return abs(Float64(eh * 1.0))
      end
      
      function tmp = code(eh, ew, t)
      	tmp = abs((eh * 1.0));
      end
      
      code[eh_, ew_, t_] := N[Abs[N[(eh * 1.0), $MachinePrecision]], $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \left|eh \cdot 1\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 rewrites46.6%

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

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

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

          \[\leadsto \left|eh \cdot \color{blue}{\cos t}\right| \]
      6. Applied rewrites63.1%

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

        \[\leadsto \left|eh \cdot 1\right| \]
      8. Step-by-step derivation
        1. Applied rewrites43.1%

          \[\leadsto \left|eh \cdot 1\right| \]
        2. Add Preprocessing

        Reproduce

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