Example 2 from Robby

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

Specification

?
\[\mathsf{TRUE}\left(\right)\]
\[\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 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{\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.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}
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. Add Preprocessing

Alternative 2: 99.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_1 := eh \cdot \sin t\\
\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{t\_1}{ew}\right) - t\_1 \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\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. Taylor expanded in eh around 0

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

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

Alternative 3: 98.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_1 := eh \cdot \sin t\\
\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{t\_1}{ew}\right) - t\_1 \cdot \sin \tan^{-1} \left(\frac{-eh}{ew}\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. Taylor expanded in eh around 0

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

    \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\color{blue}{eh \cdot \sin t}}{ew}\right) - \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 eh around 0

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

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

Alternative 4: 91.0% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
t_1 := eh \cdot \sin t\\
t_2 := ew \cdot \cos t\\
t_3 := \tan^{-1} \left(\frac{-eh}{ew}\right)\\
\mathbf{if}\;ew \leq -5 \cdot 10^{+83}:\\
\;\;\;\;\left|t\_2 \cdot \cos t\_3 - t\_1 \cdot \sin t\_3\right|\\

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

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


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

    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 eh around 0

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\color{blue}{eh \cdot \sin t}}{ew}\right) - \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 eh around 0

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

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

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

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

    if -5.00000000000000029e83 < ew < 6.69999999999999967e78

    1. Initial program 99.9%

      \[\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 eh around 0

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\color{blue}{eh \cdot \sin t}}{ew}\right) - \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 eh around 0

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

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

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

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{eh \cdot t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left|-eh\right|}{ew}\right)\right| \]
    10. Applied rewrites93.4%

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

    if 6.69999999999999967e78 < ew

    1. Initial program 99.9%

      \[\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 eh around inf

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

      \[\leadsto \left|\color{blue}{\left(-eh\right) \cdot \tan t}\right| \]
    5. Taylor expanded in t around 0

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

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

Alternative 5: 90.7% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
t_2 := \tan^{-1} \left(\frac{-eh}{ew}\right)\\
t_3 := \left|t\_1 \cdot \cos t\_2 - \left(eh \cdot \sin t\right) \cdot \sin t\_2\right|\\
\mathbf{if}\;t \leq -3.6 \cdot 10^{-91}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t \leq 3.6 \cdot 10^{-282}:\\
\;\;\;\;\left|t\_1\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3.6e-91 or 3.5999999999999998e-282 < t

    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 eh around 0

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\color{blue}{eh \cdot \sin t}}{ew}\right) - \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 eh around 0

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

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

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

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

    if -3.6e-91 < t < 3.5999999999999998e-282

    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. Taylor expanded in eh around inf

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

      \[\leadsto \left|\color{blue}{\left(-eh\right) \cdot \tan t}\right| \]
    5. Taylor expanded in t around 0

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

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

Alternative 6: 74.9% accurate, 7.2× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eh < -7.5000000000000002e105 or 4.39999999999999997e111 < eh

    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 eh around inf

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

      \[\leadsto \left|\color{blue}{\left(-eh\right) \cdot \tan t}\right| \]
    5. Taylor expanded in t around 0

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

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

    if -7.5000000000000002e105 < eh < 4.39999999999999997e111

    1. Initial program 99.9%

      \[\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 eh around inf

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

      \[\leadsto \left|\color{blue}{\left(-eh\right) \cdot \tan t}\right| \]
    5. Taylor expanded in t around 0

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

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

Alternative 7: 60.8% accurate, 8.0× speedup?

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

\\
\left|ew \cdot \cos t\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 eh around inf

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

    \[\leadsto \left|\color{blue}{\left(-eh\right) \cdot \tan t}\right| \]
  5. Taylor expanded in t around 0

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

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

Alternative 8: 9.5% accurate, 172.4× speedup?

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

\\
\left|-eh\right|
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \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 eh around inf

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

    \[\leadsto \left|\color{blue}{\left(-eh\right) \cdot \tan t}\right| \]
  5. Taylor expanded in eh around 0

    \[\leadsto \left|-1 \cdot \color{blue}{\frac{eh \cdot \sin t}{\cos t}}\right| \]
  6. Applied rewrites9.4%

    \[\leadsto \left|-eh\right| \]
  7. Add Preprocessing

Reproduce

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