Example from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 20.2s
Alternatives: 8
Speedup: N/A×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

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

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

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    2. associate-*l*N/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot eh + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    4. fma-defineN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\mathsf{fma}\left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), eh, \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right) \]
    5. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{fma.f64}\left(\left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right), eh, \left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right) \]
  4. Applied egg-rr99.9%

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

Alternative 2: 99.8% accurate, 1.1× speedup?

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

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

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\left(\cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(ew \cdot \sin t\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    2. associate-*r*N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\left(\left(\cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot ew\right) \cdot \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot ew\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(ew \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    5. cos-atanN/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(ew \cdot \frac{1}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    6. un-div-invN/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\frac{ew}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(ew, \left(\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}\right)\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    8. hypot-1-defN/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(ew, \left(\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)\right)\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    9. hypot-lowering-hypot.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(ew, \mathsf{hypot.f64}\left(1, \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    10. associate-/l/N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(ew, \mathsf{hypot.f64}\left(1, \left(\frac{eh}{\tan t \cdot ew}\right)\right)\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    11. /-lowering-/.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(ew, \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \left(\tan t \cdot ew\right)\right)\right)\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    12. *-commutativeN/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(ew, \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \left(ew \cdot \tan t\right)\right)\right)\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(ew, \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \tan t\right)\right)\right)\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    14. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(ew, \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right), \sin t\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
    15. sin-lowering-sin.f6499.8%

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(ew, \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right), \mathsf{sin.f64}\left(t\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(eh, ew\right), \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right)\right) \]
  4. Applied egg-rr99.8%

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

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

Alternative 3: 98.5% accurate, 1.5× speedup?

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

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

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    2. associate-*l*N/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot eh + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    4. fma-defineN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\mathsf{fma}\left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), eh, \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right) \]
    5. fma-lowering-fma.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{fma.f64}\left(\left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right), eh, \left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right) \]
  4. Applied egg-rr99.9%

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

    \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right) + ew \cdot \sin t\right)}\right) \]
  6. Step-by-step derivation
    1. +-lowering-+.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\left(eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right), \left(ew \cdot \sin t\right)\right)\right) \]
    2. associate-*r*N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\left(\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right), \left(ew \cdot \sin t\right)\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(eh \cdot \cos t\right), \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right), \left(ew \cdot \sin t\right)\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \cos t\right), \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right), \left(ew \cdot \sin t\right)\right)\right) \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right), \left(ew \cdot \sin t\right)\right)\right) \]
    6. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right), \left(ew \cdot \sin t\right)\right)\right) \]
    7. atan-lowering-atan.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right), \left(ew \cdot \sin t\right)\right)\right) \]
    8. /-lowering-/.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(eh, \left(ew \cdot \tan t\right)\right)\right)\right)\right), \left(ew \cdot \sin t\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \tan t\right)\right)\right)\right)\right), \left(ew \cdot \sin t\right)\right)\right) \]
    10. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right), \left(ew \cdot \sin t\right)\right)\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right), \mathsf{*.f64}\left(ew, \sin t\right)\right)\right) \]
    12. sin-lowering-sin.f6498.0%

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{sin.f64}\left(\mathsf{atan.f64}\left(\mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right), \mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right)\right) \]
  7. Simplified98.0%

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

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

Alternative 4: 80.6% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;ew \leq 2.9 \cdot 10^{-16}:\\
\;\;\;\;\left|\left(ew \cdot ew\right) \cdot \left(\frac{{\sin t}^{2}}{t\_1} \cdot -0.5\right) - t\_1\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -1.1499999999999999e74 or 2.8999999999999998e-16 < ew

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. neg-fabsN/A

        \[\leadsto \left|\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
      2. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
      3. distribute-neg-inN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) + \left(\mathsf{neg}\left(\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
      4. unsub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      5. cos-atanN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \frac{1}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      6. un-div-invN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\frac{ew \cdot \sin t}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\mathsf{neg}\left(ew \cdot \sin t\right)}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}} - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    4. Applied egg-rr85.0%

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

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \color{blue}{\left(\frac{ew \cdot t}{eh}\right)}\right)\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{/.f64}\left(\left(ew \cdot t\right), eh\right)\right)\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f6480.8%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ew, t\right), eh\right)\right)\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
    7. Simplified80.8%

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

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ew, t\right), eh\right)\right)\right), \mathsf{hypot.f64}\left(1, \color{blue}{\left(\frac{eh}{ew \cdot t}\right)}\right)\right)\right) \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ew, t\right), eh\right)\right)\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \left(ew \cdot t\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f6481.2%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ew, t\right), eh\right)\right)\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, t\right)\right)\right)\right)\right) \]
    10. Simplified81.2%

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

    if -1.1499999999999999e74 < ew < 2.8999999999999998e-16

    1. Initial program 99.9%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. neg-fabsN/A

        \[\leadsto \left|\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
      2. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
      3. distribute-neg-inN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) + \left(\mathsf{neg}\left(\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
      4. unsub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      5. cos-atanN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \frac{1}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      6. un-div-invN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\frac{ew \cdot \sin t}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\mathsf{neg}\left(ew \cdot \sin t\right)}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}} - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    4. Applied egg-rr52.2%

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

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\color{blue}{\left(\frac{-1 \cdot \left({ew}^{2} \cdot \sin t\right) - \frac{{eh}^{2} \cdot {\cos t}^{2}}{\sin t}}{ew}\right)}, \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(-1 \cdot \left({ew}^{2} \cdot \sin t\right) - \frac{{eh}^{2} \cdot {\cos t}^{2}}{\sin t}\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      2. --lowering--.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(-1 \cdot \left({ew}^{2} \cdot \sin t\right)\right), \left(\frac{{eh}^{2} \cdot {\cos t}^{2}}{\sin t}\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\left(-1 \cdot {ew}^{2}\right) \cdot \sin t\right), \left(\frac{{eh}^{2} \cdot {\cos t}^{2}}{\sin t}\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(-1 \cdot {ew}^{2}\right), \sin t\right), \left(\frac{{eh}^{2} \cdot {\cos t}^{2}}{\sin t}\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \left({ew}^{2}\right)\right), \sin t\right), \left(\frac{{eh}^{2} \cdot {\cos t}^{2}}{\sin t}\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \left(ew \cdot ew\right)\right), \sin t\right), \left(\frac{{eh}^{2} \cdot {\cos t}^{2}}{\sin t}\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ew, ew\right)\right), \sin t\right), \left(\frac{{eh}^{2} \cdot {\cos t}^{2}}{\sin t}\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      8. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ew, ew\right)\right), \mathsf{sin.f64}\left(t\right)\right), \left(\frac{{eh}^{2} \cdot {\cos t}^{2}}{\sin t}\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ew, ew\right)\right), \mathsf{sin.f64}\left(t\right)\right), \mathsf{/.f64}\left(\left({eh}^{2} \cdot {\cos t}^{2}\right), \sin t\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ew, ew\right)\right), \mathsf{sin.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({eh}^{2}\right), \left({\cos t}^{2}\right)\right), \sin t\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      11. unpow2N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ew, ew\right)\right), \mathsf{sin.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(eh \cdot eh\right), \left({\cos t}^{2}\right)\right), \sin t\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ew, ew\right)\right), \mathsf{sin.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, eh\right), \left({\cos t}^{2}\right)\right), \sin t\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      13. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ew, ew\right)\right), \mathsf{sin.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, eh\right), \mathsf{pow.f64}\left(\cos t, 2\right)\right), \sin t\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      14. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ew, ew\right)\right), \mathsf{sin.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, eh\right), \mathsf{pow.f64}\left(\mathsf{cos.f64}\left(t\right), 2\right)\right), \sin t\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      15. sin-lowering-sin.f6443.8%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ew, ew\right)\right), \mathsf{sin.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(eh, eh\right), \mathsf{pow.f64}\left(\mathsf{cos.f64}\left(t\right), 2\right)\right), \mathsf{sin.f64}\left(t\right)\right)\right), ew\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
    7. Simplified43.8%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(-1 \cdot \left(eh \cdot \cos t\right) + {ew}^{2} \cdot \left(-1 \cdot \frac{{\sin t}^{2}}{eh \cdot \cos t} + \frac{1}{2} \cdot \frac{{\sin t}^{2}}{eh \cdot \cos t}\right)\right)}\right) \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left({ew}^{2} \cdot \left(-1 \cdot \frac{{\sin t}^{2}}{eh \cdot \cos t} + \frac{1}{2} \cdot \frac{{\sin t}^{2}}{eh \cdot \cos t}\right) + -1 \cdot \left(eh \cdot \cos t\right)\right)\right) \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left({ew}^{2} \cdot \left(-1 \cdot \frac{{\sin t}^{2}}{eh \cdot \cos t} + \frac{1}{2} \cdot \frac{{\sin t}^{2}}{eh \cdot \cos t}\right) + \left(\mathsf{neg}\left(eh \cdot \cos t\right)\right)\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left({ew}^{2} \cdot \left(-1 \cdot \frac{{\sin t}^{2}}{eh \cdot \cos t} + \frac{1}{2} \cdot \frac{{\sin t}^{2}}{eh \cdot \cos t}\right) - eh \cdot \cos t\right)\right) \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\left({ew}^{2} \cdot \left(-1 \cdot \frac{{\sin t}^{2}}{eh \cdot \cos t} + \frac{1}{2} \cdot \frac{{\sin t}^{2}}{eh \cdot \cos t}\right)\right), \left(eh \cdot \cos t\right)\right)\right) \]
    10. Simplified84.9%

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

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

Alternative 5: 82.8% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \cos t \cdot eh\\ t_2 := \left|t\_1\right|\\ \mathbf{if}\;eh \leq -1.05 \cdot 10^{+36}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;eh \leq 5.2 \cdot 10^{-26}:\\ \;\;\;\;\left|\frac{ew \cdot \sin t + \frac{t\_1}{\frac{t \cdot ew}{eh}}}{\mathsf{hypot}\left(1, \frac{eh}{t \cdot ew}\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (* (cos t) eh)) (t_2 (fabs t_1)))
   (if (<= eh -1.05e+36)
     t_2
     (if (<= eh 5.2e-26)
       (fabs
        (/
         (+ (* ew (sin t)) (/ t_1 (/ (* t ew) eh)))
         (hypot 1.0 (/ eh (* t ew)))))
       t_2))))
double code(double eh, double ew, double t) {
	double t_1 = cos(t) * eh;
	double t_2 = fabs(t_1);
	double tmp;
	if (eh <= -1.05e+36) {
		tmp = t_2;
	} else if (eh <= 5.2e-26) {
		tmp = fabs((((ew * sin(t)) + (t_1 / ((t * ew) / eh))) / hypot(1.0, (eh / (t * ew)))));
	} else {
		tmp = t_2;
	}
	return tmp;
}
public static double code(double eh, double ew, double t) {
	double t_1 = Math.cos(t) * eh;
	double t_2 = Math.abs(t_1);
	double tmp;
	if (eh <= -1.05e+36) {
		tmp = t_2;
	} else if (eh <= 5.2e-26) {
		tmp = Math.abs((((ew * Math.sin(t)) + (t_1 / ((t * ew) / eh))) / Math.hypot(1.0, (eh / (t * ew)))));
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(eh, ew, t):
	t_1 = math.cos(t) * eh
	t_2 = math.fabs(t_1)
	tmp = 0
	if eh <= -1.05e+36:
		tmp = t_2
	elif eh <= 5.2e-26:
		tmp = math.fabs((((ew * math.sin(t)) + (t_1 / ((t * ew) / eh))) / math.hypot(1.0, (eh / (t * ew)))))
	else:
		tmp = t_2
	return tmp
function code(eh, ew, t)
	t_1 = Float64(cos(t) * eh)
	t_2 = abs(t_1)
	tmp = 0.0
	if (eh <= -1.05e+36)
		tmp = t_2;
	elseif (eh <= 5.2e-26)
		tmp = abs(Float64(Float64(Float64(ew * sin(t)) + Float64(t_1 / Float64(Float64(t * ew) / eh))) / hypot(1.0, Float64(eh / Float64(t * ew)))));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	t_1 = cos(t) * eh;
	t_2 = abs(t_1);
	tmp = 0.0;
	if (eh <= -1.05e+36)
		tmp = t_2;
	elseif (eh <= 5.2e-26)
		tmp = abs((((ew * sin(t)) + (t_1 / ((t * ew) / eh))) / hypot(1.0, (eh / (t * ew)))));
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$2 = N[Abs[t$95$1], $MachinePrecision]}, If[LessEqual[eh, -1.05e+36], t$95$2, If[LessEqual[eh, 5.2e-26], N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 / N[(N[(t * ew), $MachinePrecision] / eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}

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

\mathbf{elif}\;eh \leq 5.2 \cdot 10^{-26}:\\
\;\;\;\;\left|\frac{ew \cdot \sin t + \frac{t\_1}{\frac{t \cdot ew}{eh}}}{\mathsf{hypot}\left(1, \frac{eh}{t \cdot ew}\right)}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eh < -1.05000000000000002e36 or 5.2000000000000002e-26 < eh

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. neg-fabsN/A

        \[\leadsto \left|\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
      2. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
      3. distribute-neg-inN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) + \left(\mathsf{neg}\left(\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
      4. unsub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      5. cos-atanN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \frac{1}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      6. un-div-invN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\frac{ew \cdot \sin t}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\mathsf{neg}\left(ew \cdot \sin t\right)}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}} - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    4. Applied egg-rr41.8%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(eh \cdot \cos t\right)}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(eh, \cos t\right)\right) \]
      2. cos-lowering-cos.f6485.6%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right)\right) \]
    7. Simplified85.6%

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

    if -1.05000000000000002e36 < eh < 5.2000000000000002e-26

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. neg-fabsN/A

        \[\leadsto \left|\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
      2. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
      3. distribute-neg-inN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) + \left(\mathsf{neg}\left(\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
      4. unsub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      5. cos-atanN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \frac{1}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      6. un-div-invN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\frac{ew \cdot \sin t}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\mathsf{neg}\left(ew \cdot \sin t\right)}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}} - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    4. Applied egg-rr89.6%

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

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \color{blue}{\left(\frac{ew \cdot t}{eh}\right)}\right)\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{/.f64}\left(\left(ew \cdot t\right), eh\right)\right)\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f6476.4%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ew, t\right), eh\right)\right)\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, \mathsf{tan.f64}\left(t\right)\right)\right)\right)\right)\right) \]
    7. Simplified76.4%

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

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ew, t\right), eh\right)\right)\right), \mathsf{hypot.f64}\left(1, \color{blue}{\left(\frac{eh}{ew \cdot t}\right)}\right)\right)\right) \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ew, t\right), eh\right)\right)\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \left(ew \cdot t\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f6480.8%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(ew, t\right), eh\right)\right)\right), \mathsf{hypot.f64}\left(1, \mathsf{/.f64}\left(eh, \mathsf{*.f64}\left(ew, t\right)\right)\right)\right)\right) \]
    10. Simplified80.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;eh \leq -1.05 \cdot 10^{+36}:\\ \;\;\;\;\left|\cos t \cdot eh\right|\\ \mathbf{elif}\;eh \leq 5.2 \cdot 10^{-26}:\\ \;\;\;\;\left|\frac{ew \cdot \sin t + \frac{\cos t \cdot eh}{\frac{t \cdot ew}{eh}}}{\mathsf{hypot}\left(1, \frac{eh}{t \cdot ew}\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\cos t \cdot eh\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 74.4% accurate, 4.3× speedup?

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

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

\mathbf{elif}\;ew \leq 5.7 \cdot 10^{-11}:\\
\;\;\;\;\left|\cos t \cdot eh\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -1.2600000000000001e134 or 5.6999999999999997e-11 < ew

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) \cdot eh + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      4. fma-defineN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\mathsf{fma}\left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), eh, \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right) \]
      5. fma-lowering-fma.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{fma.f64}\left(\left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right), eh, \left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right) \]
    4. Applied egg-rr99.8%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(ew \cdot \sin t\right)}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(ew, \sin t\right)\right) \]
      2. sin-lowering-sin.f6474.5%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(ew, \mathsf{sin.f64}\left(t\right)\right)\right) \]
    7. Simplified74.5%

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

    if -1.2600000000000001e134 < ew < 5.6999999999999997e-11

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. neg-fabsN/A

        \[\leadsto \left|\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
      2. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
      3. distribute-neg-inN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) + \left(\mathsf{neg}\left(\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
      4. unsub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      5. cos-atanN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \frac{1}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      6. un-div-invN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\frac{ew \cdot \sin t}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\mathsf{neg}\left(ew \cdot \sin t\right)}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}} - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    4. Applied egg-rr55.0%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(eh \cdot \cos t\right)}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(eh, \cos t\right)\right) \]
      2. cos-lowering-cos.f6482.3%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right)\right) \]
    7. Simplified82.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ew \leq -1.26 \cdot 10^{+134}:\\ \;\;\;\;\left|ew \cdot \sin t\right|\\ \mathbf{elif}\;ew \leq 5.7 \cdot 10^{-11}:\\ \;\;\;\;\left|\cos t \cdot eh\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew \cdot \sin t\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 62.9% accurate, 4.5× speedup?

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

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

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. neg-fabsN/A

      \[\leadsto \left|\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
    2. fabs-lowering-fabs.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\mathsf{neg}\left(\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
    3. distribute-neg-inN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) + \left(\mathsf{neg}\left(\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right)\right) \]
    4. unsub-negN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    5. cos-atanN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\left(ew \cdot \sin t\right) \cdot \frac{1}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    6. un-div-invN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\left(\mathsf{neg}\left(\frac{ew \cdot \sin t}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right)\right) - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
    7. distribute-neg-fracN/A

      \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\mathsf{neg}\left(ew \cdot \sin t\right)}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}} - \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right) \]
  4. Applied egg-rr66.3%

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

    \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(eh \cdot \cos t\right)}\right) \]
  6. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(eh, \cos t\right)\right) \]
    2. cos-lowering-cos.f6463.0%

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(eh, \mathsf{cos.f64}\left(t\right)\right)\right) \]
  7. Simplified63.0%

    \[\leadsto \left|\color{blue}{eh \cdot \cos t}\right| \]
  8. Final simplification63.0%

    \[\leadsto \left|\cos t \cdot eh\right| \]
  9. Add Preprocessing

Alternative 8: 42.9% accurate, 9.1× 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(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 \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Add Preprocessing
  3. Applied egg-rr53.3%

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

    \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{eh}\right) \]
  5. Step-by-step derivation
    1. Simplified44.5%

      \[\leadsto \left|\color{blue}{eh}\right| \]
    2. Add Preprocessing

    Reproduce

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