(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ y 1.0) (/ x z)) x)))
(if (<= x -839233400368095400.0)
t_0
(if (<= x 4.719777420475578e-12) (- (/ (+ x (* x y)) z) x) t_0))))double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
double code(double x, double y, double z) {
double t_0 = ((y + 1.0) * (x / z)) - x;
double tmp;
if (x <= -839233400368095400.0) {
tmp = t_0;
} else if (x <= 4.719777420475578e-12) {
tmp = ((x + (x * y)) / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((y + 1.0d0) * (x / z)) - x
if (x <= (-839233400368095400.0d0)) then
tmp = t_0
else if (x <= 4.719777420475578d-12) then
tmp = ((x + (x * y)) / z) - x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
public static double code(double x, double y, double z) {
double t_0 = ((y + 1.0) * (x / z)) - x;
double tmp;
if (x <= -839233400368095400.0) {
tmp = t_0;
} else if (x <= 4.719777420475578e-12) {
tmp = ((x + (x * y)) / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
def code(x, y, z): t_0 = ((y + 1.0) * (x / z)) - x tmp = 0 if x <= -839233400368095400.0: tmp = t_0 elif x <= 4.719777420475578e-12: tmp = ((x + (x * y)) / z) - x else: tmp = t_0 return tmp
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function code(x, y, z) t_0 = Float64(Float64(Float64(y + 1.0) * Float64(x / z)) - x) tmp = 0.0 if (x <= -839233400368095400.0) tmp = t_0; elseif (x <= 4.719777420475578e-12) tmp = Float64(Float64(Float64(x + Float64(x * y)) / z) - x); else tmp = t_0; end return tmp end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
function tmp_2 = code(x, y, z) t_0 = ((y + 1.0) * (x / z)) - x; tmp = 0.0; if (x <= -839233400368095400.0) tmp = t_0; elseif (x <= 4.719777420475578e-12) tmp = ((x + (x * y)) / z) - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y + 1.0), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[x, -839233400368095400.0], t$95$0, If[LessEqual[x, 4.719777420475578e-12], N[(N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] - x), $MachinePrecision], t$95$0]]]
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
t_0 := \left(y + 1\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x \leq -839233400368095400:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4.719777420475578 \cdot 10^{-12}:\\
\;\;\;\;\frac{x + x \cdot y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.1 |
|---|---|
| Target | 0.4 |
| Herbie | 0.1 |
if x < -839233400368095360 or 4.7197774204755782e-12 < x Initial program 26.0
Simplified8.4
Taylor expanded in y around 0 8.4
Applied egg-rr0.1
Applied egg-rr0.1
if -839233400368095360 < x < 4.7197774204755782e-12Initial program 0.2
Simplified0.1
Taylor expanded in z around 0 0.1
Final simplification0.1
herbie shell --seed 2022153
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))