Octave 3.8, oct_fill_randg

Percentage Accurate: 99.8% → 99.8%
Time: 3.7s
Alternatives: 11
Speedup: 1.4×

Specification

?
\[\begin{array}{l} t_0 := a - \frac{1}{3}\\ t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right) \end{array} \]
(FPCore (a rand)
  :precision binary64
  (let* ((t_0 (- a (/ 1.0 3.0))))
  (* t_0 (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 t_0))) rand)))))
double code(double a, double rand) {
	double t_0 = a - (1.0 / 3.0);
	return t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
}
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(a, rand)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: t_0
    t_0 = a - (1.0d0 / 3.0d0)
    code = t_0 * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * t_0))) * rand))
end function
public static double code(double a, double rand) {
	double t_0 = a - (1.0 / 3.0);
	return t_0 * (1.0 + ((1.0 / Math.sqrt((9.0 * t_0))) * rand));
}
def code(a, rand):
	t_0 = a - (1.0 / 3.0)
	return t_0 * (1.0 + ((1.0 / math.sqrt((9.0 * t_0))) * rand))
function code(a, rand)
	t_0 = Float64(a - Float64(1.0 / 3.0))
	return Float64(t_0 * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * t_0))) * rand)))
end
function tmp = code(a, rand)
	t_0 = a - (1.0 / 3.0);
	tmp = t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
end
code[a_, rand_] := Block[{t$95$0 = N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := a - \frac{1}{3}\\
t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right)
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := a - \frac{1}{3}\\ t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right) \end{array} \]
(FPCore (a rand)
  :precision binary64
  (let* ((t_0 (- a (/ 1.0 3.0))))
  (* t_0 (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 t_0))) rand)))))
double code(double a, double rand) {
	double t_0 = a - (1.0 / 3.0);
	return t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
}
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(a, rand)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: t_0
    t_0 = a - (1.0d0 / 3.0d0)
    code = t_0 * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * t_0))) * rand))
end function
public static double code(double a, double rand) {
	double t_0 = a - (1.0 / 3.0);
	return t_0 * (1.0 + ((1.0 / Math.sqrt((9.0 * t_0))) * rand));
}
def code(a, rand):
	t_0 = a - (1.0 / 3.0)
	return t_0 * (1.0 + ((1.0 / math.sqrt((9.0 * t_0))) * rand))
function code(a, rand)
	t_0 = Float64(a - Float64(1.0 / 3.0))
	return Float64(t_0 * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * t_0))) * rand)))
end
function tmp = code(a, rand)
	t_0 = a - (1.0 / 3.0);
	tmp = t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
end
code[a_, rand_] := Block[{t$95$0 = N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := a - \frac{1}{3}\\
t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right)
\end{array}

Alternative 1: 99.8% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\\ t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right) \end{array} \]
(FPCore (a rand)
  :precision binary64
  (let* ((t_0
        (* (+ 1.0 (/ a -0.3333333333333333)) -0.3333333333333333)))
  (* t_0 (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 t_0))) rand)))))
double code(double a, double rand) {
	double t_0 = (1.0 + (a / -0.3333333333333333)) * -0.3333333333333333;
	return t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
}
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(a, rand)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: t_0
    t_0 = (1.0d0 + (a / (-0.3333333333333333d0))) * (-0.3333333333333333d0)
    code = t_0 * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * t_0))) * rand))
end function
public static double code(double a, double rand) {
	double t_0 = (1.0 + (a / -0.3333333333333333)) * -0.3333333333333333;
	return t_0 * (1.0 + ((1.0 / Math.sqrt((9.0 * t_0))) * rand));
}
def code(a, rand):
	t_0 = (1.0 + (a / -0.3333333333333333)) * -0.3333333333333333
	return t_0 * (1.0 + ((1.0 / math.sqrt((9.0 * t_0))) * rand))
function code(a, rand)
	t_0 = Float64(Float64(1.0 + Float64(a / -0.3333333333333333)) * -0.3333333333333333)
	return Float64(t_0 * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * t_0))) * rand)))
end
function tmp = code(a, rand)
	t_0 = (1.0 + (a / -0.3333333333333333)) * -0.3333333333333333;
	tmp = t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
end
code[a_, rand_] := Block[{t$95$0 = N[(N[(1.0 + N[(a / -0.3333333333333333), $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]}, N[(t$95$0 * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\\
t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. sub-flipN/A

      \[\leadsto \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    3. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    4. sum-to-multN/A

      \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    5. lower-unsound-*.f64N/A

      \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    6. lower-unsound-+.f64N/A

      \[\leadsto \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    7. lower-unsound-/.f64N/A

      \[\leadsto \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    8. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    9. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    10. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    11. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    12. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    13. metadata-eval99.5%

      \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  3. Applied rewrites99.5%

    \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  4. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} \cdot rand\right) \]
    2. sub-flipN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
    3. +-commutativeN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)}}} \cdot rand\right) \]
    4. sum-to-multN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
    5. lower-unsound-*.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
    6. lower-unsound-+.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    7. lower-unsound-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    8. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    9. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    10. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    11. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
    12. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
    13. metadata-eval99.5%

      \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right)}} \cdot rand\right) \]
  5. Applied rewrites99.5%

    \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)}}} \cdot rand\right) \]
  6. Add Preprocessing

Alternative 2: 99.8% accurate, 1.2× speedup?

\[\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(\frac{rand}{\sqrt{\left(a - 0.3333333333333333\right) \cdot 9}} - -1\right) \]
(FPCore (a rand)
  :precision binary64
  (*
 (* (+ 1.0 (/ a -0.3333333333333333)) -0.3333333333333333)
 (- (/ rand (sqrt (* (- a 0.3333333333333333) 9.0))) -1.0)))
double code(double a, double rand) {
	return ((1.0 + (a / -0.3333333333333333)) * -0.3333333333333333) * ((rand / sqrt(((a - 0.3333333333333333) * 9.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(a, rand)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = ((1.0d0 + (a / (-0.3333333333333333d0))) * (-0.3333333333333333d0)) * ((rand / sqrt(((a - 0.3333333333333333d0) * 9.0d0))) - (-1.0d0))
end function
public static double code(double a, double rand) {
	return ((1.0 + (a / -0.3333333333333333)) * -0.3333333333333333) * ((rand / Math.sqrt(((a - 0.3333333333333333) * 9.0))) - -1.0);
}
def code(a, rand):
	return ((1.0 + (a / -0.3333333333333333)) * -0.3333333333333333) * ((rand / math.sqrt(((a - 0.3333333333333333) * 9.0))) - -1.0)
function code(a, rand)
	return Float64(Float64(Float64(1.0 + Float64(a / -0.3333333333333333)) * -0.3333333333333333) * Float64(Float64(rand / sqrt(Float64(Float64(a - 0.3333333333333333) * 9.0))) - -1.0))
end
function tmp = code(a, rand)
	tmp = ((1.0 + (a / -0.3333333333333333)) * -0.3333333333333333) * ((rand / sqrt(((a - 0.3333333333333333) * 9.0))) - -1.0);
end
code[a_, rand_] := N[(N[(N[(1.0 + N[(a / -0.3333333333333333), $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * N[(N[(rand / N[Sqrt[N[(N[(a - 0.3333333333333333), $MachinePrecision] * 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]
\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(\frac{rand}{\sqrt{\left(a - 0.3333333333333333\right) \cdot 9}} - -1\right)
Derivation
  1. Initial program 99.8%

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. sub-flipN/A

      \[\leadsto \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    3. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    4. sum-to-multN/A

      \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    5. lower-unsound-*.f64N/A

      \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    6. lower-unsound-+.f64N/A

      \[\leadsto \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    7. lower-unsound-/.f64N/A

      \[\leadsto \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    8. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    9. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    10. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    11. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    12. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    13. metadata-eval99.5%

      \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  3. Applied rewrites99.5%

    \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  4. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} \cdot rand\right) \]
    2. sub-flipN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
    3. +-commutativeN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)}}} \cdot rand\right) \]
    4. sum-to-multN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
    5. lower-unsound-*.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
    6. lower-unsound-+.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    7. lower-unsound-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    8. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    9. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    10. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    11. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
    12. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
    13. metadata-eval99.5%

      \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right)}} \cdot rand\right) \]
  5. Applied rewrites99.5%

    \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)}}} \cdot rand\right) \]
  6. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand\right)} \]
    2. +-commutativeN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand + 1\right)} \]
    3. add-flipN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand - \left(\mathsf{neg}\left(1\right)\right)\right)} \]
  7. Applied rewrites99.5%

    \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \color{blue}{\left(\frac{rand}{\sqrt{\left(a - 0.3333333333333333\right) \cdot 9}} - -1\right)} \]
  8. Add Preprocessing

Alternative 3: 99.8% accurate, 1.4× speedup?

\[\left(\frac{rand}{\sqrt{\frac{9}{a}} \cdot a} - -1\right) \cdot \left(a - 0.3333333333333333\right) \]
(FPCore (a rand)
  :precision binary64
  (* (- (/ rand (* (sqrt (/ 9.0 a)) a)) -1.0) (- a 0.3333333333333333)))
double code(double a, double rand) {
	return ((rand / (sqrt((9.0 / a)) * a)) - -1.0) * (a - 0.3333333333333333);
}
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(a, rand)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = ((rand / (sqrt((9.0d0 / a)) * a)) - (-1.0d0)) * (a - 0.3333333333333333d0)
end function
public static double code(double a, double rand) {
	return ((rand / (Math.sqrt((9.0 / a)) * a)) - -1.0) * (a - 0.3333333333333333);
}
def code(a, rand):
	return ((rand / (math.sqrt((9.0 / a)) * a)) - -1.0) * (a - 0.3333333333333333)
function code(a, rand)
	return Float64(Float64(Float64(rand / Float64(sqrt(Float64(9.0 / a)) * a)) - -1.0) * Float64(a - 0.3333333333333333))
end
function tmp = code(a, rand)
	tmp = ((rand / (sqrt((9.0 / a)) * a)) - -1.0) * (a - 0.3333333333333333);
end
code[a_, rand_] := N[(N[(N[(rand / N[(N[Sqrt[N[(9.0 / a), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] * N[(a - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\left(\frac{rand}{\sqrt{\frac{9}{a}} \cdot a} - -1\right) \cdot \left(a - 0.3333333333333333\right)
Derivation
  1. Initial program 99.8%

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Taylor expanded in a around inf

    \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(1 + \color{blue}{\frac{rand}{a \cdot \sqrt{\frac{9}{a}}}}\right) \]
  3. Step-by-step derivation
    1. lower-/.f64N/A

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

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{rand}{a \cdot \color{blue}{\sqrt{\frac{9}{a}}}}\right) \]
    3. lower-sqrt.f64N/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{rand}{a \cdot \sqrt{\frac{9}{a}}}\right) \]
    4. lower-/.f6498.9%

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{rand}{a \cdot \sqrt{\frac{9}{a}}}\right) \]
  4. Applied rewrites98.9%

    \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(1 + \color{blue}{\frac{rand}{a \cdot \sqrt{\frac{9}{a}}}}\right) \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \left(a - \color{blue}{\frac{1}{3}}\right) \cdot \left(1 + \frac{rand}{a \cdot \sqrt{\frac{9}{a}}}\right) \]
    3. *-commutativeN/A

      \[\leadsto \color{blue}{\left(1 + \frac{rand}{a \cdot \sqrt{\frac{9}{a}}}\right) \cdot \left(a - \frac{1}{3}\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(1 + \frac{rand}{a \cdot \sqrt{\frac{9}{a}}}\right) \cdot \left(a - \frac{1}{3}\right)} \]
  6. Applied rewrites98.9%

    \[\leadsto \color{blue}{\left(\frac{rand}{\sqrt{\frac{9}{a}} \cdot a} - -1\right) \cdot \left(a - 0.3333333333333333\right)} \]
  7. Add Preprocessing

Alternative 4: 99.5% accurate, 1.5× speedup?

\[\left(a - 0.3333333333333333\right) - \frac{0.3333333333333333 - a}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \cdot rand \]
(FPCore (a rand)
  :precision binary64
  (-
 (- a 0.3333333333333333)
 (*
  (/ (- 0.3333333333333333 a) (sqrt (* 9.0 (- a 0.3333333333333333))))
  rand)))
double code(double a, double rand) {
	return (a - 0.3333333333333333) - (((0.3333333333333333 - a) / sqrt((9.0 * (a - 0.3333333333333333)))) * rand);
}
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(a, rand)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = (a - 0.3333333333333333d0) - (((0.3333333333333333d0 - a) / sqrt((9.0d0 * (a - 0.3333333333333333d0)))) * rand)
end function
public static double code(double a, double rand) {
	return (a - 0.3333333333333333) - (((0.3333333333333333 - a) / Math.sqrt((9.0 * (a - 0.3333333333333333)))) * rand);
}
def code(a, rand):
	return (a - 0.3333333333333333) - (((0.3333333333333333 - a) / math.sqrt((9.0 * (a - 0.3333333333333333)))) * rand)
function code(a, rand)
	return Float64(Float64(a - 0.3333333333333333) - Float64(Float64(Float64(0.3333333333333333 - a) / sqrt(Float64(9.0 * Float64(a - 0.3333333333333333)))) * rand))
end
function tmp = code(a, rand)
	tmp = (a - 0.3333333333333333) - (((0.3333333333333333 - a) / sqrt((9.0 * (a - 0.3333333333333333)))) * rand);
end
code[a_, rand_] := N[(N[(a - 0.3333333333333333), $MachinePrecision] - N[(N[(N[(0.3333333333333333 - a), $MachinePrecision] / N[Sqrt[N[(9.0 * N[(a - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]
\left(a - 0.3333333333333333\right) - \frac{0.3333333333333333 - a}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \cdot rand
Derivation
  1. Initial program 99.8%

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. sub-flipN/A

      \[\leadsto \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    3. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    4. sum-to-multN/A

      \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    5. lower-unsound-*.f64N/A

      \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    6. lower-unsound-+.f64N/A

      \[\leadsto \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    7. lower-unsound-/.f64N/A

      \[\leadsto \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    8. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    9. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    10. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    11. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    12. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    13. metadata-eval99.5%

      \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  3. Applied rewrites99.5%

    \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  4. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} \cdot rand\right) \]
    2. sub-flipN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
    3. +-commutativeN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)}}} \cdot rand\right) \]
    4. sum-to-multN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
    5. lower-unsound-*.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
    6. lower-unsound-+.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    7. lower-unsound-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    8. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    9. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    10. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
    11. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
    12. metadata-evalN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
    13. metadata-eval99.5%

      \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right)}} \cdot rand\right) \]
  5. Applied rewrites99.5%

    \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)}}} \cdot rand\right) \]
  6. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand\right)} \]
    2. +-commutativeN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand + 1\right)} \]
    3. add-flipN/A

      \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand - \left(\mathsf{neg}\left(1\right)\right)\right)} \]
  7. Applied rewrites99.5%

    \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \color{blue}{\left(\frac{rand}{\sqrt{\left(a - 0.3333333333333333\right) \cdot 9}} - -1\right)} \]
  8. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)} \cdot \left(\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}} - -1\right) \]
    3. lift-+.f64N/A

      \[\leadsto \left(\color{blue}{\left(1 + \frac{a}{\frac{-1}{3}}\right)} \cdot \frac{-1}{3}\right) \cdot \left(\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}} - -1\right) \]
    4. lift-/.f64N/A

      \[\leadsto \left(\left(1 + \color{blue}{\frac{a}{\frac{-1}{3}}}\right) \cdot \frac{-1}{3}\right) \cdot \left(\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}} - -1\right) \]
    5. sum-to-mult-revN/A

      \[\leadsto \color{blue}{\left(\frac{-1}{3} + a\right)} \cdot \left(\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}} - -1\right) \]
    6. +-commutativeN/A

      \[\leadsto \color{blue}{\left(a + \frac{-1}{3}\right)} \cdot \left(\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}} - -1\right) \]
    7. metadata-evalN/A

      \[\leadsto \left(a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right) \cdot \left(\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}} - -1\right) \]
    8. sub-flipN/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}} - -1\right) \]
    9. lift--.f64N/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}} - -1\right) \]
    10. lift--.f64N/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \color{blue}{\left(\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}} - -1\right)} \]
    11. sub-flipN/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \color{blue}{\left(\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}} + \left(\mathsf{neg}\left(-1\right)\right)\right)} \]
    12. lift-/.f64N/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(\color{blue}{\frac{rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}}} + \left(\mathsf{neg}\left(-1\right)\right)\right) \]
    13. mult-flipN/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(\color{blue}{rand \cdot \frac{1}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}}} + \left(\mathsf{neg}\left(-1\right)\right)\right) \]
    14. lift-sqrt.f64N/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(rand \cdot \frac{1}{\color{blue}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}}} + \left(\mathsf{neg}\left(-1\right)\right)\right) \]
    15. lift-*.f64N/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(rand \cdot \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} + \left(\mathsf{neg}\left(-1\right)\right)\right) \]
    16. *-commutativeN/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(rand \cdot \frac{1}{\sqrt{\color{blue}{9 \cdot \left(a - \frac{1}{3}\right)}}} + \left(\mathsf{neg}\left(-1\right)\right)\right) \]
    17. lift--.f64N/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(rand \cdot \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} + \left(\mathsf{neg}\left(-1\right)\right)\right) \]
    18. *-commutativeN/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(\color{blue}{\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand} + \left(\mathsf{neg}\left(-1\right)\right)\right) \]
    19. metadata-evalN/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand + \color{blue}{1}\right) \]
    20. +-commutativeN/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)} \]
  9. Applied rewrites99.8%

    \[\leadsto \color{blue}{\left(a - 0.3333333333333333\right) - \frac{0.3333333333333333 - a}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \cdot rand} \]
  10. Add Preprocessing

Alternative 5: 99.5% accurate, 1.5× speedup?

\[\left(a - 0.3333333333333333\right) - \left(0.3333333333333333 - a\right) \cdot \frac{rand}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \]
(FPCore (a rand)
  :precision binary64
  (-
 (- a 0.3333333333333333)
 (*
  (- 0.3333333333333333 a)
  (/ rand (sqrt (* 9.0 (- a 0.3333333333333333)))))))
double code(double a, double rand) {
	return (a - 0.3333333333333333) - ((0.3333333333333333 - a) * (rand / sqrt((9.0 * (a - 0.3333333333333333)))));
}
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(a, rand)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = (a - 0.3333333333333333d0) - ((0.3333333333333333d0 - a) * (rand / sqrt((9.0d0 * (a - 0.3333333333333333d0)))))
end function
public static double code(double a, double rand) {
	return (a - 0.3333333333333333) - ((0.3333333333333333 - a) * (rand / Math.sqrt((9.0 * (a - 0.3333333333333333)))));
}
def code(a, rand):
	return (a - 0.3333333333333333) - ((0.3333333333333333 - a) * (rand / math.sqrt((9.0 * (a - 0.3333333333333333)))))
function code(a, rand)
	return Float64(Float64(a - 0.3333333333333333) - Float64(Float64(0.3333333333333333 - a) * Float64(rand / sqrt(Float64(9.0 * Float64(a - 0.3333333333333333))))))
end
function tmp = code(a, rand)
	tmp = (a - 0.3333333333333333) - ((0.3333333333333333 - a) * (rand / sqrt((9.0 * (a - 0.3333333333333333)))));
end
code[a_, rand_] := N[(N[(a - 0.3333333333333333), $MachinePrecision] - N[(N[(0.3333333333333333 - a), $MachinePrecision] * N[(rand / N[Sqrt[N[(9.0 * N[(a - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(a - 0.3333333333333333\right) - \left(0.3333333333333333 - a\right) \cdot \frac{rand}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}}
Derivation
  1. Initial program 99.8%

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)} \]
    3. distribute-lft-inN/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right) \cdot 1 + \left(a - \frac{1}{3}\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)} \]
    4. *-rgt-identityN/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} + \left(a - \frac{1}{3}\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    5. add-flip-revN/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right) - \left(\mathsf{neg}\left(\left(a - \frac{1}{3}\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)\right)\right)} \]
    6. lower--.f64N/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right) - \left(\mathsf{neg}\left(\left(a - \frac{1}{3}\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)\right)\right)} \]
    7. lift-/.f64N/A

      \[\leadsto \left(a - \color{blue}{\frac{1}{3}}\right) - \left(\mathsf{neg}\left(\left(a - \frac{1}{3}\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)\right)\right) \]
    8. metadata-evalN/A

      \[\leadsto \left(a - \color{blue}{\frac{1}{3}}\right) - \left(\mathsf{neg}\left(\left(a - \frac{1}{3}\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)\right)\right) \]
    9. distribute-lft-neg-outN/A

      \[\leadsto \left(a - \frac{1}{3}\right) - \color{blue}{\left(\mathsf{neg}\left(\left(a - \frac{1}{3}\right)\right)\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)} \]
    10. lift--.f64N/A

      \[\leadsto \left(a - \frac{1}{3}\right) - \left(\mathsf{neg}\left(\color{blue}{\left(a - \frac{1}{3}\right)}\right)\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    11. sub-negate-revN/A

      \[\leadsto \left(a - \frac{1}{3}\right) - \color{blue}{\left(\frac{1}{3} - a\right)} \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    12. lower-*.f64N/A

      \[\leadsto \left(a - \frac{1}{3}\right) - \color{blue}{\left(\frac{1}{3} - a\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)} \]
    13. lower--.f6499.8%

      \[\leadsto \left(a - 0.3333333333333333\right) - \color{blue}{\left(\frac{1}{3} - a\right)} \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    14. lift-/.f64N/A

      \[\leadsto \left(a - \frac{1}{3}\right) - \left(\color{blue}{\frac{1}{3}} - a\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    15. metadata-eval99.8%

      \[\leadsto \left(a - 0.3333333333333333\right) - \left(\color{blue}{0.3333333333333333} - a\right) \cdot \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  3. Applied rewrites99.8%

    \[\leadsto \color{blue}{\left(a - 0.3333333333333333\right) - \left(0.3333333333333333 - a\right) \cdot \frac{rand}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}}} \]
  4. Add Preprocessing

Alternative 6: 98.9% accurate, 1.7× speedup?

\[\left(\frac{rand}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} - -1\right) \cdot \left(a - 0.3333333333333333\right) \]
(FPCore (a rand)
  :precision binary64
  (*
 (- (/ rand (sqrt (* 9.0 (- a 0.3333333333333333)))) -1.0)
 (- a 0.3333333333333333)))
double code(double a, double rand) {
	return ((rand / sqrt((9.0 * (a - 0.3333333333333333)))) - -1.0) * (a - 0.3333333333333333);
}
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(a, rand)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = ((rand / sqrt((9.0d0 * (a - 0.3333333333333333d0)))) - (-1.0d0)) * (a - 0.3333333333333333d0)
end function
public static double code(double a, double rand) {
	return ((rand / Math.sqrt((9.0 * (a - 0.3333333333333333)))) - -1.0) * (a - 0.3333333333333333);
}
def code(a, rand):
	return ((rand / math.sqrt((9.0 * (a - 0.3333333333333333)))) - -1.0) * (a - 0.3333333333333333)
function code(a, rand)
	return Float64(Float64(Float64(rand / sqrt(Float64(9.0 * Float64(a - 0.3333333333333333)))) - -1.0) * Float64(a - 0.3333333333333333))
end
function tmp = code(a, rand)
	tmp = ((rand / sqrt((9.0 * (a - 0.3333333333333333)))) - -1.0) * (a - 0.3333333333333333);
end
code[a_, rand_] := N[(N[(N[(rand / N[Sqrt[N[(9.0 * N[(a - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] * N[(a - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\left(\frac{rand}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} - -1\right) \cdot \left(a - 0.3333333333333333\right)
Derivation
  1. Initial program 99.8%

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \cdot \left(a - \frac{1}{3}\right)} \]
    3. lower-*.f6499.8%

      \[\leadsto \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \cdot \left(a - \frac{1}{3}\right)} \]
    4. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)} \cdot \left(a - \frac{1}{3}\right) \]
    5. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand + 1\right)} \cdot \left(a - \frac{1}{3}\right) \]
    6. add-flipN/A

      \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand - \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(a - \frac{1}{3}\right) \]
    7. metadata-evalN/A

      \[\leadsto \left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand - \color{blue}{-1}\right) \cdot \left(a - \frac{1}{3}\right) \]
    8. lower--.f6499.8%

      \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand - -1\right)} \cdot \left(a - \frac{1}{3}\right) \]
    9. lift-*.f64N/A

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand} - -1\right) \cdot \left(a - \frac{1}{3}\right) \]
    10. *-commutativeN/A

      \[\leadsto \left(\color{blue}{rand \cdot \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} - -1\right) \cdot \left(a - \frac{1}{3}\right) \]
    11. lift-/.f64N/A

      \[\leadsto \left(rand \cdot \color{blue}{\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} - -1\right) \cdot \left(a - \frac{1}{3}\right) \]
    12. mult-flip-revN/A

      \[\leadsto \left(\color{blue}{\frac{rand}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} - -1\right) \cdot \left(a - \frac{1}{3}\right) \]
    13. lower-/.f6499.8%

      \[\leadsto \left(\color{blue}{\frac{rand}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} - -1\right) \cdot \left(a - \frac{1}{3}\right) \]
    14. lift-/.f64N/A

      \[\leadsto \left(\frac{rand}{\sqrt{9 \cdot \left(a - \color{blue}{\frac{1}{3}}\right)}} - -1\right) \cdot \left(a - \frac{1}{3}\right) \]
    15. metadata-eval99.8%

      \[\leadsto \left(\frac{rand}{\sqrt{9 \cdot \left(a - \color{blue}{0.3333333333333333}\right)}} - -1\right) \cdot \left(a - \frac{1}{3}\right) \]
  3. Applied rewrites99.8%

    \[\leadsto \color{blue}{\left(\frac{rand}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} - -1\right) \cdot \left(a - 0.3333333333333333\right)} \]
  4. Add Preprocessing

Alternative 7: 98.9% accurate, 1.8× speedup?

\[\left(\frac{rand}{\sqrt{9 \cdot a}} - -1\right) \cdot \left(a - 0.3333333333333333\right) \]
(FPCore (a rand)
  :precision binary64
  (* (- (/ rand (sqrt (* 9.0 a))) -1.0) (- a 0.3333333333333333)))
double code(double a, double rand) {
	return ((rand / sqrt((9.0 * a))) - -1.0) * (a - 0.3333333333333333);
}
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(a, rand)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = ((rand / sqrt((9.0d0 * a))) - (-1.0d0)) * (a - 0.3333333333333333d0)
end function
public static double code(double a, double rand) {
	return ((rand / Math.sqrt((9.0 * a))) - -1.0) * (a - 0.3333333333333333);
}
def code(a, rand):
	return ((rand / math.sqrt((9.0 * a))) - -1.0) * (a - 0.3333333333333333)
function code(a, rand)
	return Float64(Float64(Float64(rand / sqrt(Float64(9.0 * a))) - -1.0) * Float64(a - 0.3333333333333333))
end
function tmp = code(a, rand)
	tmp = ((rand / sqrt((9.0 * a))) - -1.0) * (a - 0.3333333333333333);
end
code[a_, rand_] := N[(N[(N[(rand / N[Sqrt[N[(9.0 * a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] * N[(a - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\left(\frac{rand}{\sqrt{9 \cdot a}} - -1\right) \cdot \left(a - 0.3333333333333333\right)
Derivation
  1. Initial program 99.8%

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Taylor expanded in a around inf

    \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(1 + \color{blue}{\frac{rand}{a \cdot \sqrt{\frac{9}{a}}}}\right) \]
  3. Step-by-step derivation
    1. lower-/.f64N/A

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

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{rand}{a \cdot \color{blue}{\sqrt{\frac{9}{a}}}}\right) \]
    3. lower-sqrt.f64N/A

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{rand}{a \cdot \sqrt{\frac{9}{a}}}\right) \]
    4. lower-/.f6498.9%

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{rand}{a \cdot \sqrt{\frac{9}{a}}}\right) \]
  4. Applied rewrites98.9%

    \[\leadsto \left(a - \frac{1}{3}\right) \cdot \left(1 + \color{blue}{\frac{rand}{a \cdot \sqrt{\frac{9}{a}}}}\right) \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \left(a - \color{blue}{\frac{1}{3}}\right) \cdot \left(1 + \frac{rand}{a \cdot \sqrt{\frac{9}{a}}}\right) \]
    3. *-commutativeN/A

      \[\leadsto \color{blue}{\left(1 + \frac{rand}{a \cdot \sqrt{\frac{9}{a}}}\right) \cdot \left(a - \frac{1}{3}\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(1 + \frac{rand}{a \cdot \sqrt{\frac{9}{a}}}\right) \cdot \left(a - \frac{1}{3}\right)} \]
  6. Applied rewrites98.9%

    \[\leadsto \color{blue}{\left(\frac{rand}{\sqrt{\frac{9}{a}} \cdot a} - -1\right) \cdot \left(a - 0.3333333333333333\right)} \]
  7. Taylor expanded in a around 0

    \[\leadsto \left(\frac{rand}{\sqrt{9 \cdot a}} - -1\right) \cdot \left(a - 0.3333333333333333\right) \]
  8. Step-by-step derivation
    1. lower-sqrt.f64N/A

      \[\leadsto \left(\frac{rand}{\sqrt{9 \cdot a}} - -1\right) \cdot \left(a - \frac{1}{3}\right) \]
    2. lower-*.f6498.9%

      \[\leadsto \left(\frac{rand}{\sqrt{9 \cdot a}} - -1\right) \cdot \left(a - 0.3333333333333333\right) \]
  9. Applied rewrites98.9%

    \[\leadsto \left(\frac{rand}{\sqrt{9 \cdot a}} - -1\right) \cdot \left(a - 0.3333333333333333\right) \]
  10. Add Preprocessing

Alternative 8: 90.8% accurate, 1.4× speedup?

\[\begin{array}{l} \mathbf{if}\;rand \leq -1.9 \cdot 10^{+59}:\\ \;\;\;\;\frac{rand}{\sqrt{\frac{9}{a}}}\\ \mathbf{elif}\;rand \leq 3.2 \cdot 10^{+128}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{a - 0.3333333333333333}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \cdot rand\\ \end{array} \]
(FPCore (a rand)
  :precision binary64
  (if (<= rand -1.9e+59)
  (/ rand (sqrt (/ 9.0 a)))
  (if (<= rand 3.2e+128)
    (- a 0.3333333333333333)
    (*
     (/
      (- a 0.3333333333333333)
      (sqrt (* 9.0 (- a 0.3333333333333333))))
     rand))))
double code(double a, double rand) {
	double tmp;
	if (rand <= -1.9e+59) {
		tmp = rand / sqrt((9.0 / a));
	} else if (rand <= 3.2e+128) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = ((a - 0.3333333333333333) / sqrt((9.0 * (a - 0.3333333333333333)))) * rand;
	}
	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(a, rand)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: tmp
    if (rand <= (-1.9d+59)) then
        tmp = rand / sqrt((9.0d0 / a))
    else if (rand <= 3.2d+128) then
        tmp = a - 0.3333333333333333d0
    else
        tmp = ((a - 0.3333333333333333d0) / sqrt((9.0d0 * (a - 0.3333333333333333d0)))) * rand
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double tmp;
	if (rand <= -1.9e+59) {
		tmp = rand / Math.sqrt((9.0 / a));
	} else if (rand <= 3.2e+128) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = ((a - 0.3333333333333333) / Math.sqrt((9.0 * (a - 0.3333333333333333)))) * rand;
	}
	return tmp;
}
def code(a, rand):
	tmp = 0
	if rand <= -1.9e+59:
		tmp = rand / math.sqrt((9.0 / a))
	elif rand <= 3.2e+128:
		tmp = a - 0.3333333333333333
	else:
		tmp = ((a - 0.3333333333333333) / math.sqrt((9.0 * (a - 0.3333333333333333)))) * rand
	return tmp
function code(a, rand)
	tmp = 0.0
	if (rand <= -1.9e+59)
		tmp = Float64(rand / sqrt(Float64(9.0 / a)));
	elseif (rand <= 3.2e+128)
		tmp = Float64(a - 0.3333333333333333);
	else
		tmp = Float64(Float64(Float64(a - 0.3333333333333333) / sqrt(Float64(9.0 * Float64(a - 0.3333333333333333)))) * rand);
	end
	return tmp
end
function tmp_2 = code(a, rand)
	tmp = 0.0;
	if (rand <= -1.9e+59)
		tmp = rand / sqrt((9.0 / a));
	elseif (rand <= 3.2e+128)
		tmp = a - 0.3333333333333333;
	else
		tmp = ((a - 0.3333333333333333) / sqrt((9.0 * (a - 0.3333333333333333)))) * rand;
	end
	tmp_2 = tmp;
end
code[a_, rand_] := If[LessEqual[rand, -1.9e+59], N[(rand / N[Sqrt[N[(9.0 / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 3.2e+128], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(N[(a - 0.3333333333333333), $MachinePrecision] / N[Sqrt[N[(9.0 * N[(a - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;rand \leq -1.9 \cdot 10^{+59}:\\
\;\;\;\;\frac{rand}{\sqrt{\frac{9}{a}}}\\

\mathbf{elif}\;rand \leq 3.2 \cdot 10^{+128}:\\
\;\;\;\;a - 0.3333333333333333\\

\mathbf{else}:\\
\;\;\;\;\frac{a - 0.3333333333333333}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \cdot rand\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if rand < -1.9e59

    1. Initial program 99.8%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Taylor expanded in a around inf

      \[\leadsto \left(a - \frac{1}{3}\right) \cdot \color{blue}{1} \]
    3. Step-by-step derivation
      1. Applied rewrites63.0%

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

        \[\leadsto \color{blue}{\frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
      3. Step-by-step derivation
        1. metadata-evalN/A

          \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \color{blue}{\frac{1}{3}}\right)}} \]
        2. metadata-evalN/A

          \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
        3. lower-/.f64N/A

          \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\color{blue}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
        4. lower-*.f64N/A

          \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{\color{blue}{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
        5. lower--.f64N/A

          \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} \]
        6. metadata-evalN/A

          \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \color{blue}{\frac{1}{3}}\right)}} \]
        7. lower-sqrt.f64N/A

          \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
        8. lower-*.f64N/A

          \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
        9. lower--.f64N/A

          \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
        10. metadata-eval30.5%

          \[\leadsto \frac{rand \cdot \left(a - 0.3333333333333333\right)}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \]
      4. Applied rewrites30.5%

        \[\leadsto \color{blue}{\frac{rand \cdot \left(a - 0.3333333333333333\right)}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}}} \]
      5. Taylor expanded in a around inf

        \[\leadsto \frac{rand}{\color{blue}{\sqrt{\frac{9}{a}}}} \]
      6. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{rand}{\sqrt{\frac{9}{a}}} \]
        2. lower-sqrt.f64N/A

          \[\leadsto \frac{rand}{\sqrt{\frac{9}{a}}} \]
        3. lower-/.f6437.1%

          \[\leadsto \frac{rand}{\sqrt{\frac{9}{a}}} \]
      7. Applied rewrites37.1%

        \[\leadsto \frac{rand}{\color{blue}{\sqrt{\frac{9}{a}}}} \]

      if -1.9e59 < rand < 3.1999999999999999e128

      1. Initial program 99.8%

        \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        2. sub-flipN/A

          \[\leadsto \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        3. +-commutativeN/A

          \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        4. sum-to-multN/A

          \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        5. lower-unsound-*.f64N/A

          \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        6. lower-unsound-+.f64N/A

          \[\leadsto \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        7. lower-unsound-/.f64N/A

          \[\leadsto \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        8. lift-/.f64N/A

          \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        9. metadata-evalN/A

          \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        10. metadata-evalN/A

          \[\leadsto \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        11. lift-/.f64N/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        12. metadata-evalN/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        13. metadata-eval99.5%

          \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. Applied rewrites99.5%

        \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} \cdot rand\right) \]
        2. sub-flipN/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
        3. +-commutativeN/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)}}} \cdot rand\right) \]
        4. sum-to-multN/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
        5. lower-unsound-*.f64N/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
        6. lower-unsound-+.f64N/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
        7. lower-unsound-/.f64N/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
        8. lift-/.f64N/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
        9. metadata-evalN/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
        10. metadata-evalN/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
        11. lift-/.f64N/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
        12. metadata-evalN/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
        13. metadata-eval99.5%

          \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right)}} \cdot rand\right) \]
      5. Applied rewrites99.5%

        \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)}}} \cdot rand\right) \]
      6. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand\right)} \]
        2. +-commutativeN/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand + 1\right)} \]
        3. add-flipN/A

          \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand - \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      7. Applied rewrites99.5%

        \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \color{blue}{\left(\frac{rand}{\sqrt{\left(a - 0.3333333333333333\right) \cdot 9}} - -1\right)} \]
      8. Taylor expanded in rand around 0

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

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

          \[\leadsto \frac{-1}{3} \cdot \left(1 + \color{blue}{-3 \cdot a}\right) \]
        3. lower-*.f6462.6%

          \[\leadsto -0.3333333333333333 \cdot \left(1 + -3 \cdot \color{blue}{a}\right) \]
      10. Applied rewrites62.6%

        \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left(1 + -3 \cdot a\right)} \]
      11. Step-by-step derivation
        1. lift-*.f64N/A

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

          \[\leadsto \frac{-1}{3} \cdot \left(1 + \color{blue}{-3 \cdot a}\right) \]
        3. +-commutativeN/A

          \[\leadsto \frac{-1}{3} \cdot \left(-3 \cdot a + \color{blue}{1}\right) \]
        4. distribute-rgt-inN/A

          \[\leadsto \left(-3 \cdot a\right) \cdot \frac{-1}{3} + \color{blue}{1 \cdot \frac{-1}{3}} \]
        5. *-commutativeN/A

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

          \[\leadsto \frac{-1}{3} \cdot \left(-3 \cdot a\right) + 1 \cdot \frac{-1}{3} \]
        7. associate-*r*N/A

          \[\leadsto \left(\frac{-1}{3} \cdot -3\right) \cdot a + \color{blue}{1} \cdot \frac{-1}{3} \]
        8. metadata-evalN/A

          \[\leadsto 1 \cdot a + 1 \cdot \frac{-1}{3} \]
        9. distribute-lft-inN/A

          \[\leadsto 1 \cdot \color{blue}{\left(a + \frac{-1}{3}\right)} \]
        10. metadata-evalN/A

          \[\leadsto 1 \cdot \left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \]
        11. metadata-evalN/A

          \[\leadsto 1 \cdot \left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \]
        12. sub-flipN/A

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

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

          \[\leadsto a - \color{blue}{\frac{1}{3}} \]
        15. metadata-eval63.0%

          \[\leadsto a - 0.3333333333333333 \]
      12. Applied rewrites63.0%

        \[\leadsto \color{blue}{a - 0.3333333333333333} \]

      if 3.1999999999999999e128 < rand

      1. Initial program 99.8%

        \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. Taylor expanded in a around inf

        \[\leadsto \left(a - \frac{1}{3}\right) \cdot \color{blue}{1} \]
      3. Step-by-step derivation
        1. Applied rewrites63.0%

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

          \[\leadsto \color{blue}{\frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
        3. Step-by-step derivation
          1. metadata-evalN/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \color{blue}{\frac{1}{3}}\right)}} \]
          2. metadata-evalN/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
          3. lower-/.f64N/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\color{blue}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
          4. lower-*.f64N/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{\color{blue}{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
          5. lower--.f64N/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} \]
          6. metadata-evalN/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \color{blue}{\frac{1}{3}}\right)}} \]
          7. lower-sqrt.f64N/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
          8. lower-*.f64N/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
          9. lower--.f64N/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
          10. metadata-eval30.5%

            \[\leadsto \frac{rand \cdot \left(a - 0.3333333333333333\right)}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \]
        4. Applied rewrites30.5%

          \[\leadsto \color{blue}{\frac{rand \cdot \left(a - 0.3333333333333333\right)}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}}} \]
        5. Step-by-step derivation
          1. lift-/.f64N/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\color{blue}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{\color{blue}{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
          3. associate-/l*N/A

            \[\leadsto rand \cdot \color{blue}{\frac{a - \frac{1}{3}}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
          4. *-commutativeN/A

            \[\leadsto \frac{a - \frac{1}{3}}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot \color{blue}{rand} \]
          5. lower-*.f64N/A

            \[\leadsto \frac{a - \frac{1}{3}}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot \color{blue}{rand} \]
          6. lower-/.f6437.9%

            \[\leadsto \frac{a - 0.3333333333333333}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \cdot rand \]
        6. Applied rewrites37.9%

          \[\leadsto \frac{a - 0.3333333333333333}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \cdot \color{blue}{rand} \]
      4. Recombined 3 regimes into one program.
      5. Add Preprocessing

      Alternative 9: 90.6% accurate, 1.5× speedup?

      \[\begin{array}{l} t_0 := \frac{rand}{\sqrt{\frac{9}{a}}}\\ \mathbf{if}\;rand \leq -1.9 \cdot 10^{+59}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;rand \leq 3.2 \cdot 10^{+128}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
      (FPCore (a rand)
        :precision binary64
        (let* ((t_0 (/ rand (sqrt (/ 9.0 a)))))
        (if (<= rand -1.9e+59)
          t_0
          (if (<= rand 3.2e+128) (- a 0.3333333333333333) t_0))))
      double code(double a, double rand) {
      	double t_0 = rand / sqrt((9.0 / a));
      	double tmp;
      	if (rand <= -1.9e+59) {
      		tmp = t_0;
      	} else if (rand <= 3.2e+128) {
      		tmp = a - 0.3333333333333333;
      	} else {
      		tmp = t_0;
      	}
      	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(a, rand)
      use fmin_fmax_functions
          real(8), intent (in) :: a
          real(8), intent (in) :: rand
          real(8) :: t_0
          real(8) :: tmp
          t_0 = rand / sqrt((9.0d0 / a))
          if (rand <= (-1.9d+59)) then
              tmp = t_0
          else if (rand <= 3.2d+128) then
              tmp = a - 0.3333333333333333d0
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double a, double rand) {
      	double t_0 = rand / Math.sqrt((9.0 / a));
      	double tmp;
      	if (rand <= -1.9e+59) {
      		tmp = t_0;
      	} else if (rand <= 3.2e+128) {
      		tmp = a - 0.3333333333333333;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(a, rand):
      	t_0 = rand / math.sqrt((9.0 / a))
      	tmp = 0
      	if rand <= -1.9e+59:
      		tmp = t_0
      	elif rand <= 3.2e+128:
      		tmp = a - 0.3333333333333333
      	else:
      		tmp = t_0
      	return tmp
      
      function code(a, rand)
      	t_0 = Float64(rand / sqrt(Float64(9.0 / a)))
      	tmp = 0.0
      	if (rand <= -1.9e+59)
      		tmp = t_0;
      	elseif (rand <= 3.2e+128)
      		tmp = Float64(a - 0.3333333333333333);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(a, rand)
      	t_0 = rand / sqrt((9.0 / a));
      	tmp = 0.0;
      	if (rand <= -1.9e+59)
      		tmp = t_0;
      	elseif (rand <= 3.2e+128)
      		tmp = a - 0.3333333333333333;
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, rand_] := Block[{t$95$0 = N[(rand / N[Sqrt[N[(9.0 / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[rand, -1.9e+59], t$95$0, If[LessEqual[rand, 3.2e+128], N[(a - 0.3333333333333333), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      t_0 := \frac{rand}{\sqrt{\frac{9}{a}}}\\
      \mathbf{if}\;rand \leq -1.9 \cdot 10^{+59}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;rand \leq 3.2 \cdot 10^{+128}:\\
      \;\;\;\;a - 0.3333333333333333\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if rand < -1.9e59 or 3.1999999999999999e128 < rand

        1. Initial program 99.8%

          \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        2. Taylor expanded in a around inf

          \[\leadsto \left(a - \frac{1}{3}\right) \cdot \color{blue}{1} \]
        3. Step-by-step derivation
          1. Applied rewrites63.0%

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

            \[\leadsto \color{blue}{\frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
          3. Step-by-step derivation
            1. metadata-evalN/A

              \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \color{blue}{\frac{1}{3}}\right)}} \]
            2. metadata-evalN/A

              \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
            3. lower-/.f64N/A

              \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\color{blue}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
            4. lower-*.f64N/A

              \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{\color{blue}{9 \cdot \left(a - \frac{1}{3}\right)}}} \]
            5. lower--.f64N/A

              \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} \]
            6. metadata-evalN/A

              \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \color{blue}{\frac{1}{3}}\right)}} \]
            7. lower-sqrt.f64N/A

              \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
            8. lower-*.f64N/A

              \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
            9. lower--.f64N/A

              \[\leadsto \frac{rand \cdot \left(a - \frac{1}{3}\right)}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \]
            10. metadata-eval30.5%

              \[\leadsto \frac{rand \cdot \left(a - 0.3333333333333333\right)}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}} \]
          4. Applied rewrites30.5%

            \[\leadsto \color{blue}{\frac{rand \cdot \left(a - 0.3333333333333333\right)}{\sqrt{9 \cdot \left(a - 0.3333333333333333\right)}}} \]
          5. Taylor expanded in a around inf

            \[\leadsto \frac{rand}{\color{blue}{\sqrt{\frac{9}{a}}}} \]
          6. Step-by-step derivation
            1. lower-/.f64N/A

              \[\leadsto \frac{rand}{\sqrt{\frac{9}{a}}} \]
            2. lower-sqrt.f64N/A

              \[\leadsto \frac{rand}{\sqrt{\frac{9}{a}}} \]
            3. lower-/.f6437.1%

              \[\leadsto \frac{rand}{\sqrt{\frac{9}{a}}} \]
          7. Applied rewrites37.1%

            \[\leadsto \frac{rand}{\color{blue}{\sqrt{\frac{9}{a}}}} \]

          if -1.9e59 < rand < 3.1999999999999999e128

          1. Initial program 99.8%

            \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          2. Step-by-step derivation
            1. lift--.f64N/A

              \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            2. sub-flipN/A

              \[\leadsto \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            3. +-commutativeN/A

              \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            4. sum-to-multN/A

              \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            5. lower-unsound-*.f64N/A

              \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            6. lower-unsound-+.f64N/A

              \[\leadsto \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            7. lower-unsound-/.f64N/A

              \[\leadsto \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            8. lift-/.f64N/A

              \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            9. metadata-evalN/A

              \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            10. metadata-evalN/A

              \[\leadsto \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            11. lift-/.f64N/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            12. metadata-evalN/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
            13. metadata-eval99.5%

              \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          3. Applied rewrites99.5%

            \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          4. Step-by-step derivation
            1. lift--.f64N/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} \cdot rand\right) \]
            2. sub-flipN/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
            3. +-commutativeN/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)}}} \cdot rand\right) \]
            4. sum-to-multN/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
            5. lower-unsound-*.f64N/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
            6. lower-unsound-+.f64N/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
            7. lower-unsound-/.f64N/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
            8. lift-/.f64N/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
            9. metadata-evalN/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
            10. metadata-evalN/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
            11. lift-/.f64N/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
            12. metadata-evalN/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
            13. metadata-eval99.5%

              \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right)}} \cdot rand\right) \]
          5. Applied rewrites99.5%

            \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)}}} \cdot rand\right) \]
          6. Step-by-step derivation
            1. lift-+.f64N/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand\right)} \]
            2. +-commutativeN/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand + 1\right)} \]
            3. add-flipN/A

              \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand - \left(\mathsf{neg}\left(1\right)\right)\right)} \]
          7. Applied rewrites99.5%

            \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \color{blue}{\left(\frac{rand}{\sqrt{\left(a - 0.3333333333333333\right) \cdot 9}} - -1\right)} \]
          8. Taylor expanded in rand around 0

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

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

              \[\leadsto \frac{-1}{3} \cdot \left(1 + \color{blue}{-3 \cdot a}\right) \]
            3. lower-*.f6462.6%

              \[\leadsto -0.3333333333333333 \cdot \left(1 + -3 \cdot \color{blue}{a}\right) \]
          10. Applied rewrites62.6%

            \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left(1 + -3 \cdot a\right)} \]
          11. Step-by-step derivation
            1. lift-*.f64N/A

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

              \[\leadsto \frac{-1}{3} \cdot \left(1 + \color{blue}{-3 \cdot a}\right) \]
            3. +-commutativeN/A

              \[\leadsto \frac{-1}{3} \cdot \left(-3 \cdot a + \color{blue}{1}\right) \]
            4. distribute-rgt-inN/A

              \[\leadsto \left(-3 \cdot a\right) \cdot \frac{-1}{3} + \color{blue}{1 \cdot \frac{-1}{3}} \]
            5. *-commutativeN/A

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

              \[\leadsto \frac{-1}{3} \cdot \left(-3 \cdot a\right) + 1 \cdot \frac{-1}{3} \]
            7. associate-*r*N/A

              \[\leadsto \left(\frac{-1}{3} \cdot -3\right) \cdot a + \color{blue}{1} \cdot \frac{-1}{3} \]
            8. metadata-evalN/A

              \[\leadsto 1 \cdot a + 1 \cdot \frac{-1}{3} \]
            9. distribute-lft-inN/A

              \[\leadsto 1 \cdot \color{blue}{\left(a + \frac{-1}{3}\right)} \]
            10. metadata-evalN/A

              \[\leadsto 1 \cdot \left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \]
            11. metadata-evalN/A

              \[\leadsto 1 \cdot \left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \]
            12. sub-flipN/A

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

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

              \[\leadsto a - \color{blue}{\frac{1}{3}} \]
            15. metadata-eval63.0%

              \[\leadsto a - 0.3333333333333333 \]
          12. Applied rewrites63.0%

            \[\leadsto \color{blue}{a - 0.3333333333333333} \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 10: 63.0% accurate, 3.4× speedup?

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

          \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        2. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          2. sub-flipN/A

            \[\leadsto \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          3. +-commutativeN/A

            \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          4. sum-to-multN/A

            \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          5. lower-unsound-*.f64N/A

            \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          6. lower-unsound-+.f64N/A

            \[\leadsto \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          7. lower-unsound-/.f64N/A

            \[\leadsto \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          8. lift-/.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          9. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          10. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          11. lift-/.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          12. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          13. metadata-eval99.5%

            \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        3. Applied rewrites99.5%

          \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        4. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} \cdot rand\right) \]
          2. sub-flipN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
          3. +-commutativeN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)}}} \cdot rand\right) \]
          4. sum-to-multN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
          5. lower-unsound-*.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
          6. lower-unsound-+.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
          7. lower-unsound-/.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
          8. lift-/.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
          9. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
          10. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
          11. lift-/.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
          12. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
          13. metadata-eval99.5%

            \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right)}} \cdot rand\right) \]
        5. Applied rewrites99.5%

          \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)}}} \cdot rand\right) \]
        6. Step-by-step derivation
          1. lift-+.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand\right)} \]
          2. +-commutativeN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand + 1\right)} \]
          3. add-flipN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand - \left(\mathsf{neg}\left(1\right)\right)\right)} \]
        7. Applied rewrites99.5%

          \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \color{blue}{\left(\frac{rand}{\sqrt{\left(a - 0.3333333333333333\right) \cdot 9}} - -1\right)} \]
        8. Taylor expanded in rand around 0

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

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

            \[\leadsto \frac{-1}{3} \cdot \left(1 + \color{blue}{-3 \cdot a}\right) \]
          3. lower-*.f6462.6%

            \[\leadsto -0.3333333333333333 \cdot \left(1 + -3 \cdot \color{blue}{a}\right) \]
        10. Applied rewrites62.6%

          \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left(1 + -3 \cdot a\right)} \]
        11. Step-by-step derivation
          1. lift-*.f64N/A

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

            \[\leadsto \frac{-1}{3} \cdot \left(1 + a \cdot \color{blue}{-3}\right) \]
          3. metadata-evalN/A

            \[\leadsto \frac{-1}{3} \cdot \left(1 + a \cdot \frac{1}{\color{blue}{\frac{-1}{3}}}\right) \]
          4. mult-flipN/A

            \[\leadsto \frac{-1}{3} \cdot \left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \]
          5. lower-/.f6462.8%

            \[\leadsto -0.3333333333333333 \cdot \left(1 + \frac{a}{\color{blue}{-0.3333333333333333}}\right) \]
        12. Applied rewrites62.8%

          \[\leadsto -0.3333333333333333 \cdot \left(1 + \frac{a}{\color{blue}{-0.3333333333333333}}\right) \]
        13. Add Preprocessing

        Alternative 11: 62.8% accurate, 17.0× speedup?

        \[a - 0.3333333333333333 \]
        (FPCore (a rand)
          :precision binary64
          (- a 0.3333333333333333))
        double code(double a, double rand) {
        	return a - 0.3333333333333333;
        }
        
        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(a, rand)
        use fmin_fmax_functions
            real(8), intent (in) :: a
            real(8), intent (in) :: rand
            code = a - 0.3333333333333333d0
        end function
        
        public static double code(double a, double rand) {
        	return a - 0.3333333333333333;
        }
        
        def code(a, rand):
        	return a - 0.3333333333333333
        
        function code(a, rand)
        	return Float64(a - 0.3333333333333333)
        end
        
        function tmp = code(a, rand)
        	tmp = a - 0.3333333333333333;
        end
        
        code[a_, rand_] := N[(a - 0.3333333333333333), $MachinePrecision]
        
        a - 0.3333333333333333
        
        Derivation
        1. Initial program 99.8%

          \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        2. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          2. sub-flipN/A

            \[\leadsto \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          3. +-commutativeN/A

            \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          4. sum-to-multN/A

            \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          5. lower-unsound-*.f64N/A

            \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          6. lower-unsound-+.f64N/A

            \[\leadsto \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          7. lower-unsound-/.f64N/A

            \[\leadsto \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          8. lift-/.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          9. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          10. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          11. lift-/.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          12. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
          13. metadata-eval99.5%

            \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        3. Applied rewrites99.5%

          \[\leadsto \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        4. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a - \frac{1}{3}\right)}}} \cdot rand\right) \]
          2. sub-flipN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
          3. +-commutativeN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{3}\right)\right) + a\right)}}} \cdot rand\right) \]
          4. sum-to-multN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
          5. lower-unsound-*.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}}} \cdot rand\right) \]
          6. lower-unsound-+.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\color{blue}{\left(1 + \frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}\right)} \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
          7. lower-unsound-/.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \color{blue}{\frac{a}{\mathsf{neg}\left(\frac{1}{3}\right)}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
          8. lift-/.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
          9. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
          10. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\color{blue}{\frac{-1}{3}}}\right) \cdot \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)}} \cdot rand\right) \]
          11. lift-/.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
          12. metadata-evalN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{1}{3}}\right)\right)\right)}} \cdot rand\right) \]
          13. metadata-eval99.5%

            \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot \color{blue}{-0.3333333333333333}\right)}} \cdot rand\right) \]
        5. Applied rewrites99.5%

          \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \color{blue}{\left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right)}}} \cdot rand\right) \]
        6. Step-by-step derivation
          1. lift-+.f64N/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand\right)} \]
          2. +-commutativeN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand + 1\right)} \]
          3. add-flipN/A

            \[\leadsto \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(\left(1 + \frac{a}{\frac{-1}{3}}\right) \cdot \frac{-1}{3}\right)}} \cdot rand - \left(\mathsf{neg}\left(1\right)\right)\right)} \]
        7. Applied rewrites99.5%

          \[\leadsto \left(\left(1 + \frac{a}{-0.3333333333333333}\right) \cdot -0.3333333333333333\right) \cdot \color{blue}{\left(\frac{rand}{\sqrt{\left(a - 0.3333333333333333\right) \cdot 9}} - -1\right)} \]
        8. Taylor expanded in rand around 0

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

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

            \[\leadsto \frac{-1}{3} \cdot \left(1 + \color{blue}{-3 \cdot a}\right) \]
          3. lower-*.f6462.6%

            \[\leadsto -0.3333333333333333 \cdot \left(1 + -3 \cdot \color{blue}{a}\right) \]
        10. Applied rewrites62.6%

          \[\leadsto \color{blue}{-0.3333333333333333 \cdot \left(1 + -3 \cdot a\right)} \]
        11. Step-by-step derivation
          1. lift-*.f64N/A

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

            \[\leadsto \frac{-1}{3} \cdot \left(1 + \color{blue}{-3 \cdot a}\right) \]
          3. +-commutativeN/A

            \[\leadsto \frac{-1}{3} \cdot \left(-3 \cdot a + \color{blue}{1}\right) \]
          4. distribute-rgt-inN/A

            \[\leadsto \left(-3 \cdot a\right) \cdot \frac{-1}{3} + \color{blue}{1 \cdot \frac{-1}{3}} \]
          5. *-commutativeN/A

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

            \[\leadsto \frac{-1}{3} \cdot \left(-3 \cdot a\right) + 1 \cdot \frac{-1}{3} \]
          7. associate-*r*N/A

            \[\leadsto \left(\frac{-1}{3} \cdot -3\right) \cdot a + \color{blue}{1} \cdot \frac{-1}{3} \]
          8. metadata-evalN/A

            \[\leadsto 1 \cdot a + 1 \cdot \frac{-1}{3} \]
          9. distribute-lft-inN/A

            \[\leadsto 1 \cdot \color{blue}{\left(a + \frac{-1}{3}\right)} \]
          10. metadata-evalN/A

            \[\leadsto 1 \cdot \left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \]
          11. metadata-evalN/A

            \[\leadsto 1 \cdot \left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right) \]
          12. sub-flipN/A

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

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

            \[\leadsto a - \color{blue}{\frac{1}{3}} \]
          15. metadata-eval63.0%

            \[\leadsto a - 0.3333333333333333 \]
        12. Applied rewrites63.0%

          \[\leadsto \color{blue}{a - 0.3333333333333333} \]
        13. Add Preprocessing

        Reproduce

        ?
        herbie shell --seed 2025258 
        (FPCore (a rand)
          :name "Octave 3.8, oct_fill_randg"
          :precision binary64
          (* (- a (/ 1.0 3.0)) (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 (- a (/ 1.0 3.0))))) rand))))