Trigonometry B

Percentage Accurate: 99.5% → 100.0%
Time: 2.4s
Alternatives: 9
Speedup: 1.3×

Specification

?
\[\begin{array}{l} t_0 := \tan x \cdot \tan x\\ \frac{1 - t\_0}{1 + t\_0} \end{array} \]
(FPCore (x)
  :precision binary64
  (let* ((t_0 (* (tan x) (tan x)))) (/ (- 1 t_0) (+ 1 t_0))))
double code(double x) {
	double t_0 = tan(x) * tan(x);
	return (1.0 - t_0) / (1.0 + t_0);
}
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(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = tan(x) * tan(x)
    code = (1.0d0 - t_0) / (1.0d0 + t_0)
end function
public static double code(double x) {
	double t_0 = Math.tan(x) * Math.tan(x);
	return (1.0 - t_0) / (1.0 + t_0);
}
def code(x):
	t_0 = math.tan(x) * math.tan(x)
	return (1.0 - t_0) / (1.0 + t_0)
function code(x)
	t_0 = Float64(tan(x) * tan(x))
	return Float64(Float64(1.0 - t_0) / Float64(1.0 + t_0))
end
function tmp = code(x)
	t_0 = tan(x) * tan(x);
	tmp = (1.0 - t_0) / (1.0 + t_0);
end
code[x_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]}, N[(N[(1 - t$95$0), $MachinePrecision] / N[(1 + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \tan x \cdot \tan x\\
\frac{1 - t\_0}{1 + t\_0}
\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.5% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \tan x \cdot \tan x\\ \frac{1 - t\_0}{1 + t\_0} \end{array} \]
(FPCore (x)
  :precision binary64
  (let* ((t_0 (* (tan x) (tan x)))) (/ (- 1 t_0) (+ 1 t_0))))
double code(double x) {
	double t_0 = tan(x) * tan(x);
	return (1.0 - t_0) / (1.0 + t_0);
}
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(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = tan(x) * tan(x)
    code = (1.0d0 - t_0) / (1.0d0 + t_0)
end function
public static double code(double x) {
	double t_0 = Math.tan(x) * Math.tan(x);
	return (1.0 - t_0) / (1.0 + t_0);
}
def code(x):
	t_0 = math.tan(x) * math.tan(x)
	return (1.0 - t_0) / (1.0 + t_0)
function code(x)
	t_0 = Float64(tan(x) * tan(x))
	return Float64(Float64(1.0 - t_0) / Float64(1.0 + t_0))
end
function tmp = code(x)
	t_0 = tan(x) * tan(x);
	tmp = (1.0 - t_0) / (1.0 + t_0);
end
code[x_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]}, N[(N[(1 - t$95$0), $MachinePrecision] / N[(1 + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \tan x \cdot \tan x\\
\frac{1 - t\_0}{1 + t\_0}
\end{array}

Alternative 1: 100.0% accurate, 1.3× speedup?

\[\begin{array}{l} t_0 := \cos \left(x + x\right)\\ \left(2 \cdot t\_0\right) \cdot \frac{\left(t\_0 - -1\right) \cdot \frac{-1}{2}}{-1 - t\_0} \end{array} \]
(FPCore (x)
  :precision binary64
  (let* ((t_0 (cos (+ x x))))
  (* (* 2 t_0) (/ (* (- t_0 -1) -1/2) (- -1 t_0)))))
double code(double x) {
	double t_0 = cos((x + x));
	return (2.0 * t_0) * (((t_0 - -1.0) * -0.5) / (-1.0 - t_0));
}
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(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = cos((x + x))
    code = (2.0d0 * t_0) * (((t_0 - (-1.0d0)) * (-0.5d0)) / ((-1.0d0) - t_0))
end function
public static double code(double x) {
	double t_0 = Math.cos((x + x));
	return (2.0 * t_0) * (((t_0 - -1.0) * -0.5) / (-1.0 - t_0));
}
def code(x):
	t_0 = math.cos((x + x))
	return (2.0 * t_0) * (((t_0 - -1.0) * -0.5) / (-1.0 - t_0))
function code(x)
	t_0 = cos(Float64(x + x))
	return Float64(Float64(2.0 * t_0) * Float64(Float64(Float64(t_0 - -1.0) * -0.5) / Float64(-1.0 - t_0)))
end
function tmp = code(x)
	t_0 = cos((x + x));
	tmp = (2.0 * t_0) * (((t_0 - -1.0) * -0.5) / (-1.0 - t_0));
end
code[x_] := Block[{t$95$0 = N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]}, N[(N[(2 * t$95$0), $MachinePrecision] * N[(N[(N[(t$95$0 - -1), $MachinePrecision] * -1/2), $MachinePrecision] / N[(-1 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \cos \left(x + x\right)\\
\left(2 \cdot t\_0\right) \cdot \frac{\left(t\_0 - -1\right) \cdot \frac{-1}{2}}{-1 - t\_0}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{1 + \tan x \cdot \tan x}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x \cdot \tan x}} \]
    3. lift-tan.f64N/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x} \cdot \tan x} \]
    4. tan-quotN/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan x} \]
    5. lift-tan.f64N/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\tan x}} \]
    6. tan-quotN/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\frac{\sin x}{\cos x}}} \]
    7. frac-timesN/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
    8. add-to-fractionN/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
    9. lower-/.f64N/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
  3. Applied rewrites98.9%

    \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}}} \]
  4. Applied rewrites99.8%

    \[\leadsto \frac{\color{blue}{\frac{\cos \left(x + x\right)}{\left(\cos \left(x + x\right) + 1\right) \cdot \frac{1}{2}}}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
  5. Taylor expanded in x around inf

    \[\leadsto \color{blue}{2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)}} \]
  6. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto 2 \cdot \color{blue}{\frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)}} \]
    2. lower-/.f64N/A

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

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{\color{blue}{1} + \cos \left(2 \cdot x\right)} \]
    4. lower-cos.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    5. lower-*.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    6. lower-+.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    7. lower-*.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    8. lower-cos.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    9. lower-*.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    10. lower-+.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \color{blue}{\cos \left(2 \cdot x\right)}} \]
  7. Applied rewrites99.9%

    \[\leadsto \color{blue}{2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)}} \]
  8. Applied rewrites100.0%

    \[\leadsto \left(2 \cdot \cos \left(x + x\right)\right) \cdot \color{blue}{\frac{\left(\cos \left(x + x\right) - -1\right) \cdot \frac{-1}{2}}{-1 - \cos \left(x + x\right)}} \]
  9. Add Preprocessing

Alternative 2: 98.9% accurate, 1.3× speedup?

\[\left(\frac{-1}{2} \cdot \cos \left(x + x\right) - \frac{1}{2}\right) \cdot \left({\tan x}^{2} - 1\right) \]
(FPCore (x)
  :precision binary64
  (* (- (* -1/2 (cos (+ x x))) 1/2) (- (pow (tan x) 2) 1)))
double code(double x) {
	return ((-0.5 * cos((x + x))) - 0.5) * (pow(tan(x), 2.0) - 1.0);
}
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(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = (((-0.5d0) * cos((x + x))) - 0.5d0) * ((tan(x) ** 2.0d0) - 1.0d0)
end function
public static double code(double x) {
	return ((-0.5 * Math.cos((x + x))) - 0.5) * (Math.pow(Math.tan(x), 2.0) - 1.0);
}
def code(x):
	return ((-0.5 * math.cos((x + x))) - 0.5) * (math.pow(math.tan(x), 2.0) - 1.0)
function code(x)
	return Float64(Float64(Float64(-0.5 * cos(Float64(x + x))) - 0.5) * Float64((tan(x) ^ 2.0) - 1.0))
end
function tmp = code(x)
	tmp = ((-0.5 * cos((x + x))) - 0.5) * ((tan(x) ^ 2.0) - 1.0);
end
code[x_] := N[(N[(N[(-1/2 * N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 1/2), $MachinePrecision] * N[(N[Power[N[Tan[x], $MachinePrecision], 2], $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]
\left(\frac{-1}{2} \cdot \cos \left(x + x\right) - \frac{1}{2}\right) \cdot \left({\tan x}^{2} - 1\right)
Derivation
  1. Initial program 99.5%

    \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}} \]
    2. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)}{\mathsf{neg}\left(\left(1 + \tan x \cdot \tan x\right)\right)}} \]
    3. mult-flipN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(1 + \tan x \cdot \tan x\right)\right)}} \]
    4. *-commutativeN/A

      \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\left(1 + \tan x \cdot \tan x\right)\right)} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right)} \]
    5. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\left(1 + \tan x \cdot \tan x\right)\right)} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right)} \]
    6. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(1 + \tan x \cdot \tan x\right)\right)\right)\right)}} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    7. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{-1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(1 + \tan x \cdot \tan x\right)\right)\right)\right)} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    8. remove-double-negN/A

      \[\leadsto \frac{-1}{\color{blue}{1 + \tan x \cdot \tan x}} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    9. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{-1}{1 + \tan x \cdot \tan x}} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    10. lift-+.f64N/A

      \[\leadsto \frac{-1}{\color{blue}{1 + \tan x \cdot \tan x}} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    11. +-commutativeN/A

      \[\leadsto \frac{-1}{\color{blue}{\tan x \cdot \tan x + 1}} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    12. add-flipN/A

      \[\leadsto \frac{-1}{\color{blue}{\tan x \cdot \tan x - \left(\mathsf{neg}\left(1\right)\right)}} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    13. metadata-evalN/A

      \[\leadsto \frac{-1}{\tan x \cdot \tan x - \color{blue}{-1}} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    14. lower--.f64N/A

      \[\leadsto \frac{-1}{\color{blue}{\tan x \cdot \tan x - -1}} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    15. lift-*.f64N/A

      \[\leadsto \frac{-1}{\color{blue}{\tan x \cdot \tan x} - -1} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    16. pow2N/A

      \[\leadsto \frac{-1}{\color{blue}{{\tan x}^{2}} - -1} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    17. lower-pow.f64N/A

      \[\leadsto \frac{-1}{\color{blue}{{\tan x}^{2}} - -1} \cdot \left(\mathsf{neg}\left(\left(1 - \tan x \cdot \tan x\right)\right)\right) \]
    18. lift--.f64N/A

      \[\leadsto \frac{-1}{{\tan x}^{2} - -1} \cdot \left(\mathsf{neg}\left(\color{blue}{\left(1 - \tan x \cdot \tan x\right)}\right)\right) \]
  3. Applied rewrites99.4%

    \[\leadsto \color{blue}{\frac{-1}{{\tan x}^{2} - -1} \cdot \left({\tan x}^{2} - 1\right)} \]
  4. Applied rewrites98.9%

    \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \cos \left(x + x\right) - \frac{1}{2}\right)} \cdot \left({\tan x}^{2} - 1\right) \]
  5. Add Preprocessing

Alternative 3: 60.0% accurate, 1.8× speedup?

\[\begin{array}{l} t_0 := \cos \left(2 \cdot x\right)\\ 2 \cdot \frac{t\_0 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot t\_0\right)}{2} \end{array} \]
(FPCore (x)
  :precision binary64
  (let* ((t_0 (cos (* 2 x)))) (* 2 (/ (* t_0 (+ 1/2 (* 1/2 t_0))) 2))))
double code(double x) {
	double t_0 = cos((2.0 * x));
	return 2.0 * ((t_0 * (0.5 + (0.5 * t_0))) / 2.0);
}
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(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = cos((2.0d0 * x))
    code = 2.0d0 * ((t_0 * (0.5d0 + (0.5d0 * t_0))) / 2.0d0)
end function
public static double code(double x) {
	double t_0 = Math.cos((2.0 * x));
	return 2.0 * ((t_0 * (0.5 + (0.5 * t_0))) / 2.0);
}
def code(x):
	t_0 = math.cos((2.0 * x))
	return 2.0 * ((t_0 * (0.5 + (0.5 * t_0))) / 2.0)
function code(x)
	t_0 = cos(Float64(2.0 * x))
	return Float64(2.0 * Float64(Float64(t_0 * Float64(0.5 + Float64(0.5 * t_0))) / 2.0))
end
function tmp = code(x)
	t_0 = cos((2.0 * x));
	tmp = 2.0 * ((t_0 * (0.5 + (0.5 * t_0))) / 2.0);
end
code[x_] := Block[{t$95$0 = N[Cos[N[(2 * x), $MachinePrecision]], $MachinePrecision]}, N[(2 * N[(N[(t$95$0 * N[(1/2 + N[(1/2 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \cos \left(2 \cdot x\right)\\
2 \cdot \frac{t\_0 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot t\_0\right)}{2}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{1 + \tan x \cdot \tan x}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x \cdot \tan x}} \]
    3. lift-tan.f64N/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x} \cdot \tan x} \]
    4. tan-quotN/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan x} \]
    5. lift-tan.f64N/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\tan x}} \]
    6. tan-quotN/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\frac{\sin x}{\cos x}}} \]
    7. frac-timesN/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
    8. add-to-fractionN/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
    9. lower-/.f64N/A

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
  3. Applied rewrites98.9%

    \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}}} \]
  4. Applied rewrites99.8%

    \[\leadsto \frac{\color{blue}{\frac{\cos \left(x + x\right)}{\left(\cos \left(x + x\right) + 1\right) \cdot \frac{1}{2}}}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
  5. Taylor expanded in x around inf

    \[\leadsto \color{blue}{2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)}} \]
  6. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto 2 \cdot \color{blue}{\frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)}} \]
    2. lower-/.f64N/A

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

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{\color{blue}{1} + \cos \left(2 \cdot x\right)} \]
    4. lower-cos.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    5. lower-*.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    6. lower-+.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    7. lower-*.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    8. lower-cos.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    9. lower-*.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)} \]
    10. lower-+.f64N/A

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \color{blue}{\cos \left(2 \cdot x\right)}} \]
  7. Applied rewrites99.9%

    \[\leadsto \color{blue}{2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{1 + \cos \left(2 \cdot x\right)}} \]
  8. Taylor expanded in x around 0

    \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{2} \]
  9. Step-by-step derivation
    1. Applied rewrites60.0%

      \[\leadsto 2 \cdot \frac{\cos \left(2 \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)\right)}{2} \]
    2. Add Preprocessing

    Alternative 4: 60.0% accurate, 1.9× speedup?

    \[\frac{\left(1 - {\tan x}^{2}\right) \cdot \left(\frac{1}{2} - \frac{-1}{2}\right)}{\frac{3}{2} - \frac{1}{2}} \]
    (FPCore (x)
      :precision binary64
      (/ (* (- 1 (pow (tan x) 2)) (- 1/2 -1/2)) (- 3/2 1/2)))
    double code(double x) {
    	return ((1.0 - pow(tan(x), 2.0)) * (0.5 - -0.5)) / (1.5 - 0.5);
    }
    
    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(x)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        code = ((1.0d0 - (tan(x) ** 2.0d0)) * (0.5d0 - (-0.5d0))) / (1.5d0 - 0.5d0)
    end function
    
    public static double code(double x) {
    	return ((1.0 - Math.pow(Math.tan(x), 2.0)) * (0.5 - -0.5)) / (1.5 - 0.5);
    }
    
    def code(x):
    	return ((1.0 - math.pow(math.tan(x), 2.0)) * (0.5 - -0.5)) / (1.5 - 0.5)
    
    function code(x)
    	return Float64(Float64(Float64(1.0 - (tan(x) ^ 2.0)) * Float64(0.5 - -0.5)) / Float64(1.5 - 0.5))
    end
    
    function tmp = code(x)
    	tmp = ((1.0 - (tan(x) ^ 2.0)) * (0.5 - -0.5)) / (1.5 - 0.5);
    end
    
    code[x_] := N[(N[(N[(1 - N[Power[N[Tan[x], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision] * N[(1/2 - -1/2), $MachinePrecision]), $MachinePrecision] / N[(3/2 - 1/2), $MachinePrecision]), $MachinePrecision]
    
    \frac{\left(1 - {\tan x}^{2}\right) \cdot \left(\frac{1}{2} - \frac{-1}{2}\right)}{\frac{3}{2} - \frac{1}{2}}
    
    Derivation
    1. Initial program 99.5%

      \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{1 + \tan x \cdot \tan x}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x \cdot \tan x}} \]
      3. lift-tan.f64N/A

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x} \cdot \tan x} \]
      4. tan-quotN/A

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan x} \]
      5. lift-tan.f64N/A

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\tan x}} \]
      6. tan-quotN/A

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\frac{\sin x}{\cos x}}} \]
      7. frac-timesN/A

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
      8. add-to-fractionN/A

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
    3. Applied rewrites98.9%

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}}} \]
    4. Taylor expanded in x around 0

      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
    5. Step-by-step derivation
      1. Applied rewrites60.8%

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
      2. Taylor expanded in x around 0

        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
      3. Step-by-step derivation
        1. Applied rewrites98.9%

          \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
        2. Taylor expanded in x around 0

          \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \color{blue}{\frac{1}{2}}}} \]
        3. Step-by-step derivation
          1. Applied rewrites60.0%

            \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \color{blue}{\frac{1}{2}}}} \]
          2. Applied rewrites60.0%

            \[\leadsto \color{blue}{\frac{\left(1 - {\tan x}^{2}\right) \cdot \left(\frac{1}{2} - \frac{-1}{2}\right)}{\left(\frac{1}{2} + 1\right) - \frac{1}{2}}} \]
          3. Taylor expanded in x around 0

            \[\leadsto \frac{\left(1 - {\tan x}^{2}\right) \cdot \left(\frac{1}{2} - \frac{-1}{2}\right)}{\color{blue}{\frac{3}{2}} - \frac{1}{2}} \]
          4. Step-by-step derivation
            1. Applied rewrites60.0%

              \[\leadsto \frac{\left(1 - {\tan x}^{2}\right) \cdot \left(\frac{1}{2} - \frac{-1}{2}\right)}{\color{blue}{\frac{3}{2}} - \frac{1}{2}} \]
            2. Add Preprocessing

            Alternative 5: 58.4% accurate, 0.7× speedup?

            \[\begin{array}{l} t_0 := \tan x \cdot \tan x\\ \mathbf{if}\;\frac{1 - t\_0}{1 + t\_0} \leq \frac{-5764607523034235}{288230376151711744}:\\ \;\;\;\;\frac{1 - {x}^{2}}{1 + {x}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - \left(\frac{1}{2} \cdot \left(1 - \cos \left(x + x\right)\right)\right) \cdot \frac{-2}{-2}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}}\\ \end{array} \]
            (FPCore (x)
              :precision binary64
              (let* ((t_0 (* (tan x) (tan x))))
              (if (<=
                   (/ (- 1 t_0) (+ 1 t_0))
                   -5764607523034235/288230376151711744)
                (/ (- 1 (pow x 2)) (+ 1 (pow x 2)))
                (/
                 (- 1 (* (* 1/2 (- 1 (cos (+ x x)))) (/ -2 -2)))
                 (/ (+ (* 1 (+ 1/2 1/2)) (- 1/2 1/2)) (+ 1/2 1/2))))))
            double code(double x) {
            	double t_0 = tan(x) * tan(x);
            	double tmp;
            	if (((1.0 - t_0) / (1.0 + t_0)) <= -0.02) {
            		tmp = (1.0 - pow(x, 2.0)) / (1.0 + pow(x, 2.0));
            	} else {
            		tmp = (1.0 - ((0.5 * (1.0 - cos((x + x)))) * (-2.0 / -2.0))) / (((1.0 * (0.5 + 0.5)) + (0.5 - 0.5)) / (0.5 + 0.5));
            	}
            	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(x)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8) :: t_0
                real(8) :: tmp
                t_0 = tan(x) * tan(x)
                if (((1.0d0 - t_0) / (1.0d0 + t_0)) <= (-0.02d0)) then
                    tmp = (1.0d0 - (x ** 2.0d0)) / (1.0d0 + (x ** 2.0d0))
                else
                    tmp = (1.0d0 - ((0.5d0 * (1.0d0 - cos((x + x)))) * ((-2.0d0) / (-2.0d0)))) / (((1.0d0 * (0.5d0 + 0.5d0)) + (0.5d0 - 0.5d0)) / (0.5d0 + 0.5d0))
                end if
                code = tmp
            end function
            
            public static double code(double x) {
            	double t_0 = Math.tan(x) * Math.tan(x);
            	double tmp;
            	if (((1.0 - t_0) / (1.0 + t_0)) <= -0.02) {
            		tmp = (1.0 - Math.pow(x, 2.0)) / (1.0 + Math.pow(x, 2.0));
            	} else {
            		tmp = (1.0 - ((0.5 * (1.0 - Math.cos((x + x)))) * (-2.0 / -2.0))) / (((1.0 * (0.5 + 0.5)) + (0.5 - 0.5)) / (0.5 + 0.5));
            	}
            	return tmp;
            }
            
            def code(x):
            	t_0 = math.tan(x) * math.tan(x)
            	tmp = 0
            	if ((1.0 - t_0) / (1.0 + t_0)) <= -0.02:
            		tmp = (1.0 - math.pow(x, 2.0)) / (1.0 + math.pow(x, 2.0))
            	else:
            		tmp = (1.0 - ((0.5 * (1.0 - math.cos((x + x)))) * (-2.0 / -2.0))) / (((1.0 * (0.5 + 0.5)) + (0.5 - 0.5)) / (0.5 + 0.5))
            	return tmp
            
            function code(x)
            	t_0 = Float64(tan(x) * tan(x))
            	tmp = 0.0
            	if (Float64(Float64(1.0 - t_0) / Float64(1.0 + t_0)) <= -0.02)
            		tmp = Float64(Float64(1.0 - (x ^ 2.0)) / Float64(1.0 + (x ^ 2.0)));
            	else
            		tmp = Float64(Float64(1.0 - Float64(Float64(0.5 * Float64(1.0 - cos(Float64(x + x)))) * Float64(-2.0 / -2.0))) / Float64(Float64(Float64(1.0 * Float64(0.5 + 0.5)) + Float64(0.5 - 0.5)) / Float64(0.5 + 0.5)));
            	end
            	return tmp
            end
            
            function tmp_2 = code(x)
            	t_0 = tan(x) * tan(x);
            	tmp = 0.0;
            	if (((1.0 - t_0) / (1.0 + t_0)) <= -0.02)
            		tmp = (1.0 - (x ^ 2.0)) / (1.0 + (x ^ 2.0));
            	else
            		tmp = (1.0 - ((0.5 * (1.0 - cos((x + x)))) * (-2.0 / -2.0))) / (((1.0 * (0.5 + 0.5)) + (0.5 - 0.5)) / (0.5 + 0.5));
            	end
            	tmp_2 = tmp;
            end
            
            code[x_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(1 - t$95$0), $MachinePrecision] / N[(1 + t$95$0), $MachinePrecision]), $MachinePrecision], -5764607523034235/288230376151711744], N[(N[(1 - N[Power[x, 2], $MachinePrecision]), $MachinePrecision] / N[(1 + N[Power[x, 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1 - N[(N[(1/2 * N[(1 - N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2 / -2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(1 * N[(1/2 + 1/2), $MachinePrecision]), $MachinePrecision] + N[(1/2 - 1/2), $MachinePrecision]), $MachinePrecision] / N[(1/2 + 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
            
            \begin{array}{l}
            t_0 := \tan x \cdot \tan x\\
            \mathbf{if}\;\frac{1 - t\_0}{1 + t\_0} \leq \frac{-5764607523034235}{288230376151711744}:\\
            \;\;\;\;\frac{1 - {x}^{2}}{1 + {x}^{2}}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{1 - \left(\frac{1}{2} \cdot \left(1 - \cos \left(x + x\right)\right)\right) \cdot \frac{-2}{-2}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}}\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (/.f64 (-.f64 #s(literal 1 binary64) (*.f64 (tan.f64 x) (tan.f64 x))) (+.f64 #s(literal 1 binary64) (*.f64 (tan.f64 x) (tan.f64 x)))) < -0.02

              1. Initial program 99.5%

                \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
              2. Taylor expanded in x around 0

                \[\leadsto \frac{1 - \color{blue}{{x}^{2}}}{1 + \tan x \cdot \tan x} \]
              3. Step-by-step derivation
                1. lower-pow.f6451.9%

                  \[\leadsto \frac{1 - {x}^{\color{blue}{2}}}{1 + \tan x \cdot \tan x} \]
              4. Applied rewrites51.9%

                \[\leadsto \frac{1 - \color{blue}{{x}^{2}}}{1 + \tan x \cdot \tan x} \]
              5. Taylor expanded in x around 0

                \[\leadsto \frac{1 - {x}^{2}}{1 + \color{blue}{{x}^{2}}} \]
              6. Step-by-step derivation
                1. lower-pow.f6453.4%

                  \[\leadsto \frac{1 - {x}^{2}}{1 + {x}^{\color{blue}{2}}} \]
              7. Applied rewrites53.4%

                \[\leadsto \frac{1 - {x}^{2}}{1 + \color{blue}{{x}^{2}}} \]

              if -0.02 < (/.f64 (-.f64 #s(literal 1 binary64) (*.f64 (tan.f64 x) (tan.f64 x))) (+.f64 #s(literal 1 binary64) (*.f64 (tan.f64 x) (tan.f64 x))))

              1. Initial program 99.5%

                \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
              2. Step-by-step derivation
                1. lift-+.f64N/A

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{1 + \tan x \cdot \tan x}} \]
                2. lift-*.f64N/A

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x \cdot \tan x}} \]
                3. lift-tan.f64N/A

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x} \cdot \tan x} \]
                4. tan-quotN/A

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan x} \]
                5. lift-tan.f64N/A

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\tan x}} \]
                6. tan-quotN/A

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\frac{\sin x}{\cos x}}} \]
                7. frac-timesN/A

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                8. add-to-fractionN/A

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                9. lower-/.f64N/A

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
              3. Applied rewrites98.9%

                \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}}} \]
              4. Taylor expanded in x around 0

                \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
              5. Step-by-step derivation
                1. Applied rewrites60.8%

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                2. Taylor expanded in x around 0

                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                3. Step-by-step derivation
                  1. Applied rewrites98.9%

                    \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                  2. Taylor expanded in x around 0

                    \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \color{blue}{\frac{1}{2}}}} \]
                  3. Step-by-step derivation
                    1. Applied rewrites60.0%

                      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \color{blue}{\frac{1}{2}}}} \]
                    2. Applied rewrites60.0%

                      \[\leadsto \frac{1 - \color{blue}{\left(\frac{1}{2} \cdot \left(1 - \cos \left(x + x\right)\right)\right) \cdot \frac{-2}{-1 - \cos \left(x + x\right)}}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                    3. Taylor expanded in x around 0

                      \[\leadsto \frac{1 - \left(\frac{1}{2} \cdot \left(1 - \cos \left(x + x\right)\right)\right) \cdot \frac{-2}{\color{blue}{-2}}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                    4. Step-by-step derivation
                      1. Applied rewrites56.2%

                        \[\leadsto \frac{1 - \left(\frac{1}{2} \cdot \left(1 - \cos \left(x + x\right)\right)\right) \cdot \frac{-2}{\color{blue}{-2}}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                    5. Recombined 2 regimes into one program.
                    6. Add Preprocessing

                    Alternative 6: 56.2% accurate, 2.5× speedup?

                    \[\frac{1 - \left(\frac{1}{2} \cdot \left(1 - \cos \left(x + x\right)\right)\right) \cdot \frac{-2}{-2}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                    (FPCore (x)
                      :precision binary64
                      (/
                     (- 1 (* (* 1/2 (- 1 (cos (+ x x)))) (/ -2 -2)))
                     (/ (+ (* 1 (+ 1/2 1/2)) (- 1/2 1/2)) (+ 1/2 1/2))))
                    double code(double x) {
                    	return (1.0 - ((0.5 * (1.0 - cos((x + x)))) * (-2.0 / -2.0))) / (((1.0 * (0.5 + 0.5)) + (0.5 - 0.5)) / (0.5 + 0.5));
                    }
                    
                    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(x)
                    use fmin_fmax_functions
                        real(8), intent (in) :: x
                        code = (1.0d0 - ((0.5d0 * (1.0d0 - cos((x + x)))) * ((-2.0d0) / (-2.0d0)))) / (((1.0d0 * (0.5d0 + 0.5d0)) + (0.5d0 - 0.5d0)) / (0.5d0 + 0.5d0))
                    end function
                    
                    public static double code(double x) {
                    	return (1.0 - ((0.5 * (1.0 - Math.cos((x + x)))) * (-2.0 / -2.0))) / (((1.0 * (0.5 + 0.5)) + (0.5 - 0.5)) / (0.5 + 0.5));
                    }
                    
                    def code(x):
                    	return (1.0 - ((0.5 * (1.0 - math.cos((x + x)))) * (-2.0 / -2.0))) / (((1.0 * (0.5 + 0.5)) + (0.5 - 0.5)) / (0.5 + 0.5))
                    
                    function code(x)
                    	return Float64(Float64(1.0 - Float64(Float64(0.5 * Float64(1.0 - cos(Float64(x + x)))) * Float64(-2.0 / -2.0))) / Float64(Float64(Float64(1.0 * Float64(0.5 + 0.5)) + Float64(0.5 - 0.5)) / Float64(0.5 + 0.5)))
                    end
                    
                    function tmp = code(x)
                    	tmp = (1.0 - ((0.5 * (1.0 - cos((x + x)))) * (-2.0 / -2.0))) / (((1.0 * (0.5 + 0.5)) + (0.5 - 0.5)) / (0.5 + 0.5));
                    end
                    
                    code[x_] := N[(N[(1 - N[(N[(1/2 * N[(1 - N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2 / -2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(1 * N[(1/2 + 1/2), $MachinePrecision]), $MachinePrecision] + N[(1/2 - 1/2), $MachinePrecision]), $MachinePrecision] / N[(1/2 + 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                    
                    \frac{1 - \left(\frac{1}{2} \cdot \left(1 - \cos \left(x + x\right)\right)\right) \cdot \frac{-2}{-2}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}}
                    
                    Derivation
                    1. Initial program 99.5%

                      \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
                    2. Step-by-step derivation
                      1. lift-+.f64N/A

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{1 + \tan x \cdot \tan x}} \]
                      2. lift-*.f64N/A

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x \cdot \tan x}} \]
                      3. lift-tan.f64N/A

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x} \cdot \tan x} \]
                      4. tan-quotN/A

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan x} \]
                      5. lift-tan.f64N/A

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\tan x}} \]
                      6. tan-quotN/A

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\frac{\sin x}{\cos x}}} \]
                      7. frac-timesN/A

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                      8. add-to-fractionN/A

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                      9. lower-/.f64N/A

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                    3. Applied rewrites98.9%

                      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}}} \]
                    4. Taylor expanded in x around 0

                      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                    5. Step-by-step derivation
                      1. Applied rewrites60.8%

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                      2. Taylor expanded in x around 0

                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                      3. Step-by-step derivation
                        1. Applied rewrites98.9%

                          \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \color{blue}{\frac{1}{2}}}} \]
                        3. Step-by-step derivation
                          1. Applied rewrites60.0%

                            \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \color{blue}{\frac{1}{2}}}} \]
                          2. Applied rewrites60.0%

                            \[\leadsto \frac{1 - \color{blue}{\left(\frac{1}{2} \cdot \left(1 - \cos \left(x + x\right)\right)\right) \cdot \frac{-2}{-1 - \cos \left(x + x\right)}}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                          3. Taylor expanded in x around 0

                            \[\leadsto \frac{1 - \left(\frac{1}{2} \cdot \left(1 - \cos \left(x + x\right)\right)\right) \cdot \frac{-2}{\color{blue}{-2}}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                          4. Step-by-step derivation
                            1. Applied rewrites56.2%

                              \[\leadsto \frac{1 - \left(\frac{1}{2} \cdot \left(1 - \cos \left(x + x\right)\right)\right) \cdot \frac{-2}{\color{blue}{-2}}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                            2. Add Preprocessing

                            Alternative 7: 56.2% accurate, 3.1× speedup?

                            \[\frac{1}{\frac{1}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)}} \]
                            (FPCore (x)
                              :precision binary64
                              (/ 1 (/ 1 (+ 1/2 (* 1/2 (cos (* 2 x)))))))
                            double code(double x) {
                            	return 1.0 / (1.0 / (0.5 + (0.5 * cos((2.0 * x)))));
                            }
                            
                            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(x)
                            use fmin_fmax_functions
                                real(8), intent (in) :: x
                                code = 1.0d0 / (1.0d0 / (0.5d0 + (0.5d0 * cos((2.0d0 * x)))))
                            end function
                            
                            public static double code(double x) {
                            	return 1.0 / (1.0 / (0.5 + (0.5 * Math.cos((2.0 * x)))));
                            }
                            
                            def code(x):
                            	return 1.0 / (1.0 / (0.5 + (0.5 * math.cos((2.0 * x)))))
                            
                            function code(x)
                            	return Float64(1.0 / Float64(1.0 / Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * x))))))
                            end
                            
                            function tmp = code(x)
                            	tmp = 1.0 / (1.0 / (0.5 + (0.5 * cos((2.0 * x)))));
                            end
                            
                            code[x_] := N[(1 / N[(1 / N[(1/2 + N[(1/2 * N[Cos[N[(2 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                            
                            \frac{1}{\frac{1}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)}}
                            
                            Derivation
                            1. Initial program 99.5%

                              \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
                            2. Step-by-step derivation
                              1. lift-+.f64N/A

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{1 + \tan x \cdot \tan x}} \]
                              2. lift-*.f64N/A

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x \cdot \tan x}} \]
                              3. lift-tan.f64N/A

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x} \cdot \tan x} \]
                              4. tan-quotN/A

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan x} \]
                              5. lift-tan.f64N/A

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\tan x}} \]
                              6. tan-quotN/A

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\frac{\sin x}{\cos x}}} \]
                              7. frac-timesN/A

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                              8. add-to-fractionN/A

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                              9. lower-/.f64N/A

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                            3. Applied rewrites98.9%

                              \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}}} \]
                            4. Taylor expanded in x around 0

                              \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                            5. Step-by-step derivation
                              1. Applied rewrites60.8%

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                              2. Taylor expanded in x around 0

                                \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                              3. Step-by-step derivation
                                1. Applied rewrites98.9%

                                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                                2. Taylor expanded in x around 0

                                  \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \color{blue}{\frac{1}{2}}}} \]
                                3. Step-by-step derivation
                                  1. Applied rewrites60.0%

                                    \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \color{blue}{\frac{1}{2}}}} \]
                                  2. Taylor expanded in x around 0

                                    \[\leadsto \frac{\color{blue}{1}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites55.8%

                                      \[\leadsto \frac{\color{blue}{1}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                                    2. Taylor expanded in x around inf

                                      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)}}} \]
                                    3. Step-by-step derivation
                                      1. lower-/.f64N/A

                                        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)}}} \]
                                      2. lower-+.f64N/A

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

                                        \[\leadsto \frac{1}{\frac{1}{\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\cos \left(2 \cdot x\right)}}} \]
                                      4. lower-cos.f64N/A

                                        \[\leadsto \frac{1}{\frac{1}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)}} \]
                                      5. lower-*.f6456.2%

                                        \[\leadsto \frac{1}{\frac{1}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)}} \]
                                    4. Applied rewrites56.2%

                                      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot x\right)}}} \]
                                    5. Add Preprocessing

                                    Alternative 8: 55.8% accurate, 16.5× speedup?

                                    \[\frac{1 \cdot \left(\frac{1}{2} - \frac{-1}{2}\right)}{\left(\frac{1}{2} - -1\right) - \frac{1}{2}} \]
                                    (FPCore (x)
                                      :precision binary64
                                      (/ (* 1 (- 1/2 -1/2)) (- (- 1/2 -1) 1/2)))
                                    double code(double x) {
                                    	return (1.0 * (0.5 - -0.5)) / ((0.5 - -1.0) - 0.5);
                                    }
                                    
                                    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(x)
                                    use fmin_fmax_functions
                                        real(8), intent (in) :: x
                                        code = (1.0d0 * (0.5d0 - (-0.5d0))) / ((0.5d0 - (-1.0d0)) - 0.5d0)
                                    end function
                                    
                                    public static double code(double x) {
                                    	return (1.0 * (0.5 - -0.5)) / ((0.5 - -1.0) - 0.5);
                                    }
                                    
                                    def code(x):
                                    	return (1.0 * (0.5 - -0.5)) / ((0.5 - -1.0) - 0.5)
                                    
                                    function code(x)
                                    	return Float64(Float64(1.0 * Float64(0.5 - -0.5)) / Float64(Float64(0.5 - -1.0) - 0.5))
                                    end
                                    
                                    function tmp = code(x)
                                    	tmp = (1.0 * (0.5 - -0.5)) / ((0.5 - -1.0) - 0.5);
                                    end
                                    
                                    code[x_] := N[(N[(1 * N[(1/2 - -1/2), $MachinePrecision]), $MachinePrecision] / N[(N[(1/2 - -1), $MachinePrecision] - 1/2), $MachinePrecision]), $MachinePrecision]
                                    
                                    \frac{1 \cdot \left(\frac{1}{2} - \frac{-1}{2}\right)}{\left(\frac{1}{2} - -1\right) - \frac{1}{2}}
                                    
                                    Derivation
                                    1. Initial program 99.5%

                                      \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
                                    2. Step-by-step derivation
                                      1. lift-+.f64N/A

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{1 + \tan x \cdot \tan x}} \]
                                      2. lift-*.f64N/A

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x \cdot \tan x}} \]
                                      3. lift-tan.f64N/A

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\tan x} \cdot \tan x} \]
                                      4. tan-quotN/A

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan x} \]
                                      5. lift-tan.f64N/A

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\tan x}} \]
                                      6. tan-quotN/A

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \frac{\sin x}{\cos x} \cdot \color{blue}{\frac{\sin x}{\cos x}}} \]
                                      7. frac-timesN/A

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{1 + \color{blue}{\frac{\sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                                      8. add-to-fractionN/A

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                                      9. lower-/.f64N/A

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\cos x \cdot \cos x\right) + \sin x \cdot \sin x}{\cos x \cdot \cos x}}} \]
                                    3. Applied rewrites98.9%

                                      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\color{blue}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}}} \]
                                    4. Taylor expanded in x around 0

                                      \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                                    5. Step-by-step derivation
                                      1. Applied rewrites60.8%

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2}}\right) + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(x + x\right)\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                                      2. Taylor expanded in x around 0

                                        \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites98.9%

                                          \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \color{blue}{\frac{1}{2}}\right)}{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)}} \]
                                        2. Taylor expanded in x around 0

                                          \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \color{blue}{\frac{1}{2}}}} \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites60.0%

                                            \[\leadsto \frac{1 - \tan x \cdot \tan x}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \color{blue}{\frac{1}{2}}}} \]
                                          2. Taylor expanded in x around 0

                                            \[\leadsto \frac{\color{blue}{1}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites55.8%

                                              \[\leadsto \frac{\color{blue}{1}}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}} \]
                                            2. Step-by-step derivation
                                              1. lift-/.f64N/A

                                                \[\leadsto \color{blue}{\frac{1}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}}} \]
                                              2. lift-/.f64N/A

                                                \[\leadsto \frac{1}{\color{blue}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\frac{1}{2} + \frac{1}{2}}}} \]
                                              3. *-lft-identityN/A

                                                \[\leadsto \frac{1}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\color{blue}{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right)}}} \]
                                              4. lift-*.f64N/A

                                                \[\leadsto \frac{1}{\frac{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}{\color{blue}{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right)}}} \]
                                              5. associate-/r/N/A

                                                \[\leadsto \color{blue}{\frac{1}{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)} \cdot \left(1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right)\right)} \]
                                              6. associate-*l/N/A

                                                \[\leadsto \color{blue}{\frac{1 \cdot \left(1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right)\right)}{1 \cdot \left(\frac{1}{2} + \frac{1}{2}\right) + \left(\frac{1}{2} - \frac{1}{2}\right)}} \]
                                            3. Applied rewrites55.8%

                                              \[\leadsto \color{blue}{\frac{1 \cdot \left(\frac{1}{2} - \frac{-1}{2}\right)}{\left(\frac{1}{2} - -1\right) - \frac{1}{2}}} \]
                                            4. Add Preprocessing

                                            Alternative 9: 51.9% accurate, 35.7× speedup?

                                            \[1 - \left(x + x\right) \cdot x \]
                                            (FPCore (x)
                                              :precision binary64
                                              (- 1 (* (+ x x) x)))
                                            double code(double x) {
                                            	return 1.0 - ((x + x) * x);
                                            }
                                            
                                            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(x)
                                            use fmin_fmax_functions
                                                real(8), intent (in) :: x
                                                code = 1.0d0 - ((x + x) * x)
                                            end function
                                            
                                            public static double code(double x) {
                                            	return 1.0 - ((x + x) * x);
                                            }
                                            
                                            def code(x):
                                            	return 1.0 - ((x + x) * x)
                                            
                                            function code(x)
                                            	return Float64(1.0 - Float64(Float64(x + x) * x))
                                            end
                                            
                                            function tmp = code(x)
                                            	tmp = 1.0 - ((x + x) * x);
                                            end
                                            
                                            code[x_] := N[(1 - N[(N[(x + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
                                            
                                            1 - \left(x + x\right) \cdot x
                                            
                                            Derivation
                                            1. Initial program 99.5%

                                              \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x} \]
                                            2. Taylor expanded in x around 0

                                              \[\leadsto \color{blue}{1 + -2 \cdot {x}^{2}} \]
                                            3. Step-by-step derivation
                                              1. lower-+.f64N/A

                                                \[\leadsto 1 + \color{blue}{-2 \cdot {x}^{2}} \]
                                              2. lower-*.f64N/A

                                                \[\leadsto 1 + -2 \cdot \color{blue}{{x}^{2}} \]
                                              3. lower-pow.f6451.9%

                                                \[\leadsto 1 + -2 \cdot {x}^{\color{blue}{2}} \]
                                            4. Applied rewrites51.9%

                                              \[\leadsto \color{blue}{1 + -2 \cdot {x}^{2}} \]
                                            5. Step-by-step derivation
                                              1. lift-+.f64N/A

                                                \[\leadsto 1 + \color{blue}{-2 \cdot {x}^{2}} \]
                                              2. lift-*.f64N/A

                                                \[\leadsto 1 + -2 \cdot \color{blue}{{x}^{2}} \]
                                              3. fp-cancel-sign-sub-invN/A

                                                \[\leadsto 1 - \color{blue}{\left(\mathsf{neg}\left(-2\right)\right) \cdot {x}^{2}} \]
                                              4. lower--.f64N/A

                                                \[\leadsto 1 - \color{blue}{\left(\mathsf{neg}\left(-2\right)\right) \cdot {x}^{2}} \]
                                              5. metadata-evalN/A

                                                \[\leadsto 1 - 2 \cdot {\color{blue}{x}}^{2} \]
                                              6. lift-pow.f64N/A

                                                \[\leadsto 1 - 2 \cdot {x}^{\color{blue}{2}} \]
                                              7. unpow2N/A

                                                \[\leadsto 1 - 2 \cdot \left(x \cdot \color{blue}{x}\right) \]
                                              8. associate-*r*N/A

                                                \[\leadsto 1 - \left(2 \cdot x\right) \cdot \color{blue}{x} \]
                                              9. count-2N/A

                                                \[\leadsto 1 - \left(x + x\right) \cdot x \]
                                              10. lift-+.f64N/A

                                                \[\leadsto 1 - \left(x + x\right) \cdot x \]
                                              11. lower-*.f6451.9%

                                                \[\leadsto 1 - \left(x + x\right) \cdot \color{blue}{x} \]
                                            6. Applied rewrites51.9%

                                              \[\leadsto 1 - \color{blue}{\left(x + x\right) \cdot x} \]
                                            7. Add Preprocessing

                                            Reproduce

                                            ?
                                            herbie shell --seed 2025285 -o generate:evaluate
                                            (FPCore (x)
                                              :name "Trigonometry B"
                                              :precision binary64
                                              (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x)))))