Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, D

Percentage Accurate: 99.8% → 99.9%
Time: 4.2s
Alternatives: 6
Speedup: 2.1×

Specification

?
\[\begin{array}{l} \\ 3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \end{array} \]
(FPCore (x) :precision binary64 (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))
double code(double x) {
	return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = 3.0d0 * ((((x * 3.0d0) * x) - (x * 4.0d0)) + 1.0d0)
end function
public static double code(double x) {
	return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
def code(x):
	return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)
function code(x)
	return Float64(3.0 * Float64(Float64(Float64(Float64(x * 3.0) * x) - Float64(x * 4.0)) + 1.0))
end
function tmp = code(x)
	tmp = 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
end
code[x_] := N[(3.0 * N[(N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] - N[(x * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\end{array}

Sampling outcomes in binary64 precision:

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 6 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} \\ 3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \end{array} \]
(FPCore (x) :precision binary64 (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))
double code(double x) {
	return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = 3.0d0 * ((((x * 3.0d0) * x) - (x * 4.0d0)) + 1.0d0)
end function
public static double code(double x) {
	return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
def code(x):
	return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)
function code(x)
	return Float64(3.0 * Float64(Float64(Float64(Float64(x * 3.0) * x) - Float64(x * 4.0)) + 1.0))
end
function tmp = code(x)
	tmp = 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
end
code[x_] := N[(3.0 * N[(N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] - N[(x * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\end{array}

Alternative 1: 99.9% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(9, x, -12\right), x, 3\right) \end{array} \]
(FPCore (x) :precision binary64 (fma (fma 9.0 x -12.0) x 3.0))
double code(double x) {
	return fma(fma(9.0, x, -12.0), x, 3.0);
}
function code(x)
	return fma(fma(9.0, x, -12.0), x, 3.0)
end
code[x_] := N[(N[(9.0 * x + -12.0), $MachinePrecision] * x + 3.0), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\mathsf{fma}\left(9, x, -12\right), x, 3\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{3 + x \cdot \left(9 \cdot x - 12\right)} \]
  4. Applied rewrites99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(9, x, -12\right), x, 3\right)} \]
  5. Add Preprocessing

Alternative 2: 98.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \leq 5:\\ \;\;\;\;\mathsf{fma}\left(-12, x, 3\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot 9\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)) 5.0)
   (fma -12.0 x 3.0)
   (* (* x x) 9.0)))
double code(double x) {
	double tmp;
	if ((3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)) <= 5.0) {
		tmp = fma(-12.0, x, 3.0);
	} else {
		tmp = (x * x) * 9.0;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (Float64(3.0 * Float64(Float64(Float64(Float64(x * 3.0) * x) - Float64(x * 4.0)) + 1.0)) <= 5.0)
		tmp = fma(-12.0, x, 3.0);
	else
		tmp = Float64(Float64(x * x) * 9.0);
	end
	return tmp
end
code[x_] := If[LessEqual[N[(3.0 * N[(N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] - N[(x * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 5.0], N[(-12.0 * x + 3.0), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * 9.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \leq 5:\\
\;\;\;\;\mathsf{fma}\left(-12, x, 3\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot 9\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal 3 binary64) (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 3 binary64)) x) (*.f64 x #s(literal 4 binary64))) #s(literal 1 binary64))) < 5

    1. Initial program 100.0%

      \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{3 + -12 \cdot x} \]
    4. Step-by-step derivation
      1. Applied rewrites99.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-12, x, 3\right)} \]

      if 5 < (*.f64 #s(literal 3 binary64) (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 3 binary64)) x) (*.f64 x #s(literal 4 binary64))) #s(literal 1 binary64)))

      1. Initial program 99.6%

        \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
      2. Add Preprocessing
      3. Taylor expanded in x around inf

        \[\leadsto \color{blue}{9 \cdot {x}^{2}} \]
      4. Step-by-step derivation
        1. Applied rewrites96.3%

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

      Alternative 3: 98.4% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \leq 5:\\ \;\;\;\;\mathsf{fma}\left(-12, x, 3\right)\\ \mathbf{else}:\\ \;\;\;\;\left(9 \cdot x\right) \cdot x\\ \end{array} \end{array} \]
      (FPCore (x)
       :precision binary64
       (if (<= (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)) 5.0)
         (fma -12.0 x 3.0)
         (* (* 9.0 x) x)))
      double code(double x) {
      	double tmp;
      	if ((3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)) <= 5.0) {
      		tmp = fma(-12.0, x, 3.0);
      	} else {
      		tmp = (9.0 * x) * x;
      	}
      	return tmp;
      }
      
      function code(x)
      	tmp = 0.0
      	if (Float64(3.0 * Float64(Float64(Float64(Float64(x * 3.0) * x) - Float64(x * 4.0)) + 1.0)) <= 5.0)
      		tmp = fma(-12.0, x, 3.0);
      	else
      		tmp = Float64(Float64(9.0 * x) * x);
      	end
      	return tmp
      end
      
      code[x_] := If[LessEqual[N[(3.0 * N[(N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] - N[(x * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 5.0], N[(-12.0 * x + 3.0), $MachinePrecision], N[(N[(9.0 * x), $MachinePrecision] * x), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \leq 5:\\
      \;\;\;\;\mathsf{fma}\left(-12, x, 3\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(9 \cdot x\right) \cdot x\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 #s(literal 3 binary64) (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 3 binary64)) x) (*.f64 x #s(literal 4 binary64))) #s(literal 1 binary64))) < 5

        1. Initial program 100.0%

          \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
        2. Add Preprocessing
        3. Taylor expanded in x around 0

          \[\leadsto \color{blue}{3 + -12 \cdot x} \]
        4. Step-by-step derivation
          1. Applied rewrites99.9%

            \[\leadsto \color{blue}{\mathsf{fma}\left(-12, x, 3\right)} \]

          if 5 < (*.f64 #s(literal 3 binary64) (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 3 binary64)) x) (*.f64 x #s(literal 4 binary64))) #s(literal 1 binary64)))

          1. Initial program 99.6%

            \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
          2. Add Preprocessing
          3. Taylor expanded in x around inf

            \[\leadsto \color{blue}{9 \cdot {x}^{2}} \]
          4. Step-by-step derivation
            1. Applied rewrites96.3%

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

                \[\leadsto \color{blue}{\left(9 \cdot x\right) \cdot x} \]
            3. Recombined 2 regimes into one program.
            4. Add Preprocessing

            Alternative 4: 97.8% accurate, 2.3× speedup?

            \[\begin{array}{l} \\ \mathsf{fma}\left(9 \cdot x, x, 3\right) \end{array} \]
            (FPCore (x) :precision binary64 (fma (* 9.0 x) x 3.0))
            double code(double x) {
            	return fma((9.0 * x), x, 3.0);
            }
            
            function code(x)
            	return fma(Float64(9.0 * x), x, 3.0)
            end
            
            code[x_] := N[(N[(9.0 * x), $MachinePrecision] * x + 3.0), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \mathsf{fma}\left(9 \cdot x, x, 3\right)
            \end{array}
            
            Derivation
            1. Initial program 99.8%

              \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
            2. Add Preprocessing
            3. Taylor expanded in x around 0

              \[\leadsto \color{blue}{3 + x \cdot \left(9 \cdot x - 12\right)} \]
            4. Applied rewrites99.9%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(9, x, -12\right), x, 3\right)} \]
            5. Taylor expanded in x around inf

              \[\leadsto \mathsf{fma}\left(9 \cdot x, x, 3\right) \]
            6. Step-by-step derivation
              1. Applied rewrites97.6%

                \[\leadsto \mathsf{fma}\left(9 \cdot x, x, 3\right) \]
              2. Add Preprocessing

              Alternative 5: 51.2% accurate, 3.9× speedup?

              \[\begin{array}{l} \\ \mathsf{fma}\left(-12, x, 3\right) \end{array} \]
              (FPCore (x) :precision binary64 (fma -12.0 x 3.0))
              double code(double x) {
              	return fma(-12.0, x, 3.0);
              }
              
              function code(x)
              	return fma(-12.0, x, 3.0)
              end
              
              code[x_] := N[(-12.0 * x + 3.0), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \mathsf{fma}\left(-12, x, 3\right)
              \end{array}
              
              Derivation
              1. Initial program 99.8%

                \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
              2. Add Preprocessing
              3. Taylor expanded in x around 0

                \[\leadsto \color{blue}{3 + -12 \cdot x} \]
              4. Step-by-step derivation
                1. Applied rewrites48.8%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(-12, x, 3\right)} \]
                2. Add Preprocessing

                Alternative 6: 50.7% accurate, 27.0× speedup?

                \[\begin{array}{l} \\ 3 \end{array} \]
                (FPCore (x) :precision binary64 3.0)
                double code(double x) {
                	return 3.0;
                }
                
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(x)
                use fmin_fmax_functions
                    real(8), intent (in) :: x
                    code = 3.0d0
                end function
                
                public static double code(double x) {
                	return 3.0;
                }
                
                def code(x):
                	return 3.0
                
                function code(x)
                	return 3.0
                end
                
                function tmp = code(x)
                	tmp = 3.0;
                end
                
                code[x_] := 3.0
                
                \begin{array}{l}
                
                \\
                3
                \end{array}
                
                Derivation
                1. Initial program 99.8%

                  \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
                2. Add Preprocessing
                3. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{3} \]
                4. Step-by-step derivation
                  1. Applied rewrites48.7%

                    \[\leadsto \color{blue}{3} \]
                  2. Add Preprocessing

                  Developer Target 1: 99.8% accurate, 1.2× speedup?

                  \[\begin{array}{l} \\ 3 + \left(\left(9 \cdot x\right) \cdot x - 12 \cdot x\right) \end{array} \]
                  (FPCore (x) :precision binary64 (+ 3.0 (- (* (* 9.0 x) x) (* 12.0 x))))
                  double code(double x) {
                  	return 3.0 + (((9.0 * x) * x) - (12.0 * x));
                  }
                  
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(x)
                  use fmin_fmax_functions
                      real(8), intent (in) :: x
                      code = 3.0d0 + (((9.0d0 * x) * x) - (12.0d0 * x))
                  end function
                  
                  public static double code(double x) {
                  	return 3.0 + (((9.0 * x) * x) - (12.0 * x));
                  }
                  
                  def code(x):
                  	return 3.0 + (((9.0 * x) * x) - (12.0 * x))
                  
                  function code(x)
                  	return Float64(3.0 + Float64(Float64(Float64(9.0 * x) * x) - Float64(12.0 * x)))
                  end
                  
                  function tmp = code(x)
                  	tmp = 3.0 + (((9.0 * x) * x) - (12.0 * x));
                  end
                  
                  code[x_] := N[(3.0 + N[(N[(N[(9.0 * x), $MachinePrecision] * x), $MachinePrecision] - N[(12.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  3 + \left(\left(9 \cdot x\right) \cdot x - 12 \cdot x\right)
                  \end{array}
                  

                  Reproduce

                  ?
                  herbie shell --seed 2025018 
                  (FPCore (x)
                    :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, D"
                    :precision binary64
                  
                    :alt
                    (! :herbie-platform default (+ 3 (- (* (* 9 x) x) (* 12 x))))
                  
                    (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))