
(FPCore (x y z) :precision binary64 (* (+ x y) (- 1.0 z)))
double code(double x, double y, double z) {
return (x + y) * (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) * (1.0d0 - z)
end function
public static double code(double x, double y, double z) {
return (x + y) * (1.0 - z);
}
def code(x, y, z): return (x + y) * (1.0 - z)
function code(x, y, z) return Float64(Float64(x + y) * Float64(1.0 - z)) end
function tmp = code(x, y, z) tmp = (x + y) * (1.0 - z); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) \cdot \left(1 - z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* (+ x y) (- 1.0 z)))
double code(double x, double y, double z) {
return (x + y) * (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) * (1.0d0 - z)
end function
public static double code(double x, double y, double z) {
return (x + y) * (1.0 - z);
}
def code(x, y, z): return (x + y) * (1.0 - z)
function code(x, y, z) return Float64(Float64(x + y) * Float64(1.0 - z)) end
function tmp = code(x, y, z) tmp = (x + y) * (1.0 - z); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) \cdot \left(1 - z\right)
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (fma (- 1.0 z) y (* (- 1.0 z) x)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return fma((1.0 - z), y, ((1.0 - z) * x));
}
x, y, z = sort([x, y, z]) function code(x, y, z) return fma(Float64(1.0 - z), y, Float64(Float64(1.0 - z) * x)) end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 - z), $MachinePrecision] * y + N[(N[(1.0 - z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\mathsf{fma}\left(1 - z, y, \left(1 - z\right) \cdot x\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
+-commutative100.0%
distribute-lft-in98.4%
fma-def98.4%
Applied egg-rr98.4%
Final simplification98.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- 1.0 z) y)) (t_1 (* z (- x))))
(if (<= (- 1.0 z) -1e+238)
(* z (- y))
(if (<= (- 1.0 z) -5e+186)
t_1
(if (<= (- 1.0 z) -400.0)
t_0
(if (<= (- 1.0 z) 1.0)
(+ y x)
(if (<= (- 1.0 z) 5e+171) t_0 t_1)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = (1.0 - z) * y;
double t_1 = z * -x;
double tmp;
if ((1.0 - z) <= -1e+238) {
tmp = z * -y;
} else if ((1.0 - z) <= -5e+186) {
tmp = t_1;
} else if ((1.0 - z) <= -400.0) {
tmp = t_0;
} else if ((1.0 - z) <= 1.0) {
tmp = y + x;
} else if ((1.0 - z) <= 5e+171) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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) :: t_1
real(8) :: tmp
t_0 = (1.0d0 - z) * y
t_1 = z * -x
if ((1.0d0 - z) <= (-1d+238)) then
tmp = z * -y
else if ((1.0d0 - z) <= (-5d+186)) then
tmp = t_1
else if ((1.0d0 - z) <= (-400.0d0)) then
tmp = t_0
else if ((1.0d0 - z) <= 1.0d0) then
tmp = y + x
else if ((1.0d0 - z) <= 5d+171) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double t_0 = (1.0 - z) * y;
double t_1 = z * -x;
double tmp;
if ((1.0 - z) <= -1e+238) {
tmp = z * -y;
} else if ((1.0 - z) <= -5e+186) {
tmp = t_1;
} else if ((1.0 - z) <= -400.0) {
tmp = t_0;
} else if ((1.0 - z) <= 1.0) {
tmp = y + x;
} else if ((1.0 - z) <= 5e+171) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = (1.0 - z) * y t_1 = z * -x tmp = 0 if (1.0 - z) <= -1e+238: tmp = z * -y elif (1.0 - z) <= -5e+186: tmp = t_1 elif (1.0 - z) <= -400.0: tmp = t_0 elif (1.0 - z) <= 1.0: tmp = y + x elif (1.0 - z) <= 5e+171: tmp = t_0 else: tmp = t_1 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(Float64(1.0 - z) * y) t_1 = Float64(z * Float64(-x)) tmp = 0.0 if (Float64(1.0 - z) <= -1e+238) tmp = Float64(z * Float64(-y)); elseif (Float64(1.0 - z) <= -5e+186) tmp = t_1; elseif (Float64(1.0 - z) <= -400.0) tmp = t_0; elseif (Float64(1.0 - z) <= 1.0) tmp = Float64(y + x); elseif (Float64(1.0 - z) <= 5e+171) tmp = t_0; else tmp = t_1; end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
t_0 = (1.0 - z) * y;
t_1 = z * -x;
tmp = 0.0;
if ((1.0 - z) <= -1e+238)
tmp = z * -y;
elseif ((1.0 - z) <= -5e+186)
tmp = t_1;
elseif ((1.0 - z) <= -400.0)
tmp = t_0;
elseif ((1.0 - z) <= 1.0)
tmp = y + x;
elseif ((1.0 - z) <= 5e+171)
tmp = t_0;
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$1 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[N[(1.0 - z), $MachinePrecision], -1e+238], N[(z * (-y)), $MachinePrecision], If[LessEqual[N[(1.0 - z), $MachinePrecision], -5e+186], t$95$1, If[LessEqual[N[(1.0 - z), $MachinePrecision], -400.0], t$95$0, If[LessEqual[N[(1.0 - z), $MachinePrecision], 1.0], N[(y + x), $MachinePrecision], If[LessEqual[N[(1.0 - z), $MachinePrecision], 5e+171], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \left(1 - z\right) \cdot y\\
t_1 := z \cdot \left(-x\right)\\
\mathbf{if}\;1 - z \leq -1 \cdot 10^{+238}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\mathbf{elif}\;1 - z \leq -5 \cdot 10^{+186}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;1 - z \leq -400:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;1 - z \leq 1:\\
\;\;\;\;y + x\\
\mathbf{elif}\;1 - z \leq 5 \cdot 10^{+171}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 1 z) < -1e238Initial program 100.0%
Taylor expanded in x around 0 48.8%
Taylor expanded in z around inf 48.8%
mul-1-neg48.8%
*-commutative48.8%
distribute-rgt-neg-in48.8%
Simplified48.8%
if -1e238 < (-.f64 1 z) < -4.99999999999999954e186 or 5.0000000000000004e171 < (-.f64 1 z) Initial program 100.0%
Taylor expanded in x around inf 50.1%
*-commutative50.1%
Simplified50.1%
Taylor expanded in z around inf 50.1%
mul-1-neg50.1%
*-commutative50.1%
distribute-rgt-neg-in50.1%
Simplified50.1%
if -4.99999999999999954e186 < (-.f64 1 z) < -400 or 1 < (-.f64 1 z) < 5.0000000000000004e171Initial program 100.0%
Taylor expanded in x around 0 41.6%
if -400 < (-.f64 1 z) < 1Initial program 100.0%
Taylor expanded in z around 0 98.8%
+-commutative98.8%
Simplified98.8%
Final simplification70.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* z (- y))))
(if (<= z -2.15e+172)
t_0
(if (<= z -130.0)
t_1
(if (<= z 1.0)
(+ y x)
(if (or (<= z 1.26e+185) (not (<= z 2.8e+237))) t_1 t_0))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = z * -y;
double tmp;
if (z <= -2.15e+172) {
tmp = t_0;
} else if (z <= -130.0) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = y + x;
} else if ((z <= 1.26e+185) || !(z <= 2.8e+237)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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) :: t_1
real(8) :: tmp
t_0 = z * -x
t_1 = z * -y
if (z <= (-2.15d+172)) then
tmp = t_0
else if (z <= (-130.0d0)) then
tmp = t_1
else if (z <= 1.0d0) then
tmp = y + x
else if ((z <= 1.26d+185) .or. (.not. (z <= 2.8d+237))) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = z * -y;
double tmp;
if (z <= -2.15e+172) {
tmp = t_0;
} else if (z <= -130.0) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = y + x;
} else if ((z <= 1.26e+185) || !(z <= 2.8e+237)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = z * -x t_1 = z * -y tmp = 0 if z <= -2.15e+172: tmp = t_0 elif z <= -130.0: tmp = t_1 elif z <= 1.0: tmp = y + x elif (z <= 1.26e+185) or not (z <= 2.8e+237): tmp = t_1 else: tmp = t_0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(z * Float64(-y)) tmp = 0.0 if (z <= -2.15e+172) tmp = t_0; elseif (z <= -130.0) tmp = t_1; elseif (z <= 1.0) tmp = Float64(y + x); elseif ((z <= 1.26e+185) || !(z <= 2.8e+237)) tmp = t_1; else tmp = t_0; end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
t_0 = z * -x;
t_1 = z * -y;
tmp = 0.0;
if (z <= -2.15e+172)
tmp = t_0;
elseif (z <= -130.0)
tmp = t_1;
elseif (z <= 1.0)
tmp = y + x;
elseif ((z <= 1.26e+185) || ~((z <= 2.8e+237)))
tmp = t_1;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(z * (-y)), $MachinePrecision]}, If[LessEqual[z, -2.15e+172], t$95$0, If[LessEqual[z, -130.0], t$95$1, If[LessEqual[z, 1.0], N[(y + x), $MachinePrecision], If[Or[LessEqual[z, 1.26e+185], N[Not[LessEqual[z, 2.8e+237]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := z \cdot \left(-y\right)\\
\mathbf{if}\;z \leq -2.15 \cdot 10^{+172}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -130:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 1.26 \cdot 10^{+185} \lor \neg \left(z \leq 2.8 \cdot 10^{+237}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.1500000000000001e172 or 1.26e185 < z < 2.79999999999999983e237Initial program 100.0%
Taylor expanded in x around inf 50.1%
*-commutative50.1%
Simplified50.1%
Taylor expanded in z around inf 50.1%
mul-1-neg50.1%
*-commutative50.1%
distribute-rgt-neg-in50.1%
Simplified50.1%
if -2.1500000000000001e172 < z < -130 or 1 < z < 1.26e185 or 2.79999999999999983e237 < z Initial program 100.0%
Taylor expanded in x around 0 42.3%
Taylor expanded in z around inf 41.2%
mul-1-neg41.2%
*-commutative41.2%
distribute-rgt-neg-in41.2%
Simplified41.2%
if -130 < z < 1Initial program 100.0%
Taylor expanded in z around 0 97.5%
+-commutative97.5%
Simplified97.5%
Final simplification69.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= (- 1.0 z) -400.0) (not (<= (- 1.0 z) 2.0))) (* z (- (- y) x)) (+ y x)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (((1.0 - z) <= -400.0) || !((1.0 - z) <= 2.0)) {
tmp = z * (-y - x);
} else {
tmp = y + x;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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) :: tmp
if (((1.0d0 - z) <= (-400.0d0)) .or. (.not. ((1.0d0 - z) <= 2.0d0))) then
tmp = z * (-y - x)
else
tmp = y + x
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - z) <= -400.0) || !((1.0 - z) <= 2.0)) {
tmp = z * (-y - x);
} else {
tmp = y + x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if ((1.0 - z) <= -400.0) or not ((1.0 - z) <= 2.0): tmp = z * (-y - x) else: tmp = y + x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((Float64(1.0 - z) <= -400.0) || !(Float64(1.0 - z) <= 2.0)) tmp = Float64(z * Float64(Float64(-y) - x)); else tmp = Float64(y + x); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (((1.0 - z) <= -400.0) || ~(((1.0 - z) <= 2.0)))
tmp = z * (-y - x);
else
tmp = y + x;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[Or[LessEqual[N[(1.0 - z), $MachinePrecision], -400.0], N[Not[LessEqual[N[(1.0 - z), $MachinePrecision], 2.0]], $MachinePrecision]], N[(z * N[((-y) - x), $MachinePrecision]), $MachinePrecision], N[(y + x), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;1 - z \leq -400 \lor \neg \left(1 - z \leq 2\right):\\
\;\;\;\;z \cdot \left(\left(-y\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if (-.f64 1 z) < -400 or 2 < (-.f64 1 z) Initial program 100.0%
Taylor expanded in z around inf 98.0%
associate-*r*98.0%
neg-mul-198.0%
*-commutative98.0%
+-commutative98.0%
Simplified98.0%
if -400 < (-.f64 1 z) < 2Initial program 100.0%
Taylor expanded in z around 0 97.5%
+-commutative97.5%
Simplified97.5%
Final simplification97.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= z -1.75e+24) (not (<= z 1.0))) (* z (- x)) (+ y x)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.75e+24) || !(z <= 1.0)) {
tmp = z * -x;
} else {
tmp = y + x;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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) :: tmp
if ((z <= (-1.75d+24)) .or. (.not. (z <= 1.0d0))) then
tmp = z * -x
else
tmp = y + x
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.75e+24) || !(z <= 1.0)) {
tmp = z * -x;
} else {
tmp = y + x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (z <= -1.75e+24) or not (z <= 1.0): tmp = z * -x else: tmp = y + x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((z <= -1.75e+24) || !(z <= 1.0)) tmp = Float64(z * Float64(-x)); else tmp = Float64(y + x); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z <= -1.75e+24) || ~((z <= 1.0)))
tmp = z * -x;
else
tmp = y + x;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[Or[LessEqual[z, -1.75e+24], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], N[(y + x), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.75 \cdot 10^{+24} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1.7500000000000001e24 or 1 < z Initial program 100.0%
Taylor expanded in x around inf 59.2%
*-commutative59.2%
Simplified59.2%
Taylor expanded in z around inf 58.2%
mul-1-neg58.2%
*-commutative58.2%
distribute-rgt-neg-in58.2%
Simplified58.2%
if -1.7500000000000001e24 < z < 1Initial program 100.0%
Taylor expanded in z around 0 95.4%
+-commutative95.4%
Simplified95.4%
Final simplification76.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 1.5e-101) (* (- 1.0 z) x) (* (- 1.0 z) y)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.5e-101) {
tmp = (1.0 - z) * x;
} else {
tmp = (1.0 - z) * y;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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) :: tmp
if (y <= 1.5d-101) then
tmp = (1.0d0 - z) * x
else
tmp = (1.0d0 - z) * y
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.5e-101) {
tmp = (1.0 - z) * x;
} else {
tmp = (1.0 - z) * y;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 1.5e-101: tmp = (1.0 - z) * x else: tmp = (1.0 - z) * y return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 1.5e-101) tmp = Float64(Float64(1.0 - z) * x); else tmp = Float64(Float64(1.0 - z) * y); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 1.5e-101)
tmp = (1.0 - z) * x;
else
tmp = (1.0 - z) * y;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 1.5e-101], N[(N[(1.0 - z), $MachinePrecision] * x), $MachinePrecision], N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{-101}:\\
\;\;\;\;\left(1 - z\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(1 - z\right) \cdot y\\
\end{array}
\end{array}
if y < 1.5000000000000002e-101Initial program 100.0%
Taylor expanded in x around inf 62.9%
*-commutative62.9%
Simplified62.9%
if 1.5000000000000002e-101 < y Initial program 100.0%
Taylor expanded in x around 0 66.6%
Final simplification64.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* (- 1.0 z) (+ y x)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return (1.0 - z) * (y + x);
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 - z) * (y + x)
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return (1.0 - z) * (y + x);
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return (1.0 - z) * (y + x)
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(1.0 - z) * Float64(y + x)) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = (1.0 - z) * (y + x);
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 - z), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\left(1 - z\right) \cdot \left(y + x\right)
\end{array}
Initial program 100.0%
Final simplification100.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 1.08e-103) x y))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.08e-103) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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) :: tmp
if (y <= 1.08d-103) then
tmp = x
else
tmp = y
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.08e-103) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 1.08e-103: tmp = x else: tmp = y return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 1.08e-103) tmp = x; else tmp = y; end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 1.08e-103)
tmp = x;
else
tmp = y;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 1.08e-103], x, y]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.08 \cdot 10^{-103}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 1.0799999999999999e-103Initial program 100.0%
Taylor expanded in x around inf 62.9%
*-commutative62.9%
Simplified62.9%
Taylor expanded in z around 0 29.4%
if 1.0799999999999999e-103 < y Initial program 100.0%
Taylor expanded in x around 0 66.6%
Taylor expanded in z around 0 34.9%
Final simplification31.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (+ y x))
assert(x < y && y < z);
double code(double x, double y, double z) {
return y + x;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y + x
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return y + x;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return y + x
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(y + x) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = y + x;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
y + x
\end{array}
Initial program 100.0%
Taylor expanded in z around 0 48.3%
+-commutative48.3%
Simplified48.3%
Final simplification48.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 x)
assert(x < y && y < z);
double code(double x, double y, double z) {
return x;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x
x, y, z = sort([x, y, z]) function code(x, y, z) return x end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := x
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 54.6%
*-commutative54.6%
Simplified54.6%
Taylor expanded in z around 0 25.2%
Final simplification25.2%
herbie shell --seed 2024027
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, H"
:precision binary64
(* (+ x y) (- 1.0 z)))