Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C

Percentage Accurate: 99.9% → 99.9%
Time: 1.6s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\mathsf{TRUE}\left(\right)\]
\[\begin{array}{l} \\ 1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z):
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z)
	return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y))
end
function tmp = code(x, y, z)
	tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{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 10 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} \\ 1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z):
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z)
	return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y))
end
function tmp = code(x, y, z)
	tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

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

\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
Derivation
  1. Initial program 100.0%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 71.3% accurate, 1.1× speedup?

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

\\
\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
Derivation
  1. Initial program 100.0%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{1 + \left(4 \cdot \frac{x}{y} + 4 \cdot \frac{\frac{1}{4} \cdot y - z}{y}\right)} \]
  4. Applied rewrites73.5%

    \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}} \]
  5. Add Preprocessing

Alternative 3: 9.5% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.9 \cdot 10^{-10}:\\ \;\;\;\;\frac{y \cdot 0.25}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(1 + \left(\left(x + y \cdot 0.25\right) - z\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -3.9e-10) (/ (* y 0.25) y) (+ 1.0 (+ 1.0 (- (+ x (* y 0.25)) z)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.9e-10) {
		tmp = (y * 0.25) / y;
	} else {
		tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - z));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-3.9d-10)) then
        tmp = (y * 0.25d0) / y
    else
        tmp = 1.0d0 + (1.0d0 + ((x + (y * 0.25d0)) - z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.9e-10) {
		tmp = (y * 0.25) / y;
	} else {
		tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -3.9e-10:
		tmp = (y * 0.25) / y
	else:
		tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -3.9e-10)
		tmp = Float64(Float64(y * 0.25) / y);
	else
		tmp = Float64(1.0 + Float64(1.0 + Float64(Float64(x + Float64(y * 0.25)) - z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -3.9e-10)
		tmp = (y * 0.25) / y;
	else
		tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -3.9e-10], N[(N[(y * 0.25), $MachinePrecision] / y), $MachinePrecision], N[(1.0 + N[(1.0 + N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{-10}:\\
\;\;\;\;\frac{y \cdot 0.25}{y}\\

\mathbf{else}:\\
\;\;\;\;1 + \left(1 + \left(\left(x + y \cdot 0.25\right) - z\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.9e-10

    1. Initial program 100.0%

      \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{1 + \left(4 \cdot \frac{x}{y} + 4 \cdot \frac{\frac{1}{4} \cdot y - z}{y}\right)} \]
    4. Applied rewrites53.5%

      \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}} \]
    5. Taylor expanded in x around inf

      \[\leadsto \color{blue}{4 \cdot \frac{x}{y}} \]
    6. Applied rewrites10.6%

      \[\leadsto \color{blue}{\frac{y \cdot 0.25}{y}} \]

    if -3.9e-10 < y

    1. Initial program 100.0%

      \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto 1 + \color{blue}{\left(4 \cdot \frac{x}{y} + 4 \cdot \frac{\frac{1}{4} \cdot y - z}{y}\right)} \]
    4. Applied rewrites5.0%

      \[\leadsto 1 + \color{blue}{\left(\left(x + y \cdot 0.25\right) - z\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto 1 + \left(\frac{1}{4} \cdot y - \color{blue}{z}\right) \]
    6. Applied rewrites8.1%

      \[\leadsto 1 + \left(1 + \color{blue}{\left(\left(x + y \cdot 0.25\right) - z\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 9.9% accurate, 1.3× speedup?

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

\\
1 + \left(1 + \frac{y \cdot 0.25}{y}\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto 1 + \color{blue}{\left(4 \cdot \frac{x}{y} + 4 \cdot \frac{\frac{1}{4} \cdot y - z}{y}\right)} \]
  4. Applied rewrites3.9%

    \[\leadsto 1 + \color{blue}{\left(\left(x + y \cdot 0.25\right) - z\right)} \]
  5. Taylor expanded in x around 0

    \[\leadsto 1 + \left(\left(x + \frac{1}{4} \cdot y\right) - z\right) \]
  6. Applied rewrites7.6%

    \[\leadsto 1 + \left(\left(1 + \frac{y \cdot 0.25}{y}\right) - z\right) \]
  7. Taylor expanded in x around 0

    \[\leadsto 1 + \color{blue}{\left(4 \cdot \frac{x}{y} + 4 \cdot \frac{\frac{1}{4} \cdot y - z}{y}\right)} \]
  8. Applied rewrites9.4%

    \[\leadsto 1 + \color{blue}{\left(1 + \frac{y \cdot 0.25}{y}\right)} \]
  9. Add Preprocessing

Alternative 5: 8.5% accurate, 1.6× speedup?

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

\\
1 + \frac{y \cdot 0.25}{y}
\end{array}
Derivation
  1. Initial program 100.0%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto 1 + \frac{\color{blue}{4 \cdot \left(\frac{1}{4} \cdot y - z\right)}}{y} \]
  4. Applied rewrites8.1%

    \[\leadsto 1 + \frac{\color{blue}{y \cdot 0.25}}{y} \]
  5. Add Preprocessing

Alternative 6: 7.4% accurate, 1.8× speedup?

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

\\
\frac{y \cdot 0.25}{y}
\end{array}
Derivation
  1. Initial program 100.0%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{1 + \left(4 \cdot \frac{x}{y} + 4 \cdot \frac{\frac{1}{4} \cdot y - z}{y}\right)} \]
  4. Applied rewrites73.5%

    \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}} \]
  5. Taylor expanded in x around inf

    \[\leadsto \color{blue}{4 \cdot \frac{x}{y}} \]
  6. Applied rewrites7.1%

    \[\leadsto \color{blue}{\frac{y \cdot 0.25}{y}} \]
  7. Add Preprocessing

Alternative 7: 6.5% accurate, 2.6× speedup?

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

\\
1 + \left(1 + y \cdot 0.25\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto 1 + \color{blue}{\left(4 \cdot \frac{x}{y} + 4 \cdot \frac{\frac{1}{4} \cdot y - z}{y}\right)} \]
  4. Applied rewrites3.9%

    \[\leadsto 1 + \color{blue}{\left(\left(x + y \cdot 0.25\right) - z\right)} \]
  5. Taylor expanded in x around 0

    \[\leadsto 1 + \left(\left(x + \frac{1}{4} \cdot y\right) - z\right) \]
  6. Applied rewrites7.6%

    \[\leadsto 1 + \left(\left(1 + \frac{y \cdot 0.25}{y}\right) - z\right) \]
  7. Taylor expanded in x around 0

    \[\leadsto 1 + \left(\left(x + \frac{1}{4} \cdot y\right) - \color{blue}{z}\right) \]
  8. Applied rewrites3.4%

    \[\leadsto 1 + y \cdot \color{blue}{0.25} \]
  9. Taylor expanded in x around 0

    \[\leadsto 1 + \left(\left(x + \frac{1}{4} \cdot y\right) - \color{blue}{z}\right) \]
  10. Applied rewrites5.7%

    \[\leadsto 1 + \left(1 + \color{blue}{y \cdot 0.25}\right) \]
  11. Add Preprocessing

Alternative 8: 3.5% accurate, 3.4× speedup?

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

\\
1 + y \cdot 0.25
\end{array}
Derivation
  1. Initial program 100.0%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto 1 + \color{blue}{\left(4 \cdot \frac{x}{y} + 4 \cdot \frac{\frac{1}{4} \cdot y - z}{y}\right)} \]
  4. Applied rewrites3.9%

    \[\leadsto 1 + \color{blue}{\left(\left(x + y \cdot 0.25\right) - z\right)} \]
  5. Taylor expanded in x around 0

    \[\leadsto 1 + \left(\left(x + \frac{1}{4} \cdot y\right) - z\right) \]
  6. Applied rewrites7.6%

    \[\leadsto 1 + \left(\left(1 + \frac{y \cdot 0.25}{y}\right) - z\right) \]
  7. Taylor expanded in x around 0

    \[\leadsto 1 + \left(\left(x + \frac{1}{4} \cdot y\right) - \color{blue}{z}\right) \]
  8. Applied rewrites3.4%

    \[\leadsto 1 + y \cdot \color{blue}{0.25} \]
  9. Add Preprocessing

Alternative 9: 3.1% accurate, 3.4× speedup?

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

\\
x + y \cdot 0.25
\end{array}
Derivation
  1. Initial program 100.0%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto 1 + \color{blue}{\left(4 \cdot \frac{x}{y} + 4 \cdot \frac{\frac{1}{4} \cdot y - z}{y}\right)} \]
  4. Applied rewrites3.9%

    \[\leadsto 1 + \color{blue}{\left(\left(x + y \cdot 0.25\right) - z\right)} \]
  5. Taylor expanded in x around 0

    \[\leadsto 1 + \left(\left(x + \frac{1}{4} \cdot y\right) - z\right) \]
  6. Applied rewrites7.6%

    \[\leadsto 1 + \left(\left(1 + \frac{y \cdot 0.25}{y}\right) - z\right) \]
  7. Taylor expanded in x around inf

    \[\leadsto \color{blue}{4 \cdot \frac{x}{y}} \]
  8. Applied rewrites3.1%

    \[\leadsto \color{blue}{x + y \cdot 0.25} \]
  9. Add Preprocessing

Alternative 10: 2.7% accurate, 5.2× speedup?

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

\\
y \cdot 0.25
\end{array}
Derivation
  1. Initial program 100.0%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{1 + \left(4 \cdot \frac{x}{y} + 4 \cdot \frac{\frac{1}{4} \cdot y - z}{y}\right)} \]
  4. Applied rewrites73.5%

    \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}} \]
  5. Taylor expanded in x around inf

    \[\leadsto x \cdot \color{blue}{\left(4 \cdot \frac{\frac{1}{4} - \frac{z}{y}}{x} + 4 \cdot \frac{1}{y}\right)} \]
  6. Applied rewrites2.6%

    \[\leadsto y \cdot \color{blue}{0.25} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024321 
(FPCore (x y z)
  :name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
  :precision binary64
  :pre (TRUE)
  (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))