Data.Random.Distribution.T:$ccdf from random-fu-0.2.6.2

Percentage Accurate: 99.9% → 100.0%
Time: 6.0s
Alternatives: 6
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{x + y}{y + y} \end{array} \]
(FPCore (x y) :precision binary64 (/ (+ x y) (+ y y)))
double code(double x, double y) {
	return (x + y) / (y + y);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x + y) / (y + y)
end function
public static double code(double x, double y) {
	return (x + y) / (y + y);
}
def code(x, y):
	return (x + y) / (y + y)
function code(x, y)
	return Float64(Float64(x + y) / Float64(y + y))
end
function tmp = code(x, y)
	tmp = (x + y) / (y + y);
end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(y + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x + y}{y + y}
\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.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x + y}{y + y} \end{array} \]
(FPCore (x y) :precision binary64 (/ (+ x y) (+ y y)))
double code(double x, double y) {
	return (x + y) / (y + y);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x + y) / (y + y)
end function
public static double code(double x, double y) {
	return (x + y) / (y + y);
}
def code(x, y):
	return (x + y) / (y + y)
function code(x, y)
	return Float64(Float64(x + y) / Float64(y + y))
end
function tmp = code(x, y)
	tmp = (x + y) / (y + y);
end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(y + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x + y}{y + y}
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(0.5, \frac{x}{y}, 0.5\right) \end{array} \]
(FPCore (x y) :precision binary64 (fma 0.5 (/ x y) 0.5))
double code(double x, double y) {
	return fma(0.5, (x / y), 0.5);
}
function code(x, y)
	return fma(0.5, Float64(x / y), 0.5)
end
code[x_, y_] := N[(0.5 * N[(x / y), $MachinePrecision] + 0.5), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(0.5, \frac{x}{y}, 0.5\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{x + y}{y + y} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\frac{1}{2} + \frac{1}{2} \cdot \frac{x}{y}} \]
  4. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x}{y} + \frac{1}{2}} \]
    2. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, \frac{x}{y}, \frac{1}{2}\right)} \]
    3. /-lowering-/.f64100.0

      \[\leadsto \mathsf{fma}\left(0.5, \color{blue}{\frac{x}{y}}, 0.5\right) \]
  5. Simplified100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, \frac{x}{y}, 0.5\right)} \]
  6. Add Preprocessing

Alternative 2: 97.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x + y}{y + y}\\ t_1 := \frac{x}{y + y}\\ \mathbf{if}\;t\_0 \leq -10000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (+ x y) (+ y y))) (t_1 (/ x (+ y y))))
   (if (<= t_0 -10000.0) t_1 (if (<= t_0 1.0) 0.5 t_1))))
double code(double x, double y) {
	double t_0 = (x + y) / (y + y);
	double t_1 = x / (y + y);
	double tmp;
	if (t_0 <= -10000.0) {
		tmp = t_1;
	} else if (t_0 <= 1.0) {
		tmp = 0.5;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x + y) / (y + y)
    t_1 = x / (y + y)
    if (t_0 <= (-10000.0d0)) then
        tmp = t_1
    else if (t_0 <= 1.0d0) then
        tmp = 0.5d0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (x + y) / (y + y);
	double t_1 = x / (y + y);
	double tmp;
	if (t_0 <= -10000.0) {
		tmp = t_1;
	} else if (t_0 <= 1.0) {
		tmp = 0.5;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = (x + y) / (y + y)
	t_1 = x / (y + y)
	tmp = 0
	if t_0 <= -10000.0:
		tmp = t_1
	elif t_0 <= 1.0:
		tmp = 0.5
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(Float64(x + y) / Float64(y + y))
	t_1 = Float64(x / Float64(y + y))
	tmp = 0.0
	if (t_0 <= -10000.0)
		tmp = t_1;
	elseif (t_0 <= 1.0)
		tmp = 0.5;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x + y) / (y + y);
	t_1 = x / (y + y);
	tmp = 0.0;
	if (t_0 <= -10000.0)
		tmp = t_1;
	elseif (t_0 <= 1.0)
		tmp = 0.5;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(y + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(y + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -10000.0], t$95$1, If[LessEqual[t$95$0, 1.0], 0.5, t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x + y}{y + y}\\
t_1 := \frac{x}{y + y}\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;0.5\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 x y) (+.f64 y y)) < -1e4 or 1 < (/.f64 (+.f64 x y) (+.f64 y y))

    1. Initial program 100.0%

      \[\frac{x + y}{y + y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \frac{\color{blue}{x}}{y + y} \]
    4. Step-by-step derivation
      1. Simplified97.5%

        \[\leadsto \frac{\color{blue}{x}}{y + y} \]

      if -1e4 < (/.f64 (+.f64 x y) (+.f64 y y)) < 1

      1. Initial program 100.0%

        \[\frac{x + y}{y + y} \]
      2. Add Preprocessing
      3. Taylor expanded in x around 0

        \[\leadsto \color{blue}{\frac{1}{2}} \]
      4. Step-by-step derivation
        1. Simplified97.2%

          \[\leadsto \color{blue}{0.5} \]
      5. Recombined 2 regimes into one program.
      6. Add Preprocessing

      Alternative 3: 50.9% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5.6 \cdot 10^{+200}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(y + y\right)\right)\\ \end{array} \end{array} \]
      (FPCore (x y) :precision binary64 (if (<= x 5.6e+200) 0.5 (* x (* x (+ y y)))))
      double code(double x, double y) {
      	double tmp;
      	if (x <= 5.6e+200) {
      		tmp = 0.5;
      	} else {
      		tmp = x * (x * (y + y));
      	}
      	return tmp;
      }
      
      real(8) function code(x, y)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8) :: tmp
          if (x <= 5.6d+200) then
              tmp = 0.5d0
          else
              tmp = x * (x * (y + y))
          end if
          code = tmp
      end function
      
      public static double code(double x, double y) {
      	double tmp;
      	if (x <= 5.6e+200) {
      		tmp = 0.5;
      	} else {
      		tmp = x * (x * (y + y));
      	}
      	return tmp;
      }
      
      def code(x, y):
      	tmp = 0
      	if x <= 5.6e+200:
      		tmp = 0.5
      	else:
      		tmp = x * (x * (y + y))
      	return tmp
      
      function code(x, y)
      	tmp = 0.0
      	if (x <= 5.6e+200)
      		tmp = 0.5;
      	else
      		tmp = Float64(x * Float64(x * Float64(y + y)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y)
      	tmp = 0.0;
      	if (x <= 5.6e+200)
      		tmp = 0.5;
      	else
      		tmp = x * (x * (y + y));
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_] := If[LessEqual[x, 5.6e+200], 0.5, N[(x * N[(x * N[(y + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq 5.6 \cdot 10^{+200}:\\
      \;\;\;\;0.5\\
      
      \mathbf{else}:\\
      \;\;\;\;x \cdot \left(x \cdot \left(y + y\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 5.59999999999999969e200

        1. Initial program 100.0%

          \[\frac{x + y}{y + y} \]
        2. Add Preprocessing
        3. Taylor expanded in x around 0

          \[\leadsto \color{blue}{\frac{1}{2}} \]
        4. Step-by-step derivation
          1. Simplified53.5%

            \[\leadsto \color{blue}{0.5} \]

          if 5.59999999999999969e200 < x

          1. Initial program 100.0%

            \[\frac{x + y}{y + y} \]
          2. Add Preprocessing
          3. Taylor expanded in x around inf

            \[\leadsto \frac{\color{blue}{x}}{y + y} \]
          4. Step-by-step derivation
            1. Simplified91.0%

              \[\leadsto \frac{\color{blue}{x}}{y + y} \]
            2. Step-by-step derivation
              1. clear-numN/A

                \[\leadsto \color{blue}{\frac{1}{\frac{y + y}{x}}} \]
              2. associate-/r/N/A

                \[\leadsto \color{blue}{\frac{1}{y + y} \cdot x} \]
              3. flip-+N/A

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

                \[\leadsto \frac{1}{\frac{\color{blue}{0}}{y - y}} \cdot x \]
              5. +-inversesN/A

                \[\leadsto \frac{1}{\frac{\color{blue}{y - y}}{y - y}} \cdot x \]
              6. +-inversesN/A

                \[\leadsto \frac{1}{\frac{y - y}{\color{blue}{0}}} \cdot x \]
              7. +-inversesN/A

                \[\leadsto \frac{1}{\frac{y - y}{\color{blue}{y \cdot y - y \cdot y}}} \cdot x \]
              8. clear-numN/A

                \[\leadsto \color{blue}{\frac{y \cdot y - y \cdot y}{y - y}} \cdot x \]
              9. flip-+N/A

                \[\leadsto \color{blue}{\left(y + y\right)} \cdot x \]
              10. *-lowering-*.f64N/A

                \[\leadsto \color{blue}{\left(y + y\right) \cdot x} \]
              11. +-lowering-+.f644.4

                \[\leadsto \color{blue}{\left(y + y\right)} \cdot x \]
            3. Applied egg-rr4.4%

              \[\leadsto \color{blue}{\left(y + y\right) \cdot x} \]
            4. Step-by-step derivation
              1. flip-+N/A

                \[\leadsto \color{blue}{\frac{y \cdot y - y \cdot y}{y - y}} \cdot x \]
              2. +-inversesN/A

                \[\leadsto \frac{\color{blue}{0}}{y - y} \cdot x \]
              3. mul0-lftN/A

                \[\leadsto \frac{\color{blue}{0 \cdot x}}{y - y} \cdot x \]
              4. +-inversesN/A

                \[\leadsto \frac{0 \cdot x}{\color{blue}{0}} \cdot x \]
              5. associate-*l/N/A

                \[\leadsto \color{blue}{\left(\frac{0}{0} \cdot x\right)} \cdot x \]
              6. +-inversesN/A

                \[\leadsto \left(\frac{\color{blue}{y \cdot y - y \cdot y}}{0} \cdot x\right) \cdot x \]
              7. +-inversesN/A

                \[\leadsto \left(\frac{y \cdot y - y \cdot y}{\color{blue}{y - y}} \cdot x\right) \cdot x \]
              8. flip-+N/A

                \[\leadsto \left(\color{blue}{\left(y + y\right)} \cdot x\right) \cdot x \]
              9. *-lowering-*.f64N/A

                \[\leadsto \color{blue}{\left(\left(y + y\right) \cdot x\right)} \cdot x \]
              10. +-lowering-+.f6436.6

                \[\leadsto \left(\color{blue}{\left(y + y\right)} \cdot x\right) \cdot x \]
            5. Applied egg-rr36.6%

              \[\leadsto \color{blue}{\left(\left(y + y\right) \cdot x\right)} \cdot x \]
          5. Recombined 2 regimes into one program.
          6. Final simplification52.1%

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.6 \cdot 10^{+200}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(y + y\right)\right)\\ \end{array} \]
          7. Add Preprocessing

          Alternative 4: 99.9% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \frac{x + y}{y + y} \end{array} \]
          (FPCore (x y) :precision binary64 (/ (+ x y) (+ y y)))
          double code(double x, double y) {
          	return (x + y) / (y + y);
          }
          
          real(8) function code(x, y)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              code = (x + y) / (y + y)
          end function
          
          public static double code(double x, double y) {
          	return (x + y) / (y + y);
          }
          
          def code(x, y):
          	return (x + y) / (y + y)
          
          function code(x, y)
          	return Float64(Float64(x + y) / Float64(y + y))
          end
          
          function tmp = code(x, y)
          	tmp = (x + y) / (y + y);
          end
          
          code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(y + y), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \frac{x + y}{y + y}
          \end{array}
          
          Derivation
          1. Initial program 100.0%

            \[\frac{x + y}{y + y} \]
          2. Add Preprocessing
          3. Add Preprocessing

          Alternative 5: 49.4% accurate, 18.0× speedup?

          \[\begin{array}{l} \\ 0.5 \end{array} \]
          (FPCore (x y) :precision binary64 0.5)
          double code(double x, double y) {
          	return 0.5;
          }
          
          real(8) function code(x, y)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              code = 0.5d0
          end function
          
          public static double code(double x, double y) {
          	return 0.5;
          }
          
          def code(x, y):
          	return 0.5
          
          function code(x, y)
          	return 0.5
          end
          
          function tmp = code(x, y)
          	tmp = 0.5;
          end
          
          code[x_, y_] := 0.5
          
          \begin{array}{l}
          
          \\
          0.5
          \end{array}
          
          Derivation
          1. Initial program 100.0%

            \[\frac{x + y}{y + y} \]
          2. Add Preprocessing
          3. Taylor expanded in x around 0

            \[\leadsto \color{blue}{\frac{1}{2}} \]
          4. Step-by-step derivation
            1. Simplified49.6%

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

            Alternative 6: 2.6% accurate, 18.0× speedup?

            \[\begin{array}{l} \\ 0 \end{array} \]
            (FPCore (x y) :precision binary64 0.0)
            double code(double x, double y) {
            	return 0.0;
            }
            
            real(8) function code(x, y)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                code = 0.0d0
            end function
            
            public static double code(double x, double y) {
            	return 0.0;
            }
            
            def code(x, y):
            	return 0.0
            
            function code(x, y)
            	return 0.0
            end
            
            function tmp = code(x, y)
            	tmp = 0.0;
            end
            
            code[x_, y_] := 0.0
            
            \begin{array}{l}
            
            \\
            0
            \end{array}
            
            Derivation
            1. Initial program 100.0%

              \[\frac{x + y}{y + y} \]
            2. Add Preprocessing
            3. Taylor expanded in x around inf

              \[\leadsto \frac{\color{blue}{x}}{y + y} \]
            4. Step-by-step derivation
              1. Simplified50.8%

                \[\leadsto \frac{\color{blue}{x}}{y + y} \]
              2. Step-by-step derivation
                1. clear-numN/A

                  \[\leadsto \color{blue}{\frac{1}{\frac{y + y}{x}}} \]
                2. associate-/r/N/A

                  \[\leadsto \color{blue}{\frac{1}{y + y} \cdot x} \]
                3. flip-+N/A

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

                  \[\leadsto \frac{1}{\frac{\color{blue}{0}}{y - y}} \cdot x \]
                5. +-inversesN/A

                  \[\leadsto \frac{1}{\frac{\color{blue}{y - y}}{y - y}} \cdot x \]
                6. +-inversesN/A

                  \[\leadsto \frac{1}{\frac{y - y}{\color{blue}{0}}} \cdot x \]
                7. +-inversesN/A

                  \[\leadsto \frac{1}{\frac{y - y}{\color{blue}{y \cdot y - y \cdot y}}} \cdot x \]
                8. clear-numN/A

                  \[\leadsto \color{blue}{\frac{y \cdot y - y \cdot y}{y - y}} \cdot x \]
                9. flip-+N/A

                  \[\leadsto \color{blue}{\left(y + y\right)} \cdot x \]
                10. *-lowering-*.f64N/A

                  \[\leadsto \color{blue}{\left(y + y\right) \cdot x} \]
                11. +-lowering-+.f643.8

                  \[\leadsto \color{blue}{\left(y + y\right)} \cdot x \]
              3. Applied egg-rr3.8%

                \[\leadsto \color{blue}{\left(y + y\right) \cdot x} \]
              4. Step-by-step derivation
                1. flip-+N/A

                  \[\leadsto \color{blue}{\frac{y \cdot y - y \cdot y}{y - y}} \cdot x \]
                2. +-inversesN/A

                  \[\leadsto \frac{\color{blue}{0}}{y - y} \cdot x \]
                3. mul0-lftN/A

                  \[\leadsto \frac{\color{blue}{0 \cdot x}}{y - y} \cdot x \]
                4. +-inversesN/A

                  \[\leadsto \frac{0 \cdot x}{\color{blue}{0}} \cdot x \]
                5. associate-*l/N/A

                  \[\leadsto \color{blue}{\left(\frac{0}{0} \cdot x\right)} \cdot x \]
                6. +-inversesN/A

                  \[\leadsto \left(\frac{\color{blue}{y \cdot y - y \cdot y}}{0} \cdot x\right) \cdot x \]
                7. +-inversesN/A

                  \[\leadsto \left(\frac{y \cdot y - y \cdot y}{\color{blue}{y - y}} \cdot x\right) \cdot x \]
                8. flip-+N/A

                  \[\leadsto \left(\color{blue}{\left(y + y\right)} \cdot x\right) \cdot x \]
                9. *-lowering-*.f64N/A

                  \[\leadsto \color{blue}{\left(\left(y + y\right) \cdot x\right)} \cdot x \]
                10. +-lowering-+.f645.6

                  \[\leadsto \left(\color{blue}{\left(y + y\right)} \cdot x\right) \cdot x \]
              5. Applied egg-rr5.6%

                \[\leadsto \color{blue}{\left(\left(y + y\right) \cdot x\right)} \cdot x \]
              6. Step-by-step derivation
                1. associate-*l*N/A

                  \[\leadsto \color{blue}{\left(y + y\right) \cdot \left(x \cdot x\right)} \]
                2. flip-+N/A

                  \[\leadsto \color{blue}{\frac{y \cdot y - y \cdot y}{y - y}} \cdot \left(x \cdot x\right) \]
                3. +-inversesN/A

                  \[\leadsto \frac{\color{blue}{0}}{y - y} \cdot \left(x \cdot x\right) \]
                4. metadata-evalN/A

                  \[\leadsto \frac{\color{blue}{0 - 0}}{y - y} \cdot \left(x \cdot x\right) \]
                5. metadata-evalN/A

                  \[\leadsto \frac{\color{blue}{0 \cdot 0} - 0}{y - y} \cdot \left(x \cdot x\right) \]
                6. metadata-evalN/A

                  \[\leadsto \frac{0 \cdot 0 - \color{blue}{0 \cdot 0}}{y - y} \cdot \left(x \cdot x\right) \]
                7. +-inversesN/A

                  \[\leadsto \frac{0 \cdot 0 - 0 \cdot 0}{\color{blue}{0}} \cdot \left(x \cdot x\right) \]
                8. metadata-evalN/A

                  \[\leadsto \frac{0 \cdot 0 - 0 \cdot 0}{\color{blue}{0 + 0}} \cdot \left(x \cdot x\right) \]
                9. flip--N/A

                  \[\leadsto \color{blue}{\left(0 - 0\right)} \cdot \left(x \cdot x\right) \]
                10. metadata-evalN/A

                  \[\leadsto \color{blue}{0} \cdot \left(x \cdot x\right) \]
                11. mul0-lft2.6

                  \[\leadsto \color{blue}{0} \]
              7. Applied egg-rr2.6%

                \[\leadsto \color{blue}{0} \]
              8. Add Preprocessing

              Developer Target 1: 100.0% accurate, 0.9× speedup?

              \[\begin{array}{l} \\ 0.5 \cdot \frac{x}{y} + 0.5 \end{array} \]
              (FPCore (x y) :precision binary64 (+ (* 0.5 (/ x y)) 0.5))
              double code(double x, double y) {
              	return (0.5 * (x / y)) + 0.5;
              }
              
              real(8) function code(x, y)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  code = (0.5d0 * (x / y)) + 0.5d0
              end function
              
              public static double code(double x, double y) {
              	return (0.5 * (x / y)) + 0.5;
              }
              
              def code(x, y):
              	return (0.5 * (x / y)) + 0.5
              
              function code(x, y)
              	return Float64(Float64(0.5 * Float64(x / y)) + 0.5)
              end
              
              function tmp = code(x, y)
              	tmp = (0.5 * (x / y)) + 0.5;
              end
              
              code[x_, y_] := N[(N[(0.5 * N[(x / y), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              0.5 \cdot \frac{x}{y} + 0.5
              \end{array}
              

              Reproduce

              ?
              herbie shell --seed 2024196 
              (FPCore (x y)
                :name "Data.Random.Distribution.T:$ccdf from random-fu-0.2.6.2"
                :precision binary64
              
                :alt
                (! :herbie-platform default (+ (* 1/2 (/ x y)) 1/2))
              
                (/ (+ x y) (+ y y)))