
(FPCore (x) :precision binary64 (/ x (+ (* x x) 1)))
double code(double x) {
return x / ((x * x) + 1.0);
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = x / ((x * x) + 1.0d0)
end function
public static double code(double x) {
return x / ((x * x) + 1.0);
}
def code(x): return x / ((x * x) + 1.0)
function code(x) return Float64(x / Float64(Float64(x * x) + 1.0)) end
function tmp = code(x) tmp = x / ((x * x) + 1.0); end
code[x_] := N[(x / N[(N[(x * x), $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision]
\frac{x}{x \cdot x + 1}
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ x (+ (* x x) 1)))
double code(double x) {
return x / ((x * x) + 1.0);
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = x / ((x * x) + 1.0d0)
end function
public static double code(double x) {
return x / ((x * x) + 1.0);
}
def code(x): return x / ((x * x) + 1.0)
function code(x) return Float64(x / Float64(Float64(x * x) + 1.0)) end
function tmp = code(x) tmp = x / ((x * x) + 1.0); end
code[x_] := N[(x / N[(N[(x * x), $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision]
\frac{x}{x \cdot x + 1}
(FPCore (x) :precision binary64 (/ 1 (- x (/ -1 x))))
double code(double x) {
return 1.0 / (x - (-1.0 / x));
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 1.0d0 / (x - ((-1.0d0) / x))
end function
public static double code(double x) {
return 1.0 / (x - (-1.0 / x));
}
def code(x): return 1.0 / (x - (-1.0 / x))
function code(x) return Float64(1.0 / Float64(x - Float64(-1.0 / x))) end
function tmp = code(x) tmp = 1.0 / (x - (-1.0 / x)); end
code[x_] := N[(1 / N[(x - N[(-1 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{x - \frac{-1}{x}}
Initial program 77.1%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
frac-2negN/A
add-sound-/N/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
lower--.f64N/A
metadata-eval77.1%
Applied rewrites77.1%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate-/r/N/A
lift-/.f64N/A
lift-/.f6477.1%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
sub-to-fraction-revN/A
lower--.f64N/A
add-sound-/N/A
lower-/.f6499.9%
Applied rewrites99.9%
herbie shell --seed 2025326 -o generate:taylor -o generate:evaluate
(FPCore (x)
:name "x / (x^2 + 1)"
:precision binary64
(/ x (+ (* x x) 1)))