Example 2 from Robby

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

Specification

?
\[\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} \]
(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}
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}

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} 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} \]
(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}
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}

Alternative 1: 99.8% accurate, 1.2× speedup?

\[\left|\mathsf{fma}\left(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}\right)\right| \]
(FPCore (eh ew t)
 :precision binary64
 (fabs
  (fma
   (* (sin t) (- eh))
   (tanh (asinh (* (/ (tan t) ew) (- eh))))
   (/ (* (cos t) ew) (cosh (asinh (/ (* (tan t) eh) ew)))))))
double code(double eh, double ew, double t) {
	return fabs(fma((sin(t) * -eh), tanh(asinh(((tan(t) / ew) * -eh))), ((cos(t) * ew) / cosh(asinh(((tan(t) * eh) / ew))))));
}
function code(eh, ew, t)
	return abs(fma(Float64(sin(t) * Float64(-eh)), tanh(asinh(Float64(Float64(tan(t) / ew) * Float64(-eh)))), Float64(Float64(cos(t) * ew) / cosh(asinh(Float64(Float64(tan(t) * eh) / ew))))))
end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * (-eh)), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / N[Cosh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\mathsf{fma}\left(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}\right)\right|
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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}\right)}\right| \]
  3. Add Preprocessing

Alternative 2: 98.4% accurate, 1.8× speedup?

\[\left|\mathsf{fma}\left(\frac{ew}{1}, \cos t, \left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)\right)\right| \]
(FPCore (eh ew t)
 :precision binary64
 (fabs
  (fma
   (/ ew 1.0)
   (cos t)
   (* (* (sin t) eh) (tanh (asinh (* (/ (tan t) ew) eh)))))))
double code(double eh, double ew, double t) {
	return fabs(fma((ew / 1.0), cos(t), ((sin(t) * eh) * tanh(asinh(((tan(t) / ew) * eh))))));
}
function code(eh, ew, t)
	return abs(fma(Float64(ew / 1.0), cos(t), Float64(Float64(sin(t) * eh) * tanh(asinh(Float64(Float64(tan(t) / ew) * eh))))))
end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew / 1.0), $MachinePrecision] * N[Cos[t], $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\mathsf{fma}\left(\frac{ew}{1}, \cos t, \left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)\right)\right|
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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}\right)}\right| \]
  3. Taylor expanded in eh around 0

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

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

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

    Alternative 3: 98.1% accurate, 2.3× speedup?

    \[\left|\mathsf{fma}\left(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{1}\right)\right| \]
    (FPCore (eh ew t)
     :precision binary64
     (fabs
      (fma
       (* (sin t) (- eh))
       (tanh (asinh (* (/ t ew) (- eh))))
       (/ (* (cos t) ew) 1.0))))
    double code(double eh, double ew, double t) {
    	return fabs(fma((sin(t) * -eh), tanh(asinh(((t / ew) * -eh))), ((cos(t) * ew) / 1.0)));
    }
    
    function code(eh, ew, t)
    	return abs(fma(Float64(sin(t) * Float64(-eh)), tanh(asinh(Float64(Float64(t / ew) * Float64(-eh)))), Float64(Float64(cos(t) * ew) / 1.0)))
    end
    
    code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * (-eh)), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(N[(t / ew), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
    
    \left|\mathsf{fma}\left(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{1}\right)\right|
    
    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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}\right)}\right| \]
    3. Taylor expanded in eh around 0

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

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

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

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

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

      Alternative 4: 98.1% accurate, 2.4× speedup?

      \[\left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(\frac{t}{ew} \cdot \left(-eh\right)\right) - \cos t \cdot \frac{ew}{1}\right| \]
      (FPCore (eh ew t)
       :precision binary64
       (fabs
        (-
         (* (* (sin t) eh) (tanh (asinh (* (/ t ew) (- eh)))))
         (* (cos t) (/ ew 1.0)))))
      double code(double eh, double ew, double t) {
      	return fabs((((sin(t) * eh) * tanh(asinh(((t / ew) * -eh)))) - (cos(t) * (ew / 1.0))));
      }
      
      def code(eh, ew, t):
      	return math.fabs((((math.sin(t) * eh) * math.tanh(math.asinh(((t / ew) * -eh)))) - (math.cos(t) * (ew / 1.0))))
      
      function code(eh, ew, t)
      	return abs(Float64(Float64(Float64(sin(t) * eh) * tanh(asinh(Float64(Float64(t / ew) * Float64(-eh))))) - Float64(cos(t) * Float64(ew / 1.0))))
      end
      
      function tmp = code(eh, ew, t)
      	tmp = abs((((sin(t) * eh) * tanh(asinh(((t / ew) * -eh)))) - (cos(t) * (ew / 1.0))));
      end
      
      code[eh_, ew_, t_] := N[Abs[N[(N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(N[(t / ew), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[t], $MachinePrecision] * N[(ew / 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
      
      \left|\left(\sin t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(\frac{t}{ew} \cdot \left(-eh\right)\right) - \cos t \cdot \frac{ew}{1}\right|
      
      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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}\right)}\right| \]
      3. Taylor expanded in eh around 0

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

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

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

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

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

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

            \[\leadsto \left|\color{blue}{\left(\sin t \cdot \left(-eh\right)\right) \cdot \tanh \sinh^{-1} \left(\frac{t}{ew} \cdot \left(-eh\right)\right) + \frac{\cos t \cdot ew}{1}}\right| \]
          3. +-commutativeN/A

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

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

            \[\leadsto \left|\frac{\cos t \cdot ew}{1} + \left(\sin t \cdot \color{blue}{\left(\mathsf{neg}\left(eh\right)\right)}\right) \cdot \tanh \sinh^{-1} \left(\frac{t}{ew} \cdot \left(-eh\right)\right)\right| \]
          6. distribute-rgt-neg-outN/A

            \[\leadsto \left|\frac{\cos t \cdot ew}{1} + \color{blue}{\left(\mathsf{neg}\left(\sin t \cdot eh\right)\right)} \cdot \tanh \sinh^{-1} \left(\frac{t}{ew} \cdot \left(-eh\right)\right)\right| \]
          7. lift-sin.f64N/A

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

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

        Alternative 5: 75.0% accurate, 2.2× speedup?

        \[\begin{array}{l} \mathbf{if}\;\left|t\right| \leq 1.28 \cdot 10^{+20}:\\ \;\;\;\;\left|\mathsf{fma}\left(\sin \left(\left|t\right|\right) \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\left|t\right|}{ew} \cdot \left(-eh\right)\right), \frac{\left(1 + -0.5 \cdot {\left(\left|t\right|\right)}^{2}\right) \cdot ew}{1}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left({\left(\frac{\tan \left(\left|t\right|\right)}{ew} \cdot eh\right)}^{2} - -1\right) \cdot \left(\cos \left(\left|t\right|\right) \cdot ew\right)}{1}\right|\\ \end{array} \]
        (FPCore (eh ew t)
         :precision binary64
         (if (<= (fabs t) 1.28e+20)
           (fabs
            (fma
             (* (sin (fabs t)) (- eh))
             (tanh (asinh (* (/ (fabs t) ew) (- eh))))
             (/ (* (+ 1.0 (* -0.5 (pow (fabs t) 2.0))) ew) 1.0)))
           (fabs
            (/
             (* (- (pow (* (/ (tan (fabs t)) ew) eh) 2.0) -1.0) (* (cos (fabs t)) ew))
             1.0))))
        double code(double eh, double ew, double t) {
        	double tmp;
        	if (fabs(t) <= 1.28e+20) {
        		tmp = fabs(fma((sin(fabs(t)) * -eh), tanh(asinh(((fabs(t) / ew) * -eh))), (((1.0 + (-0.5 * pow(fabs(t), 2.0))) * ew) / 1.0)));
        	} else {
        		tmp = fabs((((pow(((tan(fabs(t)) / ew) * eh), 2.0) - -1.0) * (cos(fabs(t)) * ew)) / 1.0));
        	}
        	return tmp;
        }
        
        function code(eh, ew, t)
        	tmp = 0.0
        	if (abs(t) <= 1.28e+20)
        		tmp = abs(fma(Float64(sin(abs(t)) * Float64(-eh)), tanh(asinh(Float64(Float64(abs(t) / ew) * Float64(-eh)))), Float64(Float64(Float64(1.0 + Float64(-0.5 * (abs(t) ^ 2.0))) * ew) / 1.0)));
        	else
        		tmp = abs(Float64(Float64(Float64((Float64(Float64(tan(abs(t)) / ew) * eh) ^ 2.0) - -1.0) * Float64(cos(abs(t)) * ew)) / 1.0));
        	end
        	return tmp
        end
        
        code[eh_, ew_, t_] := If[LessEqual[N[Abs[t], $MachinePrecision], 1.28e+20], N[Abs[N[(N[(N[Sin[N[Abs[t], $MachinePrecision]], $MachinePrecision] * (-eh)), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(N[(N[Abs[t], $MachinePrecision] / ew), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(N[(N[(1.0 + N[(-0.5 * N[Power[N[Abs[t], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[Power[N[(N[(N[Tan[N[Abs[t], $MachinePrecision]], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision], 2.0], $MachinePrecision] - -1.0), $MachinePrecision] * N[(N[Cos[N[Abs[t], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]], $MachinePrecision]]
        
        \begin{array}{l}
        \mathbf{if}\;\left|t\right| \leq 1.28 \cdot 10^{+20}:\\
        \;\;\;\;\left|\mathsf{fma}\left(\sin \left(\left|t\right|\right) \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\left|t\right|}{ew} \cdot \left(-eh\right)\right), \frac{\left(1 + -0.5 \cdot {\left(\left|t\right|\right)}^{2}\right) \cdot ew}{1}\right)\right|\\
        
        \mathbf{else}:\\
        \;\;\;\;\left|\frac{\left({\left(\frac{\tan \left(\left|t\right|\right)}{ew} \cdot eh\right)}^{2} - -1\right) \cdot \left(\cos \left(\left|t\right|\right) \cdot ew\right)}{1}\right|\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if t < 1.28e20

          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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}\right)}\right| \]
          3. Taylor expanded in eh around 0

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

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

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

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

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

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

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

                \[\leadsto \left|\mathsf{fma}\left(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{t}{ew} \cdot \left(-eh\right)\right), \frac{\left(1 + \frac{-1}{2} \cdot \color{blue}{{t}^{2}}\right) \cdot ew}{1}\right)\right| \]
              3. lower-pow.f6458.1%

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

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

            if 1.28e20 < 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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}\right)}\right| \]
            3. Applied rewrites76.1%

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

              \[\leadsto \left|\frac{\left({\left(\frac{\tan t}{ew} \cdot eh\right)}^{2} - -1\right) \cdot \left(\cos t \cdot ew\right)}{\color{blue}{1}}\right| \]
            5. Step-by-step derivation
              1. Applied rewrites61.7%

                \[\leadsto \left|\frac{\left({\left(\frac{\tan t}{ew} \cdot eh\right)}^{2} - -1\right) \cdot \left(\cos t \cdot ew\right)}{\color{blue}{1}}\right| \]
            6. Recombined 2 regimes into one program.
            7. Add Preprocessing

            Alternative 6: 74.6% accurate, 2.4× speedup?

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

              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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}\right)}\right| \]
              3. Taylor expanded in eh around 0

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

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

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

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

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

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

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

                    \[\leadsto \left|\mathsf{fma}\left(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{t}{ew} \cdot \left(-eh\right)\right), \frac{\left(1 + \frac{-1}{2} \cdot \color{blue}{{t}^{2}}\right) \cdot ew}{1}\right)\right| \]
                  3. lower-pow.f6458.1%

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

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

                if 1.06e20 < 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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\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.3%

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

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

              Alternative 7: 74.4% accurate, 3.0× speedup?

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

                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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}\right)}\right| \]
                3. Taylor expanded in eh around 0

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

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

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

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

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

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

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

                    if 3.5999999999999997e32 < 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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\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.3%

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

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

                  Alternative 8: 61.3% accurate, 6.7× speedup?

                  \[\left|ew \cdot \cos t\right| \]
                  (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]
                  
                  \left|ew \cdot \cos t\right|
                  
                  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(\sin t \cdot \left(-eh\right), \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \frac{\cos t \cdot ew}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\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.3%

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

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

                  Alternative 9: 41.4% accurate, 25.0× speedup?

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

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

                    \[\leadsto \color{blue}{\sqrt{ew}} \cdot \sqrt{\frac{\cos t \cdot ew - \left(-\left(\sin t \cdot eh\right) \cdot \left(eh \cdot \frac{\tan t}{ew}\right)\right)}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}} \]
                  4. Step-by-step derivation
                    1. lower-sqrt.f6419.1%

                      \[\leadsto \sqrt{ew} \cdot \sqrt{\frac{\cos t \cdot ew - \left(-\left(\sin t \cdot eh\right) \cdot \left(eh \cdot \frac{\tan t}{ew}\right)\right)}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)}} \]
                  5. Applied rewrites19.1%

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

                    \[\leadsto \sqrt{ew} \cdot \color{blue}{\sqrt{ew}} \]
                  7. Step-by-step derivation
                    1. lower-sqrt.f6420.6%

                      \[\leadsto \sqrt{ew} \cdot \sqrt{ew} \]
                  8. Applied rewrites20.6%

                    \[\leadsto \sqrt{ew} \cdot \color{blue}{\sqrt{ew}} \]
                  9. Add Preprocessing

                  Reproduce

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