
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
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
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
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
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -5e+36) (not (<= z 2e+20))) (* x (+ (/ y z) -1.0)) (/ (fma x (- y z) x) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5e+36) || !(z <= 2e+20)) {
tmp = x * ((y / z) + -1.0);
} else {
tmp = fma(x, (y - z), x) / z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -5e+36) || !(z <= 2e+20)) tmp = Float64(x * Float64(Float64(y / z) + -1.0)); else tmp = Float64(fma(x, Float64(y - z), x) / z); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -5e+36], N[Not[LessEqual[z, 2e+20]], $MachinePrecision]], N[(x * N[(N[(y / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y - z), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+36} \lor \neg \left(z \leq 2 \cdot 10^{+20}\right):\\
\;\;\;\;x \cdot \left(\frac{y}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\
\end{array}
\end{array}
if z < -4.99999999999999977e36 or 2e20 < z Initial program 68.6%
Taylor expanded in x around 0 68.6%
associate--l+68.6%
+-commutative68.6%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 99.9%
if -4.99999999999999977e36 < z < 2e20Initial program 99.9%
distribute-lft-in99.9%
fma-def99.9%
*-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.2e-16) (not (<= z 2.45e-51))) (* x (+ -1.0 (/ (+ y 1.0) z))) (/ (+ x (* x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.2e-16) || !(z <= 2.45e-51)) {
tmp = x * (-1.0 + ((y + 1.0) / z));
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-5.2d-16)) .or. (.not. (z <= 2.45d-51))) then
tmp = x * ((-1.0d0) + ((y + 1.0d0) / z))
else
tmp = (x + (x * y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.2e-16) || !(z <= 2.45e-51)) {
tmp = x * (-1.0 + ((y + 1.0) / z));
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.2e-16) or not (z <= 2.45e-51): tmp = x * (-1.0 + ((y + 1.0) / z)) else: tmp = (x + (x * y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.2e-16) || !(z <= 2.45e-51)) tmp = Float64(x * Float64(-1.0 + Float64(Float64(y + 1.0) / z))); else tmp = Float64(Float64(x + Float64(x * y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.2e-16) || ~((z <= 2.45e-51))) tmp = x * (-1.0 + ((y + 1.0) / z)); else tmp = (x + (x * y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.2e-16], N[Not[LessEqual[z, 2.45e-51]], $MachinePrecision]], N[(x * N[(-1.0 + N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{-16} \lor \neg \left(z \leq 2.45 \cdot 10^{-51}\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y + 1}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\end{array}
\end{array}
if z < -5.1999999999999997e-16 or 2.44999999999999987e-51 < z Initial program 74.6%
Taylor expanded in x around 0 74.6%
associate--l+74.6%
+-commutative74.6%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
if -5.1999999999999997e-16 < z < 2.44999999999999987e-51Initial program 100.0%
distribute-lft-in100.0%
fma-def100.0%
*-rgt-identity100.0%
Simplified100.0%
Taylor expanded in z around 0 100.0%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.05e+36) (not (<= z 2e+20))) (* x (+ (/ y z) -1.0)) (/ (* x (+ (- y z) 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e+36) || !(z <= 2e+20)) {
tmp = x * ((y / z) + -1.0);
} else {
tmp = (x * ((y - z) + 1.0)) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.05d+36)) .or. (.not. (z <= 2d+20))) then
tmp = x * ((y / z) + (-1.0d0))
else
tmp = (x * ((y - z) + 1.0d0)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e+36) || !(z <= 2e+20)) {
tmp = x * ((y / z) + -1.0);
} else {
tmp = (x * ((y - z) + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.05e+36) or not (z <= 2e+20): tmp = x * ((y / z) + -1.0) else: tmp = (x * ((y - z) + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.05e+36) || !(z <= 2e+20)) tmp = Float64(x * Float64(Float64(y / z) + -1.0)); else tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.05e+36) || ~((z <= 2e+20))) tmp = x * ((y / z) + -1.0); else tmp = (x * ((y - z) + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.05e+36], N[Not[LessEqual[z, 2e+20]], $MachinePrecision]], N[(x * N[(N[(y / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+36} \lor \neg \left(z \leq 2 \cdot 10^{+20}\right):\\
\;\;\;\;x \cdot \left(\frac{y}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\end{array}
\end{array}
if z < -1.05000000000000002e36 or 2e20 < z Initial program 68.6%
Taylor expanded in x around 0 68.6%
associate--l+68.6%
+-commutative68.6%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 99.9%
if -1.05000000000000002e36 < z < 2e20Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= z -1.0)
(- x)
(if (<= z 4.7e-291)
(/ x z)
(if (<= z 2.9e-114) (* y (/ x z)) (if (<= z 1.0) (/ x z) (- x))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 4.7e-291) {
tmp = x / z;
} else if (z <= 2.9e-114) {
tmp = y * (x / z);
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.0d0)) then
tmp = -x
else if (z <= 4.7d-291) then
tmp = x / z
else if (z <= 2.9d-114) then
tmp = y * (x / z)
else if (z <= 1.0d0) then
tmp = x / z
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 4.7e-291) {
tmp = x / z;
} else if (z <= 2.9e-114) {
tmp = y * (x / z);
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 4.7e-291: tmp = x / z elif z <= 2.9e-114: tmp = y * (x / z) elif z <= 1.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(-x); elseif (z <= 4.7e-291) tmp = Float64(x / z); elseif (z <= 2.9e-114) tmp = Float64(y * Float64(x / z)); elseif (z <= 1.0) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = -x; elseif (z <= 4.7e-291) tmp = x / z; elseif (z <= 2.9e-114) tmp = y * (x / z); elseif (z <= 1.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], (-x), If[LessEqual[z, 4.7e-291], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.9e-114], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 4.7 \cdot 10^{-291}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-114}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 70.8%
Taylor expanded in z around inf 77.3%
mul-1-neg77.3%
Simplified77.3%
if -1 < z < 4.6999999999999998e-291 or 2.89999999999999997e-114 < z < 1Initial program 99.9%
Taylor expanded in y around 0 64.2%
associate-/l*64.2%
Simplified64.2%
Taylor expanded in z around 0 61.6%
if 4.6999999999999998e-291 < z < 2.89999999999999997e-114Initial program 99.9%
Taylor expanded in y around inf 62.1%
associate-/l*50.0%
associate-/r/67.3%
Simplified67.3%
Final simplification69.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 9.2e-10))) (* x (+ (/ y z) -1.0)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 9.2e-10)) {
tmp = x * ((y / z) + -1.0);
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.0d0)) .or. (.not. (y <= 9.2d-10))) then
tmp = x * ((y / z) + (-1.0d0))
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 9.2e-10)) {
tmp = x * ((y / z) + -1.0);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 9.2e-10): tmp = x * ((y / z) + -1.0) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 9.2e-10)) tmp = Float64(x * Float64(Float64(y / z) + -1.0)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 9.2e-10))) tmp = x * ((y / z) + -1.0); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 9.2e-10]], $MachinePrecision]], N[(x * N[(N[(y / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 9.2 \cdot 10^{-10}\right):\\
\;\;\;\;x \cdot \left(\frac{y}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1 or 9.20000000000000028e-10 < y Initial program 82.8%
Taylor expanded in x around 0 82.8%
associate--l+82.8%
+-commutative82.8%
associate-*r/88.0%
+-commutative88.0%
associate--l+88.0%
div-sub88.0%
sub-neg88.0%
*-inverses88.0%
metadata-eval88.0%
Simplified88.0%
Taylor expanded in y around inf 88.0%
if -1 < y < 9.20000000000000028e-10Initial program 90.4%
Taylor expanded in x around 0 90.4%
associate--l+90.4%
+-commutative90.4%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-rgt-in99.0%
associate-*l/99.2%
*-lft-identity99.2%
neg-mul-199.2%
unsub-neg99.2%
Simplified99.2%
Final simplification94.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.05) (not (<= z 1.0))) (* x (+ (/ y z) -1.0)) (/ (+ x (* x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05) || !(z <= 1.0)) {
tmp = x * ((y / z) + -1.0);
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.05d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x * ((y / z) + (-1.0d0))
else
tmp = (x + (x * y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05) || !(z <= 1.0)) {
tmp = x * ((y / z) + -1.0);
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.05) or not (z <= 1.0): tmp = x * ((y / z) + -1.0) else: tmp = (x + (x * y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.05) || !(z <= 1.0)) tmp = Float64(x * Float64(Float64(y / z) + -1.0)); else tmp = Float64(Float64(x + Float64(x * y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.05) || ~((z <= 1.0))) tmp = x * ((y / z) + -1.0); else tmp = (x + (x * y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.05], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * N[(N[(y / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(\frac{y}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\end{array}
\end{array}
if z < -1.05000000000000004 or 1 < z Initial program 70.8%
Taylor expanded in x around 0 70.8%
associate--l+70.8%
+-commutative70.8%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 99.1%
if -1.05000000000000004 < z < 1Initial program 99.9%
distribute-lft-in100.0%
fma-def99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 98.4%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -61000000000.0) (not (<= y 1.1e+49))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -61000000000.0) || !(y <= 1.1e+49)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-61000000000.0d0)) .or. (.not. (y <= 1.1d+49))) then
tmp = y * (x / z)
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -61000000000.0) || !(y <= 1.1e+49)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -61000000000.0) or not (y <= 1.1e+49): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -61000000000.0) || !(y <= 1.1e+49)) tmp = Float64(y * Float64(x / z)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -61000000000.0) || ~((y <= 1.1e+49))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -61000000000.0], N[Not[LessEqual[y, 1.1e+49]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -61000000000 \lor \neg \left(y \leq 1.1 \cdot 10^{+49}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -6.1e10 or 1.1e49 < y Initial program 82.0%
Taylor expanded in y around inf 71.8%
associate-/l*65.3%
associate-/r/74.3%
Simplified74.3%
if -6.1e10 < y < 1.1e49Initial program 90.2%
Taylor expanded in x around 0 90.2%
associate--l+90.2%
+-commutative90.2%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 97.4%
sub-neg97.4%
metadata-eval97.4%
distribute-rgt-in97.3%
associate-*l/97.5%
*-lft-identity97.5%
neg-mul-197.5%
unsub-neg97.5%
Simplified97.5%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (<= y -3.5e+14) (* y (/ x z)) (if (<= y 2.2e+48) (- (/ x z) x) (/ (* x y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+14) {
tmp = y * (x / z);
} else if (y <= 2.2e+48) {
tmp = (x / z) - x;
} else {
tmp = (x * y) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-3.5d+14)) then
tmp = y * (x / z)
else if (y <= 2.2d+48) then
tmp = (x / z) - x
else
tmp = (x * y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+14) {
tmp = y * (x / z);
} else if (y <= 2.2e+48) {
tmp = (x / z) - x;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.5e+14: tmp = y * (x / z) elif y <= 2.2e+48: tmp = (x / z) - x else: tmp = (x * y) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.5e+14) tmp = Float64(y * Float64(x / z)); elseif (y <= 2.2e+48) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(x * y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.5e+14) tmp = y * (x / z); elseif (y <= 2.2e+48) tmp = (x / z) - x; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.5e+14], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.2e+48], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+14}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+48}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
\end{array}
if y < -3.5e14Initial program 79.6%
Taylor expanded in y around inf 66.9%
associate-/l*63.2%
associate-/r/73.4%
Simplified73.4%
if -3.5e14 < y < 2.1999999999999999e48Initial program 90.2%
Taylor expanded in x around 0 90.2%
associate--l+90.2%
+-commutative90.2%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 97.4%
sub-neg97.4%
metadata-eval97.4%
distribute-rgt-in97.3%
associate-*l/97.5%
*-lft-identity97.5%
neg-mul-197.5%
unsub-neg97.5%
Simplified97.5%
if 2.1999999999999999e48 < y Initial program 84.8%
Taylor expanded in y around inf 77.3%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = -x
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 70.8%
Taylor expanded in z around inf 77.3%
mul-1-neg77.3%
Simplified77.3%
if -1 < z < 1Initial program 99.9%
Taylor expanded in y around 0 60.0%
associate-/l*60.0%
Simplified60.0%
Taylor expanded in z around 0 58.4%
Final simplification66.9%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 86.9%
Taylor expanded in z around inf 36.3%
mul-1-neg36.3%
Simplified36.3%
Final simplification36.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
(if (< x -2.71483106713436e-162)
t_0
(if (< x 3.874108816439546e-197)
(* (* x (+ (- y z) 1.0)) (/ 1.0 z))
t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} 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
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + y) * (x / z)) - x
if (x < (-2.71483106713436d-162)) then
tmp = t_0
else if (x < 3.874108816439546d-197) then
tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 + y) * (x / z)) - x tmp = 0 if x < -2.71483106713436e-162: tmp = t_0 elif x < 3.874108816439546e-197: tmp = (x * ((y - z) + 1.0)) * (1.0 / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x) tmp = 0.0 if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 + y) * (x / z)) - x; tmp = 0.0; if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = (x * ((y - z) + 1.0)) * (1.0 / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023308
(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))