(FPCore (x y z t) :precision binary64 (+ x (* (- y x) (/ z t))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* (- y x) (/ z t)))))
(if (<= x -1.5349570345577026e-128)
t_1
(if (<= x 1.5069737614011972e-298) (+ x (* (- (/ y t) (/ x t)) z)) t_1))))double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
double code(double x, double y, double z, double t) {
double t_1 = x + ((y - x) * (z / t));
double tmp;
if (x <= -1.5349570345577026e-128) {
tmp = t_1;
} else if (x <= 1.5069737614011972e-298) {
tmp = x + (((y / t) - (x / t)) * z);
} else {
tmp = t_1;
}
return tmp;
}
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 = x + ((y - x) * (z / 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) :: tmp
t_1 = x + ((y - x) * (z / t))
if (x <= (-1.5349570345577026d-128)) then
tmp = t_1
else if (x <= 1.5069737614011972d-298) then
tmp = x + (((y / t) - (x / t)) * z)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((y - x) * (z / t));
double tmp;
if (x <= -1.5349570345577026e-128) {
tmp = t_1;
} else if (x <= 1.5069737614011972e-298) {
tmp = x + (((y / t) - (x / t)) * z);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): return x + ((y - x) * (z / t))
def code(x, y, z, t): t_1 = x + ((y - x) * (z / t)) tmp = 0 if x <= -1.5349570345577026e-128: tmp = t_1 elif x <= 1.5069737614011972e-298: tmp = x + (((y / t) - (x / t)) * z) else: tmp = t_1 return tmp
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) * Float64(z / t))) end
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(y - x) * Float64(z / t))) tmp = 0.0 if (x <= -1.5349570345577026e-128) tmp = t_1; elseif (x <= 1.5069737614011972e-298) tmp = Float64(x + Float64(Float64(Float64(y / t) - Float64(x / t)) * z)); else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t) tmp = x + ((y - x) * (z / t)); end
function tmp_2 = code(x, y, z, t) t_1 = x + ((y - x) * (z / t)); tmp = 0.0; if (x <= -1.5349570345577026e-128) tmp = t_1; elseif (x <= 1.5069737614011972e-298) tmp = x + (((y / t) - (x / t)) * z); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.5349570345577026e-128], t$95$1, If[LessEqual[x, 1.5069737614011972e-298], N[(x + N[(N[(N[(y / t), $MachinePrecision] - N[(x / t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
t_1 := x + \left(y - x\right) \cdot \frac{z}{t}\\
\mathbf{if}\;x \leq -1.5349570345577026 \cdot 10^{-128}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.5069737614011972 \cdot 10^{-298}:\\
\;\;\;\;x + \left(\frac{y}{t} - \frac{x}{t}\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 2.3 |
|---|---|
| Target | 2.4 |
| Herbie | 2.4 |
if x < -1.53495703455770257e-128 or 1.50697376140119718e-298 < x Initial program 1.6
if -1.53495703455770257e-128 < x < 1.50697376140119718e-298Initial program 5.3
Taylor expanded in y around 0 4.8
Taylor expanded in z around 0 5.8
Final simplification2.4
herbie shell --seed 2022152
(FPCore (x y z t)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"
:precision binary64
:herbie-target
(if (< (* (- y x) (/ z t)) -1013646692435.8867) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) 0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))
(+ x (* (- y x) (/ z t))))