Example 2 from Robby

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

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

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

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

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

Alternative 2: 85.5% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin t \cdot eh\\ t_2 := \left|t\_1\right|\\ \mathbf{if}\;eh \leq -9 \cdot 10^{+143}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;eh \leq 1.12 \cdot 10^{+132}:\\ \;\;\;\;\left|\frac{t\_1 \cdot \left(eh \cdot \frac{\tan t}{ew}\right) + \cos t \cdot ew}{\frac{1}{{\left(1 + {\left(\frac{ew}{eh \cdot \tan t}\right)}^{-2}\right)}^{-0.5}}}\right|\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (* (sin t) eh)) (t_2 (fabs t_1)))
   (if (<= eh -9e+143)
     t_2
     (if (<= eh 1.12e+132)
       (fabs
        (/
         (+ (* t_1 (* eh (/ (tan t) ew))) (* (cos t) ew))
         (/ 1.0 (pow (+ 1.0 (pow (/ ew (* eh (tan t))) -2.0)) -0.5))))
       t_2))))
double code(double eh, double ew, double t) {
	double t_1 = sin(t) * eh;
	double t_2 = fabs(t_1);
	double tmp;
	if (eh <= -9e+143) {
		tmp = t_2;
	} else if (eh <= 1.12e+132) {
		tmp = fabs((((t_1 * (eh * (tan(t) / ew))) + (cos(t) * ew)) / (1.0 / pow((1.0 + pow((ew / (eh * tan(t))), -2.0)), -0.5))));
	} else {
		tmp = 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) :: tmp
    t_1 = sin(t) * eh
    t_2 = abs(t_1)
    if (eh <= (-9d+143)) then
        tmp = t_2
    else if (eh <= 1.12d+132) then
        tmp = abs((((t_1 * (eh * (tan(t) / ew))) + (cos(t) * ew)) / (1.0d0 / ((1.0d0 + ((ew / (eh * tan(t))) ** (-2.0d0))) ** (-0.5d0)))))
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double t_1 = Math.sin(t) * eh;
	double t_2 = Math.abs(t_1);
	double tmp;
	if (eh <= -9e+143) {
		tmp = t_2;
	} else if (eh <= 1.12e+132) {
		tmp = Math.abs((((t_1 * (eh * (Math.tan(t) / ew))) + (Math.cos(t) * ew)) / (1.0 / Math.pow((1.0 + Math.pow((ew / (eh * Math.tan(t))), -2.0)), -0.5))));
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(eh, ew, t):
	t_1 = math.sin(t) * eh
	t_2 = math.fabs(t_1)
	tmp = 0
	if eh <= -9e+143:
		tmp = t_2
	elif eh <= 1.12e+132:
		tmp = math.fabs((((t_1 * (eh * (math.tan(t) / ew))) + (math.cos(t) * ew)) / (1.0 / math.pow((1.0 + math.pow((ew / (eh * math.tan(t))), -2.0)), -0.5))))
	else:
		tmp = t_2
	return tmp
function code(eh, ew, t)
	t_1 = Float64(sin(t) * eh)
	t_2 = abs(t_1)
	tmp = 0.0
	if (eh <= -9e+143)
		tmp = t_2;
	elseif (eh <= 1.12e+132)
		tmp = abs(Float64(Float64(Float64(t_1 * Float64(eh * Float64(tan(t) / ew))) + Float64(cos(t) * ew)) / Float64(1.0 / (Float64(1.0 + (Float64(ew / Float64(eh * tan(t))) ^ -2.0)) ^ -0.5))));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	t_1 = sin(t) * eh;
	t_2 = abs(t_1);
	tmp = 0.0;
	if (eh <= -9e+143)
		tmp = t_2;
	elseif (eh <= 1.12e+132)
		tmp = abs((((t_1 * (eh * (tan(t) / ew))) + (cos(t) * ew)) / (1.0 / ((1.0 + ((ew / (eh * tan(t))) ^ -2.0)) ^ -0.5))));
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$2 = N[Abs[t$95$1], $MachinePrecision]}, If[LessEqual[eh, -9e+143], t$95$2, If[LessEqual[eh, 1.12e+132], N[Abs[N[(N[(N[(t$95$1 * N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[Power[N[(1.0 + N[Power[N[(ew / N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}

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

\mathbf{elif}\;eh \leq 1.12 \cdot 10^{+132}:\\
\;\;\;\;\left|\frac{t\_1 \cdot \left(eh \cdot \frac{\tan t}{ew}\right) + \cos t \cdot ew}{\frac{1}{{\left(1 + {\left(\frac{ew}{eh \cdot \tan t}\right)}^{-2}\right)}^{-0.5}}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eh < -8.9999999999999993e143 or 1.12e132 < 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. Applied rewrites30.1%

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

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

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

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      2. lower-*.f64N/A

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      3. lower-sin.f6477.1

        \[\leadsto \left|\color{blue}{\sin t} \cdot eh\right| \]
    7. Applied rewrites77.1%

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

    if -8.9999999999999993e143 < eh < 1.12e132

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;eh \leq -9 \cdot 10^{+143}:\\ \;\;\;\;\left|\sin t \cdot eh\right|\\ \mathbf{elif}\;eh \leq 1.12 \cdot 10^{+132}:\\ \;\;\;\;\left|\frac{\left(\sin t \cdot eh\right) \cdot \left(eh \cdot \frac{\tan t}{ew}\right) + \cos t \cdot ew}{\frac{1}{{\left(1 + {\left(\frac{ew}{eh \cdot \tan t}\right)}^{-2}\right)}^{-0.5}}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\sin t \cdot eh\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 76.5% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;ew \leq 1.6 \cdot 10^{-76}:\\
\;\;\;\;\left|t\_3\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{t\_3}{ew}, eh \cdot \tan t, \cos t \cdot ew\right)\right| \cdot t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ew < -3.39999999999999997e-66

    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. Applied rewrites99.8%

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

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

    if -3.39999999999999997e-66 < ew < 1.5999999999999999e-76

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

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

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

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

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      2. lower-*.f64N/A

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      3. lower-sin.f6476.0

        \[\leadsto \left|\color{blue}{\sin t} \cdot eh\right| \]
    7. Applied rewrites76.0%

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

    if 1.5999999999999999e-76 < 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. Applied rewrites99.8%

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

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

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

Alternative 4: 76.5% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;ew \leq 1.6 \cdot 10^{-76}:\\
\;\;\;\;\left|t\_1\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -3.39999999999999997e-66 or 1.5999999999999999e-76 < 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. Applied rewrites99.8%

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

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

    if -3.39999999999999997e-66 < ew < 1.5999999999999999e-76

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

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

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

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

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      2. lower-*.f64N/A

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      3. lower-sin.f6476.0

        \[\leadsto \left|\color{blue}{\sin t} \cdot eh\right| \]
    7. Applied rewrites76.0%

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

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

Alternative 5: 72.5% accurate, 2.4× speedup?

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

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

\mathbf{elif}\;eh \leq 1.36 \cdot 10^{-58}:\\
\;\;\;\;\left|\mathsf{fma}\left(\left(-0.5 \cdot eh\right) \cdot \left(\frac{\sin t}{ew} \cdot \tan t\right), eh, \left(-ew\right) \cdot \cos t\right)\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eh < -2.5500000000000001e79 or 1.36000000000000007e-58 < 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. Applied rewrites37.9%

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

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

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

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      2. lower-*.f64N/A

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      3. lower-sin.f6469.4

        \[\leadsto \left|\color{blue}{\sin t} \cdot eh\right| \]
    7. Applied rewrites69.4%

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

    if -2.5500000000000001e79 < eh < 1.36000000000000007e-58

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(\left(\tan t \cdot \frac{\sin t}{ew}\right) \cdot \left(-0.5 \cdot eh\right), \color{blue}{eh}, \left(-ew\right) \cdot \cos t\right)\right| \]
    9. Recombined 2 regimes into one program.
    10. Final simplification78.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;eh \leq -2.55 \cdot 10^{+79}:\\ \;\;\;\;\left|\sin t \cdot eh\right|\\ \mathbf{elif}\;eh \leq 1.36 \cdot 10^{-58}:\\ \;\;\;\;\left|\mathsf{fma}\left(\left(-0.5 \cdot eh\right) \cdot \left(\frac{\sin t}{ew} \cdot \tan t\right), eh, \left(-ew\right) \cdot \cos t\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\sin t \cdot eh\right|\\ \end{array} \]
    11. Add Preprocessing

    Alternative 6: 72.4% accurate, 7.1× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \left|\sin t \cdot eh\right|\\ \mathbf{if}\;eh \leq -2.55 \cdot 10^{+79}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;eh \leq 1.36 \cdot 10^{-58}:\\ \;\;\;\;\left|\left(-ew\right) \cdot \cos t\right|\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (eh ew t)
     :precision binary64
     (let* ((t_1 (fabs (* (sin t) eh))))
       (if (<= eh -2.55e+79)
         t_1
         (if (<= eh 1.36e-58) (fabs (* (- ew) (cos t))) t_1))))
    double code(double eh, double ew, double t) {
    	double t_1 = fabs((sin(t) * eh));
    	double tmp;
    	if (eh <= -2.55e+79) {
    		tmp = t_1;
    	} else if (eh <= 1.36e-58) {
    		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((sin(t) * eh))
        if (eh <= (-2.55d+79)) then
            tmp = t_1
        else if (eh <= 1.36d-58) 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((Math.sin(t) * eh));
    	double tmp;
    	if (eh <= -2.55e+79) {
    		tmp = t_1;
    	} else if (eh <= 1.36e-58) {
    		tmp = Math.abs((-ew * Math.cos(t)));
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    def code(eh, ew, t):
    	t_1 = math.fabs((math.sin(t) * eh))
    	tmp = 0
    	if eh <= -2.55e+79:
    		tmp = t_1
    	elif eh <= 1.36e-58:
    		tmp = math.fabs((-ew * math.cos(t)))
    	else:
    		tmp = t_1
    	return tmp
    
    function code(eh, ew, t)
    	t_1 = abs(Float64(sin(t) * eh))
    	tmp = 0.0
    	if (eh <= -2.55e+79)
    		tmp = t_1;
    	elseif (eh <= 1.36e-58)
    		tmp = abs(Float64(Float64(-ew) * cos(t)));
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    function tmp_2 = code(eh, ew, t)
    	t_1 = abs((sin(t) * eh));
    	tmp = 0.0;
    	if (eh <= -2.55e+79)
    		tmp = t_1;
    	elseif (eh <= 1.36e-58)
    		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[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -2.55e+79], t$95$1, If[LessEqual[eh, 1.36e-58], N[Abs[N[((-ew) * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \left|\sin t \cdot eh\right|\\
    \mathbf{if}\;eh \leq -2.55 \cdot 10^{+79}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;eh \leq 1.36 \cdot 10^{-58}:\\
    \;\;\;\;\left|\left(-ew\right) \cdot \cos t\right|\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if eh < -2.5500000000000001e79 or 1.36000000000000007e-58 < 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. Applied rewrites37.9%

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

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

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

          \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
        2. lower-*.f64N/A

          \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
        3. lower-sin.f6469.4

          \[\leadsto \left|\color{blue}{\sin t} \cdot eh\right| \]
      7. Applied rewrites69.4%

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

      if -2.5500000000000001e79 < eh < 1.36000000000000007e-58

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

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

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

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

          \[\leadsto \left|\color{blue}{\left(-1 \cdot ew\right) \cdot \cos t}\right| \]
        2. lower-*.f64N/A

          \[\leadsto \left|\color{blue}{\left(-1 \cdot ew\right) \cdot \cos t}\right| \]
        3. mul-1-negN/A

          \[\leadsto \left|\color{blue}{\left(\mathsf{neg}\left(ew\right)\right)} \cdot \cos t\right| \]
        4. lower-neg.f64N/A

          \[\leadsto \left|\color{blue}{\left(-ew\right)} \cdot \cos t\right| \]
        5. lower-cos.f6487.9

          \[\leadsto \left|\left(-ew\right) \cdot \color{blue}{\cos t}\right| \]
      7. Applied rewrites87.9%

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

    Alternative 7: 57.9% accurate, 7.2× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \left|\sin t \cdot eh\right|\\ \mathbf{if}\;eh \leq -2.5 \cdot 10^{+79}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;eh \leq 1.35 \cdot 10^{-58}:\\ \;\;\;\;\left|-ew\right|\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (eh ew t)
     :precision binary64
     (let* ((t_1 (fabs (* (sin t) eh))))
       (if (<= eh -2.5e+79) t_1 (if (<= eh 1.35e-58) (fabs (- ew)) t_1))))
    double code(double eh, double ew, double t) {
    	double t_1 = fabs((sin(t) * eh));
    	double tmp;
    	if (eh <= -2.5e+79) {
    		tmp = t_1;
    	} else if (eh <= 1.35e-58) {
    		tmp = fabs(-ew);
    	} 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((sin(t) * eh))
        if (eh <= (-2.5d+79)) then
            tmp = t_1
        else if (eh <= 1.35d-58) then
            tmp = abs(-ew)
        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((Math.sin(t) * eh));
    	double tmp;
    	if (eh <= -2.5e+79) {
    		tmp = t_1;
    	} else if (eh <= 1.35e-58) {
    		tmp = Math.abs(-ew);
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    def code(eh, ew, t):
    	t_1 = math.fabs((math.sin(t) * eh))
    	tmp = 0
    	if eh <= -2.5e+79:
    		tmp = t_1
    	elif eh <= 1.35e-58:
    		tmp = math.fabs(-ew)
    	else:
    		tmp = t_1
    	return tmp
    
    function code(eh, ew, t)
    	t_1 = abs(Float64(sin(t) * eh))
    	tmp = 0.0
    	if (eh <= -2.5e+79)
    		tmp = t_1;
    	elseif (eh <= 1.35e-58)
    		tmp = abs(Float64(-ew));
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    function tmp_2 = code(eh, ew, t)
    	t_1 = abs((sin(t) * eh));
    	tmp = 0.0;
    	if (eh <= -2.5e+79)
    		tmp = t_1;
    	elseif (eh <= 1.35e-58)
    		tmp = abs(-ew);
    	else
    		tmp = t_1;
    	end
    	tmp_2 = tmp;
    end
    
    code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -2.5e+79], t$95$1, If[LessEqual[eh, 1.35e-58], N[Abs[(-ew)], $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \left|\sin t \cdot eh\right|\\
    \mathbf{if}\;eh \leq -2.5 \cdot 10^{+79}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;eh \leq 1.35 \cdot 10^{-58}:\\
    \;\;\;\;\left|-ew\right|\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if eh < -2.5e79 or 1.3499999999999999e-58 < 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. Applied rewrites37.9%

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

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

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

          \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
        2. lower-*.f64N/A

          \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
        3. lower-sin.f6469.4

          \[\leadsto \left|\color{blue}{\sin t} \cdot eh\right| \]
      7. Applied rewrites69.4%

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

      if -2.5e79 < eh < 1.3499999999999999e-58

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

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

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

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

          \[\leadsto \left|\color{blue}{\mathsf{neg}\left(ew\right)}\right| \]
        2. lower-neg.f6457.3

          \[\leadsto \left|\color{blue}{-ew}\right| \]
      7. Applied rewrites57.3%

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

    Alternative 8: 41.9% accurate, 172.4× speedup?

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

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

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

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

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

        \[\leadsto \left|\color{blue}{-ew}\right| \]
    7. Applied rewrites41.2%

      \[\leadsto \left|\color{blue}{-ew}\right| \]
    8. Add Preprocessing

    Reproduce

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