
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (fma (sin y) (- z) (+ x (cos y))))
double code(double x, double y, double z) {
return fma(sin(y), -z, (x + cos(y)));
}
function code(x, y, z) return fma(sin(y), Float64(-z), Float64(x + cos(y))) end
code[x_, y_, z_] := N[(N[Sin[y], $MachinePrecision] * (-z) + N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin y, -z, x + \cos y\right)
\end{array}
Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x -3.7e+79) x (if (<= x 1.05e-10) (- (cos y) (* (sin y) z)) (+ x (cos y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.7e+79) {
tmp = x;
} else if (x <= 1.05e-10) {
tmp = cos(y) - (sin(y) * z);
} else {
tmp = x + cos(y);
}
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 (x <= (-3.7d+79)) then
tmp = x
else if (x <= 1.05d-10) then
tmp = cos(y) - (sin(y) * z)
else
tmp = x + cos(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.7e+79) {
tmp = x;
} else if (x <= 1.05e-10) {
tmp = Math.cos(y) - (Math.sin(y) * z);
} else {
tmp = x + Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.7e+79: tmp = x elif x <= 1.05e-10: tmp = math.cos(y) - (math.sin(y) * z) else: tmp = x + math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.7e+79) tmp = x; elseif (x <= 1.05e-10) tmp = Float64(cos(y) - Float64(sin(y) * z)); else tmp = Float64(x + cos(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.7e+79) tmp = x; elseif (x <= 1.05e-10) tmp = cos(y) - (sin(y) * z); else tmp = x + cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.7e+79], x, If[LessEqual[x, 1.05e-10], N[(N[Cos[y], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.7 \cdot 10^{+79}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-10}:\\
\;\;\;\;\cos y - \sin y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + \cos y\\
\end{array}
\end{array}
if x < -3.70000000000000009e79Initial program 100.0%
Taylor expanded in x around inf 91.6%
if -3.70000000000000009e79 < x < 1.05e-10Initial program 99.8%
Taylor expanded in x around 0 94.8%
if 1.05e-10 < x Initial program 100.0%
Taylor expanded in z around 0 88.8%
+-commutative88.8%
Simplified88.8%
Final simplification92.8%
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* (sin y) z)))
double code(double x, double y, double z) {
return (x + cos(y)) - (sin(y) * 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 + cos(y)) - (sin(y) * z)
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (Math.sin(y) * z);
}
def code(x, y, z): return (x + math.cos(y)) - (math.sin(y) * z)
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(sin(y) * z)) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (sin(y) * z); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - \sin y \cdot z
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.7e+91) (not (<= z 2.65e+213))) (* z (- (sin y))) (+ x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.7e+91) || !(z <= 2.65e+213)) {
tmp = z * -sin(y);
} else {
tmp = x + cos(y);
}
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.7d+91)) .or. (.not. (z <= 2.65d+213))) then
tmp = z * -sin(y)
else
tmp = x + cos(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.7e+91) || !(z <= 2.65e+213)) {
tmp = z * -Math.sin(y);
} else {
tmp = x + Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.7e+91) or not (z <= 2.65e+213): tmp = z * -math.sin(y) else: tmp = x + math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.7e+91) || !(z <= 2.65e+213)) tmp = Float64(z * Float64(-sin(y))); else tmp = Float64(x + cos(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.7e+91) || ~((z <= 2.65e+213))) tmp = z * -sin(y); else tmp = x + cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.7e+91], N[Not[LessEqual[z, 2.65e+213]], $MachinePrecision]], N[(z * (-N[Sin[y], $MachinePrecision])), $MachinePrecision], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{+91} \lor \neg \left(z \leq 2.65 \cdot 10^{+213}\right):\\
\;\;\;\;z \cdot \left(-\sin y\right)\\
\mathbf{else}:\\
\;\;\;\;x + \cos y\\
\end{array}
\end{array}
if z < -1.7e91 or 2.6499999999999999e213 < z Initial program 99.8%
Taylor expanded in z around inf 72.0%
associate-*r*72.0%
neg-mul-172.0%
*-commutative72.0%
Simplified72.0%
if -1.7e91 < z < 2.6499999999999999e213Initial program 99.9%
Taylor expanded in z around 0 89.2%
+-commutative89.2%
Simplified89.2%
Final simplification84.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.9e+19) (not (<= y 9.5e-5))) (+ x (cos y)) (+ x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.9e+19) || !(y <= 9.5e-5)) {
tmp = x + cos(y);
} else {
tmp = x + (1.0 - (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 <= (-4.9d+19)) .or. (.not. (y <= 9.5d-5))) then
tmp = x + cos(y)
else
tmp = x + (1.0d0 - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4.9e+19) || !(y <= 9.5e-5)) {
tmp = x + Math.cos(y);
} else {
tmp = x + (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.9e+19) or not (y <= 9.5e-5): tmp = x + math.cos(y) else: tmp = x + (1.0 - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.9e+19) || !(y <= 9.5e-5)) tmp = Float64(x + cos(y)); else tmp = Float64(x + Float64(1.0 - Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.9e+19) || ~((y <= 9.5e-5))) tmp = x + cos(y); else tmp = x + (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.9e+19], N[Not[LessEqual[y, 9.5e-5]], $MachinePrecision]], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.9 \cdot 10^{+19} \lor \neg \left(y \leq 9.5 \cdot 10^{-5}\right):\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;x + \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if y < -4.9e19 or 9.5000000000000005e-5 < y Initial program 99.8%
Taylor expanded in z around 0 64.2%
+-commutative64.2%
Simplified64.2%
if -4.9e19 < y < 9.5000000000000005e-5Initial program 100.0%
Taylor expanded in y around 0 97.9%
associate-+r+97.9%
+-commutative97.9%
associate-+l+97.9%
mul-1-neg97.9%
unsub-neg97.9%
Simplified97.9%
Final simplification81.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -1e-29) (not (<= x 8.5e-15))) (+ x 1.0) (cos y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1e-29) || !(x <= 8.5e-15)) {
tmp = x + 1.0;
} else {
tmp = cos(y);
}
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 ((x <= (-1d-29)) .or. (.not. (x <= 8.5d-15))) then
tmp = x + 1.0d0
else
tmp = cos(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1e-29) || !(x <= 8.5e-15)) {
tmp = x + 1.0;
} else {
tmp = Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1e-29) or not (x <= 8.5e-15): tmp = x + 1.0 else: tmp = math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1e-29) || !(x <= 8.5e-15)) tmp = Float64(x + 1.0); else tmp = cos(y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1e-29) || ~((x <= 8.5e-15))) tmp = x + 1.0; else tmp = cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1e-29], N[Not[LessEqual[x, 8.5e-15]], $MachinePrecision]], N[(x + 1.0), $MachinePrecision], N[Cos[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-29} \lor \neg \left(x \leq 8.5 \cdot 10^{-15}\right):\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;\cos y\\
\end{array}
\end{array}
if x < -9.99999999999999943e-30 or 8.50000000000000007e-15 < x Initial program 99.9%
Taylor expanded in y around 0 79.5%
+-commutative79.5%
Simplified79.5%
if -9.99999999999999943e-30 < x < 8.50000000000000007e-15Initial program 99.9%
Taylor expanded in z around 0 61.7%
+-commutative61.7%
Simplified61.7%
Taylor expanded in x around 0 61.6%
Final simplification70.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.25e+22) (not (<= y 3.85e+62))) (+ x 1.0) (+ x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e+22) || !(y <= 3.85e+62)) {
tmp = x + 1.0;
} else {
tmp = x + (1.0 - (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 <= (-1.25d+22)) .or. (.not. (y <= 3.85d+62))) then
tmp = x + 1.0d0
else
tmp = x + (1.0d0 - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e+22) || !(y <= 3.85e+62)) {
tmp = x + 1.0;
} else {
tmp = x + (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.25e+22) or not (y <= 3.85e+62): tmp = x + 1.0 else: tmp = x + (1.0 - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.25e+22) || !(y <= 3.85e+62)) tmp = Float64(x + 1.0); else tmp = Float64(x + Float64(1.0 - Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.25e+22) || ~((y <= 3.85e+62))) tmp = x + 1.0; else tmp = x + (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.25e+22], N[Not[LessEqual[y, 3.85e+62]], $MachinePrecision]], N[(x + 1.0), $MachinePrecision], N[(x + N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+22} \lor \neg \left(y \leq 3.85 \cdot 10^{+62}\right):\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;x + \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if y < -1.2499999999999999e22 or 3.8500000000000001e62 < y Initial program 99.8%
Taylor expanded in y around 0 42.4%
+-commutative42.4%
Simplified42.4%
if -1.2499999999999999e22 < y < 3.8500000000000001e62Initial program 100.0%
Taylor expanded in y around 0 90.8%
associate-+r+90.8%
+-commutative90.8%
associate-+l+90.8%
mul-1-neg90.8%
unsub-neg90.8%
Simplified90.8%
Final simplification70.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.9e-12) (not (<= x 5.8e-37))) (+ x 1.0) (- 1.0 (* y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.9e-12) || !(x <= 5.8e-37)) {
tmp = x + 1.0;
} else {
tmp = 1.0 - (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 ((x <= (-1.9d-12)) .or. (.not. (x <= 5.8d-37))) then
tmp = x + 1.0d0
else
tmp = 1.0d0 - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.9e-12) || !(x <= 5.8e-37)) {
tmp = x + 1.0;
} else {
tmp = 1.0 - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.9e-12) or not (x <= 5.8e-37): tmp = x + 1.0 else: tmp = 1.0 - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.9e-12) || !(x <= 5.8e-37)) tmp = Float64(x + 1.0); else tmp = Float64(1.0 - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.9e-12) || ~((x <= 5.8e-37))) tmp = x + 1.0; else tmp = 1.0 - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.9e-12], N[Not[LessEqual[x, 5.8e-37]], $MachinePrecision]], N[(x + 1.0), $MachinePrecision], N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{-12} \lor \neg \left(x \leq 5.8 \cdot 10^{-37}\right):\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;1 - y \cdot z\\
\end{array}
\end{array}
if x < -1.89999999999999998e-12 or 5.80000000000000009e-37 < x Initial program 99.9%
Taylor expanded in y around 0 81.5%
+-commutative81.5%
Simplified81.5%
if -1.89999999999999998e-12 < x < 5.80000000000000009e-37Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 99.9%
Taylor expanded in y around 0 52.5%
mul-1-neg52.5%
unsub-neg52.5%
Simplified52.5%
Final simplification67.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.45e+248) (not (<= z 7e+215))) (* y (- z)) (+ x 1.0)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.45e+248) || !(z <= 7e+215)) {
tmp = y * -z;
} else {
tmp = x + 1.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) :: tmp
if ((z <= (-1.45d+248)) .or. (.not. (z <= 7d+215))) then
tmp = y * -z
else
tmp = x + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.45e+248) || !(z <= 7e+215)) {
tmp = y * -z;
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.45e+248) or not (z <= 7e+215): tmp = y * -z else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.45e+248) || !(z <= 7e+215)) tmp = Float64(y * Float64(-z)); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.45e+248) || ~((z <= 7e+215))) tmp = y * -z; else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.45e+248], N[Not[LessEqual[z, 7e+215]], $MachinePrecision]], N[(y * (-z)), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{+248} \lor \neg \left(z \leq 7 \cdot 10^{+215}\right):\\
\;\;\;\;y \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if z < -1.45e248 or 6.99999999999999954e215 < z Initial program 99.8%
Taylor expanded in z around inf 82.5%
associate-*r*82.5%
neg-mul-182.5%
*-commutative82.5%
Simplified82.5%
Taylor expanded in y around 0 51.4%
mul-1-neg51.4%
*-commutative51.4%
distribute-rgt-neg-in51.4%
Simplified51.4%
if -1.45e248 < z < 6.99999999999999954e215Initial program 99.9%
Taylor expanded in y around 0 67.5%
+-commutative67.5%
Simplified67.5%
Final simplification65.1%
(FPCore (x y z) :precision binary64 (if (<= x -0.56) x (if (<= x 0.77) 1.0 x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -0.56) {
tmp = x;
} else if (x <= 0.77) {
tmp = 1.0;
} 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 (x <= (-0.56d0)) then
tmp = x
else if (x <= 0.77d0) then
tmp = 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -0.56) {
tmp = x;
} else if (x <= 0.77) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -0.56: tmp = x elif x <= 0.77: tmp = 1.0 else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -0.56) tmp = x; elseif (x <= 0.77) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -0.56) tmp = x; elseif (x <= 0.77) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -0.56], x, If[LessEqual[x, 0.77], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.56:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 0.77:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -0.56000000000000005 or 0.77000000000000002 < x Initial program 99.9%
Taylor expanded in x around inf 81.1%
if -0.56000000000000005 < x < 0.77000000000000002Initial program 99.9%
Taylor expanded in x around 0 98.9%
Taylor expanded in y around 0 39.9%
Final simplification59.7%
(FPCore (x y z) :precision binary64 (+ x 1.0))
double code(double x, double y, double z) {
return x + 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + 1.0d0
end function
public static double code(double x, double y, double z) {
return x + 1.0;
}
def code(x, y, z): return x + 1.0
function code(x, y, z) return Float64(x + 1.0) end
function tmp = code(x, y, z) tmp = x + 1.0; end
code[x_, y_, z_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
x + 1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 60.4%
+-commutative60.4%
Simplified60.4%
Final simplification60.4%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
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
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 60.5%
Taylor expanded in y around 0 22.2%
Final simplification22.2%
herbie shell --seed 2023312
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, B"
:precision binary64
(- (+ x (cos y)) (* z (sin y))))