
(FPCore (x) :precision binary64 :pre TRUE (+ (* x x) 1.0))
double code(double x) {
return (x * x) + 1.0;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (x * x) + 1.0d0
end function
public static double code(double x) {
return (x * x) + 1.0;
}
def code(x): return (x * x) + 1.0
function code(x) return Float64(Float64(x * x) + 1.0) end
function tmp = code(x) tmp = (x * x) + 1.0; end
code[x_] := N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (x * x) + (1) END code
x \cdot x + 1
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 :pre TRUE (+ (* x x) 1.0))
double code(double x) {
return (x * x) + 1.0;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (x * x) + 1.0d0
end function
public static double code(double x) {
return (x * x) + 1.0;
}
def code(x): return (x * x) + 1.0
function code(x) return Float64(Float64(x * x) + 1.0) end
function tmp = code(x) tmp = (x * x) + 1.0; end
code[x_] := N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (x * x) + (1) END code
x \cdot x + 1
(FPCore (x) :precision binary64 :pre TRUE (fma x x 1.0))
double code(double x) {
return fma(x, x, 1.0);
}
function code(x) return fma(x, x, 1.0) end
code[x_] := N[(x * x + 1.0), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (x * x) + (1) END code
\mathsf{fma}\left(x, x, 1\right)
Initial program 100.0%
Applied rewrites100.0%
(FPCore (x) :precision binary64 :pre TRUE 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = 1 END code
1
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites52.0%
herbie shell --seed 2026092
(FPCore (x)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, A"
:precision binary64
(+ (* x x) 1.0))