Example 2 from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 14.5s
Alternatives: 9
Speedup: 1.2×

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(\frac{\cos t}{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}, ew, \left(\tanh \sinh^{-1} \left(\frac{eh}{ew} \cdot \tan t\right) \cdot \sin t\right) \cdot eh\right)\right| \]
(FPCore (eh ew t)
  :precision binary64
  (fabs
 (fma
  (/ (cos t) (sqrt (- (pow (/ (* (tan t) eh) ew) 2.0) -1.0)))
  ew
  (* (* (tanh (asinh (* (/ eh ew) (tan t)))) (sin t)) eh))))
double code(double eh, double ew, double t) {
	return fabs(fma((cos(t) / sqrt((pow(((tan(t) * eh) / ew), 2.0) - -1.0))), ew, ((tanh(asinh(((eh / ew) * tan(t)))) * sin(t)) * eh)));
}
function code(eh, ew, t)
	return abs(fma(Float64(cos(t) / sqrt(Float64((Float64(Float64(tan(t) * eh) / ew) ^ 2.0) - -1.0))), ew, Float64(Float64(tanh(asinh(Float64(Float64(eh / ew) * tan(t)))) * sin(t)) * eh)))
end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Cos[t], $MachinePrecision] / N[Sqrt[N[(N[Power[N[(N[(N[Tan[t], $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision], 2.0], $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * ew + N[(N[(N[Tanh[N[ArcSinh[N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\mathsf{fma}\left(\frac{\cos t}{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}, ew, \left(\tanh \sinh^{-1} \left(\frac{eh}{ew} \cdot \tan t\right) \cdot \sin t\right) \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. Applied rewrites99.8%

    \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\cos t}{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}, 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. Applied rewrites99.8%

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

Alternative 2: 99.0% accurate, 1.5× speedup?

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

      \[\leadsto \left|\frac{\cos t \cdot ew}{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}} - \tanh \sinh^{-1} \left(\color{blue}{\frac{t}{ew}} \cdot \left(-eh\right)\right) \cdot \left(\sin t \cdot eh\right)\right| \]
    3. Step-by-step derivation
      1. lower-/.f6499.0%

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

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

    Alternative 3: 98.5% accurate, 1.8× speedup?

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

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\cos t}{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}, 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. Applied rewrites99.8%

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

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

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

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

    Alternative 4: 73.0% accurate, 1.8× speedup?

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

      1. Initial program 99.8%

        \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
      2. Taylor expanded in eh around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 3.7e11 < ew

      1. Initial program 99.8%

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

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

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

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

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

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

        Alternative 5: 72.9% accurate, 2.4× speedup?

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

          1. Initial program 99.8%

            \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
          2. Taylor expanded in eh around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 3.7e11 < ew

          1. Initial program 99.8%

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

            \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\cos t}{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}, 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.f6462.8%

              \[\leadsto \left|ew \cdot \cos t\right| \]
          5. Applied rewrites62.8%

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

        Alternative 6: 62.8% 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}{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}, 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.f6462.8%

            \[\leadsto \left|ew \cdot \cos t\right| \]
        5. Applied rewrites62.8%

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

        Alternative 7: 41.2% accurate, 10.4× speedup?

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

          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}{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}, 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.f6462.8%

              \[\leadsto \left|ew \cdot \cos t\right| \]
          5. Applied rewrites62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 7.9999999999999996e33 < t

          1. Initial program 99.8%

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

            \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{\cos t}{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}, 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.f6462.8%

              \[\leadsto \left|ew \cdot \cos t\right| \]
          5. Applied rewrites62.8%

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

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

              \[\leadsto \color{blue}{\sqrt{\left(ew \cdot \cos t\right) \cdot \left(ew \cdot \cos t\right)}} \]
            3. pow1/2N/A

              \[\leadsto \color{blue}{{\left(\left(ew \cdot \cos t\right) \cdot \left(ew \cdot \cos t\right)\right)}^{\frac{1}{2}}} \]
            4. pow-to-expN/A

              \[\leadsto \color{blue}{e^{\log \left(\left(ew \cdot \cos t\right) \cdot \left(ew \cdot \cos t\right)\right) \cdot \frac{1}{2}}} \]
          7. Applied rewrites32.8%

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

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

              \[\leadsto \sqrt{{ew}^{2}} \]
            2. lower-pow.f6425.6%

              \[\leadsto \sqrt{{ew}^{2}} \]
          10. Applied rewrites25.6%

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

        Alternative 8: 39.5% accurate, 19.9× speedup?

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

            \[\leadsto \left|ew \cdot \cos t\right| \]
        5. Applied rewrites62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left|\left(\frac{-1}{2} \cdot ew\right) \cdot \left(t \cdot t\right) + ew\right| \]
          8. associate-*r*N/A

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

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

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

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

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

        Alternative 9: 39.5% accurate, 19.9× speedup?

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

            \[\leadsto \left|ew \cdot \cos t\right| \]
        5. Applied rewrites62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Reproduce

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