Example 2 from Robby

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

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

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

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

Alternative 2: 99.1% accurate, 1.1× speedup?

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

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

    \[\leadsto \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{\color{blue}{-1 \cdot \left(eh \cdot t\right)}}{ew}\right)\right| \]
  4. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \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{\color{blue}{\left(-1 \cdot eh\right) \cdot t}}{ew}\right)\right| \]
    2. lower-*.f64N/A

      \[\leadsto \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{\color{blue}{\left(-1 \cdot eh\right) \cdot t}}{ew}\right)\right| \]
    3. mul-1-negN/A

      \[\leadsto \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{\color{blue}{\left(\mathsf{neg}\left(eh\right)\right)} \cdot t}{ew}\right)\right| \]
    4. lower-neg.f6499.2

      \[\leadsto \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{\color{blue}{\left(-eh\right)} \cdot t}{ew}\right)\right| \]
  5. Applied rewrites99.2%

    \[\leadsto \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{\color{blue}{\left(-eh\right) \cdot t}}{ew}\right)\right| \]
  6. Final simplification99.2%

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

Alternative 3: 85.1% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
t_1 := \tan t \cdot eh\\
t_2 := eh \cdot \sin t\\
t_3 := \left|t\_2\right|\\
\mathbf{if}\;eh \leq -1.15 \cdot 10^{+75}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;eh \leq 4.1 \cdot 10^{+177}:\\
\;\;\;\;\frac{\left|\mathsf{fma}\left(\frac{t\_2}{ew}, t\_1, \cos t \cdot ew\right)\right|}{\frac{--1}{{\left({\left(\frac{ew}{t\_1}\right)}^{-2} + 1\right)}^{-0.5}}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eh < -1.1499999999999999e75 or 4.10000000000000014e177 < 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 rewrites28.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 rewrites38.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 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.f6478.6

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

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

    if -1.1499999999999999e75 < eh < 4.10000000000000014e177

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;eh \leq -1.15 \cdot 10^{+75}:\\ \;\;\;\;\left|eh \cdot \sin t\right|\\ \mathbf{elif}\;eh \leq 4.1 \cdot 10^{+177}:\\ \;\;\;\;\frac{\left|\mathsf{fma}\left(\frac{eh \cdot \sin t}{ew}, \tan t \cdot eh, \cos t \cdot ew\right)\right|}{\frac{--1}{{\left({\left(\frac{ew}{\tan t \cdot eh}\right)}^{-2} + 1\right)}^{-0.5}}}\\ \mathbf{else}:\\ \;\;\;\;\left|eh \cdot \sin t\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 75.8% accurate, 1.3× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -5.80000000000000037e-15 or 8.0000000000000007e-130 < 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 \color{blue}{\left|\mathsf{fma}\left(\sin t \cdot \left(-eh\right), -\sin \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right), \cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot \left(\cos t \cdot ew\right)\right)\right|} \]
    4. Applied rewrites83.8%

      \[\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 -5.80000000000000037e-15 < ew < 8.0000000000000007e-130

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

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

      \[\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.f6475.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ew \leq -5.8 \cdot 10^{-15}:\\ \;\;\;\;\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)\\ \mathbf{elif}\;ew \leq 8 \cdot 10^{-130}:\\ \;\;\;\;\left|eh \cdot \sin t\right|\\ \mathbf{else}:\\ \;\;\;\;\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)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 74.7% accurate, 7.1× speedup?

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

\\
\begin{array}{l}
t_1 := \left|\left(-ew\right) \cdot \cos t\right|\\
\mathbf{if}\;ew \leq -5.8 \cdot 10^{-15}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;ew \leq 8.5 \cdot 10^{-130}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -5.80000000000000037e-15 or 8.50000000000000033e-130 < 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 rewrites83.8%

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

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

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

      \[\leadsto \left|\color{blue}{\left(-ew\right) \cdot \cos t}\right| \]

    if -5.80000000000000037e-15 < ew < 8.50000000000000033e-130

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

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

      \[\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.f6475.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ew \leq -5.8 \cdot 10^{-15}:\\ \;\;\;\;\left|\left(-ew\right) \cdot \cos t\right|\\ \mathbf{elif}\;ew \leq 8.5 \cdot 10^{-130}:\\ \;\;\;\;\left|eh \cdot \sin t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(-ew\right) \cdot \cos t\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 60.9% accurate, 7.2× speedup?

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

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

\mathbf{elif}\;t \leq 6.5 \cdot 10^{-94}:\\
\;\;\;\;\left|-ew\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.4000000000000001e-24 or 6.4999999999999996e-94 < 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. Applied rewrites51.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 rewrites67.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 -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.f6455.4

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

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

    if -1.4000000000000001e-24 < t < 6.4999999999999996e-94

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

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

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

      \[\leadsto \left|\color{blue}{-ew}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification63.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.4 \cdot 10^{-24}:\\ \;\;\;\;\left|eh \cdot \sin t\right|\\ \mathbf{elif}\;t \leq 6.5 \cdot 10^{-94}:\\ \;\;\;\;\left|-ew\right|\\ \mathbf{else}:\\ \;\;\;\;\left|eh \cdot \sin t\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 42.3% 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 rewrites61.3%

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

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

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

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

Reproduce

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