
(FPCore (x y) :precision binary64 :pre TRUE (* (+ x y) (- x y)))
double code(double x, double y) {
return (x + y) * (x - y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) * (x - y)
end function
public static double code(double x, double y) {
return (x + y) * (x - y);
}
def code(x, y): return (x + y) * (x - y)
function code(x, y) return Float64(Float64(x + y) * Float64(x - y)) end
function tmp = code(x, y) tmp = (x + y) * (x - y); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (x + y) * (x - y) END code
\left(x + y\right) \cdot \left(x - y\right)
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (* (+ x y) (- x y)))
double code(double x, double y) {
return (x + y) * (x - y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) * (x - y)
end function
public static double code(double x, double y) {
return (x + y) * (x - y);
}
def code(x, y): return (x + y) * (x - y)
function code(x, y) return Float64(Float64(x + y) * Float64(x - y)) end
function tmp = code(x, y) tmp = (x + y) * (x - y); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (x + y) * (x - y) END code
\left(x + y\right) \cdot \left(x - y\right)
(FPCore (x y) :precision binary64 :pre TRUE (* (fabs y) (- (fabs x) (fabs y))))
double code(double x, double y) {
return fabs(y) * (fabs(x) - fabs(y));
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = abs(y) * (abs(x) - abs(y))
end function
public static double code(double x, double y) {
return Math.abs(y) * (Math.abs(x) - Math.abs(y));
}
def code(x, y): return math.fabs(y) * (math.fabs(x) - math.fabs(y))
function code(x, y) return Float64(abs(y) * Float64(abs(x) - abs(y))) end
function tmp = code(x, y) tmp = abs(y) * (abs(x) - abs(y)); end
code[x_, y_] := N[(N[Abs[y], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] - N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (abs(y)) * ((abs(x)) - (abs(y))) END code
\left|y\right| \cdot \left(\left|x\right| - \left|y\right|\right)
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites57.1%
herbie shell --seed 2026092
(FPCore (x y)
:name "Examples.Basics.BasicTests:f1 from sbv-4.4"
:precision binary64
(* (+ x y) (- x y)))