
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / 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 = x + ((y * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / 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 = x + ((y * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (fma (/ y t) (- z x) x))
double code(double x, double y, double z, double t) {
return fma((y / t), (z - x), x);
}
function code(x, y, z, t) return fma(Float64(y / t), Float64(z - x), x) end
code[x_, y_, z_, t_] := N[(N[(y / t), $MachinePrecision] * N[(z - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)
\end{array}
Initial program 93.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (/ (* y (- z x)) t))) (t_2 (* y (/ (- z x) t))))
(if (<= t_1 -5e+305)
t_2
(if (<= t_1 2e+146)
(+ x (/ (* y z) t))
(if (<= t_1 2e+306) (- x (/ (* y x) t)) t_2)))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((y * (z - x)) / t);
double t_2 = y * ((z - x) / t);
double tmp;
if (t_1 <= -5e+305) {
tmp = t_2;
} else if (t_1 <= 2e+146) {
tmp = x + ((y * z) / t);
} else if (t_1 <= 2e+306) {
tmp = x - ((y * x) / t);
} else {
tmp = t_2;
}
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
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x + ((y * (z - x)) / t)
t_2 = y * ((z - x) / t)
if (t_1 <= (-5d+305)) then
tmp = t_2
else if (t_1 <= 2d+146) then
tmp = x + ((y * z) / t)
else if (t_1 <= 2d+306) then
tmp = x - ((y * x) / t)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((y * (z - x)) / t);
double t_2 = y * ((z - x) / t);
double tmp;
if (t_1 <= -5e+305) {
tmp = t_2;
} else if (t_1 <= 2e+146) {
tmp = x + ((y * z) / t);
} else if (t_1 <= 2e+306) {
tmp = x - ((y * x) / t);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((y * (z - x)) / t) t_2 = y * ((z - x) / t) tmp = 0 if t_1 <= -5e+305: tmp = t_2 elif t_1 <= 2e+146: tmp = x + ((y * z) / t) elif t_1 <= 2e+306: tmp = x - ((y * x) / t) else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(y * Float64(z - x)) / t)) t_2 = Float64(y * Float64(Float64(z - x) / t)) tmp = 0.0 if (t_1 <= -5e+305) tmp = t_2; elseif (t_1 <= 2e+146) tmp = Float64(x + Float64(Float64(y * z) / t)); elseif (t_1 <= 2e+306) tmp = Float64(x - Float64(Float64(y * x) / t)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((y * (z - x)) / t); t_2 = y * ((z - x) / t); tmp = 0.0; if (t_1 <= -5e+305) tmp = t_2; elseif (t_1 <= 2e+146) tmp = x + ((y * z) / t); elseif (t_1 <= 2e+306) tmp = x - ((y * x) / t); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+305], t$95$2, If[LessEqual[t$95$1, 2e+146], N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+306], N[(x - N[(N[(y * x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\
t_2 := y \cdot \frac{z - x}{t}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+305}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+146}:\\
\;\;\;\;x + \frac{y \cdot z}{t}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;x - \frac{y \cdot x}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -5.00000000000000009e305 or 2.00000000000000003e306 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) Initial program 82.8%
Taylor expanded in y around inf
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6493.1
Applied rewrites93.1%
if -5.00000000000000009e305 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 1.99999999999999987e146Initial program 98.7%
Taylor expanded in z around inf
lower-*.f6486.5
Applied rewrites86.5%
if 1.99999999999999987e146 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 2.00000000000000003e306Initial program 99.8%
Taylor expanded in x around inf
mul-1-negN/A
unsub-negN/A
distribute-lft-out--N/A
*-rgt-identityN/A
associate-/l*N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.5
Applied rewrites80.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* t x) t)))
(if (<= z -7.4e-43)
(* (/ y t) z)
(if (<= z -2.8e-277)
(* y (/ (- x) t))
(if (<= z -4.8e-304)
t_1
(if (<= z 5.1e-264)
(/ (* x (- y)) t)
(if (<= z 2.6e-22) t_1 (* y (/ z t)))))))))
double code(double x, double y, double z, double t) {
double t_1 = (t * x) / t;
double tmp;
if (z <= -7.4e-43) {
tmp = (y / t) * z;
} else if (z <= -2.8e-277) {
tmp = y * (-x / t);
} else if (z <= -4.8e-304) {
tmp = t_1;
} else if (z <= 5.1e-264) {
tmp = (x * -y) / t;
} else if (z <= 2.6e-22) {
tmp = t_1;
} else {
tmp = y * (z / t);
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = (t * x) / t
if (z <= (-7.4d-43)) then
tmp = (y / t) * z
else if (z <= (-2.8d-277)) then
tmp = y * (-x / t)
else if (z <= (-4.8d-304)) then
tmp = t_1
else if (z <= 5.1d-264) then
tmp = (x * -y) / t
else if (z <= 2.6d-22) then
tmp = t_1
else
tmp = y * (z / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (t * x) / t;
double tmp;
if (z <= -7.4e-43) {
tmp = (y / t) * z;
} else if (z <= -2.8e-277) {
tmp = y * (-x / t);
} else if (z <= -4.8e-304) {
tmp = t_1;
} else if (z <= 5.1e-264) {
tmp = (x * -y) / t;
} else if (z <= 2.6e-22) {
tmp = t_1;
} else {
tmp = y * (z / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = (t * x) / t tmp = 0 if z <= -7.4e-43: tmp = (y / t) * z elif z <= -2.8e-277: tmp = y * (-x / t) elif z <= -4.8e-304: tmp = t_1 elif z <= 5.1e-264: tmp = (x * -y) / t elif z <= 2.6e-22: tmp = t_1 else: tmp = y * (z / t) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(t * x) / t) tmp = 0.0 if (z <= -7.4e-43) tmp = Float64(Float64(y / t) * z); elseif (z <= -2.8e-277) tmp = Float64(y * Float64(Float64(-x) / t)); elseif (z <= -4.8e-304) tmp = t_1; elseif (z <= 5.1e-264) tmp = Float64(Float64(x * Float64(-y)) / t); elseif (z <= 2.6e-22) tmp = t_1; else tmp = Float64(y * Float64(z / t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (t * x) / t; tmp = 0.0; if (z <= -7.4e-43) tmp = (y / t) * z; elseif (z <= -2.8e-277) tmp = y * (-x / t); elseif (z <= -4.8e-304) tmp = t_1; elseif (z <= 5.1e-264) tmp = (x * -y) / t; elseif (z <= 2.6e-22) tmp = t_1; else tmp = y * (z / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t * x), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[z, -7.4e-43], N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, -2.8e-277], N[(y * N[((-x) / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -4.8e-304], t$95$1, If[LessEqual[z, 5.1e-264], N[(N[(x * (-y)), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[z, 2.6e-22], t$95$1, N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t \cdot x}{t}\\
\mathbf{if}\;z \leq -7.4 \cdot 10^{-43}:\\
\;\;\;\;\frac{y}{t} \cdot z\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{-277}:\\
\;\;\;\;y \cdot \frac{-x}{t}\\
\mathbf{elif}\;z \leq -4.8 \cdot 10^{-304}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.1 \cdot 10^{-264}:\\
\;\;\;\;\frac{x \cdot \left(-y\right)}{t}\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -7.4e-43Initial program 90.3%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f6454.5
Applied rewrites54.5%
Applied rewrites59.8%
if -7.4e-43 < z < -2.79999999999999976e-277Initial program 92.6%
Taylor expanded in y around inf
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6457.8
Applied rewrites57.8%
Taylor expanded in z around 0
Applied rewrites44.0%
if -2.79999999999999976e-277 < z < -4.8000000000000002e-304 or 5.10000000000000024e-264 < z < 2.6e-22Initial program 95.5%
Taylor expanded in t around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6483.5
Applied rewrites83.5%
Taylor expanded in y around 0
Applied rewrites49.5%
if -4.8000000000000002e-304 < z < 5.10000000000000024e-264Initial program 100.0%
Taylor expanded in y around inf
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6477.2
Applied rewrites77.2%
Taylor expanded in z around 0
Applied rewrites85.8%
if 2.6e-22 < z Initial program 95.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f6459.2
Applied rewrites59.2%
Applied rewrites63.8%
Final simplification56.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* t x) t)))
(if (<= z -3.05e+38)
(* (/ y t) z)
(if (<= z -4.8e-304)
t_1
(if (<= z 5.1e-264)
(/ (* x (- y)) t)
(if (<= z 2.6e-22) t_1 (* y (/ z t))))))))
double code(double x, double y, double z, double t) {
double t_1 = (t * x) / t;
double tmp;
if (z <= -3.05e+38) {
tmp = (y / t) * z;
} else if (z <= -4.8e-304) {
tmp = t_1;
} else if (z <= 5.1e-264) {
tmp = (x * -y) / t;
} else if (z <= 2.6e-22) {
tmp = t_1;
} else {
tmp = y * (z / t);
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = (t * x) / t
if (z <= (-3.05d+38)) then
tmp = (y / t) * z
else if (z <= (-4.8d-304)) then
tmp = t_1
else if (z <= 5.1d-264) then
tmp = (x * -y) / t
else if (z <= 2.6d-22) then
tmp = t_1
else
tmp = y * (z / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (t * x) / t;
double tmp;
if (z <= -3.05e+38) {
tmp = (y / t) * z;
} else if (z <= -4.8e-304) {
tmp = t_1;
} else if (z <= 5.1e-264) {
tmp = (x * -y) / t;
} else if (z <= 2.6e-22) {
tmp = t_1;
} else {
tmp = y * (z / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = (t * x) / t tmp = 0 if z <= -3.05e+38: tmp = (y / t) * z elif z <= -4.8e-304: tmp = t_1 elif z <= 5.1e-264: tmp = (x * -y) / t elif z <= 2.6e-22: tmp = t_1 else: tmp = y * (z / t) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(t * x) / t) tmp = 0.0 if (z <= -3.05e+38) tmp = Float64(Float64(y / t) * z); elseif (z <= -4.8e-304) tmp = t_1; elseif (z <= 5.1e-264) tmp = Float64(Float64(x * Float64(-y)) / t); elseif (z <= 2.6e-22) tmp = t_1; else tmp = Float64(y * Float64(z / t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (t * x) / t; tmp = 0.0; if (z <= -3.05e+38) tmp = (y / t) * z; elseif (z <= -4.8e-304) tmp = t_1; elseif (z <= 5.1e-264) tmp = (x * -y) / t; elseif (z <= 2.6e-22) tmp = t_1; else tmp = y * (z / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t * x), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[z, -3.05e+38], N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, -4.8e-304], t$95$1, If[LessEqual[z, 5.1e-264], N[(N[(x * (-y)), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[z, 2.6e-22], t$95$1, N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t \cdot x}{t}\\
\mathbf{if}\;z \leq -3.05 \cdot 10^{+38}:\\
\;\;\;\;\frac{y}{t} \cdot z\\
\mathbf{elif}\;z \leq -4.8 \cdot 10^{-304}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.1 \cdot 10^{-264}:\\
\;\;\;\;\frac{x \cdot \left(-y\right)}{t}\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -3.05e38Initial program 88.7%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f6458.2
Applied rewrites58.2%
Applied rewrites64.4%
if -3.05e38 < z < -4.8000000000000002e-304 or 5.10000000000000024e-264 < z < 2.6e-22Initial program 94.7%
Taylor expanded in t around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6485.2
Applied rewrites85.2%
Taylor expanded in y around 0
Applied rewrites42.5%
if -4.8000000000000002e-304 < z < 5.10000000000000024e-264Initial program 100.0%
Taylor expanded in y around inf
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6477.2
Applied rewrites77.2%
Taylor expanded in z around 0
Applied rewrites85.8%
if 2.6e-22 < z Initial program 95.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f6459.2
Applied rewrites59.2%
Applied rewrites63.8%
Final simplification54.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- x (/ (* y x) t)))) (if (<= x -3.7e-86) t_1 (if (<= x 4e-24) (* y (/ (- z x) t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x - ((y * x) / t);
double tmp;
if (x <= -3.7e-86) {
tmp = t_1;
} else if (x <= 4e-24) {
tmp = y * ((z - x) / t);
} 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
real(8) :: t_1
real(8) :: tmp
t_1 = x - ((y * x) / t)
if (x <= (-3.7d-86)) then
tmp = t_1
else if (x <= 4d-24) then
tmp = y * ((z - x) / t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x - ((y * x) / t);
double tmp;
if (x <= -3.7e-86) {
tmp = t_1;
} else if (x <= 4e-24) {
tmp = y * ((z - x) / t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x - ((y * x) / t) tmp = 0 if x <= -3.7e-86: tmp = t_1 elif x <= 4e-24: tmp = y * ((z - x) / t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x - Float64(Float64(y * x) / t)) tmp = 0.0 if (x <= -3.7e-86) tmp = t_1; elseif (x <= 4e-24) tmp = Float64(y * Float64(Float64(z - x) / t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x - ((y * x) / t); tmp = 0.0; if (x <= -3.7e-86) tmp = t_1; elseif (x <= 4e-24) tmp = y * ((z - x) / t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(N[(y * x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.7e-86], t$95$1, If[LessEqual[x, 4e-24], N[(y * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{y \cdot x}{t}\\
\mathbf{if}\;x \leq -3.7 \cdot 10^{-86}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-24}:\\
\;\;\;\;y \cdot \frac{z - x}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.6999999999999998e-86 or 3.99999999999999969e-24 < x Initial program 95.3%
Taylor expanded in x around inf
mul-1-negN/A
unsub-negN/A
distribute-lft-out--N/A
*-rgt-identityN/A
associate-/l*N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6485.6
Applied rewrites85.6%
if -3.6999999999999998e-86 < x < 3.99999999999999969e-24Initial program 90.8%
Taylor expanded in y around inf
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6477.2
Applied rewrites77.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (/ (- z x) t)))) (if (<= y -5e-111) t_1 (if (<= y 3.5e-90) (/ (* t x) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * ((z - x) / t);
double tmp;
if (y <= -5e-111) {
tmp = t_1;
} else if (y <= 3.5e-90) {
tmp = (t * x) / t;
} 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
real(8) :: t_1
real(8) :: tmp
t_1 = y * ((z - x) / t)
if (y <= (-5d-111)) then
tmp = t_1
else if (y <= 3.5d-90) then
tmp = (t * x) / t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y * ((z - x) / t);
double tmp;
if (y <= -5e-111) {
tmp = t_1;
} else if (y <= 3.5e-90) {
tmp = (t * x) / t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * ((z - x) / t) tmp = 0 if y <= -5e-111: tmp = t_1 elif y <= 3.5e-90: tmp = (t * x) / t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(Float64(z - x) / t)) tmp = 0.0 if (y <= -5e-111) tmp = t_1; elseif (y <= 3.5e-90) tmp = Float64(Float64(t * x) / t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * ((z - x) / t); tmp = 0.0; if (y <= -5e-111) tmp = t_1; elseif (y <= 3.5e-90) tmp = (t * x) / t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5e-111], t$95$1, If[LessEqual[y, 3.5e-90], N[(N[(t * x), $MachinePrecision] / t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \frac{z - x}{t}\\
\mathbf{if}\;y \leq -5 \cdot 10^{-111}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-90}:\\
\;\;\;\;\frac{t \cdot x}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -5.0000000000000003e-111 or 3.4999999999999999e-90 < y Initial program 90.8%
Taylor expanded in y around inf
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6476.3
Applied rewrites76.3%
if -5.0000000000000003e-111 < y < 3.4999999999999999e-90Initial program 99.2%
Taylor expanded in t around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6486.0
Applied rewrites86.0%
Taylor expanded in y around 0
Applied rewrites56.6%
Final simplification69.5%
(FPCore (x y z t) :precision binary64 (if (<= z -3.05e+38) (* (/ y t) z) (if (<= z 2.6e-22) (/ (* t x) t) (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.05e+38) {
tmp = (y / t) * z;
} else if (z <= 2.6e-22) {
tmp = (t * x) / t;
} else {
tmp = y * (z / t);
}
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
real(8) :: tmp
if (z <= (-3.05d+38)) then
tmp = (y / t) * z
else if (z <= 2.6d-22) then
tmp = (t * x) / t
else
tmp = y * (z / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.05e+38) {
tmp = (y / t) * z;
} else if (z <= 2.6e-22) {
tmp = (t * x) / t;
} else {
tmp = y * (z / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.05e+38: tmp = (y / t) * z elif z <= 2.6e-22: tmp = (t * x) / t else: tmp = y * (z / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.05e+38) tmp = Float64(Float64(y / t) * z); elseif (z <= 2.6e-22) tmp = Float64(Float64(t * x) / t); else tmp = Float64(y * Float64(z / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.05e+38) tmp = (y / t) * z; elseif (z <= 2.6e-22) tmp = (t * x) / t; else tmp = y * (z / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.05e+38], N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 2.6e-22], N[(N[(t * x), $MachinePrecision] / t), $MachinePrecision], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.05 \cdot 10^{+38}:\\
\;\;\;\;\frac{y}{t} \cdot z\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-22}:\\
\;\;\;\;\frac{t \cdot x}{t}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -3.05e38Initial program 88.7%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f6458.2
Applied rewrites58.2%
Applied rewrites64.4%
if -3.05e38 < z < 2.6e-22Initial program 95.1%
Taylor expanded in t around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6484.9
Applied rewrites84.9%
Taylor expanded in y around 0
Applied rewrites39.2%
if 2.6e-22 < z Initial program 95.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f6459.2
Applied rewrites59.2%
Applied rewrites63.8%
Final simplification51.3%
(FPCore (x y z t) :precision binary64 (* (/ y t) z))
double code(double x, double y, double z, double t) {
return (y / t) * z;
}
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 = (y / t) * z
end function
public static double code(double x, double y, double z, double t) {
return (y / t) * z;
}
def code(x, y, z, t): return (y / t) * z
function code(x, y, z, t) return Float64(Float64(y / t) * z) end
function tmp = code(x, y, z, t) tmp = (y / t) * z; end
code[x_, y_, z_, t_] := N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{t} \cdot z
\end{array}
Initial program 93.7%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
Applied rewrites38.4%
Final simplification38.4%
(FPCore (x y z t) :precision binary64 (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / 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 = x - ((x * (y / t)) + (-z * (y / t)))
end function
public static double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / t)));
}
def code(x, y, z, t): return x - ((x * (y / t)) + (-z * (y / t)))
function code(x, y, z, t) return Float64(x - Float64(Float64(x * Float64(y / t)) + Float64(Float64(-z) * Float64(y / t)))) end
function tmp = code(x, y, z, t) tmp = x - ((x * (y / t)) + (-z * (y / t))); end
code[x_, y_, z_, t_] := N[(x - N[(N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision] + N[((-z) * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)
\end{array}
herbie shell --seed 2024233
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:alt
(! :herbie-platform default (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
(+ x (/ (* y (- z x)) t)))