
(FPCore (x y z) :precision binary64 :pre TRUE (* (/ 1.0 2.0) (+ x (* y (sqrt z)))))
double code(double x, double y, double z) {
return (1.0 / 2.0) * (x + (y * sqrt(z)));
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / 2.0d0) * (x + (y * sqrt(z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / 2.0) * (x + (y * Math.sqrt(z)));
}
def code(x, y, z): return (1.0 / 2.0) * (x + (y * math.sqrt(z)))
function code(x, y, z) return Float64(Float64(1.0 / 2.0) * Float64(x + Float64(y * sqrt(z)))) end
function tmp = code(x, y, z) tmp = (1.0 / 2.0) * (x + (y * sqrt(z))); end
code[x_, y_, z_] := N[(N[(1.0 / 2.0), $MachinePrecision] * N[(x + N[(y * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = ((1) / (2)) * (x + (y * (sqrt(z)))) END code
\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right)
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (* (/ 1.0 2.0) (+ x (* y (sqrt z)))))
double code(double x, double y, double z) {
return (1.0 / 2.0) * (x + (y * sqrt(z)));
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / 2.0d0) * (x + (y * sqrt(z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / 2.0) * (x + (y * Math.sqrt(z)));
}
def code(x, y, z): return (1.0 / 2.0) * (x + (y * math.sqrt(z)))
function code(x, y, z) return Float64(Float64(1.0 / 2.0) * Float64(x + Float64(y * sqrt(z)))) end
function tmp = code(x, y, z) tmp = (1.0 / 2.0) * (x + (y * sqrt(z))); end
code[x_, y_, z_] := N[(N[(1.0 / 2.0), $MachinePrecision] * N[(x + N[(y * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = ((1) / (2)) * (x + (y * (sqrt(z)))) END code
\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right)
(FPCore (x y z) :precision binary64 :pre TRUE (* 0.5 (+ x (* y (sqrt z)))))
double code(double x, double y, double z) {
return 0.5 * (x + (y * sqrt(z)));
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * (x + (y * sqrt(z)))
end function
public static double code(double x, double y, double z) {
return 0.5 * (x + (y * Math.sqrt(z)));
}
def code(x, y, z): return 0.5 * (x + (y * math.sqrt(z)))
function code(x, y, z) return Float64(0.5 * Float64(x + Float64(y * sqrt(z)))) end
function tmp = code(x, y, z) tmp = 0.5 * (x + (y * sqrt(z))); end
code[x_, y_, z_] := N[(0.5 * N[(x + N[(y * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (5e-1) * (x + (y * (sqrt(z)))) END code
0.5 \cdot \left(x + y \cdot \sqrt{z}\right)
Initial program 99.8%
Evaluated real constant99.8%
(FPCore (x y z) :precision binary64 :pre TRUE (* 0.5 (fma (sqrt z) y x)))
double code(double x, double y, double z) {
return 0.5 * fma(sqrt(z), y, x);
}
function code(x, y, z) return Float64(0.5 * fma(sqrt(z), y, x)) end
code[x_, y_, z_] := N[(0.5 * N[(N[Sqrt[z], $MachinePrecision] * y + x), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (5e-1) * (((sqrt(z)) * y) + x) END code
0.5 \cdot \mathsf{fma}\left(\sqrt{z}, y, x\right)
Initial program 99.8%
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 :pre TRUE (if (<= x -17135672566.239237) (* 0.5 x) (if (<= x 5.62844316176412e-46) (* 0.5 (* y (sqrt z))) (* 0.5 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -17135672566.239237) {
tmp = 0.5 * x;
} else if (x <= 5.62844316176412e-46) {
tmp = 0.5 * (y * sqrt(z));
} else {
tmp = 0.5 * x;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-17135672566.239237d0)) then
tmp = 0.5d0 * x
else if (x <= 5.62844316176412d-46) then
tmp = 0.5d0 * (y * sqrt(z))
else
tmp = 0.5d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -17135672566.239237) {
tmp = 0.5 * x;
} else if (x <= 5.62844316176412e-46) {
tmp = 0.5 * (y * Math.sqrt(z));
} else {
tmp = 0.5 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -17135672566.239237: tmp = 0.5 * x elif x <= 5.62844316176412e-46: tmp = 0.5 * (y * math.sqrt(z)) else: tmp = 0.5 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -17135672566.239237) tmp = Float64(0.5 * x); elseif (x <= 5.62844316176412e-46) tmp = Float64(0.5 * Float64(y * sqrt(z))); else tmp = Float64(0.5 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -17135672566.239237) tmp = 0.5 * x; elseif (x <= 5.62844316176412e-46) tmp = 0.5 * (y * sqrt(z)); else tmp = 0.5 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -17135672566.239237], N[(0.5 * x), $MachinePrecision], If[LessEqual[x, 5.62844316176412e-46], N[(0.5 * N[(y * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * x), $MachinePrecision]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET tmp_1 = IF (x <= (5628443161764119920644829953410590951875344298681555851493315816868097534915156825371220837143217692897771044975596156645369916304844082333147525787353515625e-202)) THEN ((5e-1) * (y * (sqrt(z)))) ELSE ((5e-1) * x) ENDIF IN LET tmp = IF (x <= (-171356725662392368316650390625e-19)) THEN ((5e-1) * x) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;x \leq -17135672566.239237:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{elif}\;x \leq 5.62844316176412 \cdot 10^{-46}:\\
\;\;\;\;0.5 \cdot \left(y \cdot \sqrt{z}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot x\\
\end{array}
if x < -17135672566.239237 or 5.6284431617641199e-46 < x Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites51.3%
if -17135672566.239237 < x < 5.6284431617641199e-46Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites50.0%
(FPCore (x y z) :precision binary64 :pre TRUE (* 0.5 x))
double code(double x, double y, double z) {
return 0.5 * x;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * x
end function
public static double code(double x, double y, double z) {
return 0.5 * x;
}
def code(x, y, z): return 0.5 * x
function code(x, y, z) return Float64(0.5 * x) end
function tmp = code(x, y, z) tmp = 0.5 * x; end
code[x_, y_, z_] := N[(0.5 * x), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (5e-1) * x END code
0.5 \cdot x
Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites51.3%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Diagrams.Solve.Polynomial:quadForm from diagrams-solve-0.1, B"
:precision binary64
(* (/ 1.0 2.0) (+ x (* y (sqrt z)))))