
(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 11 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 (+ 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(x + Float64(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[(x + N[(N[Cos[y], $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\cos y - z \cdot \sin y\right)
\end{array}
Initial program 99.9%
associate--l+100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.5e-10) (not (<= x 1.55e-9))) (+ x (cos y)) (- (cos y) (* z (sin y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e-10) || !(x <= 1.55e-9)) {
tmp = x + cos(y);
} else {
tmp = cos(y) - (z * sin(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 <= (-5.5d-10)) .or. (.not. (x <= 1.55d-9))) then
tmp = x + cos(y)
else
tmp = cos(y) - (z * sin(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e-10) || !(x <= 1.55e-9)) {
tmp = x + Math.cos(y);
} else {
tmp = Math.cos(y) - (z * Math.sin(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.5e-10) or not (x <= 1.55e-9): tmp = x + math.cos(y) else: tmp = math.cos(y) - (z * math.sin(y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.5e-10) || !(x <= 1.55e-9)) tmp = Float64(x + cos(y)); else tmp = Float64(cos(y) - Float64(z * sin(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.5e-10) || ~((x <= 1.55e-9))) tmp = x + cos(y); else tmp = cos(y) - (z * sin(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.5e-10], N[Not[LessEqual[x, 1.55e-9]], $MachinePrecision]], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{-10} \lor \neg \left(x \leq 1.55 \cdot 10^{-9}\right):\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;\cos y - z \cdot \sin y\\
\end{array}
\end{array}
if x < -5.4999999999999996e-10 or 1.55000000000000002e-9 < x Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around 0 83.6%
+-commutative83.6%
Simplified83.6%
if -5.4999999999999996e-10 < x < 1.55000000000000002e-9Initial program 99.9%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around 0 99.6%
Final simplification91.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.3e+147) (not (<= z 4.6e+136))) (* z (- (sin y))) (+ x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.3e+147) || !(z <= 4.6e+136)) {
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.3d+147)) .or. (.not. (z <= 4.6d+136))) 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.3e+147) || !(z <= 4.6e+136)) {
tmp = z * -Math.sin(y);
} else {
tmp = x + Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.3e+147) or not (z <= 4.6e+136): tmp = z * -math.sin(y) else: tmp = x + math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.3e+147) || !(z <= 4.6e+136)) 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.3e+147) || ~((z <= 4.6e+136))) tmp = z * -sin(y); else tmp = x + cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.3e+147], N[Not[LessEqual[z, 4.6e+136]], $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.3 \cdot 10^{+147} \lor \neg \left(z \leq 4.6 \cdot 10^{+136}\right):\\
\;\;\;\;z \cdot \left(-\sin y\right)\\
\mathbf{else}:\\
\;\;\;\;x + \cos y\\
\end{array}
\end{array}
if z < -1.2999999999999999e147 or 4.6e136 < z Initial program 99.8%
associate--l+99.9%
Simplified99.9%
Taylor expanded in z around inf 82.4%
associate-*r*82.4%
neg-mul-182.4%
*-commutative82.4%
Simplified82.4%
if -1.2999999999999999e147 < z < 4.6e136Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around 0 91.8%
+-commutative91.8%
Simplified91.8%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -135.0) (not (<= y 250000.0))) (+ x (cos y)) (+ x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -135.0) || !(y <= 250000.0)) {
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 <= (-135.0d0)) .or. (.not. (y <= 250000.0d0))) 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 <= -135.0) || !(y <= 250000.0)) {
tmp = x + Math.cos(y);
} else {
tmp = x + (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -135.0) or not (y <= 250000.0): tmp = x + math.cos(y) else: tmp = x + (1.0 - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -135.0) || !(y <= 250000.0)) 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 <= -135.0) || ~((y <= 250000.0))) tmp = x + cos(y); else tmp = x + (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -135.0], N[Not[LessEqual[y, 250000.0]], $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 -135 \lor \neg \left(y \leq 250000\right):\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;x + \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if y < -135 or 2.5e5 < y Initial program 99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in z around 0 68.8%
+-commutative68.8%
Simplified68.8%
if -135 < y < 2.5e5Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 98.3%
associate-+r+98.3%
+-commutative98.3%
associate-+l+98.3%
mul-1-neg98.3%
unsub-neg98.3%
Simplified98.3%
Final simplification83.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.2e+41) (not (<= y 3700000.0))) (+ x 1.0) (+ x (+ 1.0 (* y (- (* y -0.5) z))))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.2e+41) || !(y <= 3700000.0)) {
tmp = x + 1.0;
} else {
tmp = x + (1.0 + (y * ((y * -0.5) - 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.2d+41)) .or. (.not. (y <= 3700000.0d0))) then
tmp = x + 1.0d0
else
tmp = x + (1.0d0 + (y * ((y * (-0.5d0)) - z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4.2e+41) || !(y <= 3700000.0)) {
tmp = x + 1.0;
} else {
tmp = x + (1.0 + (y * ((y * -0.5) - z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.2e+41) or not (y <= 3700000.0): tmp = x + 1.0 else: tmp = x + (1.0 + (y * ((y * -0.5) - z))) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.2e+41) || !(y <= 3700000.0)) tmp = Float64(x + 1.0); else tmp = Float64(x + Float64(1.0 + Float64(y * Float64(Float64(y * -0.5) - z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.2e+41) || ~((y <= 3700000.0))) tmp = x + 1.0; else tmp = x + (1.0 + (y * ((y * -0.5) - z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.2e+41], N[Not[LessEqual[y, 3700000.0]], $MachinePrecision]], N[(x + 1.0), $MachinePrecision], N[(x + N[(1.0 + N[(y * N[(N[(y * -0.5), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+41} \lor \neg \left(y \leq 3700000\right):\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;x + \left(1 + y \cdot \left(y \cdot -0.5 - z\right)\right)\\
\end{array}
\end{array}
if y < -4.1999999999999999e41 or 3.7e6 < y Initial program 99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 47.9%
+-commutative47.9%
Simplified47.9%
if -4.1999999999999999e41 < y < 3.7e6Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 95.5%
+-commutative95.5%
associate-+l+95.5%
+-commutative95.5%
mul-1-neg95.5%
unsub-neg95.5%
*-commutative95.5%
unpow295.5%
associate-*l*95.5%
distribute-lft-out--95.5%
Simplified95.5%
Final simplification73.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -3900.0) (not (<= y 3900000.0))) (+ x 1.0) (+ x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3900.0) || !(y <= 3900000.0)) {
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 <= (-3900.0d0)) .or. (.not. (y <= 3900000.0d0))) 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 <= -3900.0) || !(y <= 3900000.0)) {
tmp = x + 1.0;
} else {
tmp = x + (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3900.0) or not (y <= 3900000.0): tmp = x + 1.0 else: tmp = x + (1.0 - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3900.0) || !(y <= 3900000.0)) 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 <= -3900.0) || ~((y <= 3900000.0))) tmp = x + 1.0; else tmp = x + (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3900.0], N[Not[LessEqual[y, 3900000.0]], $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 -3900 \lor \neg \left(y \leq 3900000\right):\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;x + \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if y < -3900 or 3.9e6 < y Initial program 99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 46.9%
+-commutative46.9%
Simplified46.9%
if -3900 < y < 3.9e6Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 98.3%
associate-+r+98.3%
+-commutative98.3%
associate-+l+98.3%
mul-1-neg98.3%
unsub-neg98.3%
Simplified98.3%
Final simplification73.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.9e+204) (not (<= z 7e+165))) (- 1.0 (* y z)) (+ x 1.0)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9e+204) || !(z <= 7e+165)) {
tmp = 1.0 - (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.9d+204)) .or. (.not. (z <= 7d+165))) then
tmp = 1.0d0 - (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.9e+204) || !(z <= 7e+165)) {
tmp = 1.0 - (y * z);
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.9e+204) or not (z <= 7e+165): tmp = 1.0 - (y * z) else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.9e+204) || !(z <= 7e+165)) tmp = Float64(1.0 - Float64(y * z)); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.9e+204) || ~((z <= 7e+165))) tmp = 1.0 - (y * z); else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.9e+204], N[Not[LessEqual[z, 7e+165]], $MachinePrecision]], N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+204} \lor \neg \left(z \leq 7 \cdot 10^{+165}\right):\\
\;\;\;\;1 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if z < -1.8999999999999999e204 or 6.99999999999999991e165 < z Initial program 99.8%
associate--l+99.9%
Simplified99.9%
add-cube-cbrt98.2%
pow398.1%
Applied egg-rr98.1%
Taylor expanded in x around 0 47.0%
unpow1/391.9%
Simplified91.9%
Taylor expanded in y around 0 49.1%
distribute-rgt-out49.4%
metadata-eval49.4%
*-commutative49.4%
mul-1-neg49.4%
Simplified49.4%
if -1.8999999999999999e204 < z < 6.99999999999999991e165Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 75.0%
+-commutative75.0%
Simplified75.0%
Final simplification70.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.5e+203) (not (<= z 6.2e+165))) (- (* y z)) (+ x 1.0)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.5e+203) || !(z <= 6.2e+165)) {
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 <= (-4.5d+203)) .or. (.not. (z <= 6.2d+165))) 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 <= -4.5e+203) || !(z <= 6.2e+165)) {
tmp = -(y * z);
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.5e+203) or not (z <= 6.2e+165): tmp = -(y * z) else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.5e+203) || !(z <= 6.2e+165)) tmp = Float64(-Float64(y * z)); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.5e+203) || ~((z <= 6.2e+165))) tmp = -(y * z); else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.5e+203], N[Not[LessEqual[z, 6.2e+165]], $MachinePrecision]], (-N[(y * z), $MachinePrecision]), N[(x + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+203} \lor \neg \left(z \leq 6.2 \cdot 10^{+165}\right):\\
\;\;\;\;-y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if z < -4.5000000000000003e203 or 6.2000000000000003e165 < z Initial program 99.8%
associate--l+99.9%
Simplified99.9%
Taylor expanded in z around inf 89.5%
associate-*r*89.5%
neg-mul-189.5%
*-commutative89.5%
Simplified89.5%
Taylor expanded in y around 0 45.4%
mul-1-neg45.4%
distribute-rgt-neg-in45.4%
Simplified45.4%
if -4.5000000000000003e203 < z < 6.2000000000000003e165Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 75.0%
+-commutative75.0%
Simplified75.0%
Final simplification69.5%
(FPCore (x y z) :precision binary64 (if (<= x -0.49) x (if (<= x 1.3) 1.0 x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -0.49) {
tmp = x;
} else if (x <= 1.3) {
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.49d0)) then
tmp = x
else if (x <= 1.3d0) 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.49) {
tmp = x;
} else if (x <= 1.3) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -0.49: tmp = x elif x <= 1.3: tmp = 1.0 else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -0.49) tmp = x; elseif (x <= 1.3) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -0.49) tmp = x; elseif (x <= 1.3) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -0.49], x, If[LessEqual[x, 1.3], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.49:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -0.48999999999999999 or 1.30000000000000004 < x Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around inf 80.3%
if -0.48999999999999999 < x < 1.30000000000000004Initial program 99.9%
associate--l+99.9%
Simplified99.9%
add-cube-cbrt98.7%
pow398.7%
Applied egg-rr98.7%
Taylor expanded in x around 0 71.7%
unpow1/395.5%
Simplified95.5%
Taylor expanded in y around 0 43.3%
Final simplification61.2%
(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%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 62.8%
+-commutative62.8%
Simplified62.8%
Final simplification62.8%
(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%
associate--l+100.0%
Simplified100.0%
add-cube-cbrt98.3%
pow398.3%
Applied egg-rr98.3%
Taylor expanded in x around 0 42.7%
unpow1/358.6%
Simplified58.6%
Taylor expanded in y around 0 23.8%
Final simplification23.8%
herbie shell --seed 2024053
(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))))