log(x)*20/log(10)

Percentage Accurate: 99.6% → 99.6%
Time: 1.3s
Alternatives: 1
Speedup: 1.0×

Specification

?
\[-1000 \leq x \land x \leq 1000\]
\[\begin{array}{l} \\ \log x \cdot 20 \end{array} \]
(FPCore (x) :precision binary64 (* (log x) 20.0))
double code(double x) {
	return log(x) * 20.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = log(x) * 20.0d0
end function
public static double code(double x) {
	return Math.log(x) * 20.0;
}
def code(x):
	return math.log(x) * 20.0
function code(x)
	return Float64(log(x) * 20.0)
end
function tmp = code(x)
	tmp = log(x) * 20.0;
end
code[x_] := N[(N[Log[x], $MachinePrecision] * 20.0), $MachinePrecision]
\begin{array}{l}

\\
\log x \cdot 20
\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: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \log x \cdot 20 \end{array} \]
(FPCore (x) :precision binary64 (* (log x) 20.0))
double code(double x) {
	return log(x) * 20.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = log(x) * 20.0d0
end function
public static double code(double x) {
	return Math.log(x) * 20.0;
}
def code(x):
	return math.log(x) * 20.0
function code(x)
	return Float64(log(x) * 20.0)
end
function tmp = code(x)
	tmp = log(x) * 20.0;
end
code[x_] := N[(N[Log[x], $MachinePrecision] * 20.0), $MachinePrecision]
\begin{array}{l}

\\
\log x \cdot 20
\end{array}

Alternative 1: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 20 \cdot \log x \end{array} \]
(FPCore (x) :precision binary64 (* 20.0 (log x)))
double code(double x) {
	return 20.0 * log(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 20.0d0 * log(x)
end function
public static double code(double x) {
	return 20.0 * Math.log(x);
}
def code(x):
	return 20.0 * math.log(x)
function code(x)
	return Float64(20.0 * log(x))
end
function tmp = code(x)
	tmp = 20.0 * log(x);
end
code[x_] := N[(20.0 * N[Log[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
20 \cdot \log x
\end{array}
Derivation
  1. Initial program 99.5%

    \[\log x \cdot 20 \]
  2. Add Preprocessing
  3. Final simplification99.5%

    \[\leadsto 20 \cdot \log x \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 1 
(FPCore (x)
  :name "log(x)*20/log(10)"
  :precision binary64
  :pre (and (<= -1000.0 x) (<= x 1000.0))
  (* (log x) 20.0))