Development.Shake.Profile:generateTrace from shake-0.15.5

Percentage Accurate: 100.0% → 100.0%
Time: 507.0ms
Alternatives: 1
Speedup: 9.0×

Specification

?
\[\begin{array}{l} \\ 1000000 \cdot \left(x - x\right) \end{array} \]
(FPCore (x) :precision binary64 (* 1000000.0 (- x x)))
double code(double x) {
	return 1000000.0 * (x - x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1000000.0d0 * (x - x)
end function
public static double code(double x) {
	return 1000000.0 * (x - x);
}
def code(x):
	return 1000000.0 * (x - x)
function code(x)
	return Float64(1000000.0 * Float64(x - x))
end
function tmp = code(x)
	tmp = 1000000.0 * (x - x);
end
code[x_] := N[(1000000.0 * N[(x - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1000000 \cdot \left(x - x\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 1 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: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 1000000 \cdot \left(x - x\right) \end{array} \]
(FPCore (x) :precision binary64 (* 1000000.0 (- x x)))
double code(double x) {
	return 1000000.0 * (x - x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1000000.0d0 * (x - x)
end function
public static double code(double x) {
	return 1000000.0 * (x - x);
}
def code(x):
	return 1000000.0 * (x - x)
function code(x)
	return Float64(1000000.0 * Float64(x - x))
end
function tmp = code(x)
	tmp = 1000000.0 * (x - x);
end
code[x_] := N[(1000000.0 * N[(x - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1000000 \cdot \left(x - x\right)
\end{array}

Alternative 1: 100.0% accurate, 9.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (x) :precision binary64 0.0)
double code(double x) {
	return 0.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 0.0d0
end function
public static double code(double x) {
	return 0.0;
}
def code(x):
	return 0.0
function code(x)
	return 0.0
end
function tmp = code(x)
	tmp = 0.0;
end
code[x_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 100.0%

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

    \[\leadsto \color{blue}{0} \]
  4. Step-by-step derivation
    1. Applied rewrites100.0%

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

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

    \[\begin{array}{l} \\ 0 \end{array} \]
    (FPCore (x) :precision binary64 0.0)
    double code(double x) {
    	return 0.0;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = 0.0d0
    end function
    
    public static double code(double x) {
    	return 0.0;
    }
    
    def code(x):
    	return 0.0
    
    function code(x)
    	return 0.0
    end
    
    function tmp = code(x)
    	tmp = 0.0;
    end
    
    code[x_] := 0.0
    
    \begin{array}{l}
    
    \\
    0
    \end{array}
    

    Reproduce

    ?
    herbie shell --seed 2024308 
    (FPCore (x)
      :name "Development.Shake.Profile:generateTrace from shake-0.15.5"
      :precision binary64
    
      :alt
      (! :herbie-platform default 0)
    
      (* 1000000.0 (- x x)))