
(FPCore (x y) :precision binary64 :pre TRUE (- x (* (/ 3.0 8.0) y)))
double code(double x, double y) {
return x - ((3.0 / 8.0) * y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x - ((3.0d0 / 8.0d0) * y)
end function
public static double code(double x, double y) {
return x - ((3.0 / 8.0) * y);
}
def code(x, y): return x - ((3.0 / 8.0) * y)
function code(x, y) return Float64(x - Float64(Float64(3.0 / 8.0) * y)) end
function tmp = code(x, y) tmp = x - ((3.0 / 8.0) * y); end
code[x_, y_] := N[(x - N[(N[(3.0 / 8.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x - (((3) / (8)) * y) END code
x - \frac{3}{8} \cdot y
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (- x (* (/ 3.0 8.0) y)))
double code(double x, double y) {
return x - ((3.0 / 8.0) * y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x - ((3.0d0 / 8.0d0) * y)
end function
public static double code(double x, double y) {
return x - ((3.0 / 8.0) * y);
}
def code(x, y): return x - ((3.0 / 8.0) * y)
function code(x, y) return Float64(x - Float64(Float64(3.0 / 8.0) * y)) end
function tmp = code(x, y) tmp = x - ((3.0 / 8.0) * y); end
code[x_, y_] := N[(x - N[(N[(3.0 / 8.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x - (((3) / (8)) * y) END code
x - \frac{3}{8} \cdot y
(FPCore (x y) :precision binary64 :pre TRUE (fma -0.375 y x))
double code(double x, double y) {
return fma(-0.375, y, x);
}
function code(x, y) return fma(-0.375, y, x) end
code[x_, y_] := N[(-0.375 * y + x), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((-375e-3) * y) + x END code
\mathsf{fma}\left(-0.375, y, x\right)
Initial program 99.9%
Applied rewrites100.0%
(FPCore (x y) :precision binary64 :pre TRUE (* -0.375 y))
double code(double x, double y) {
return -0.375 * y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (-0.375d0) * y
end function
public static double code(double x, double y) {
return -0.375 * y;
}
def code(x, y): return -0.375 * y
function code(x, y) return Float64(-0.375 * y) end
function tmp = code(x, y) tmp = -0.375 * y; end
code[x_, y_] := N[(-0.375 * y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (-375e-3) * y END code
-0.375 \cdot y
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites50.0%
herbie shell --seed 2026092
(FPCore (x y)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, A"
:precision binary64
(- x (* (/ 3.0 8.0) y)))