Example 2 from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 17.3s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} 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?

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

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

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

    Alternative 2: 98.5% accurate, 1.8× speedup?

    \[\left|\frac{\cos t \cdot ew}{1} - \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right) \cdot \left(\sin t \cdot eh\right)\right| \]
    (FPCore (eh ew t)
     :precision binary64
     (fabs
      (-
       (/ (* (cos t) ew) 1.0)
       (* (tanh (asinh (* (/ (tan t) ew) (- eh)))) (* (sin t) eh)))))
    double code(double eh, double ew, double t) {
    	return fabs((((cos(t) * ew) / 1.0) - (tanh(asinh(((tan(t) / ew) * -eh))) * (sin(t) * eh))));
    }
    
    def code(eh, ew, t):
    	return math.fabs((((math.cos(t) * ew) / 1.0) - (math.tanh(math.asinh(((math.tan(t) / ew) * -eh))) * (math.sin(t) * eh))))
    
    function code(eh, ew, t)
    	return abs(Float64(Float64(Float64(cos(t) * ew) / 1.0) - Float64(tanh(asinh(Float64(Float64(tan(t) / ew) * Float64(-eh)))) * Float64(sin(t) * eh))))
    end
    
    function tmp = code(eh, ew, t)
    	tmp = abs((((cos(t) * ew) / 1.0) - (tanh(asinh(((tan(t) / ew) * -eh))) * (sin(t) * eh))));
    end
    
    code[eh_, ew_, t_] := N[Abs[N[(N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / 1.0), $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]
    
    \left|\frac{\cos t \cdot ew}{1} - \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right) \cdot \left(\sin t \cdot eh\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. Step-by-step derivation
      1. Applied rewrites99.8%

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

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

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

        Alternative 3: 98.5% accurate, 1.8× speedup?

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

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

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

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

        Alternative 4: 90.6% accurate, 1.8× speedup?

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

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

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

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

          if 1.75e-114 < 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 t around 0

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

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

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

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

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

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

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

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

              \[\leadsto \left|\color{blue}{\frac{ew \cdot \cos t}{\sqrt{\mathsf{fma}\left(\frac{\left(-eh\right) \cdot t}{ew}, \frac{\left(-eh\right) \cdot t}{ew}, 1\right)}} - \tanh \sinh^{-1} \left(\frac{\left(-eh\right) \cdot t}{ew}\right) \cdot \left(\sin t \cdot eh\right)}\right| \]
          9. Recombined 2 regimes into one program.
          10. Add Preprocessing

          Alternative 5: 90.3% accurate, 2.1× speedup?

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

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

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

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

            if 1.75e-114 < 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. Step-by-step derivation
              1. Applied rewrites99.8%

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

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

                \[\leadsto \left|\mathsf{fma}\left(\frac{\cos t}{\cosh \color{blue}{\left(\frac{eh \cdot t}{ew}\right)}}, ew, \tanh \sinh^{-1} \left(\frac{eh}{ew} \cdot \tan t\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{\cos t}{\cosh \left(\frac{eh \cdot t}{\color{blue}{ew}}\right)}, ew, \tanh \sinh^{-1} \left(\frac{eh}{ew} \cdot \tan t\right) \cdot \left(\sin t \cdot eh\right)\right)\right| \]
                2. lower-*.f6488.6%

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

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

                \[\leadsto \left|\mathsf{fma}\left(\frac{\cos t}{\cosh \left(\frac{eh \cdot t}{ew}\right)}, ew, \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{\cos t}{\cosh \left(\frac{eh \cdot t}{ew}\right)}, ew, \tanh \left(\frac{eh \cdot t}{\color{blue}{ew}}\right) \cdot \left(\sin t \cdot eh\right)\right)\right| \]
                2. lower-*.f6488.8%

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

                \[\leadsto \left|\mathsf{fma}\left(\frac{\cos t}{\cosh \left(\frac{eh \cdot t}{ew}\right)}, ew, \tanh \color{blue}{\left(\frac{eh \cdot t}{ew}\right)} \cdot \left(\sin t \cdot eh\right)\right)\right| \]
            3. Recombined 2 regimes into one program.
            4. Add Preprocessing

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

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

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

            Alternative 7: 42.1% accurate, 78.2× speedup?

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

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

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

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

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

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

                \[\leadsto \sqrt{-1 \cdot ew} \cdot \sqrt{-1 \cdot \color{blue}{ew}} \]
            8. Applied rewrites20.8%

              \[\leadsto \sqrt{-1 \cdot ew} \cdot \sqrt{\color{blue}{-1 \cdot ew}} \]
            9. Step-by-step derivation
              1. lower-unsound-*.f64N/A

                \[\leadsto \color{blue}{\sqrt{-1 \cdot ew} \cdot \sqrt{-1 \cdot ew}} \]
              2. lower-unsound-sqrt.f64N/A

                \[\leadsto \color{blue}{\sqrt{-1 \cdot ew}} \cdot \sqrt{-1 \cdot ew} \]
              3. lower-unsound-sqrt.f64N/A

                \[\leadsto \sqrt{-1 \cdot ew} \cdot \color{blue}{\sqrt{-1 \cdot ew}} \]
              4. sqrt-prodN/A

                \[\leadsto \color{blue}{\sqrt{\left(-1 \cdot ew\right) \cdot \left(-1 \cdot ew\right)}} \]
            10. Applied rewrites42.1%

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

            Alternative 8: 21.8% accurate, 125.6× speedup?

            \[-ew \]
            (FPCore (eh ew t) :precision binary64 (- ew))
            double code(double eh, double ew, double t) {
            	return -ew;
            }
            
            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 = -ew
            end function
            
            public static double code(double eh, double ew, double t) {
            	return -ew;
            }
            
            def code(eh, ew, t):
            	return -ew
            
            function code(eh, ew, t)
            	return Float64(-ew)
            end
            
            function tmp = code(eh, ew, t)
            	tmp = -ew;
            end
            
            code[eh_, ew_, t_] := (-ew)
            
            -ew
            
            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 rewrites39.3%

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

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

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

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

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

                \[\leadsto \sqrt{-1 \cdot ew} \cdot \sqrt{-1 \cdot \color{blue}{ew}} \]
            8. Applied rewrites20.8%

              \[\leadsto \sqrt{-1 \cdot ew} \cdot \sqrt{\color{blue}{-1 \cdot ew}} \]
            9. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto \color{blue}{\sqrt{-1 \cdot ew} \cdot \sqrt{-1 \cdot ew}} \]
              2. lift-sqrt.f64N/A

                \[\leadsto \color{blue}{\sqrt{-1 \cdot ew}} \cdot \sqrt{-1 \cdot ew} \]
              3. lift-sqrt.f64N/A

                \[\leadsto \sqrt{-1 \cdot ew} \cdot \color{blue}{\sqrt{-1 \cdot ew}} \]
              4. rem-square-sqrt21.8%

                \[\leadsto \color{blue}{-1 \cdot ew} \]
            10. Applied rewrites21.8%

              \[\leadsto \color{blue}{-ew} \]
            11. Add Preprocessing

            Reproduce

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