
(FPCore (x y) :precision binary64 :pre TRUE (- (* x 2.0) y))
double code(double x, double y) {
return (x * 2.0) - y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 2.0d0) - y
end function
public static double code(double x, double y) {
return (x * 2.0) - y;
}
def code(x, y): return (x * 2.0) - y
function code(x, y) return Float64(Float64(x * 2.0) - y) end
function tmp = code(x, y) tmp = (x * 2.0) - y; end
code[x_, y_] := N[(N[(x * 2.0), $MachinePrecision] - y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (x * (2)) - y END code
x \cdot 2 - y
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (- (* x 2.0) y))
double code(double x, double y) {
return (x * 2.0) - y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 2.0d0) - y
end function
public static double code(double x, double y) {
return (x * 2.0) - y;
}
def code(x, y): return (x * 2.0) - y
function code(x, y) return Float64(Float64(x * 2.0) - y) end
function tmp = code(x, y) tmp = (x * 2.0) - y; end
code[x_, y_] := N[(N[(x * 2.0), $MachinePrecision] - y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (x * (2)) - y END code
x \cdot 2 - y
(FPCore (x y) :precision binary64 :pre TRUE (- (+ x x) y))
double code(double x, double y) {
return (x + x) - y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + x) - y
end function
public static double code(double x, double y) {
return (x + x) - y;
}
def code(x, y): return (x + x) - y
function code(x, y) return Float64(Float64(x + x) - y) end
function tmp = code(x, y) tmp = (x + x) - y; end
code[x_, y_] := N[(N[(x + x), $MachinePrecision] - y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (x + x) - y END code
\left(x + x\right) - y
Initial program 100.0%
Applied rewrites100.0%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= y -4.155509726251822e+46) (- y) (if (<= y 2.426229654520916e+48) (+ x x) (- y))))
double code(double x, double y) {
double tmp;
if (y <= -4.155509726251822e+46) {
tmp = -y;
} else if (y <= 2.426229654520916e+48) {
tmp = x + x;
} else {
tmp = -y;
}
return tmp;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-4.155509726251822d+46)) then
tmp = -y
else if (y <= 2.426229654520916d+48) then
tmp = x + x
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -4.155509726251822e+46) {
tmp = -y;
} else if (y <= 2.426229654520916e+48) {
tmp = x + x;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.155509726251822e+46: tmp = -y elif y <= 2.426229654520916e+48: tmp = x + x else: tmp = -y return tmp
function code(x, y) tmp = 0.0 if (y <= -4.155509726251822e+46) tmp = Float64(-y); elseif (y <= 2.426229654520916e+48) tmp = Float64(x + x); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4.155509726251822e+46) tmp = -y; elseif (y <= 2.426229654520916e+48) tmp = x + x; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.155509726251822e+46], (-y), If[LessEqual[y, 2.426229654520916e+48], N[(x + x), $MachinePrecision], (-y)]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp_1 = IF (y <= (2426229654520915891643607200729785382101422440448)) THEN (x + x) ELSE (- y) ENDIF IN LET tmp = IF (y <= (-41555097262518219140230899091581622926874509312)) THEN (- y) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;y \leq -4.155509726251822 \cdot 10^{+46}:\\
\;\;\;\;-y\\
\mathbf{elif}\;y \leq 2.426229654520916 \cdot 10^{+48}:\\
\;\;\;\;x + x\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
if y < -4.1555097262518219e46 or 2.4262296545209159e48 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites50.1%
Applied rewrites50.1%
if -4.1555097262518219e46 < y < 2.4262296545209159e48Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites50.1%
Applied rewrites50.1%
Taylor expanded in x around inf
Applied rewrites51.3%
Applied rewrites51.3%
(FPCore (x y) :precision binary64 :pre TRUE (- y))
double code(double x, double y) {
return -y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -y
end function
public static double code(double x, double y) {
return -y;
}
def code(x, y): return -y
function code(x, y) return Float64(-y) end
function tmp = code(x, y) tmp = -y; end
code[x_, y_] := (-y)
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = - y END code
-y
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites50.1%
Applied rewrites50.1%
herbie shell --seed 2026092
(FPCore (x y)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, C"
:precision binary64
(- (* x 2.0) y))