From f0f838c13f4a552dca7b5dbaca066a382c1145f8 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sun, 14 Nov 2021 12:15:17 +0700 Subject: Update Franklin --- blog/conseq.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'blog/conseq.md') diff --git a/blog/conseq.md b/blog/conseq.md index c4d98ad..27dada3 100644 --- a/blog/conseq.md +++ b/blog/conseq.md @@ -12,7 +12,7 @@ whose domain is a subset of the set of all integers. Such sequences will be using functional programming paradigm, where functions are more similar to the ones in math (in contrast to imperative style with side effects confusing to inexperenced coders). The idea is taken from [subsection 3.5.2 -of SICP][] and adapted to Python, which, compare to Scheme, is significantly +of SICP] and adapted to Python, which, compare to Scheme, is significantly more popular: Python is pre-installed on almost every modern Unix-like system, namely macOS, GNU/Linux and the \*BSDs; and even at MIT, the new 6.01 in Python has recently replaced the legendary 6.001 (SICP). @@ -37,12 +37,12 @@ can be imported directly from ``itertools``: ``` To open a Python emulator, simply lauch your terminal and run `python`. -If that is somehow still too struggling, navigate to [the interactive shell][] +If that is somehow still too struggling, navigate to [the interactive shell] on Python.org. *Let's get it started* with somethings everyone hates: recursively defined sequences, e.g. the famous Fibonacci ($F_n = F_{n-1} + F_{n-2}$, -$F_1 = 1$ and $F_0 = 0$). Since [Python does not support][] [tail recursion][], +$F_1 = 1$ and $F_0 = 0$). Since [Python does not support] [tail recursion], it's generally **not** a good idea to define anything recursively (which is, ironically, the only trivial *functional* solution in this case) but since we will only evaluate the first few terms @@ -82,7 +82,7 @@ It is noticable that the elements having been iterated through (using `next`) will disappear forever in the void (oh no!), but that is the cost we are willing to pay to save some memory, especially when we need to evaluate a member of (arbitrarily) large index to estimate the sequence's limit. -One case in point is estimating a definite integral using [left Riemann sum][]. +One case in point is estimating a definite integral using [left Riemann sum]. ```python def integral(f, a, b): @@ -123,8 +123,8 @@ the result is somewhat acceptable: Since we are comfortable with sequence of sums, let's move on to sums of a sequence, which are called series. For estimation, again, we are going to make use of infinite sequences of partial sums, which are implemented as -`itertools.accumulate` by thoughtful Python developers. [Geometric][] and -[p-series][] can be defined as follow: +`itertools.accumulate` by thoughtful Python developers. [Geometric] and +[p-series] can be defined as follow: ```python from itertools import accumulate as partial_sums @@ -161,7 +161,7 @@ We can observe that it takes quite a lot of steps to get the precision we would generally expect ($s_{11}$ is only precise to the first decimal place; second decimal places: $s_{101}$; third: $s_{2304}$). Luckily, many techniques for series acceleration are available. -[Shanks transformation][] for instance, can be implemented as follow: +[Shanks transformation] for instance, can be implemented as follow: ```python from itertools import islice, tee @@ -176,7 +176,7 @@ the anonymous function $(x, y, z) \mapsto \frac{xz - y^2}{x + z - 2y}$ and `map` is a higher order function applying that function to respective elements of subsequences starting from index 1, 2 and 3 of `seq`. On Python 2, one should import `imap` from `itertools` to get the same -[lazy][] behavior of `map` on Python 3. +[lazy] behavior of `map` on Python 3. ```python >>> s = shanks(p_series(2)) @@ -251,7 +251,7 @@ def power_series(c, start=0, a=0): ``` We can use this to compute functions that can be written as -[Taylor series][]: +[Taylor series]: ```python from math import factorial -- cgit 1.4.1