Example 2 from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 18.1s
Alternatives: 11
Speedup: N/A×

Specification

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

\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

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

\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}

Alternative 1: 99.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_1 := eh \cdot \frac{\tan t}{ew}\\
\left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, t\_1\right)} + eh \cdot \left(\sin t \cdot \sin \tan^{-1} t\_1\right)\right|
\end{array}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-neg99.8%

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

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

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

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

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(-eh\right) \cdot \frac{\tan t}{ew}}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    6. add-sqr-sqrt47.6%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{-eh} \cdot \sqrt{-eh}\right)} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    7. sqrt-unprod91.0%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\left(-eh\right) \cdot \left(-eh\right)}} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    8. sqr-neg91.0%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{eh \cdot eh}} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    9. sqrt-unprod52.2%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{eh} \cdot \sqrt{eh}\right)} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    10. add-sqr-sqrt99.8%

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

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

Alternative 2: 99.0% accurate, 1.3× speedup?

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

\\
\left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, eh \cdot \frac{\tan t}{ew}\right)} + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{ew}\right)\right)\right|
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-neg99.8%

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

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

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

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

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(-eh\right) \cdot \frac{\tan t}{ew}}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    6. add-sqr-sqrt47.6%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{-eh} \cdot \sqrt{-eh}\right)} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    7. sqrt-unprod91.0%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\left(-eh\right) \cdot \left(-eh\right)}} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    8. sqr-neg91.0%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{eh \cdot eh}} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    9. sqrt-unprod52.2%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{eh} \cdot \sqrt{eh}\right)} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    10. add-sqr-sqrt99.8%

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

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

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

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

Alternative 3: 98.5% accurate, 1.5× speedup?

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

\\
\left|ew \cdot \cos t + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\right)\right|
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-neg99.8%

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

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

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

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

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(-eh\right) \cdot \frac{\tan t}{ew}}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    6. add-sqr-sqrt47.6%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{-eh} \cdot \sqrt{-eh}\right)} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    7. sqrt-unprod91.0%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\left(-eh\right) \cdot \left(-eh\right)}} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    8. sqr-neg91.0%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{eh \cdot eh}} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    9. sqrt-unprod52.2%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{eh} \cdot \sqrt{eh}\right)} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    10. add-sqr-sqrt99.8%

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

    \[\leadsto \left|\color{blue}{\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, eh \cdot \frac{\tan t}{ew}\right)} + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\right)}\right| \]
  5. Taylor expanded in ew around inf 98.1%

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

Alternative 4: 86.8% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ew \leq -2 \cdot 10^{+122} \lor \neg \left(ew \leq 3.5 \cdot 10^{-37}\right):\\ \;\;\;\;\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{ew}\right)\right)\right|\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (if (or (<= ew -2e+122) (not (<= ew 3.5e-37)))
   (fabs (* (* ew (cos t)) (cos (atan (* eh (/ (tan t) (- ew)))))))
   (fabs (+ ew (* eh (* (sin t) (sin (atan (/ (* t eh) ew)))))))))
double code(double eh, double ew, double t) {
	double tmp;
	if ((ew <= -2e+122) || !(ew <= 3.5e-37)) {
		tmp = fabs(((ew * cos(t)) * cos(atan((eh * (tan(t) / -ew))))));
	} else {
		tmp = fabs((ew + (eh * (sin(t) * sin(atan(((t * eh) / ew)))))));
	}
	return tmp;
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((ew <= (-2d+122)) .or. (.not. (ew <= 3.5d-37))) then
        tmp = abs(((ew * cos(t)) * cos(atan((eh * (tan(t) / -ew))))))
    else
        tmp = abs((ew + (eh * (sin(t) * sin(atan(((t * eh) / ew)))))))
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double tmp;
	if ((ew <= -2e+122) || !(ew <= 3.5e-37)) {
		tmp = Math.abs(((ew * Math.cos(t)) * Math.cos(Math.atan((eh * (Math.tan(t) / -ew))))));
	} else {
		tmp = Math.abs((ew + (eh * (Math.sin(t) * Math.sin(Math.atan(((t * eh) / ew)))))));
	}
	return tmp;
}
def code(eh, ew, t):
	tmp = 0
	if (ew <= -2e+122) or not (ew <= 3.5e-37):
		tmp = math.fabs(((ew * math.cos(t)) * math.cos(math.atan((eh * (math.tan(t) / -ew))))))
	else:
		tmp = math.fabs((ew + (eh * (math.sin(t) * math.sin(math.atan(((t * eh) / ew)))))))
	return tmp
function code(eh, ew, t)
	tmp = 0.0
	if ((ew <= -2e+122) || !(ew <= 3.5e-37))
		tmp = abs(Float64(Float64(ew * cos(t)) * cos(atan(Float64(eh * Float64(tan(t) / Float64(-ew)))))));
	else
		tmp = abs(Float64(ew + Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(t * eh) / ew)))))));
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	tmp = 0.0;
	if ((ew <= -2e+122) || ~((ew <= 3.5e-37)))
		tmp = abs(((ew * cos(t)) * cos(atan((eh * (tan(t) / -ew))))));
	else
		tmp = abs((ew + (eh * (sin(t) * sin(atan(((t * eh) / ew)))))));
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2e+122], N[Not[LessEqual[ew, 3.5e-37]], $MachinePrecision]], N[Abs[N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew + N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2 \cdot 10^{+122} \lor \neg \left(ew \leq 3.5 \cdot 10^{-37}\right):\\
\;\;\;\;\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\left|ew + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{ew}\right)\right)\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -2.00000000000000003e122 or 3.5000000000000001e-37 < ew

    1. Initial program 99.8%

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

      \[\leadsto \left|\color{blue}{ew \cdot \left(\cos t \cdot \cos \tan^{-1} \left(-1 \cdot \frac{eh \cdot \tan t}{ew}\right)\right)}\right| \]
    4. Step-by-step derivation
      1. associate-*r*92.6%

        \[\leadsto \left|\color{blue}{\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(-1 \cdot \frac{eh \cdot \tan t}{ew}\right)}\right| \]
      2. *-commutative92.6%

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

        \[\leadsto \left|\cos \tan^{-1} \color{blue}{\left(-\frac{eh \cdot \tan t}{ew}\right)} \cdot \left(ew \cdot \cos t\right)\right| \]
      4. associate-*r/92.6%

        \[\leadsto \left|\cos \tan^{-1} \left(-\color{blue}{eh \cdot \frac{\tan t}{ew}}\right) \cdot \left(ew \cdot \cos t\right)\right| \]
      5. distribute-rgt-neg-in92.6%

        \[\leadsto \left|\cos \tan^{-1} \color{blue}{\left(eh \cdot \left(-\frac{\tan t}{ew}\right)\right)} \cdot \left(ew \cdot \cos t\right)\right| \]
      6. distribute-neg-frac292.6%

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

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

    if -2.00000000000000003e122 < ew < 3.5000000000000001e-37

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg99.8%

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

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

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

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

        \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(-eh\right) \cdot \frac{\tan t}{ew}}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
      6. add-sqr-sqrt49.3%

        \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{-eh} \cdot \sqrt{-eh}\right)} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
      7. sqrt-unprod96.4%

        \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\left(-eh\right) \cdot \left(-eh\right)}} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
      8. sqr-neg96.4%

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

        \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{eh} \cdot \sqrt{eh}\right)} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
      10. add-sqr-sqrt99.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ew \leq -2 \cdot 10^{+122} \lor \neg \left(ew \leq 3.5 \cdot 10^{-37}\right):\\ \;\;\;\;\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{ew}\right)\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 56.1% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -3400 \lor \neg \left(t \leq 500\right):\\ \;\;\;\;\left|ew \cdot \cos \tan^{-1} \left(\frac{eh \cdot \tan t}{ew}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew + t \cdot \left(t \cdot \left(ew \cdot -0.5\right) - eh \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{-ew}\right)\right)\right|\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (if (or (<= t -3400.0) (not (<= t 500.0)))
   (fabs (* ew (cos (atan (/ (* eh (tan t)) ew)))))
   (fabs
    (+
     ew
     (* t (- (* t (* ew -0.5)) (* eh (sin (atan (/ (* t eh) (- ew)))))))))))
double code(double eh, double ew, double t) {
	double tmp;
	if ((t <= -3400.0) || !(t <= 500.0)) {
		tmp = fabs((ew * cos(atan(((eh * tan(t)) / ew)))));
	} else {
		tmp = fabs((ew + (t * ((t * (ew * -0.5)) - (eh * sin(atan(((t * eh) / -ew))))))));
	}
	return tmp;
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((t <= (-3400.0d0)) .or. (.not. (t <= 500.0d0))) then
        tmp = abs((ew * cos(atan(((eh * tan(t)) / ew)))))
    else
        tmp = abs((ew + (t * ((t * (ew * (-0.5d0))) - (eh * sin(atan(((t * eh) / -ew))))))))
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double tmp;
	if ((t <= -3400.0) || !(t <= 500.0)) {
		tmp = Math.abs((ew * Math.cos(Math.atan(((eh * Math.tan(t)) / ew)))));
	} else {
		tmp = Math.abs((ew + (t * ((t * (ew * -0.5)) - (eh * Math.sin(Math.atan(((t * eh) / -ew))))))));
	}
	return tmp;
}
def code(eh, ew, t):
	tmp = 0
	if (t <= -3400.0) or not (t <= 500.0):
		tmp = math.fabs((ew * math.cos(math.atan(((eh * math.tan(t)) / ew)))))
	else:
		tmp = math.fabs((ew + (t * ((t * (ew * -0.5)) - (eh * math.sin(math.atan(((t * eh) / -ew))))))))
	return tmp
function code(eh, ew, t)
	tmp = 0.0
	if ((t <= -3400.0) || !(t <= 500.0))
		tmp = abs(Float64(ew * cos(atan(Float64(Float64(eh * tan(t)) / ew)))));
	else
		tmp = abs(Float64(ew + Float64(t * Float64(Float64(t * Float64(ew * -0.5)) - Float64(eh * sin(atan(Float64(Float64(t * eh) / Float64(-ew)))))))));
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	tmp = 0.0;
	if ((t <= -3400.0) || ~((t <= 500.0)))
		tmp = abs((ew * cos(atan(((eh * tan(t)) / ew)))));
	else
		tmp = abs((ew + (t * ((t * (ew * -0.5)) - (eh * sin(atan(((t * eh) / -ew))))))));
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -3400.0], N[Not[LessEqual[t, 500.0]], $MachinePrecision]], N[Abs[N[(ew * N[Cos[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew + N[(t * N[(N[(t * N[(ew * -0.5), $MachinePrecision]), $MachinePrecision] - N[(eh * N[Sin[N[ArcTan[N[(N[(t * eh), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -3400 \lor \neg \left(t \leq 500\right):\\
\;\;\;\;\left|ew \cdot \cos \tan^{-1} \left(\frac{eh \cdot \tan t}{ew}\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\left|ew + t \cdot \left(t \cdot \left(ew \cdot -0.5\right) - eh \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{-ew}\right)\right)\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3400 or 500 < t

    1. Initial program 99.7%

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

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

        \[\leadsto \left|ew \cdot \cos \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left(eh \cdot \tan t\right)}{ew}\right)}\right| \]
      2. neg-mul-113.9%

        \[\leadsto \left|ew \cdot \cos \tan^{-1} \left(\frac{\color{blue}{-eh \cdot \tan t}}{ew}\right)\right| \]
      3. distribute-lft-neg-in13.9%

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

      \[\leadsto \left|\color{blue}{ew \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)}\right| \]
    6. Step-by-step derivation
      1. add-sqr-sqrt6.0%

        \[\leadsto \left|ew \cdot \cos \tan^{-1} \left(\frac{\color{blue}{\left(\sqrt{-eh} \cdot \sqrt{-eh}\right)} \cdot \tan t}{ew}\right)\right| \]
      2. sqrt-unprod13.4%

        \[\leadsto \left|ew \cdot \cos \tan^{-1} \left(\frac{\color{blue}{\sqrt{\left(-eh\right) \cdot \left(-eh\right)}} \cdot \tan t}{ew}\right)\right| \]
      3. sqr-neg13.4%

        \[\leadsto \left|ew \cdot \cos \tan^{-1} \left(\frac{\sqrt{\color{blue}{eh \cdot eh}} \cdot \tan t}{ew}\right)\right| \]
      4. sqrt-unprod7.9%

        \[\leadsto \left|ew \cdot \cos \tan^{-1} \left(\frac{\color{blue}{\left(\sqrt{eh} \cdot \sqrt{eh}\right)} \cdot \tan t}{ew}\right)\right| \]
      5. add-sqr-sqrt13.9%

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

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

      \[\leadsto \left|ew \cdot \cos \tan^{-1} \left(\frac{\color{blue}{{\left(eh \cdot \tan t\right)}^{1}}}{ew}\right)\right| \]
    8. Step-by-step derivation
      1. unpow113.9%

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

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

    if -3400 < t < 500

    1. Initial program 100.0%

      \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt46.3%

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

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

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

      \[\leadsto \left|\color{blue}{ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew + -0.5 \cdot \frac{{eh}^{2}}{ew}\right) - eh \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \tan t}{ew}\right)\right)}\right| \]
    6. Step-by-step derivation
      1. distribute-lft-out59.8%

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

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

        \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot \left(ew + \frac{{eh}^{2}}{ew}\right)\right) - eh \cdot \sin \tan^{-1} \left(\frac{\color{blue}{-eh \cdot \tan t}}{ew}\right)\right)\right| \]
      4. distribute-lft-neg-out59.8%

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

      \[\leadsto \left|\color{blue}{ew + t \cdot \left(t \cdot \left(-0.5 \cdot \left(ew + \frac{{eh}^{2}}{ew}\right)\right) - eh \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)}\right| \]
    8. Taylor expanded in ew around inf 97.7%

      \[\leadsto \left|ew + t \cdot \left(t \cdot \color{blue}{\left(-0.5 \cdot ew\right)} - eh \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    9. Taylor expanded in t around 0 97.7%

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

        \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew\right) - eh \cdot \sin \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left(eh \cdot t\right)}{ew}\right)}\right)\right| \]
      2. associate-*r*97.7%

        \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew\right) - eh \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(-1 \cdot eh\right) \cdot t}}{ew}\right)\right)\right| \]
      3. mul-1-neg97.7%

        \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew\right) - eh \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(-eh\right)} \cdot t}{ew}\right)\right)\right| \]
    11. Simplified97.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -3400 \lor \neg \left(t \leq 500\right):\\ \;\;\;\;\left|ew \cdot \cos \tan^{-1} \left(\frac{eh \cdot \tan t}{ew}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew + t \cdot \left(t \cdot \left(ew \cdot -0.5\right) - eh \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{-ew}\right)\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 79.5% accurate, 2.2× speedup?

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

\\
\left|ew + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{ew}\right)\right)\right|
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-neg99.8%

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

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

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

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

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(-eh\right) \cdot \frac{\tan t}{ew}}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    6. add-sqr-sqrt47.6%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{-eh} \cdot \sqrt{-eh}\right)} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    7. sqrt-unprod91.0%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\left(-eh\right) \cdot \left(-eh\right)}} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    8. sqr-neg91.0%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{eh \cdot eh}} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    9. sqrt-unprod52.2%

      \[\leadsto \left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{eh} \cdot \sqrt{eh}\right)} \cdot \frac{\tan t}{ew}\right)} + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    10. add-sqr-sqrt99.8%

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

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

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

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

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

Alternative 7: 55.9% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -31 \lor \neg \left(t \leq 6200\right):\\ \;\;\;\;\left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew + t \cdot \left(t \cdot \left(ew \cdot -0.5\right) - eh \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{-ew}\right)\right)\right|\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (if (or (<= t -31.0) (not (<= t 6200.0)))
   (fabs (* ew (/ 1.0 (hypot 1.0 (* (tan t) (/ eh ew))))))
   (fabs
    (+
     ew
     (* t (- (* t (* ew -0.5)) (* eh (sin (atan (/ (* t eh) (- ew)))))))))))
double code(double eh, double ew, double t) {
	double tmp;
	if ((t <= -31.0) || !(t <= 6200.0)) {
		tmp = fabs((ew * (1.0 / hypot(1.0, (tan(t) * (eh / ew))))));
	} else {
		tmp = fabs((ew + (t * ((t * (ew * -0.5)) - (eh * sin(atan(((t * eh) / -ew))))))));
	}
	return tmp;
}
public static double code(double eh, double ew, double t) {
	double tmp;
	if ((t <= -31.0) || !(t <= 6200.0)) {
		tmp = Math.abs((ew * (1.0 / Math.hypot(1.0, (Math.tan(t) * (eh / ew))))));
	} else {
		tmp = Math.abs((ew + (t * ((t * (ew * -0.5)) - (eh * Math.sin(Math.atan(((t * eh) / -ew))))))));
	}
	return tmp;
}
def code(eh, ew, t):
	tmp = 0
	if (t <= -31.0) or not (t <= 6200.0):
		tmp = math.fabs((ew * (1.0 / math.hypot(1.0, (math.tan(t) * (eh / ew))))))
	else:
		tmp = math.fabs((ew + (t * ((t * (ew * -0.5)) - (eh * math.sin(math.atan(((t * eh) / -ew))))))))
	return tmp
function code(eh, ew, t)
	tmp = 0.0
	if ((t <= -31.0) || !(t <= 6200.0))
		tmp = abs(Float64(ew * Float64(1.0 / hypot(1.0, Float64(tan(t) * Float64(eh / ew))))));
	else
		tmp = abs(Float64(ew + Float64(t * Float64(Float64(t * Float64(ew * -0.5)) - Float64(eh * sin(atan(Float64(Float64(t * eh) / Float64(-ew)))))))));
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	tmp = 0.0;
	if ((t <= -31.0) || ~((t <= 6200.0)))
		tmp = abs((ew * (1.0 / hypot(1.0, (tan(t) * (eh / ew))))));
	else
		tmp = abs((ew + (t * ((t * (ew * -0.5)) - (eh * sin(atan(((t * eh) / -ew))))))));
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -31.0], N[Not[LessEqual[t, 6200.0]], $MachinePrecision]], N[Abs[N[(ew * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew + N[(t * N[(N[(t * N[(ew * -0.5), $MachinePrecision]), $MachinePrecision] - N[(eh * N[Sin[N[ArcTan[N[(N[(t * eh), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -31 \lor \neg \left(t \leq 6200\right):\\
\;\;\;\;\left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|ew + t \cdot \left(t \cdot \left(ew \cdot -0.5\right) - eh \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{-ew}\right)\right)\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -31 or 6200 < t

    1. Initial program 99.7%

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

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

        \[\leadsto \left|ew \cdot \cos \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left(eh \cdot \tan t\right)}{ew}\right)}\right| \]
      2. neg-mul-113.9%

        \[\leadsto \left|ew \cdot \cos \tan^{-1} \left(\frac{\color{blue}{-eh \cdot \tan t}}{ew}\right)\right| \]
      3. distribute-lft-neg-in13.9%

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

      \[\leadsto \left|\color{blue}{ew \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)}\right| \]
    6. Step-by-step derivation
      1. cos-atan13.5%

        \[\leadsto \left|ew \cdot \color{blue}{\frac{1}{\sqrt{1 + \frac{\left(-eh\right) \cdot \tan t}{ew} \cdot \frac{\left(-eh\right) \cdot \tan t}{ew}}}}\right| \]
      2. hypot-1-def13.5%

        \[\leadsto \left|ew \cdot \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \frac{\left(-eh\right) \cdot \tan t}{ew}\right)}}\right| \]
      3. associate-/l*13.5%

        \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\left(-eh\right) \cdot \frac{\tan t}{ew}}\right)}\right| \]
      4. add-sqr-sqrt5.9%

        \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{-eh} \cdot \sqrt{-eh}\right)} \cdot \frac{\tan t}{ew}\right)}\right| \]
      5. sqrt-unprod12.5%

        \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\left(-eh\right) \cdot \left(-eh\right)}} \cdot \frac{\tan t}{ew}\right)}\right| \]
      6. sqr-neg12.5%

        \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{eh \cdot eh}} \cdot \frac{\tan t}{ew}\right)}\right| \]
      7. sqrt-unprod7.7%

        \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{eh} \cdot \sqrt{eh}\right)} \cdot \frac{\tan t}{ew}\right)}\right| \]
      8. add-sqr-sqrt13.5%

        \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{eh} \cdot \frac{\tan t}{ew}\right)}\right| \]
    7. Applied egg-rr13.5%

      \[\leadsto \left|ew \cdot \color{blue}{\frac{1}{\mathsf{hypot}\left(1, eh \cdot \frac{\tan t}{ew}\right)}}\right| \]
    8. Step-by-step derivation
      1. *-commutative13.5%

        \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\frac{\tan t}{ew} \cdot eh}\right)}\right| \]
      2. associate-*l/13.5%

        \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\frac{\tan t \cdot eh}{ew}}\right)}\right| \]
      3. associate-*r/13.5%

        \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\tan t \cdot \frac{eh}{ew}}\right)}\right| \]
    9. Simplified13.5%

      \[\leadsto \left|ew \cdot \color{blue}{\frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}}\right| \]

    if -31 < t < 6200

    1. Initial program 100.0%

      \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt46.3%

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

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

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

      \[\leadsto \left|\color{blue}{ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew + -0.5 \cdot \frac{{eh}^{2}}{ew}\right) - eh \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \tan t}{ew}\right)\right)}\right| \]
    6. Step-by-step derivation
      1. distribute-lft-out59.8%

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

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

        \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot \left(ew + \frac{{eh}^{2}}{ew}\right)\right) - eh \cdot \sin \tan^{-1} \left(\frac{\color{blue}{-eh \cdot \tan t}}{ew}\right)\right)\right| \]
      4. distribute-lft-neg-out59.8%

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

      \[\leadsto \left|\color{blue}{ew + t \cdot \left(t \cdot \left(-0.5 \cdot \left(ew + \frac{{eh}^{2}}{ew}\right)\right) - eh \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)}\right| \]
    8. Taylor expanded in ew around inf 97.7%

      \[\leadsto \left|ew + t \cdot \left(t \cdot \color{blue}{\left(-0.5 \cdot ew\right)} - eh \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right| \]
    9. Taylor expanded in t around 0 97.7%

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

        \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew\right) - eh \cdot \sin \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left(eh \cdot t\right)}{ew}\right)}\right)\right| \]
      2. associate-*r*97.7%

        \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew\right) - eh \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(-1 \cdot eh\right) \cdot t}}{ew}\right)\right)\right| \]
      3. mul-1-neg97.7%

        \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew\right) - eh \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(-eh\right)} \cdot t}{ew}\right)\right)\right| \]
    11. Simplified97.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -31 \lor \neg \left(t \leq 6200\right):\\ \;\;\;\;\left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew + t \cdot \left(t \cdot \left(ew \cdot -0.5\right) - eh \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{-ew}\right)\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 42.2% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}\right| \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (fabs (* ew (/ 1.0 (hypot 1.0 (* (tan t) (/ eh ew)))))))
double code(double eh, double ew, double t) {
	return fabs((ew * (1.0 / hypot(1.0, (tan(t) * (eh / ew))))));
}
public static double code(double eh, double ew, double t) {
	return Math.abs((ew * (1.0 / Math.hypot(1.0, (Math.tan(t) * (eh / ew))))));
}
def code(eh, ew, t):
	return math.fabs((ew * (1.0 / math.hypot(1.0, (math.tan(t) * (eh / ew))))))
function code(eh, ew, t)
	return abs(Float64(ew * Float64(1.0 / hypot(1.0, Float64(tan(t) * Float64(eh / ew))))))
end
function tmp = code(eh, ew, t)
	tmp = abs((ew * (1.0 / hypot(1.0, (tan(t) * (eh / ew))))));
end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}\right|
\end{array}
Derivation
  1. Initial program 99.8%

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

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

      \[\leadsto \left|ew \cdot \cos \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left(eh \cdot \tan t\right)}{ew}\right)}\right| \]
    2. neg-mul-141.9%

      \[\leadsto \left|ew \cdot \cos \tan^{-1} \left(\frac{\color{blue}{-eh \cdot \tan t}}{ew}\right)\right| \]
    3. distribute-lft-neg-in41.9%

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

    \[\leadsto \left|\color{blue}{ew \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)}\right| \]
  6. Step-by-step derivation
    1. cos-atan41.5%

      \[\leadsto \left|ew \cdot \color{blue}{\frac{1}{\sqrt{1 + \frac{\left(-eh\right) \cdot \tan t}{ew} \cdot \frac{\left(-eh\right) \cdot \tan t}{ew}}}}\right| \]
    2. hypot-1-def41.6%

      \[\leadsto \left|ew \cdot \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \frac{\left(-eh\right) \cdot \tan t}{ew}\right)}}\right| \]
    3. associate-/l*41.6%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\left(-eh\right) \cdot \frac{\tan t}{ew}}\right)}\right| \]
    4. add-sqr-sqrt19.5%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{-eh} \cdot \sqrt{-eh}\right)} \cdot \frac{\tan t}{ew}\right)}\right| \]
    5. sqrt-unprod35.5%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\left(-eh\right) \cdot \left(-eh\right)}} \cdot \frac{\tan t}{ew}\right)}\right| \]
    6. sqr-neg35.5%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{eh \cdot eh}} \cdot \frac{\tan t}{ew}\right)}\right| \]
    7. sqrt-unprod22.1%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{eh} \cdot \sqrt{eh}\right)} \cdot \frac{\tan t}{ew}\right)}\right| \]
    8. add-sqr-sqrt41.6%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{eh} \cdot \frac{\tan t}{ew}\right)}\right| \]
  7. Applied egg-rr41.6%

    \[\leadsto \left|ew \cdot \color{blue}{\frac{1}{\mathsf{hypot}\left(1, eh \cdot \frac{\tan t}{ew}\right)}}\right| \]
  8. Step-by-step derivation
    1. *-commutative41.6%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\frac{\tan t}{ew} \cdot eh}\right)}\right| \]
    2. associate-*l/41.6%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\frac{\tan t \cdot eh}{ew}}\right)}\right| \]
    3. associate-*r/41.6%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\tan t \cdot \frac{eh}{ew}}\right)}\right| \]
  9. Simplified41.6%

    \[\leadsto \left|ew \cdot \color{blue}{\frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}}\right| \]
  10. Add Preprocessing

Alternative 9: 41.4% accurate, 3.0× speedup?

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

\\
\cos \tan^{-1} \left(t \cdot \frac{eh}{ew}\right) \cdot \left|ew\right|
\end{array}
Derivation
  1. Initial program 99.8%

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

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

      \[\leadsto \left|ew \cdot \cos \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left(eh \cdot \tan t\right)}{ew}\right)}\right| \]
    2. neg-mul-141.9%

      \[\leadsto \left|ew \cdot \cos \tan^{-1} \left(\frac{\color{blue}{-eh \cdot \tan t}}{ew}\right)\right| \]
    3. distribute-lft-neg-in41.9%

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

    \[\leadsto \left|\color{blue}{ew \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)}\right| \]
  6. Taylor expanded in t around 0 40.6%

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

      \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew\right) - eh \cdot \sin \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left(eh \cdot t\right)}{ew}\right)}\right)\right| \]
    2. associate-*r*52.1%

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

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

    \[\leadsto \left|ew \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\left(-eh\right) \cdot t}{ew}\right)}\right| \]
  9. Step-by-step derivation
    1. add-sqr-sqrt40.4%

      \[\leadsto \color{blue}{\sqrt{\left|ew \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot t}{ew}\right)\right|} \cdot \sqrt{\left|ew \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot t}{ew}\right)\right|}} \]
    2. pow240.4%

      \[\leadsto \color{blue}{{\left(\sqrt{\left|ew \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot t}{ew}\right)\right|}\right)}^{2}} \]
    3. associate-/l*40.4%

      \[\leadsto {\left(\sqrt{\left|ew \cdot \cos \tan^{-1} \color{blue}{\left(\left(-eh\right) \cdot \frac{t}{ew}\right)}\right|}\right)}^{2} \]
  10. Applied egg-rr40.4%

    \[\leadsto \color{blue}{{\left(\sqrt{\left|ew \cdot \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{t}{ew}\right)\right|}\right)}^{2}} \]
  11. Step-by-step derivation
    1. *-un-lft-identity40.4%

      \[\leadsto \color{blue}{1 \cdot {\left(\sqrt{\left|ew \cdot \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{t}{ew}\right)\right|}\right)}^{2}} \]
    2. unpow240.4%

      \[\leadsto 1 \cdot \color{blue}{\left(\sqrt{\left|ew \cdot \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{t}{ew}\right)\right|} \cdot \sqrt{\left|ew \cdot \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{t}{ew}\right)\right|}\right)} \]
    3. add-sqr-sqrt40.6%

      \[\leadsto 1 \cdot \color{blue}{\left|ew \cdot \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{t}{ew}\right)\right|} \]
    4. distribute-lft-neg-out40.6%

      \[\leadsto 1 \cdot \left|ew \cdot \cos \tan^{-1} \color{blue}{\left(-eh \cdot \frac{t}{ew}\right)}\right| \]
    5. associate-/l*40.6%

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

      \[\leadsto 1 \cdot \left|ew \cdot \cos \color{blue}{\left(-\tan^{-1} \left(\frac{eh \cdot t}{ew}\right)\right)}\right| \]
    7. associate-/l*40.6%

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

    \[\leadsto \color{blue}{1 \cdot \left|ew \cdot \cos \left(-\tan^{-1} \left(eh \cdot \frac{t}{ew}\right)\right)\right|} \]
  13. Step-by-step derivation
    1. *-lft-identity40.6%

      \[\leadsto \color{blue}{\left|ew \cdot \cos \left(-\tan^{-1} \left(eh \cdot \frac{t}{ew}\right)\right)\right|} \]
    2. fabs-mul40.6%

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

      \[\leadsto \color{blue}{\left|\cos \left(-\tan^{-1} \left(eh \cdot \frac{t}{ew}\right)\right)\right| \cdot \left|ew\right|} \]
    4. rem-square-sqrt40.6%

      \[\leadsto \left|\color{blue}{\sqrt{\cos \left(-\tan^{-1} \left(eh \cdot \frac{t}{ew}\right)\right)} \cdot \sqrt{\cos \left(-\tan^{-1} \left(eh \cdot \frac{t}{ew}\right)\right)}}\right| \cdot \left|ew\right| \]
    5. fabs-sqr40.6%

      \[\leadsto \color{blue}{\left(\sqrt{\cos \left(-\tan^{-1} \left(eh \cdot \frac{t}{ew}\right)\right)} \cdot \sqrt{\cos \left(-\tan^{-1} \left(eh \cdot \frac{t}{ew}\right)\right)}\right)} \cdot \left|ew\right| \]
    6. rem-square-sqrt40.6%

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

      \[\leadsto \color{blue}{\cos \tan^{-1} \left(eh \cdot \frac{t}{ew}\right)} \cdot \left|ew\right| \]
    8. associate-*r/40.6%

      \[\leadsto \cos \tan^{-1} \color{blue}{\left(\frac{eh \cdot t}{ew}\right)} \cdot \left|ew\right| \]
    9. *-commutative40.6%

      \[\leadsto \cos \tan^{-1} \left(\frac{\color{blue}{t \cdot eh}}{ew}\right) \cdot \left|ew\right| \]
    10. associate-/l*40.6%

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

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

Alternative 10: 40.6% accurate, 4.4× speedup?

\[\begin{array}{l} \\ \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, eh \cdot \frac{t}{-ew}\right)}\right| \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (fabs (* ew (/ 1.0 (hypot 1.0 (* eh (/ t (- ew))))))))
double code(double eh, double ew, double t) {
	return fabs((ew * (1.0 / hypot(1.0, (eh * (t / -ew))))));
}
public static double code(double eh, double ew, double t) {
	return Math.abs((ew * (1.0 / Math.hypot(1.0, (eh * (t / -ew))))));
}
def code(eh, ew, t):
	return math.fabs((ew * (1.0 / math.hypot(1.0, (eh * (t / -ew))))))
function code(eh, ew, t)
	return abs(Float64(ew * Float64(1.0 / hypot(1.0, Float64(eh * Float64(t / Float64(-ew)))))))
end
function tmp = code(eh, ew, t)
	tmp = abs((ew * (1.0 / hypot(1.0, (eh * (t / -ew))))));
end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(eh * N[(t / (-ew)), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, eh \cdot \frac{t}{-ew}\right)}\right|
\end{array}
Derivation
  1. Initial program 99.8%

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

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

      \[\leadsto \left|ew \cdot \cos \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left(eh \cdot \tan t\right)}{ew}\right)}\right| \]
    2. neg-mul-141.9%

      \[\leadsto \left|ew \cdot \cos \tan^{-1} \left(\frac{\color{blue}{-eh \cdot \tan t}}{ew}\right)\right| \]
    3. distribute-lft-neg-in41.9%

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

    \[\leadsto \left|\color{blue}{ew \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)}\right| \]
  6. Taylor expanded in t around 0 40.6%

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

      \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew\right) - eh \cdot \sin \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left(eh \cdot t\right)}{ew}\right)}\right)\right| \]
    2. associate-*r*52.1%

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

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

    \[\leadsto \left|ew \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\left(-eh\right) \cdot t}{ew}\right)}\right| \]
  9. Step-by-step derivation
    1. cos-atan39.6%

      \[\leadsto \left|ew \cdot \color{blue}{\frac{1}{\sqrt{1 + \frac{\left(-eh\right) \cdot t}{ew} \cdot \frac{\left(-eh\right) \cdot t}{ew}}}}\right| \]
    2. hypot-1-def39.6%

      \[\leadsto \left|ew \cdot \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \frac{\left(-eh\right) \cdot t}{ew}\right)}}\right| \]
    3. associate-/l*39.7%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\left(-eh\right) \cdot \frac{t}{ew}}\right)}\right| \]
  10. Applied egg-rr39.7%

    \[\leadsto \left|ew \cdot \color{blue}{\frac{1}{\mathsf{hypot}\left(1, \left(-eh\right) \cdot \frac{t}{ew}\right)}}\right| \]
  11. Step-by-step derivation
    1. *-commutative39.7%

      \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\frac{t}{ew} \cdot \left(-eh\right)}\right)}\right| \]
  12. Simplified39.7%

    \[\leadsto \left|ew \cdot \color{blue}{\frac{1}{\mathsf{hypot}\left(1, \frac{t}{ew} \cdot \left(-eh\right)\right)}}\right| \]
  13. Final simplification39.7%

    \[\leadsto \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, eh \cdot \frac{t}{-ew}\right)}\right| \]
  14. Add Preprocessing

Alternative 11: 39.1% accurate, 8.4× speedup?

\[\begin{array}{l} \\ \left|ew + -0.5 \cdot \left(ew \cdot \left(t \cdot t\right)\right)\right| \end{array} \]
(FPCore (eh ew t) :precision binary64 (fabs (+ ew (* -0.5 (* ew (* t t))))))
double code(double eh, double ew, double t) {
	return fabs((ew + (-0.5 * (ew * (t * t)))));
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    code = abs((ew + ((-0.5d0) * (ew * (t * t)))))
end function
public static double code(double eh, double ew, double t) {
	return Math.abs((ew + (-0.5 * (ew * (t * t)))));
}
def code(eh, ew, t):
	return math.fabs((ew + (-0.5 * (ew * (t * t)))))
function code(eh, ew, t)
	return abs(Float64(ew + Float64(-0.5 * Float64(ew * Float64(t * t)))))
end
function tmp = code(eh, ew, t)
	tmp = abs((ew + (-0.5 * (ew * (t * t)))));
end
code[eh_, ew_, t_] := N[Abs[N[(ew + N[(-0.5 * N[(ew * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|ew + -0.5 \cdot \left(ew \cdot \left(t \cdot t\right)\right)\right|
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrt47.0%

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

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

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

    \[\leadsto \left|\color{blue}{ew + t \cdot \left(t \cdot \left(-0.5 \cdot ew + -0.5 \cdot \frac{{eh}^{2}}{ew}\right) - eh \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \tan t}{ew}\right)\right)}\right| \]
  6. Step-by-step derivation
    1. distribute-lft-out32.8%

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

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

      \[\leadsto \left|ew + t \cdot \left(t \cdot \left(-0.5 \cdot \left(ew + \frac{{eh}^{2}}{ew}\right)\right) - eh \cdot \sin \tan^{-1} \left(\frac{\color{blue}{-eh \cdot \tan t}}{ew}\right)\right)\right| \]
    4. distribute-lft-neg-out32.8%

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

    \[\leadsto \left|\color{blue}{ew + t \cdot \left(t \cdot \left(-0.5 \cdot \left(ew + \frac{{eh}^{2}}{ew}\right)\right) - eh \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)}\right| \]
  8. Taylor expanded in ew around inf 37.8%

    \[\leadsto \left|ew + \color{blue}{-0.5 \cdot \left(ew \cdot {t}^{2}\right)}\right| \]
  9. Step-by-step derivation
    1. *-commutative37.8%

      \[\leadsto \left|ew + -0.5 \cdot \color{blue}{\left({t}^{2} \cdot ew\right)}\right| \]
  10. Simplified37.8%

    \[\leadsto \left|ew + \color{blue}{-0.5 \cdot \left({t}^{2} \cdot ew\right)}\right| \]
  11. Step-by-step derivation
    1. unpow237.8%

      \[\leadsto \left|ew + -0.5 \cdot \left(\color{blue}{\left(t \cdot t\right)} \cdot ew\right)\right| \]
  12. Applied egg-rr37.8%

    \[\leadsto \left|ew + -0.5 \cdot \left(\color{blue}{\left(t \cdot t\right)} \cdot ew\right)\right| \]
  13. Final simplification37.8%

    \[\leadsto \left|ew + -0.5 \cdot \left(ew \cdot \left(t \cdot t\right)\right)\right| \]
  14. Add Preprocessing

Reproduce

?
herbie shell --seed 2024123 
(FPCore (eh ew t)
  :name "Example 2 from Robby"
  :precision binary64
  (fabs (- (* (* ew (cos t)) (cos (atan (/ (* (- eh) (tan t)) ew)))) (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))