(FPCore (x y z t) :precision binary64 (+ (+ (+ (- (sqrt (+ x 1.0)) (sqrt x)) (- (sqrt (+ y 1.0)) (sqrt y))) (- (sqrt (+ z 1.0)) (sqrt z))) (- (sqrt (+ t 1.0)) (sqrt t))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ (sqrt (+ 1.0 y)) (sqrt y)))
(t_2 (+ (sqrt (+ 1.0 x)) (sqrt x))))
(+
(+ (* (/ 1.0 t_2) (/ (+ t_2 t_1) t_1)) (- (sqrt (+ 1.0 z)) (sqrt z)))
(- (sqrt (+ 1.0 t)) (sqrt t)))))double code(double x, double y, double z, double t) {
return (((sqrt((x + 1.0)) - sqrt(x)) + (sqrt((y + 1.0)) - sqrt(y))) + (sqrt((z + 1.0)) - sqrt(z))) + (sqrt((t + 1.0)) - sqrt(t));
}
double code(double x, double y, double z, double t) {
double t_1 = sqrt((1.0 + y)) + sqrt(y);
double t_2 = sqrt((1.0 + x)) + sqrt(x);
return (((1.0 / t_2) * ((t_2 + t_1) / t_1)) + (sqrt((1.0 + z)) - sqrt(z))) + (sqrt((1.0 + t)) - sqrt(t));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((sqrt((x + 1.0d0)) - sqrt(x)) + (sqrt((y + 1.0d0)) - sqrt(y))) + (sqrt((z + 1.0d0)) - sqrt(z))) + (sqrt((t + 1.0d0)) - sqrt(t))
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
t_1 = sqrt((1.0d0 + y)) + sqrt(y)
t_2 = sqrt((1.0d0 + x)) + sqrt(x)
code = (((1.0d0 / t_2) * ((t_2 + t_1) / t_1)) + (sqrt((1.0d0 + z)) - sqrt(z))) + (sqrt((1.0d0 + t)) - sqrt(t))
end function
public static double code(double x, double y, double z, double t) {
return (((Math.sqrt((x + 1.0)) - Math.sqrt(x)) + (Math.sqrt((y + 1.0)) - Math.sqrt(y))) + (Math.sqrt((z + 1.0)) - Math.sqrt(z))) + (Math.sqrt((t + 1.0)) - Math.sqrt(t));
}
public static double code(double x, double y, double z, double t) {
double t_1 = Math.sqrt((1.0 + y)) + Math.sqrt(y);
double t_2 = Math.sqrt((1.0 + x)) + Math.sqrt(x);
return (((1.0 / t_2) * ((t_2 + t_1) / t_1)) + (Math.sqrt((1.0 + z)) - Math.sqrt(z))) + (Math.sqrt((1.0 + t)) - Math.sqrt(t));
}
def code(x, y, z, t): return (((math.sqrt((x + 1.0)) - math.sqrt(x)) + (math.sqrt((y + 1.0)) - math.sqrt(y))) + (math.sqrt((z + 1.0)) - math.sqrt(z))) + (math.sqrt((t + 1.0)) - math.sqrt(t))
def code(x, y, z, t): t_1 = math.sqrt((1.0 + y)) + math.sqrt(y) t_2 = math.sqrt((1.0 + x)) + math.sqrt(x) return (((1.0 / t_2) * ((t_2 + t_1) / t_1)) + (math.sqrt((1.0 + z)) - math.sqrt(z))) + (math.sqrt((1.0 + t)) - math.sqrt(t))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) + Float64(sqrt(Float64(y + 1.0)) - sqrt(y))) + Float64(sqrt(Float64(z + 1.0)) - sqrt(z))) + Float64(sqrt(Float64(t + 1.0)) - sqrt(t))) end
function code(x, y, z, t) t_1 = Float64(sqrt(Float64(1.0 + y)) + sqrt(y)) t_2 = Float64(sqrt(Float64(1.0 + x)) + sqrt(x)) return Float64(Float64(Float64(Float64(1.0 / t_2) * Float64(Float64(t_2 + t_1) / t_1)) + Float64(sqrt(Float64(1.0 + z)) - sqrt(z))) + Float64(sqrt(Float64(1.0 + t)) - sqrt(t))) end
function tmp = code(x, y, z, t) tmp = (((sqrt((x + 1.0)) - sqrt(x)) + (sqrt((y + 1.0)) - sqrt(y))) + (sqrt((z + 1.0)) - sqrt(z))) + (sqrt((t + 1.0)) - sqrt(t)); end
function tmp = code(x, y, z, t) t_1 = sqrt((1.0 + y)) + sqrt(y); t_2 = sqrt((1.0 + x)) + sqrt(x); tmp = (((1.0 / t_2) * ((t_2 + t_1) / t_1)) + (sqrt((1.0 + z)) - sqrt(z))) + (sqrt((1.0 + t)) - sqrt(t)); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(z + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(t + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(1.0 / t$95$2), $MachinePrecision] * N[(N[(t$95$2 + t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)
\begin{array}{l}
t_1 := \sqrt{1 + y} + \sqrt{y}\\
t_2 := \sqrt{1 + x} + \sqrt{x}\\
\left(\frac{1}{t_2} \cdot \frac{t_2 + t_1}{t_1} + \left(\sqrt{1 + z} - \sqrt{z}\right)\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 5.0 |
|---|---|
| Target | 0.3 |
| Herbie | 1.3 |
Initial program 5.0
Applied egg-rr4.7
Taylor expanded in x around 0 2.4
Applied egg-rr1.3
Applied egg-rr1.3
Final simplification1.3
herbie shell --seed 2022160
(FPCore (x y z t)
:name "Main:z from "
:precision binary64
:herbie-target
(+ (+ (+ (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x))) (/ 1.0 (+ (sqrt (+ y 1.0)) (sqrt y)))) (/ 1.0 (+ (sqrt (+ z 1.0)) (sqrt z)))) (- (sqrt (+ t 1.0)) (sqrt t)))
(+ (+ (+ (- (sqrt (+ x 1.0)) (sqrt x)) (- (sqrt (+ y 1.0)) (sqrt y))) (- (sqrt (+ z 1.0)) (sqrt z))) (- (sqrt (+ t 1.0)) (sqrt t))))