
(FPCore (x y z) :precision binary64 :pre TRUE (* x (sqrt (- (* y y) (* z z)))))
double code(double x, double y, double z) {
return x * sqrt(((y * y) - (z * 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 = x * sqrt(((y * y) - (z * z)))
end function
public static double code(double x, double y, double z) {
return x * Math.sqrt(((y * y) - (z * z)));
}
def code(x, y, z): return x * math.sqrt(((y * y) - (z * z)))
function code(x, y, z) return Float64(x * sqrt(Float64(Float64(y * y) - Float64(z * z)))) end
function tmp = code(x, y, z) tmp = x * sqrt(((y * y) - (z * z))); end
code[x_, y_, z_] := N[(x * N[Sqrt[N[(N[(y * y), $MachinePrecision] - N[(z * 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 = x * (sqrt(((y * y) - (z * z)))) END code
x \cdot \sqrt{y \cdot y - z \cdot z}
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (* x (sqrt (- (* y y) (* z z)))))
double code(double x, double y, double z) {
return x * sqrt(((y * y) - (z * 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 = x * sqrt(((y * y) - (z * z)))
end function
public static double code(double x, double y, double z) {
return x * Math.sqrt(((y * y) - (z * z)));
}
def code(x, y, z): return x * math.sqrt(((y * y) - (z * z)))
function code(x, y, z) return Float64(x * sqrt(Float64(Float64(y * y) - Float64(z * z)))) end
function tmp = code(x, y, z) tmp = x * sqrt(((y * y) - (z * z))); end
code[x_, y_, z_] := N[(x * N[Sqrt[N[(N[(y * y), $MachinePrecision] - N[(z * 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 = x * (sqrt(((y * y) - (z * z)))) END code
x \cdot \sqrt{y \cdot y - z \cdot z}
(FPCore (x y z) :precision binary64 :pre TRUE (* (sqrt (fabs (+ z (fabs y)))) (* (sqrt (fabs (- (fabs y) z))) x)))
double code(double x, double y, double z) {
return sqrt(fabs((z + fabs(y)))) * (sqrt(fabs((fabs(y) - z))) * 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 = sqrt(abs((z + abs(y)))) * (sqrt(abs((abs(y) - z))) * x)
end function
public static double code(double x, double y, double z) {
return Math.sqrt(Math.abs((z + Math.abs(y)))) * (Math.sqrt(Math.abs((Math.abs(y) - z))) * x);
}
def code(x, y, z): return math.sqrt(math.fabs((z + math.fabs(y)))) * (math.sqrt(math.fabs((math.fabs(y) - z))) * x)
function code(x, y, z) return Float64(sqrt(abs(Float64(z + abs(y)))) * Float64(sqrt(abs(Float64(abs(y) - z))) * x)) end
function tmp = code(x, y, z) tmp = sqrt(abs((z + abs(y)))) * (sqrt(abs((abs(y) - z))) * x); end
code[x_, y_, z_] := N[(N[Sqrt[N[Abs[N[(z + N[Abs[y], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[Abs[N[(N[Abs[y], $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * 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 = (sqrt((abs((z + (abs(y))))))) * ((sqrt((abs(((abs(y)) - z))))) * x) END code
\sqrt{\left|z + \left|y\right|\right|} \cdot \left(\sqrt{\left|\left|y\right| - z\right|} \cdot x\right)
Initial program 68.4%
Applied rewrites99.4%
(FPCore (x y z) :precision binary64 :pre TRUE (* x (fabs y)))
double code(double x, double y, double z) {
return x * fabs(y);
}
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 = x * abs(y)
end function
public static double code(double x, double y, double z) {
return x * Math.abs(y);
}
def code(x, y, z): return x * math.fabs(y)
function code(x, y, z) return Float64(x * abs(y)) end
function tmp = code(x, y, z) tmp = x * abs(y); end
code[x_, y_, z_] := N[(x * N[Abs[y], $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 = x * (abs(y)) END code
x \cdot \left|y\right|
Initial program 68.4%
Taylor expanded in y around inf
Applied rewrites52.3%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, B"
:precision binary64
(* x (sqrt (- (* y y) (* z z)))))