Example 2 from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 8.6s
Alternatives: 9
Speedup: N/A×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\ \left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right| \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew))))
   (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
	double t_1 = atan(((-eh * tan(t)) / ew));
	return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(eh, ew, t)
use fmin_fmax_functions
    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}

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 9 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))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(eh, ew, t)
use fmin_fmax_functions
    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.2× speedup?

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

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

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

Alternative 2: 98.5% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \left|\mathsf{fma}\left(ew, \cos t, \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot \left(\sin t \cdot eh\right)\right)\right| \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (fabs
  (fma ew (cos t) (* (tanh (asinh (* (/ (tan t) ew) eh))) (* (sin t) eh)))))
double code(double eh, double ew, double t) {
	return fabs(fma(ew, cos(t), (tanh(asinh(((tan(t) / ew) * eh))) * (sin(t) * eh))));
}
function code(eh, ew, t)
	return abs(fma(ew, cos(t), Float64(tanh(asinh(Float64(Float64(tan(t) / ew) * eh))) * Float64(sin(t) * eh))))
end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Cos[t], $MachinePrecision] + N[(N[Tanh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

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

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

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

    \[\leadsto \left|\mathsf{fma}\left(\color{blue}{ew}, \cos t, \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot \left(\sin t \cdot eh\right)\right)\right| \]
  4. Step-by-step derivation
    1. Applied rewrites98.5%

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

    Alternative 3: 90.4% accurate, 1.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \sinh^{-1} \left(\frac{t}{ew} \cdot eh\right)\\ \mathbf{if}\;ew \leq 4.2 \cdot 10^{+93}:\\ \;\;\;\;\left|\mathsf{fma}\left(\frac{ew}{\cosh t\_1}, \cos t, \tanh t\_1 \cdot \left(\sin t \cdot eh\right)\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew \cdot \cos t\right|\\ \end{array} \end{array} \]
    (FPCore (eh ew t)
     :precision binary64
     (let* ((t_1 (asinh (* (/ t ew) eh))))
       (if (<= ew 4.2e+93)
         (fabs (fma (/ ew (cosh t_1)) (cos t) (* (tanh t_1) (* (sin t) eh))))
         (fabs (* ew (cos t))))))
    double code(double eh, double ew, double t) {
    	double t_1 = asinh(((t / ew) * eh));
    	double tmp;
    	if (ew <= 4.2e+93) {
    		tmp = fabs(fma((ew / cosh(t_1)), cos(t), (tanh(t_1) * (sin(t) * eh))));
    	} else {
    		tmp = fabs((ew * cos(t)));
    	}
    	return tmp;
    }
    
    function code(eh, ew, t)
    	t_1 = asinh(Float64(Float64(t / ew) * eh))
    	tmp = 0.0
    	if (ew <= 4.2e+93)
    		tmp = abs(fma(Float64(ew / cosh(t_1)), cos(t), Float64(tanh(t_1) * Float64(sin(t) * eh))));
    	else
    		tmp = abs(Float64(ew * cos(t)));
    	end
    	return tmp
    end
    
    code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcSinh[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, 4.2e+93], N[Abs[N[(N[(ew / N[Cosh[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Cos[t], $MachinePrecision] + N[(N[Tanh[t$95$1], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \sinh^{-1} \left(\frac{t}{ew} \cdot eh\right)\\
    \mathbf{if}\;ew \leq 4.2 \cdot 10^{+93}:\\
    \;\;\;\;\left|\mathsf{fma}\left(\frac{ew}{\cosh t\_1}, \cos t, \tanh t\_1 \cdot \left(\sin t \cdot eh\right)\right)\right|\\
    
    \mathbf{else}:\\
    \;\;\;\;\left|ew \cdot \cos t\right|\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if ew < 4.1999999999999996e93

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

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

        \[\leadsto \left|\mathsf{fma}\left(\frac{ew}{\cosh \sinh^{-1} \left(\frac{\color{blue}{t}}{ew} \cdot eh\right)}, \cos t, \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot \left(\sin t \cdot eh\right)\right)\right| \]
      4. Step-by-step derivation
        1. Applied rewrites90.1%

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

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

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

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

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

            \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
          4. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \left|ew \cdot \color{blue}{\cos t}\right| \]
            2. lower-cos.f6461.7

              \[\leadsto \left|ew \cdot \cos t\right| \]
          5. Applied rewrites61.7%

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

        Alternative 4: 89.9% accurate, 2.1× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{eh \cdot t}{ew}\\ \mathbf{if}\;ew \leq 3.8 \cdot 10^{+76}:\\ \;\;\;\;\left|\mathsf{fma}\left(\frac{ew}{\cosh t\_1}, \cos t, \tanh t\_1 \cdot \left(\sin t \cdot eh\right)\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew \cdot \cos t\right|\\ \end{array} \end{array} \]
        (FPCore (eh ew t)
         :precision binary64
         (let* ((t_1 (/ (* eh t) ew)))
           (if (<= ew 3.8e+76)
             (fabs (fma (/ ew (cosh t_1)) (cos t) (* (tanh t_1) (* (sin t) eh))))
             (fabs (* ew (cos t))))))
        double code(double eh, double ew, double t) {
        	double t_1 = (eh * t) / ew;
        	double tmp;
        	if (ew <= 3.8e+76) {
        		tmp = fabs(fma((ew / cosh(t_1)), cos(t), (tanh(t_1) * (sin(t) * eh))));
        	} else {
        		tmp = fabs((ew * cos(t)));
        	}
        	return tmp;
        }
        
        function code(eh, ew, t)
        	t_1 = Float64(Float64(eh * t) / ew)
        	tmp = 0.0
        	if (ew <= 3.8e+76)
        		tmp = abs(fma(Float64(ew / cosh(t_1)), cos(t), Float64(tanh(t_1) * Float64(sin(t) * eh))));
        	else
        		tmp = abs(Float64(ew * cos(t)));
        	end
        	return tmp
        end
        
        code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh * t), $MachinePrecision] / ew), $MachinePrecision]}, If[LessEqual[ew, 3.8e+76], N[Abs[N[(N[(ew / N[Cosh[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Cos[t], $MachinePrecision] + N[(N[Tanh[t$95$1], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_1 := \frac{eh \cdot t}{ew}\\
        \mathbf{if}\;ew \leq 3.8 \cdot 10^{+76}:\\
        \;\;\;\;\left|\mathsf{fma}\left(\frac{ew}{\cosh t\_1}, \cos t, \tanh t\_1 \cdot \left(\sin t \cdot eh\right)\right)\right|\\
        
        \mathbf{else}:\\
        \;\;\;\;\left|ew \cdot \cos t\right|\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if ew < 3.80000000000000024e76

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

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

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

              \[\leadsto \left|\mathsf{fma}\left(\frac{ew}{\cosh \left(\frac{eh \cdot t}{\color{blue}{ew}}\right)}, \cos t, \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot \left(\sin t \cdot eh\right)\right)\right| \]
            2. lower-*.f6489.6

              \[\leadsto \left|\mathsf{fma}\left(\frac{ew}{\cosh \left(\frac{eh \cdot t}{ew}\right)}, \cos t, \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot \left(\sin t \cdot eh\right)\right)\right| \]
          5. Applied rewrites89.6%

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

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

              \[\leadsto \left|\mathsf{fma}\left(\frac{ew}{\cosh \left(\frac{eh \cdot t}{ew}\right)}, \cos t, \tanh \left(\frac{eh \cdot t}{\color{blue}{ew}}\right) \cdot \left(\sin t \cdot eh\right)\right)\right| \]
            2. lower-*.f6489.8

              \[\leadsto \left|\mathsf{fma}\left(\frac{ew}{\cosh \left(\frac{eh \cdot t}{ew}\right)}, \cos t, \tanh \left(\frac{eh \cdot t}{ew}\right) \cdot \left(\sin t \cdot eh\right)\right)\right| \]
          8. Applied rewrites89.8%

            \[\leadsto \left|\mathsf{fma}\left(\frac{ew}{\cosh \left(\frac{eh \cdot t}{ew}\right)}, \cos t, \tanh \color{blue}{\left(\frac{eh \cdot t}{ew}\right)} \cdot \left(\sin t \cdot eh\right)\right)\right| \]

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

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

            \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
          4. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \left|ew \cdot \color{blue}{\cos t}\right| \]
            2. lower-cos.f6461.7

              \[\leadsto \left|ew \cdot \cos t\right| \]
          5. Applied rewrites61.7%

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

        Alternative 5: 68.5% accurate, 2.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;eh \leq 5.4 \cdot 10^{+133}:\\ \;\;\;\;\left|ew \cdot \cos t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{\tan \left(\pi + t\right)}{ew}\right)\right|\\ \end{array} \end{array} \]
        (FPCore (eh ew t)
         :precision binary64
         (if (<= eh 5.4e+133)
           (fabs (* ew (cos t)))
           (fabs (* (* (sin t) eh) (tanh (asinh (* eh (/ (tan (+ PI t)) ew))))))))
        double code(double eh, double ew, double t) {
        	double tmp;
        	if (eh <= 5.4e+133) {
        		tmp = fabs((ew * cos(t)));
        	} else {
        		tmp = fabs(((sin(t) * eh) * tanh(asinh((eh * (tan((((double) M_PI) + t)) / ew))))));
        	}
        	return tmp;
        }
        
        def code(eh, ew, t):
        	tmp = 0
        	if eh <= 5.4e+133:
        		tmp = math.fabs((ew * math.cos(t)))
        	else:
        		tmp = math.fabs(((math.sin(t) * eh) * math.tanh(math.asinh((eh * (math.tan((math.pi + t)) / ew))))))
        	return tmp
        
        function code(eh, ew, t)
        	tmp = 0.0
        	if (eh <= 5.4e+133)
        		tmp = abs(Float64(ew * cos(t)));
        	else
        		tmp = abs(Float64(Float64(sin(t) * eh) * tanh(asinh(Float64(eh * Float64(tan(Float64(pi + t)) / ew))))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(eh, ew, t)
        	tmp = 0.0;
        	if (eh <= 5.4e+133)
        		tmp = abs((ew * cos(t)));
        	else
        		tmp = abs(((sin(t) * eh) * tanh(asinh((eh * (tan((pi + t)) / ew))))));
        	end
        	tmp_2 = tmp;
        end
        
        code[eh_, ew_, t_] := If[LessEqual[eh, 5.4e+133], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(eh * N[(N[Tan[N[(Pi + t), $MachinePrecision]], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;eh \leq 5.4 \cdot 10^{+133}:\\
        \;\;\;\;\left|ew \cdot \cos t\right|\\
        
        \mathbf{else}:\\
        \;\;\;\;\left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{\tan \left(\pi + t\right)}{ew}\right)\right|\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if eh < 5.4000000000000004e133

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

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

            \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
          4. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \left|ew \cdot \color{blue}{\cos t}\right| \]
            2. lower-cos.f6461.7

              \[\leadsto \left|ew \cdot \cos t\right| \]
          5. Applied rewrites61.7%

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

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

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

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

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

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

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

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            6. lower-atan.f64N/A

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            7. lower-*.f64N/A

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            8. lower-/.f64N/A

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            9. lower-*.f64N/A

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            10. lower-sin.f64N/A

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            11. lower-*.f64N/A

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

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

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

              \[\leadsto \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\right| \]
            2. tan-+PI-revN/A

              \[\leadsto \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{\tan \left(t + \mathsf{PI}\left(\right)\right)}{ew}\right)\right| \]
            3. lower-tan.f64N/A

              \[\leadsto \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{\tan \left(t + \mathsf{PI}\left(\right)\right)}{ew}\right)\right| \]
            4. +-commutativeN/A

              \[\leadsto \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{\tan \left(\mathsf{PI}\left(\right) + t\right)}{ew}\right)\right| \]
            5. lower-+.f64N/A

              \[\leadsto \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{\tan \left(\mathsf{PI}\left(\right) + t\right)}{ew}\right)\right| \]
            6. lower-PI.f6441.7

              \[\leadsto \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{\tan \left(\pi + t\right)}{ew}\right)\right| \]
          7. Applied rewrites41.7%

            \[\leadsto \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{\tan \left(\pi + t\right)}{ew}\right)\right| \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 6: 68.5% accurate, 3.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;eh \leq 5.4 \cdot 10^{+133}:\\ \;\;\;\;\left|ew \cdot \cos t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{t}{ew}\right)\right|\\ \end{array} \end{array} \]
        (FPCore (eh ew t)
         :precision binary64
         (if (<= eh 5.4e+133)
           (fabs (* ew (cos t)))
           (fabs (* (* (sin t) eh) (tanh (asinh (* eh (/ t ew))))))))
        double code(double eh, double ew, double t) {
        	double tmp;
        	if (eh <= 5.4e+133) {
        		tmp = fabs((ew * cos(t)));
        	} else {
        		tmp = fabs(((sin(t) * eh) * tanh(asinh((eh * (t / ew))))));
        	}
        	return tmp;
        }
        
        def code(eh, ew, t):
        	tmp = 0
        	if eh <= 5.4e+133:
        		tmp = math.fabs((ew * math.cos(t)))
        	else:
        		tmp = math.fabs(((math.sin(t) * eh) * math.tanh(math.asinh((eh * (t / ew))))))
        	return tmp
        
        function code(eh, ew, t)
        	tmp = 0.0
        	if (eh <= 5.4e+133)
        		tmp = abs(Float64(ew * cos(t)));
        	else
        		tmp = abs(Float64(Float64(sin(t) * eh) * tanh(asinh(Float64(eh * Float64(t / ew))))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(eh, ew, t)
        	tmp = 0.0;
        	if (eh <= 5.4e+133)
        		tmp = abs((ew * cos(t)));
        	else
        		tmp = abs(((sin(t) * eh) * tanh(asinh((eh * (t / ew))))));
        	end
        	tmp_2 = tmp;
        end
        
        code[eh_, ew_, t_] := If[LessEqual[eh, 5.4e+133], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(eh * N[(t / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;eh \leq 5.4 \cdot 10^{+133}:\\
        \;\;\;\;\left|ew \cdot \cos t\right|\\
        
        \mathbf{else}:\\
        \;\;\;\;\left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{t}{ew}\right)\right|\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if eh < 5.4000000000000004e133

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

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

            \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
          4. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \left|ew \cdot \color{blue}{\cos t}\right| \]
            2. lower-cos.f6461.7

              \[\leadsto \left|ew \cdot \cos t\right| \]
          5. Applied rewrites61.7%

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

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

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

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

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

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

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

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            6. lower-atan.f64N/A

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            7. lower-*.f64N/A

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            8. lower-/.f64N/A

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            9. lower-*.f64N/A

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            10. lower-sin.f64N/A

              \[\leadsto \left|-1 \cdot \left(eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-1 \cdot \frac{eh \cdot \sin t}{ew \cdot \cos t}\right)\right)\right)\right| \]
            11. lower-*.f64N/A

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

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

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

            \[\leadsto \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{t}{ew}\right)\right| \]
          7. Step-by-step derivation
            1. lower-/.f6441.7

              \[\leadsto \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{t}{ew}\right)\right| \]
          8. Applied rewrites41.7%

            \[\leadsto \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(eh \cdot \frac{t}{ew}\right)\right| \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 7: 61.7% accurate, 6.7× speedup?

        \[\begin{array}{l} \\ \left|ew \cdot \cos t\right| \end{array} \]
        (FPCore (eh ew t) :precision binary64 (fabs (* ew (cos t))))
        double code(double eh, double ew, double t) {
        	return fabs((ew * cos(t)));
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(8) function code(eh, ew, t)
        use fmin_fmax_functions
            real(8), intent (in) :: eh
            real(8), intent (in) :: ew
            real(8), intent (in) :: t
            code = abs((ew * cos(t)))
        end function
        
        public static double code(double eh, double ew, double t) {
        	return Math.abs((ew * Math.cos(t)));
        }
        
        def code(eh, ew, t):
        	return math.fabs((ew * math.cos(t)))
        
        function code(eh, ew, t)
        	return abs(Float64(ew * cos(t)))
        end
        
        function tmp = code(eh, ew, t)
        	tmp = abs((ew * cos(t)));
        end
        
        code[eh_, ew_, t_] := N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \left|ew \cdot \cos t\right|
        \end{array}
        
        Derivation
        1. Initial program 99.8%

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

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

          \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
        4. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto \left|ew \cdot \color{blue}{\cos t}\right| \]
          2. lower-cos.f6461.7

            \[\leadsto \left|ew \cdot \cos t\right| \]
        5. Applied rewrites61.7%

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

        Alternative 8: 38.9% accurate, 11.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq 380000000:\\ \;\;\;\;\left|\mathsf{fma}\left(t \cdot t, -0.5, 1\right) \cdot ew\right|\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{ew}^{2}}\\ \end{array} \end{array} \]
        (FPCore (eh ew t)
         :precision binary64
         (if (<= t 380000000.0)
           (fabs (* (fma (* t t) -0.5 1.0) ew))
           (sqrt (pow ew 2.0))))
        double code(double eh, double ew, double t) {
        	double tmp;
        	if (t <= 380000000.0) {
        		tmp = fabs((fma((t * t), -0.5, 1.0) * ew));
        	} else {
        		tmp = sqrt(pow(ew, 2.0));
        	}
        	return tmp;
        }
        
        function code(eh, ew, t)
        	tmp = 0.0
        	if (t <= 380000000.0)
        		tmp = abs(Float64(fma(Float64(t * t), -0.5, 1.0) * ew));
        	else
        		tmp = sqrt((ew ^ 2.0));
        	end
        	return tmp
        end
        
        code[eh_, ew_, t_] := If[LessEqual[t, 380000000.0], N[Abs[N[(N[(N[(t * t), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[Power[ew, 2.0], $MachinePrecision]], $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;t \leq 380000000:\\
        \;\;\;\;\left|\mathsf{fma}\left(t \cdot t, -0.5, 1\right) \cdot ew\right|\\
        
        \mathbf{else}:\\
        \;\;\;\;\sqrt{{ew}^{2}}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if t < 3.8e8

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

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

            \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
          4. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \left|ew \cdot \color{blue}{\cos t}\right| \]
            2. lower-cos.f6461.7

              \[\leadsto \left|ew \cdot \cos t\right| \]
          5. Applied rewrites61.7%

            \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
          6. Taylor expanded in t around 0

            \[\leadsto \left|ew \cdot \left(1 + \color{blue}{\frac{-1}{2} \cdot {t}^{2}}\right)\right| \]
          7. Step-by-step derivation
            1. lower-+.f64N/A

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

              \[\leadsto \left|ew \cdot \left(1 + \frac{-1}{2} \cdot {t}^{\color{blue}{2}}\right)\right| \]
            3. lower-pow.f6438.1

              \[\leadsto \left|ew \cdot \left(1 + -0.5 \cdot {t}^{2}\right)\right| \]
          8. Applied rewrites38.1%

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

              \[\leadsto \left|ew \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {t}^{2}\right)}\right| \]
            2. *-commutativeN/A

              \[\leadsto \left|\left(1 + \frac{-1}{2} \cdot {t}^{2}\right) \cdot \color{blue}{ew}\right| \]
            3. lower-*.f6438.1

              \[\leadsto \left|\left(1 + -0.5 \cdot {t}^{2}\right) \cdot \color{blue}{ew}\right| \]
            4. lift-+.f64N/A

              \[\leadsto \left|\left(1 + \frac{-1}{2} \cdot {t}^{2}\right) \cdot ew\right| \]
            5. +-commutativeN/A

              \[\leadsto \left|\left(\frac{-1}{2} \cdot {t}^{2} + 1\right) \cdot ew\right| \]
            6. lift-*.f64N/A

              \[\leadsto \left|\left(\frac{-1}{2} \cdot {t}^{2} + 1\right) \cdot ew\right| \]
            7. *-commutativeN/A

              \[\leadsto \left|\left({t}^{2} \cdot \frac{-1}{2} + 1\right) \cdot ew\right| \]
            8. lower-fma.f6438.1

              \[\leadsto \left|\mathsf{fma}\left({t}^{2}, -0.5, 1\right) \cdot ew\right| \]
            9. lift-pow.f64N/A

              \[\leadsto \left|\mathsf{fma}\left({t}^{2}, \frac{-1}{2}, 1\right) \cdot ew\right| \]
            10. unpow2N/A

              \[\leadsto \left|\mathsf{fma}\left(t \cdot t, \frac{-1}{2}, 1\right) \cdot ew\right| \]
            11. lower-*.f6438.1

              \[\leadsto \left|\mathsf{fma}\left(t \cdot t, -0.5, 1\right) \cdot ew\right| \]
          10. Applied rewrites38.1%

            \[\leadsto \left|\color{blue}{\mathsf{fma}\left(t \cdot t, -0.5, 1\right) \cdot ew}\right| \]

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

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

            \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
          4. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \left|ew \cdot \color{blue}{\cos t}\right| \]
            2. lower-cos.f6461.7

              \[\leadsto \left|ew \cdot \cos t\right| \]
          5. Applied rewrites61.7%

            \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
          6. Step-by-step derivation
            1. lift-fabs.f64N/A

              \[\leadsto \color{blue}{\left|ew \cdot \cos t\right|} \]
            2. rem-sqrt-square-revN/A

              \[\leadsto \color{blue}{\sqrt{\left(ew \cdot \cos t\right) \cdot \left(ew \cdot \cos t\right)}} \]
            3. lower-sqrt.f64N/A

              \[\leadsto \color{blue}{\sqrt{\left(ew \cdot \cos t\right) \cdot \left(ew \cdot \cos t\right)}} \]
            4. pow2N/A

              \[\leadsto \sqrt{\color{blue}{{\left(ew \cdot \cos t\right)}^{2}}} \]
          7. Applied rewrites34.2%

            \[\leadsto \color{blue}{\sqrt{{\left(\cos t \cdot ew\right)}^{2}}} \]
          8. Taylor expanded in t around 0

            \[\leadsto \sqrt{\color{blue}{{ew}^{2}}} \]
          9. Step-by-step derivation
            1. lower-pow.f6424.5

              \[\leadsto \sqrt{{ew}^{\color{blue}{2}}} \]
          10. Applied rewrites24.5%

            \[\leadsto \sqrt{\color{blue}{{ew}^{2}}} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 9: 38.1% accurate, 18.9× speedup?

        \[\begin{array}{l} \\ \left|\mathsf{fma}\left(t \cdot t, -0.5, 1\right) \cdot ew\right| \end{array} \]
        (FPCore (eh ew t) :precision binary64 (fabs (* (fma (* t t) -0.5 1.0) ew)))
        double code(double eh, double ew, double t) {
        	return fabs((fma((t * t), -0.5, 1.0) * ew));
        }
        
        function code(eh, ew, t)
        	return abs(Float64(fma(Float64(t * t), -0.5, 1.0) * ew))
        end
        
        code[eh_, ew_, t_] := N[Abs[N[(N[(N[(t * t), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \left|\mathsf{fma}\left(t \cdot t, -0.5, 1\right) \cdot 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. Applied rewrites99.8%

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

          \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
        4. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto \left|ew \cdot \color{blue}{\cos t}\right| \]
          2. lower-cos.f6461.7

            \[\leadsto \left|ew \cdot \cos t\right| \]
        5. Applied rewrites61.7%

          \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
        6. Taylor expanded in t around 0

          \[\leadsto \left|ew \cdot \left(1 + \color{blue}{\frac{-1}{2} \cdot {t}^{2}}\right)\right| \]
        7. Step-by-step derivation
          1. lower-+.f64N/A

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

            \[\leadsto \left|ew \cdot \left(1 + \frac{-1}{2} \cdot {t}^{\color{blue}{2}}\right)\right| \]
          3. lower-pow.f6438.1

            \[\leadsto \left|ew \cdot \left(1 + -0.5 \cdot {t}^{2}\right)\right| \]
        8. Applied rewrites38.1%

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

            \[\leadsto \left|ew \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {t}^{2}\right)}\right| \]
          2. *-commutativeN/A

            \[\leadsto \left|\left(1 + \frac{-1}{2} \cdot {t}^{2}\right) \cdot \color{blue}{ew}\right| \]
          3. lower-*.f6438.1

            \[\leadsto \left|\left(1 + -0.5 \cdot {t}^{2}\right) \cdot \color{blue}{ew}\right| \]
          4. lift-+.f64N/A

            \[\leadsto \left|\left(1 + \frac{-1}{2} \cdot {t}^{2}\right) \cdot ew\right| \]
          5. +-commutativeN/A

            \[\leadsto \left|\left(\frac{-1}{2} \cdot {t}^{2} + 1\right) \cdot ew\right| \]
          6. lift-*.f64N/A

            \[\leadsto \left|\left(\frac{-1}{2} \cdot {t}^{2} + 1\right) \cdot ew\right| \]
          7. *-commutativeN/A

            \[\leadsto \left|\left({t}^{2} \cdot \frac{-1}{2} + 1\right) \cdot ew\right| \]
          8. lower-fma.f6438.1

            \[\leadsto \left|\mathsf{fma}\left({t}^{2}, -0.5, 1\right) \cdot ew\right| \]
          9. lift-pow.f64N/A

            \[\leadsto \left|\mathsf{fma}\left({t}^{2}, \frac{-1}{2}, 1\right) \cdot ew\right| \]
          10. unpow2N/A

            \[\leadsto \left|\mathsf{fma}\left(t \cdot t, \frac{-1}{2}, 1\right) \cdot ew\right| \]
          11. lower-*.f6438.1

            \[\leadsto \left|\mathsf{fma}\left(t \cdot t, -0.5, 1\right) \cdot ew\right| \]
        10. Applied rewrites38.1%

          \[\leadsto \left|\color{blue}{\mathsf{fma}\left(t \cdot t, -0.5, 1\right) \cdot ew}\right| \]
        11. Add Preprocessing

        Reproduce

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