[{"content":"Limits: Exact Value or an Approximation? Probably the majority of people will say that the limit is an exact construct and not an approximation but instead a unique real number. For the sake of simplicity we will keep it in the real number domain and use polynomials as examples. And indeed, this statement is correct. But books and intuitive explanations always talk about arbitrarily close etc. But arbitrarily close still is not exactly at the point right? It is just arbitrarily close ¯\\_(ツ)_/¯\nWe will try to convince even the biggest skeptic (me) that the limit is indeed an exact number and not just an approximation. For this, it might make sense to look at the derivative formula as it is intuitively relatively clear and makes up for great insights.\nFor all the mathematicians and rigorous folks, the following sections might sometimes not be completely accurate in favor of intuitive clarity. If you however spot a critical error, feel free to reach out!\nLimit Notation Stop, before we dive straight into derivatives we should make something clear. What the hell does \\(\\lim_{x \\to a} f(x)\\) mean? This expression reads as follows: \u0026ldquo;The limit f(x) as x approaches a\u0026rdquo;. To make it a bit less abstract, let’s say we have a function \\(f(x)=x^2\\) and we want to find its limit at \\(x=3\\). This leads to the following expression: \\(\\lim_{x \\to 3} x^2\\) which reads as \u0026ldquo;The limit of x^2 as x approaches 3\u0026rdquo;. The key here is that this expression does not simply set \\(x=3\\) and plug it into \\(f(x)\\). Instead, we approach \\(f(x)\\) from both sides which looks like the following table:\nApproach from the left \\(f(x)=x^2\\) Approach from the right \\(f(x)=x^2\\) 2.9 8.41 3.1 9.61 2.99 8.9401 3.01 9.0601 2.999 8.994001 3.001 9.006001 2.9999 8.99940001 3.0001 9.00060001 2.99999 8.9999400001 3.00001 9.0000600001 Table (1). Values approaching \\(x=3\\) from both sides for \\(f(x)=x^2\\) As shown in Table (1), both sides approach 9 but they do not strictly equal 9 and on top of that we did not use \\(x=3\\) instead we used values slightly bigger or smaller than \\(x\\).\nThis also means that the limit and the actual function value at the point do not have to be the same thing. For example, we can define a function that behaves like \\(f(x)=x\\) everywhere around \\(x=3\\), but then manually set the value at \\(x=3\\) to 10:\n$$ f(x)= \\begin{cases} x, \u0026amp; x\\neq 3 \\\\ 10, \u0026amp; x=3 \\end{cases} $$\nFor now it suffices to understand, that the notation \\(\\lim_{x \\to a} f(x)\\), specifically the \\(x\\to a\\) part, means that we approach something.\nDerivative Before we dive into the formalism of the derivative, let’s provide some intuition. Assuming we have well defined functions, the derivative provides the slope at any given point.\nThe idea behind the formula of the derivative is, that we take two points \\(x_1\\) and \\(x_2\\) on the x-axis and calculate the difference of their corresponding function values over the interval \\([x_1,x_2]\\).\nWe can do so by taking the difference of the values \\(y_1=f(x_1)\\) and \\(y_2=f(x_2)\\) and dividing them by the difference of the values \\(x_1,x_2\\). We can write this as follows:\n$$ \\begin{aligned} \\text{(1)}\\quad \\frac{f(x_2)-f(x_1)}{x_2-x_1} = \\frac{y_2-y_1}{x_2-x_1} \\ = \\frac{\\Delta y}{\\Delta x} \\end{aligned} $$\nEquation (1), provides the average slope over an interval \\([x_1,x_2]\\). In case you are unfamiliar or scared of \\(\\Delta x\\) and \\(\\Delta y\\), they are just a compact way, to write the differences between two points. The slope of equation (1) is also referred to as the slope of the secant line. This is simply the line we get, when drawing a line through \\(y_1\\) and \\(y_2\\).\nWhile this sounds all super interesting and cool, we are still computing the slope between two different points, but the derivative provides the value at a single point. So how does this work?\nIn order to show this, let’s first dissect the formula for the derivative piece by piece. The definition of the derivative is the following:\n$$ \\text{(2)}\\quad f\u0026rsquo;(x)=\\lim_{h \\to 0} \\text{ }\\frac{f(x+h)-f(x)}{h} $$\nNow, let’s make this easier to digest and use \\(f(x)=x^2\\). When plugging in \\(x^2\\) we get the following:\n$$ \\begin{aligned} f\u0026rsquo;(x) \u0026amp;= \\lim_{h \\to 0} \\text{ }\\frac{(x+h)^2 - x^2}{h} \\\\ \u0026amp;= \\lim_{h \\to 0} \\text{ }\\frac{x^2 + 2xh + h^2 - x^2}{h} \\\\ \u0026amp;= \\lim_{h \\to 0} \\text{ }\\frac{2xh + h^2}{h} \\\\ \u0026amp;= \\lim_{h \\to 0} \\text{ }2x + h \\\\ \u0026amp;= 2x \\end{aligned} $$\nAfter evaluating the expression we end up with \\(f\u0026rsquo;(x)=2x\\) which is also the derivative as we know. Previously, we were talking about secant lines and the derivative now provides us with the slope of the tangent line at one point. The difference between a secant and a tangent line is that a secant line is determined by two distinct points on the curve, while the tangent line captures the limiting slope at a single point. Thus, the derivative gives us the exact instantaneous slope at that point instead of an average slope over a small interval \\([x_1,x_2]\\).\nBut stop. The derivative formula above somehow bites the intuitive explanation that we approach something but do not set the \\(x\\) to the value we approach and thus in this case \\(h\\) never truly equals \\(0\\) but instead we approach \\(0\\). So where the hell did the \\(h\\) go? Why did it simply disappear if we said it never equals \\(0\\)? Well, before we can truly answer this question we must stay strong and dive just a tiny bit deeper.\nThe big ol\u0026rsquo; \\(\\epsilon\\)-\\(\\delta\\) The \\(\\epsilon\\)-\\(\\delta\\)-definition looks like this:\n$$ \\text{(3)}\\quad \\lim_{x \\to a} f(x) = L \\quad \\Longleftrightarrow \\quad \\forall \\epsilon \u0026gt; 0\\ \\exists \\delta \u0026gt; 0 \\forall x: 0 \u0026lt; |x-a| \u0026lt; \\delta \\Rightarrow |f(x)-L| \u0026lt; \\epsilon $$\nYikes, that\u0026rsquo;s heavy. Let’s walk through it step by step. First of all we have an equivalence which means that from the right side the left side follows and vice versa. Let’s focus on the right part:\n$$ \\forall \\epsilon \u0026gt; 0\\ \\exists \\delta \u0026gt; 0 \\forall x: 0 \u0026lt; |x-a| \u0026lt; \\delta \\Rightarrow |f(x)-L| \u0026lt; \\epsilon $$\nThis is a conditional statement and reads as follows:\n\u0026ldquo;For all epsilon bigger than 0, there exists a delta greater than 0, such that IF the distance between \\(x\\) and \\(a\\) is strictly greater than 0 and less than delta THEN the difference between \\(f(x)\\) and \\(L\\) is less than epsilon.\u0026rdquo;\nEven in its written form it still sounds a bit heavy so let’s make use of a picture. We all know the saying \u0026ldquo;A picture tells a thousand words\u0026rdquo; ✨\nFigure (1). \\(\\epsilon\\)-\\(\\delta\\)-Definition visualized. Source (modified): Math StackExchange\nIn Figure (1) there are two important parts. First the horizontal lines around the limit \\(L\\), spanning the red tube, which are denoted with \\(L+\\epsilon\\) and \\(L-\\epsilon\\). They set the error or maximum accepted deviation distance around the limit \\(L\\), that we accept for our function values \\(f(x)\\). In short, all values \\(f(x)\\) must fall within this range.\nThe second part shows a blue tube around \\(a\\) which is bounded by \\(a+\\delta\\) and \\(a-\\delta\\). This interval sets the boundary around the point \\(a\\) in which all points \\(a_i\\in [a-\\delta;a+\\delta]\\) must satisfy \\(|f(a_i)-L| \u0026lt; \\epsilon\\).\nWe can see that if we tighten the accepted error (red tube) we also have to tighten the blue tube because otherwise there may be inputs \\(a_i\\in [a-\\delta;a+\\delta]\\) where \\(|f(a_i)-L| \\geq \\epsilon\\) and thus the condition is broken.\nPutting it all together Okay, we have now talked about derivatives and the \\(\\epsilon\\)-\\(\\delta\\)-definition. How should this convince even the biggest skeptic that limits are indeed exact? The ✨magic✨ is buried inside the \\(\\epsilon\\)-\\(\\delta\\)-definition and can be greatly understood with derivatives.\nSecant line approaching a tangent line for y equals x squared An interactive graph of y equals x squared. A slider changes the nonzero h value used in the difference quotient. P Q Distance from the fixed point, \\(|h|\\) +1 Approach Right Left Secant slope \\(2x + h =\\) 4.00 Tangent slope \\(2x =\\) 3.00 Remaining gap \\(|h| =\\) 1.00 Secant Tangent \\(\\Delta x\\), \\(\\Delta y\\) Figure (2). Secant lines for \\(f(x)=x^2\\) at \\(x=1.5\\). The slider never uses \\(h=0\\); it only makes nonzero values of \\(h\\) smaller, so the secant slope \\(2x+h\\) approaches the exact tangent slope \\(2x\\). Without JavaScript, read this as the static relation: for \\(x=1.5\\), the secant slope is \\(2x+h\\), and as nonzero \\(h\\) approaches 0 this approaches \\(2x\\).\nWhen going back to derivatives, we learned that the derivative \\(f\u0026rsquo;(x)\\) is the slope of the tangent at point \\(x\\). Furthermore, it is the value that all secants converge to, when the distance of the two points of the secants approach \\(0.\\) Looking at Figure (2), every secant slope is still an approximation because \\(h\\neq0\\), but the value of the slope of those secants are forced toward the exact tangent slope which in turn is the limit.\nAnd here comes the important part: In formula (2) we asked why \\(h\\) suddenly disappeared. The important point is that \\(\\lim_{x\\to a}\\) is an infinite process in which we get closer and closer but we never set \\(h=0\\) into the original fraction.\n$$ \\begin{aligned} \u0026amp;= \\lim_{h \\to 0} \\text{ }\\frac{2xh + h^2}{h} \\\\ \u0026amp;= \\lim_{h \\to 0} \\text{ }2x + h \\\\ \\end{aligned} $$\nThe original expression is even undefined at \\(h=0\\). We were only able to make this cancellation because we approach \\(0\\) but do not set \\(h=0\\). Instead, we simplified the expression for all \\(h\\neq0\\).\nThis infinite process is stated in the \\(\\epsilon\\)-\\(\\delta\\)-definition in (3) which states that the right side of the equivalence must hold \\(\\forall\\epsilon\\) . This is also what we mean with infinite process, since there are infinitely many (positive) numbers and we can make the red tube in Figure (1) as small as we want. The condition \\(0 \u0026lt; |x-a| \u0026lt; \\delta\\) describes exactly this idea, where we look for inputs arbitrarily close to \\(a\\) but not equal to \\(a\\) itself.\nWe can illustrate this behavior in Figure (2) where we can make the distance \\(h\\) smaller and smaller but for non-zero \\(h\\), we would get a secant and not a tangent. However, we are interested in the slope at the exact point and that is given by the tangent at that point. That requires us to take the limit, as we cannot just put \\(h=0\\) and magically let \\(h\\) disappear.\nAnother way to intuitively think about it is that the secant slopes approach one exact value, and because of that, the value at the exact point should behave like the slope of the tangent line at that point. This further illustrates that the limit is a separate object from the value at \\(h=0\\). This is further illustrated in Figure (3) which shows a piecewise function where \\(f(x)=x\\) for all values except for \\(x=3\\). Now we see that \\(\\lim_{x\\to 3} f(x)\\) is equal to \\(3\\) but \\(f(3)=10\\). Therefore the limit when approaching \\(a\\) can be different from \\(f(a)\\) and hence the limit and the function value are two separate objects.\nThe limit at x equals 3 differs from the defined value A graph of y equals x with an open circle at three comma three and a filled point at three comma ten. y = x limit value: 3 defined value: 10 x y 0 3 6 3 10 Nearby rule \\(f(x)=x\\) for \\(x\\neq3\\) Limit \\(\\lim_{x\\to3} f(x)=3\\) Actual value \\(f(3)=10\\) Values near \\(x=3\\) Value at \\(x=3\\) Reference lines Figure (3). A function can approach one value while being defined as another value at the exact point. Here the nearby values follow \\(y=x\\), so the limit as \\(x\\to3\\) is 3, but the actual function value is \\(f(3)=10\\). Since \\(\\lim_{x\\to 3} f(x)=3\\), the nearby behavior at \\(x=3\\) suggests that \\(f(3)\\) would be \\(3\\). However, we see that this is not the case and \\(f(3)=10\\). And since \\(\\lim_{x\\to 3} f(x)=3\\) (our expected behavior at \\(x=3\\)) was different from the actual function value \\(f(3)\\) we can go even further and deduce that the function is not continuous 💡.\nBut what does continuity mean? That\u0026rsquo;s another story :)\nThe End Now you might think, what a wall of text, for something that is accepted as a fact. That is correct, but sometimes especially when working with infinities, it feels correct and wrong at the same time. It took me a while to intuitively accept the fact that limits are really exact and not just a super close approximation. And even when it made intuitive sense after working with limits a while, as soon as I stopped working with them and came back after a while, there was this weird feeling again. The explanation above however, satisfied my intuition. I think sometimes there are topics, where you need a certain amount of exposure in order to get this satisfied feeling. Another contributing factor is to really understand and dissect definitions. For a while I somewhat glossed over the \\(\\forall\\epsilon\\) requirement in the \\(\\epsilon\\)-\\(\\delta\\)-definition but this is the most crucial part, that also makes everything less magical. If this still does not convince you directly, that\u0026rsquo;s okay. Read the article again, take your time and do not hesitate to incorporate other resources.\nWith this post, I tried to provide different perspectives of the exactness of limits to satisfy other peers that might have the same weird feeling I once had.\n","permalink":"https://miguelperez.me/posts/limits/","summary":"\u003ch1 id=\"limits-exact-value-or-an-approximation\"\u003eLimits: Exact Value or an Approximation?\u003c/h1\u003e\n\u003cp\u003eProbably the majority of people will say that the limit is an exact construct and not an approximation but instead a unique real number. For the sake of simplicity we will keep it in the real number domain and use polynomials as examples. And indeed, this statement is correct. But books and intuitive explanations always talk about arbitrarily close etc. But arbitrarily close still is not exactly at the point right? It is just arbitrarily close ¯\\_(ツ)_/¯\u003cbr\u003e\nWe will try to convince even the biggest skeptic (me) that the limit is indeed an exact number and not just an approximation.\nFor this, it might make sense to look at the derivative formula as it is intuitively relatively clear and makes up for great insights.\u003c/p\u003e","title":"Limits: Exact Value or an Approximation?"},{"content":"To gain more experience in software-engineering I was playing around with the thought to contribute to open-source software. Since I started reading \u0026ldquo;Programming Rust\u0026rdquo; by O\u0026rsquo;Reilly to get started with a low-level language, I got also interested in understanding what happens under the hood when we execute or compile a program.\nTherefore, I thought it might be a good idea to look into the Rust Programming language itself. Coincidentally, I found this video from Esteban Kuber, which ultimately made sure to check out the Rust compiler.\nI started reading through the Rust compiler guide and followed all instructions. Everything worked out the first time till I ran the first tests. After executing the tests on the standard library with the following command: python ./x.py test --stage 0 library/std one test case failed. I wondered if the reason was that I ran the tests with the stage 0 compiler but since every other test case succeeded I got skeptical and checked out the error message:\nfailures: ---- fs::tests::read_link stdout ---- thread \u0026#39;fs::tests::read_link\u0026#39; panicked at \u0026#39;fs::read_link(r\u0026#34;C:\\Documents and Settings\\\u0026#34;) failed with: The system cannot find the file specified. (os error 2)\u0026#39;, library\\std\\src\\fs\\tests.rs:839:20 The source code of the corresponding test case looks like this:\nfn read_link() { if cfg!(windows) { // directory symlink assert_eq!(check!(fs::read_link(r\u0026#34;C:\\Users\\All Users\u0026#34;)), Path::new(r\u0026#34;C:\\ProgramData\u0026#34;)); // junction assert_eq!(check!(fs::read_link(r\u0026#34;C:\\Users\\Default User\u0026#34;)), Path::new(r\u0026#34;C:\\Users\\Default\u0026#34;)); // junction with special permissions assert_eq!(check!(fs::read_link(r\u0026#34;C:\\Documents and Settings\\\u0026#34;)), Path::new(r\u0026#34;C:\\Users\u0026#34;)); } let tmpdir = tmpdir(); let link = tmpdir.join(\u0026#34;link\u0026#34;); if !got_symlink_permission(\u0026amp;tmpdir) { return; }; check!(symlink_file(\u0026amp;\u0026#34;foo\u0026#34;, \u0026amp;link)); assert_eq!(check!(fs::read_link(\u0026amp;link)).to_str().unwrap(), \u0026#34;foo\u0026#34;); } From the error message it gets pretty clear that we are failing at the following line:\nassert_eq!(check!(fs::read_link(r\u0026#34;C:\\Documents and Settings\\\u0026#34;)), Path::new(r\u0026#34;C:\\Users\u0026#34;)); First, I thought that there might be a problem with my Windows installation since my PC was pretty new, and I freshly installed Windows 11. I asked for help in the Rust Zulip and also their discord server but it seemed that my Windows 11 installation was correct. However, even on Zulip or on discord nobody directly knew that the problem was a bit of both, the formulation of the test case and how Windows names important folders.\nThrough testing, googling, and chatting with other rustaceans we could trace down the problem that if you install Windows in a foreign (non-English) language, some folders like the Documents and Settings folder will be installed with names in the corresponding installation language. It does not even matter if you change the system language to English. The Documents and Settings folder will remain in the installation language.\nBut since my impression was, that Rust gets more popular and therefore more people will probably start contributing to the compiler, especially people from non-English countries, the test case should eventually be changed. The test case itself works correctly, but I think before other developers have this problem as well we could eventually make a quality of life change to the test case. Therefore, I created an issue on GitHub and after exchanging with other contributors we found a solution to make this test case suitable for everyone.\nTo be safe, we agreed that we would always execute the whole test during CI (continuous integration), therefore we check if the environment variable CI is set. If the variable is not set, e.g. we execute the test locally on our machine and do not provide it, then we check if the folder Documents and Settings exists, and if so, we execute the whole test, and otherwise we skip the following assert:\nassert_eq!(check!(fs::read_link(r\u0026#34;C:\\Documents and Settings\\\u0026#34;)), Path::new(r\u0026#34;C:\\Users\u0026#34;)); In the end, the final change looks like that:\n#[test] fn read_link() { if cfg!(windows) { // directory symlink assert_eq!(check!(fs::read_link(r\u0026#34;C:\\Users\\All Users\u0026#34;)), Path::new(r\u0026#34;C:\\ProgramData\u0026#34;)); // junction assert_eq!(check!(fs::read_link(r\u0026#34;C:\\Users\\Default User\u0026#34;)), Path::new(r\u0026#34;C:\\Users\\Default\u0026#34;)); // junction with special permissions // Since not all localized windows versions contain the folder \u0026#34;Documents and Settings\u0026#34; in english, // we will briefly check, if it exists and otherwise skip the test. Except during CI we will always execute the test. if Path::new(r\u0026#34;C:\\Documents and Settings\\\u0026#34;).exists() || env::var_os(\u0026#34;CI\u0026#34;).is_some() { assert_eq!( check!(fs::read_link(r\u0026#34;C:\\Documents and Settings\\\u0026#34;)), Path::new(r\u0026#34;C:\\Users\u0026#34;) ); } } let tmpdir = tmpdir(); let link = tmpdir.join(\u0026#34;link\u0026#34;); if !got_symlink_permission(\u0026amp;tmpdir) { return; }; check!(symlink_file(\u0026amp;\u0026#34;foo\u0026#34;, \u0026amp;link)); assert_eq!(check!(fs::read_link(\u0026amp;link)).to_str().unwrap(), \u0026#34;foo\u0026#34;); } You can find the pull request here.\n","permalink":"https://miguelperez.me/posts/rust-contribution/","summary":"\u003cp\u003eTo gain more experience in software-engineering I was playing around with the thought to contribute to open-source software.\nSince I started reading \u003ca href=\"https://www.amazon.de/Programming-Rust-Fast-Systems-Development/dp/1492052590\"\u003e\u0026ldquo;Programming Rust\u0026rdquo; by O\u0026rsquo;Reilly\u003c/a\u003e to get started with a low-level language, I got also interested in understanding what happens under the hood when we execute or compile a program.\u003c/p\u003e\n\u003cp\u003eTherefore, I thought it might be a good idea to look into the \u003ca href=\"https://www.rust-lang.org/\"\u003eRust Programming language\u003c/a\u003e itself. Coincidentally, I found this \u003ca href=\"https://www.youtube.com/watch?v=9H9SO2u6Q20\"\u003evideo\u003c/a\u003e\nfrom Esteban Kuber, which ultimately made sure to check out the Rust compiler.\u003c/p\u003e","title":"Rust Compiler Contribution"}]