Example 2 from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 11.7s
Alternatives: 7
Speedup: 1.0×

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 7 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.0× speedup?

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\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. cos-neg-revN/A

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

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

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

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

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
    8. lower-atan.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \color{blue}{\tan^{-1} \left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
    9. lower-/.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
    10. lift-*.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(-eh\right) \cdot \tan 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| \]
    11. lift-neg.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh\right)\right)} \cdot \tan 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| \]
    12. distribute-lft-neg-outN/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh \cdot \tan t\right)\right)}\right)}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    13. remove-double-negN/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\color{blue}{eh \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| \]
    14. *-commutativeN/A

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

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

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

Alternative 2: 99.7% accurate, 1.1× speedup?

\[\left|\frac{1}{\frac{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}{\cos t \cdot ew}} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
(FPCore (eh ew t)
  :precision binary64
  (fabs
 (-
  (/ 1 (/ (sqrt (- (pow (/ (* (tan t) eh) ew) 2) -1)) (* (cos t) ew)))
  (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))
double code(double eh, double ew, double t) {
	return fabs(((1.0 / (sqrt((pow(((tan(t) * eh) / ew), 2.0) - -1.0)) / (cos(t) * ew))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / 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(((1.0d0 / (sqrt(((((tan(t) * eh) / ew) ** 2.0d0) - (-1.0d0))) / (cos(t) * ew))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew))))))
end function
public static double code(double eh, double ew, double t) {
	return Math.abs(((1.0 / (Math.sqrt((Math.pow(((Math.tan(t) * eh) / ew), 2.0) - -1.0)) / (Math.cos(t) * ew))) - ((eh * Math.sin(t)) * Math.sin(Math.atan(((-eh * Math.tan(t)) / ew))))));
}
def code(eh, ew, t):
	return math.fabs(((1.0 / (math.sqrt((math.pow(((math.tan(t) * eh) / ew), 2.0) - -1.0)) / (math.cos(t) * ew))) - ((eh * math.sin(t)) * math.sin(math.atan(((-eh * math.tan(t)) / ew))))))
function code(eh, ew, t)
	return abs(Float64(Float64(1.0 / Float64(sqrt(Float64((Float64(Float64(tan(t) * eh) / ew) ^ 2.0) - -1.0)) / Float64(cos(t) * ew))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(Float64(-eh) * tan(t)) / ew))))))
end
function tmp = code(eh, ew, t)
	tmp = abs(((1.0 / (sqrt(((((tan(t) * eh) / ew) ^ 2.0) - -1.0)) / (cos(t) * ew))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew))))));
end
code[eh_, ew_, t_] := N[Abs[N[(N[(1 / N[(N[Sqrt[N[(N[Power[N[(N[(N[Tan[t], $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision], 2], $MachinePrecision] - -1), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{1}{\frac{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}{\cos t \cdot ew}} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan 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. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \left|\color{blue}{\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. lift-cos.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\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| \]
    3. lift-atan.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \color{blue}{\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| \]
    4. cos-atanN/A

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

      \[\leadsto \left|\color{blue}{\frac{ew \cdot \cos t}{\sqrt{1 + \frac{\left(-eh\right) \cdot \tan t}{ew} \cdot \frac{\left(-eh\right) \cdot \tan t}{ew}}}} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    6. div-flipN/A

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

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

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

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

Alternative 3: 94.2% accurate, 1.3× speedup?

\[\begin{array}{l} t_1 := {\left(\frac{\tan t}{\left|ew\right|} \cdot eh\right)}^{2} - -1\\ t_2 := \tan^{-1} \left(\frac{-1 \cdot \left(eh \cdot t\right)}{\left|ew\right|}\right)\\ \mathbf{if}\;\left|ew\right| \leq 3500000000000000210333675290624:\\ \;\;\;\;\left|\left(\left|ew\right| \cdot \cos t\right) \cdot \cos t\_2 - \left(eh \cdot \sin t\right) \cdot \sin t\_2\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t\_1 \cdot \left(\frac{\cos t}{\sqrt{t\_1}} \cdot \left|ew\right|\right)\right|\\ \end{array} \]
(FPCore (eh ew t)
  :precision binary64
  (let* ((t_1 (- (pow (* (/ (tan t) (fabs ew)) eh) 2) -1))
       (t_2 (atan (/ (* -1 (* eh t)) (fabs ew)))))
  (if (<= (fabs ew) 3500000000000000210333675290624)
    (fabs
     (-
      (* (* (fabs ew) (cos t)) (cos t_2))
      (* (* eh (sin t)) (sin t_2))))
    (fabs (* t_1 (* (/ (cos t) (sqrt t_1)) (fabs ew)))))))
double code(double eh, double ew, double t) {
	double t_1 = pow(((tan(t) / fabs(ew)) * eh), 2.0) - -1.0;
	double t_2 = atan(((-1.0 * (eh * t)) / fabs(ew)));
	double tmp;
	if (fabs(ew) <= 3.5e+30) {
		tmp = fabs((((fabs(ew) * cos(t)) * cos(t_2)) - ((eh * sin(t)) * sin(t_2))));
	} else {
		tmp = fabs((t_1 * ((cos(t) / sqrt(t_1)) * fabs(ew))));
	}
	return tmp;
}
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
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (((tan(t) / abs(ew)) * eh) ** 2.0d0) - (-1.0d0)
    t_2 = atan((((-1.0d0) * (eh * t)) / abs(ew)))
    if (abs(ew) <= 3.5d+30) then
        tmp = abs((((abs(ew) * cos(t)) * cos(t_2)) - ((eh * sin(t)) * sin(t_2))))
    else
        tmp = abs((t_1 * ((cos(t) / sqrt(t_1)) * abs(ew))))
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double t_1 = Math.pow(((Math.tan(t) / Math.abs(ew)) * eh), 2.0) - -1.0;
	double t_2 = Math.atan(((-1.0 * (eh * t)) / Math.abs(ew)));
	double tmp;
	if (Math.abs(ew) <= 3.5e+30) {
		tmp = Math.abs((((Math.abs(ew) * Math.cos(t)) * Math.cos(t_2)) - ((eh * Math.sin(t)) * Math.sin(t_2))));
	} else {
		tmp = Math.abs((t_1 * ((Math.cos(t) / Math.sqrt(t_1)) * Math.abs(ew))));
	}
	return tmp;
}
def code(eh, ew, t):
	t_1 = math.pow(((math.tan(t) / math.fabs(ew)) * eh), 2.0) - -1.0
	t_2 = math.atan(((-1.0 * (eh * t)) / math.fabs(ew)))
	tmp = 0
	if math.fabs(ew) <= 3.5e+30:
		tmp = math.fabs((((math.fabs(ew) * math.cos(t)) * math.cos(t_2)) - ((eh * math.sin(t)) * math.sin(t_2))))
	else:
		tmp = math.fabs((t_1 * ((math.cos(t) / math.sqrt(t_1)) * math.fabs(ew))))
	return tmp
function code(eh, ew, t)
	t_1 = Float64((Float64(Float64(tan(t) / abs(ew)) * eh) ^ 2.0) - -1.0)
	t_2 = atan(Float64(Float64(-1.0 * Float64(eh * t)) / abs(ew)))
	tmp = 0.0
	if (abs(ew) <= 3.5e+30)
		tmp = abs(Float64(Float64(Float64(abs(ew) * cos(t)) * cos(t_2)) - Float64(Float64(eh * sin(t)) * sin(t_2))));
	else
		tmp = abs(Float64(t_1 * Float64(Float64(cos(t) / sqrt(t_1)) * abs(ew))));
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	t_1 = (((tan(t) / abs(ew)) * eh) ^ 2.0) - -1.0;
	t_2 = atan(((-1.0 * (eh * t)) / abs(ew)));
	tmp = 0.0;
	if (abs(ew) <= 3.5e+30)
		tmp = abs((((abs(ew) * cos(t)) * cos(t_2)) - ((eh * sin(t)) * sin(t_2))));
	else
		tmp = abs((t_1 * ((cos(t) / sqrt(t_1)) * abs(ew))));
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Power[N[(N[(N[Tan[t], $MachinePrecision] / N[Abs[ew], $MachinePrecision]), $MachinePrecision] * eh), $MachinePrecision], 2], $MachinePrecision] - -1), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(-1 * N[(eh * t), $MachinePrecision]), $MachinePrecision] / N[Abs[ew], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[ew], $MachinePrecision], 3500000000000000210333675290624], N[Abs[N[(N[(N[(N[Abs[ew], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$1 * N[(N[(N[Cos[t], $MachinePrecision] / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Abs[ew], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
t_1 := {\left(\frac{\tan t}{\left|ew\right|} \cdot eh\right)}^{2} - -1\\
t_2 := \tan^{-1} \left(\frac{-1 \cdot \left(eh \cdot t\right)}{\left|ew\right|}\right)\\
\mathbf{if}\;\left|ew\right| \leq 3500000000000000210333675290624:\\
\;\;\;\;\left|\left(\left|ew\right| \cdot \cos t\right) \cdot \cos t\_2 - \left(eh \cdot \sin t\right) \cdot \sin t\_2\right|\\

\mathbf{else}:\\
\;\;\;\;\left|t\_1 \cdot \left(\frac{\cos t}{\sqrt{t\_1}} \cdot \left|ew\right|\right)\right|\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < 3.5000000000000002e30

    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.7%

        \[\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.7%

      \[\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.7%

        \[\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.7%

      \[\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| \]

    if 3.5000000000000002e30 < 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. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\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. cos-neg-revN/A

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

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

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

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

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

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
      8. lower-atan.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \color{blue}{\tan^{-1} \left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
      9. lower-/.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
      10. lift-*.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(-eh\right) \cdot \tan 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| \]
      11. lift-neg.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh\right)\right)} \cdot \tan 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| \]
      12. distribute-lft-neg-outN/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh \cdot \tan t\right)\right)}\right)}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
      13. remove-double-negN/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\color{blue}{eh \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| \]
      14. *-commutativeN/A

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

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\cos \tan^{-1} \left(\frac{\tan t \cdot eh}{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 rewrites77.0%

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

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

Alternative 4: 84.8% accurate, 1.5× speedup?

\[\begin{array}{l} t_1 := {\left(\frac{\tan t}{\left|ew\right|} \cdot eh\right)}^{2} - -1\\ \mathbf{if}\;\left|ew\right| \leq \frac{1178420618842611}{1636695303948070935006594848413799576108321023021532394741645684048066898202337277441635046162952078575443342063780035504608628272942696526664263794688}:\\ \;\;\;\;\left|\left(\left(-eh\right) \cdot \tanh \sinh^{-1} \left(\frac{t}{\left|ew\right|} \cdot \left(-eh\right)\right)\right) \cdot \sin t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t\_1 \cdot \left(\frac{\cos t}{\sqrt{t\_1}} \cdot \left|ew\right|\right)\right|\\ \end{array} \]
(FPCore (eh ew t)
  :precision binary64
  (let* ((t_1 (- (pow (* (/ (tan t) (fabs ew)) eh) 2) -1)))
  (if (<=
       (fabs ew)
       1178420618842611/1636695303948070935006594848413799576108321023021532394741645684048066898202337277441635046162952078575443342063780035504608628272942696526664263794688)
    (fabs
     (* (* (- eh) (tanh (asinh (* (/ t (fabs ew)) (- eh))))) (sin t)))
    (fabs (* t_1 (* (/ (cos t) (sqrt t_1)) (fabs ew)))))))
double code(double eh, double ew, double t) {
	double t_1 = pow(((tan(t) / fabs(ew)) * eh), 2.0) - -1.0;
	double tmp;
	if (fabs(ew) <= 7.2e-136) {
		tmp = fabs(((-eh * tanh(asinh(((t / fabs(ew)) * -eh)))) * sin(t)));
	} else {
		tmp = fabs((t_1 * ((cos(t) / sqrt(t_1)) * fabs(ew))));
	}
	return tmp;
}
def code(eh, ew, t):
	t_1 = math.pow(((math.tan(t) / math.fabs(ew)) * eh), 2.0) - -1.0
	tmp = 0
	if math.fabs(ew) <= 7.2e-136:
		tmp = math.fabs(((-eh * math.tanh(math.asinh(((t / math.fabs(ew)) * -eh)))) * math.sin(t)))
	else:
		tmp = math.fabs((t_1 * ((math.cos(t) / math.sqrt(t_1)) * math.fabs(ew))))
	return tmp
function code(eh, ew, t)
	t_1 = Float64((Float64(Float64(tan(t) / abs(ew)) * eh) ^ 2.0) - -1.0)
	tmp = 0.0
	if (abs(ew) <= 7.2e-136)
		tmp = abs(Float64(Float64(Float64(-eh) * tanh(asinh(Float64(Float64(t / abs(ew)) * Float64(-eh))))) * sin(t)));
	else
		tmp = abs(Float64(t_1 * Float64(Float64(cos(t) / sqrt(t_1)) * abs(ew))));
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	t_1 = (((tan(t) / abs(ew)) * eh) ^ 2.0) - -1.0;
	tmp = 0.0;
	if (abs(ew) <= 7.2e-136)
		tmp = abs(((-eh * tanh(asinh(((t / abs(ew)) * -eh)))) * sin(t)));
	else
		tmp = abs((t_1 * ((cos(t) / sqrt(t_1)) * abs(ew))));
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Power[N[(N[(N[Tan[t], $MachinePrecision] / N[Abs[ew], $MachinePrecision]), $MachinePrecision] * eh), $MachinePrecision], 2], $MachinePrecision] - -1), $MachinePrecision]}, If[LessEqual[N[Abs[ew], $MachinePrecision], 1178420618842611/1636695303948070935006594848413799576108321023021532394741645684048066898202337277441635046162952078575443342063780035504608628272942696526664263794688], N[Abs[N[(N[((-eh) * N[Tanh[N[ArcSinh[N[(N[(t / N[Abs[ew], $MachinePrecision]), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$1 * N[(N[(N[Cos[t], $MachinePrecision] / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Abs[ew], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_1 := {\left(\frac{\tan t}{\left|ew\right|} \cdot eh\right)}^{2} - -1\\
\mathbf{if}\;\left|ew\right| \leq \frac{1178420618842611}{1636695303948070935006594848413799576108321023021532394741645684048066898202337277441635046162952078575443342063780035504608628272942696526664263794688}:\\
\;\;\;\;\left|\left(\left(-eh\right) \cdot \tanh \sinh^{-1} \left(\frac{t}{\left|ew\right|} \cdot \left(-eh\right)\right)\right) \cdot \sin t\right|\\

\mathbf{else}:\\
\;\;\;\;\left|t\_1 \cdot \left(\frac{\cos t}{\sqrt{t\_1}} \cdot \left|ew\right|\right)\right|\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < 7.1999999999999996e-136

    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.7%

      \[\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.7%

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

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

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

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

    if 7.1999999999999996e-136 < 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. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\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. cos-neg-revN/A

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

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

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

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

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

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
      8. lower-atan.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \color{blue}{\tan^{-1} \left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
      9. lower-/.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
      10. lift-*.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(-eh\right) \cdot \tan 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| \]
      11. lift-neg.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh\right)\right)} \cdot \tan 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| \]
      12. distribute-lft-neg-outN/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh \cdot \tan t\right)\right)}\right)}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
      13. remove-double-negN/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\color{blue}{eh \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| \]
      14. *-commutativeN/A

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

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\cos \tan^{-1} \left(\frac{\tan t \cdot eh}{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 rewrites77.0%

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

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

Alternative 5: 75.2% accurate, 2.5× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|ew\right| \leq \frac{6867846810695183}{3121748550315992231381597229793166305748598142664971150859156959625371738819765620120306103063491971159826931121406622895447975679288285306290176}:\\ \;\;\;\;\left|\left(\left(-eh\right) \cdot \tanh \sinh^{-1} \left(\frac{t}{\left|ew\right|} \cdot \left(-eh\right)\right)\right) \cdot \sin t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left|ew\right| \cdot \cos t\right|\\ \end{array} \]
(FPCore (eh ew t)
  :precision binary64
  (if (<=
     (fabs ew)
     6867846810695183/3121748550315992231381597229793166305748598142664971150859156959625371738819765620120306103063491971159826931121406622895447975679288285306290176)
  (fabs
   (* (* (- eh) (tanh (asinh (* (/ t (fabs ew)) (- eh))))) (sin t)))
  (fabs (* (fabs ew) (cos t)))))
double code(double eh, double ew, double t) {
	double tmp;
	if (fabs(ew) <= 2.2e-129) {
		tmp = fabs(((-eh * tanh(asinh(((t / fabs(ew)) * -eh)))) * sin(t)));
	} else {
		tmp = fabs((fabs(ew) * cos(t)));
	}
	return tmp;
}
def code(eh, ew, t):
	tmp = 0
	if math.fabs(ew) <= 2.2e-129:
		tmp = math.fabs(((-eh * math.tanh(math.asinh(((t / math.fabs(ew)) * -eh)))) * math.sin(t)))
	else:
		tmp = math.fabs((math.fabs(ew) * math.cos(t)))
	return tmp
function code(eh, ew, t)
	tmp = 0.0
	if (abs(ew) <= 2.2e-129)
		tmp = abs(Float64(Float64(Float64(-eh) * tanh(asinh(Float64(Float64(t / abs(ew)) * Float64(-eh))))) * sin(t)));
	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) <= 2.2e-129)
		tmp = abs(((-eh * tanh(asinh(((t / abs(ew)) * -eh)))) * sin(t)));
	else
		tmp = abs((abs(ew) * cos(t)));
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := If[LessEqual[N[Abs[ew], $MachinePrecision], 6867846810695183/3121748550315992231381597229793166305748598142664971150859156959625371738819765620120306103063491971159826931121406622895447975679288285306290176], N[Abs[N[(N[((-eh) * N[Tanh[N[ArcSinh[N[(N[(t / N[Abs[ew], $MachinePrecision]), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[t], $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 \frac{6867846810695183}{3121748550315992231381597229793166305748598142664971150859156959625371738819765620120306103063491971159826931121406622895447975679288285306290176}:\\
\;\;\;\;\left|\left(\left(-eh\right) \cdot \tanh \sinh^{-1} \left(\frac{t}{\left|ew\right|} \cdot \left(-eh\right)\right)\right) \cdot \sin t\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\left|ew\right| \cdot \cos t\right|\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < 2.2e-129

    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.7%

      \[\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.7%

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

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

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

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

    if 2.2e-129 < 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. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\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. cos-neg-revN/A

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

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

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

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

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

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
      8. lower-atan.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \color{blue}{\tan^{-1} \left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
      9. lower-/.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
      10. lift-*.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(-eh\right) \cdot \tan 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| \]
      11. lift-neg.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh\right)\right)} \cdot \tan 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| \]
      12. distribute-lft-neg-outN/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh \cdot \tan t\right)\right)}\right)}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
      13. remove-double-negN/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\color{blue}{eh \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| \]
      14. *-commutativeN/A

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

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\cos \tan^{-1} \left(\frac{\tan t \cdot eh}{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 rewrites77.0%

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

      \[\leadsto \left|\frac{1}{\color{blue}{\frac{1}{ew}}}\right| \]
    6. Step-by-step derivation
      1. lower-/.f6442.5%

        \[\leadsto \left|\frac{1}{\frac{1}{\color{blue}{ew}}}\right| \]
    7. Applied rewrites42.5%

      \[\leadsto \left|\frac{1}{\color{blue}{\frac{1}{ew}}}\right| \]
    8. Taylor expanded in eh around 0

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

        \[\leadsto \left|ew \cdot \color{blue}{\cos t}\right| \]
      2. lower-cos.f6462.5%

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

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

Alternative 6: 62.5% accurate, 8.0× 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. Step-by-step derivation
    1. lift-cos.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\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. cos-neg-revN/A

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

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

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

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

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
    8. lower-atan.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \color{blue}{\tan^{-1} \left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
    9. lower-/.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
    10. lift-*.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(-eh\right) \cdot \tan 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| \]
    11. lift-neg.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh\right)\right)} \cdot \tan 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| \]
    12. distribute-lft-neg-outN/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh \cdot \tan t\right)\right)}\right)}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    13. remove-double-negN/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\color{blue}{eh \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| \]
    14. *-commutativeN/A

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

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

    \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\cos \tan^{-1} \left(\frac{\tan t \cdot eh}{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 rewrites77.0%

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

    \[\leadsto \left|\frac{1}{\color{blue}{\frac{1}{ew}}}\right| \]
  6. Step-by-step derivation
    1. lower-/.f6442.5%

      \[\leadsto \left|\frac{1}{\frac{1}{\color{blue}{ew}}}\right| \]
  7. Applied rewrites42.5%

    \[\leadsto \left|\frac{1}{\color{blue}{\frac{1}{ew}}}\right| \]
  8. Taylor expanded in eh around 0

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

      \[\leadsto \left|ew \cdot \color{blue}{\cos t}\right| \]
    2. lower-cos.f6462.5%

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

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

Alternative 7: 42.5% accurate, 34.5× speedup?

\[\left|\frac{1}{\frac{1}{ew}}\right| \]
(FPCore (eh ew t)
  :precision binary64
  (fabs (/ 1 (/ 1 ew))))
double code(double eh, double ew, double t) {
	return fabs((1.0 / (1.0 / 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((1.0d0 / (1.0d0 / ew)))
end function
public static double code(double eh, double ew, double t) {
	return Math.abs((1.0 / (1.0 / ew)));
}
def code(eh, ew, t):
	return math.fabs((1.0 / (1.0 / ew)))
function code(eh, ew, t)
	return abs(Float64(1.0 / Float64(1.0 / ew)))
end
function tmp = code(eh, ew, t)
	tmp = abs((1.0 / (1.0 / ew)));
end
code[eh_, ew_, t_] := N[Abs[N[(1 / N[(1 / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{1}{\frac{1}{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. Step-by-step derivation
    1. lift-cos.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\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. cos-neg-revN/A

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

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

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

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

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

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
    8. lower-atan.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \color{blue}{\tan^{-1} \left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
    9. lower-/.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(-eh\right) \cdot \tan 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| \]
    10. lift-*.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(-eh\right) \cdot \tan 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| \]
    11. lift-neg.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh\right)\right)} \cdot \tan 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| \]
    12. distribute-lft-neg-outN/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(eh \cdot \tan t\right)\right)}\right)}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    13. remove-double-negN/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\color{blue}{eh \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| \]
    14. *-commutativeN/A

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

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

    \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\cos \tan^{-1} \left(\frac{\tan t \cdot eh}{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 rewrites77.0%

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

    \[\leadsto \left|\frac{1}{\color{blue}{\frac{1}{ew}}}\right| \]
  6. Step-by-step derivation
    1. lower-/.f6442.5%

      \[\leadsto \left|\frac{1}{\frac{1}{\color{blue}{ew}}}\right| \]
  7. Applied rewrites42.5%

    \[\leadsto \left|\frac{1}{\color{blue}{\frac{1}{ew}}}\right| \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2025271 -o generate:evaluate
(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)))))))