Social Day, surprisingly productive

Added 2022-04-01

Worked on automation script for a friend's business, build intuition for Rudin's proof of the Weierstrass Approximation Theorem


Ok day, spent most of the day hanging out with friends.

Spent 2h writing some tampermonkey scripts to automate work for someone, once finished it'll save them a lot of time. Some useful js is

function $$(x) {
  return Array.from(document.querySelectorAll(x));
}
function $(x) {
  return document.querySelector(x);
}

Then you can do stuff like

$$("span")
  .find((s) => s.textContent === "Print")
  .click();

Which is nice. Also when automating stuff it's better to loop until elements are found (the way selenium does it) then to hook DOMContentLoaded, since DOMContentLoaded is meaningless for single page apps.

Spent an hour reading rudin, Managed to build some intuition for his inscrutable proof of the weierstrass approximation theorem.

Got home, spent 40m trying to fix stupid wifi card issue again (I hate computers). Spent an hour procrastinating by reading random blogs and looking at books on amazon.

Spent an hour writing cut the enemy. Should have been faster but I got sidetracked reading the book of five rings.

Spent another 30m doing nothing, spent an hour listening to a podcast about ai alignment while eating dinner.

Spent an hour on youtube and discord, was 9pm, went running because I diden't go earlier (sigma grindset amirite). It felt good to do something difficult after an unproductive day.

Spent 30m on discord, REALLY should have been journaling because it's late, then spent an hour journaling (mostly writing up the WAT theorem, agh I need to go to sleep earlier!)

WAT theorem

I should extract this to a post later, it can be followed by someone with basic calculus knowledge if I patiently explain each step

Rudin sets

Qn(x)=cn(1x2)nQ_n(x) = c_n(1 - x^2)^n

With cnc_n picked such that 11Qn(x)dx=1\int_{-1}^{1} Q_n(x)dx = 1. This seems wierd, but if you read the proof backwards you see the key step: Since QnQ_n goes to zero when xx isn't close to the origin (see desmos) we can split the error integral into three parts, both (1,δ)(-1,-\delta) and (δ,1)(\delta,1) parts go to zero (because QnQ_n goes to zero away from the origin) and the (δ,δ)(\delta, -\delta) part can be delt with using continuity.

Set the approximating polynomials PnP_n as

Pn(x)=11f(x+t)Qn(t)dtP_n(x) = \int_{-1}^1 f(x+t)Q_n(t)dt

(The PnP_n can be shown to be polynomial by messing with the integral then differentiating, I think. not sure about this part)

Now because 11Qn(t)dt=1\int_{-1}^1 Q_n(t)dt = 1 and f(x)f(x) is constant we have

f(x)=11f(x)Qn(t)dtf(x) = \int_{-1}^{1} f(x)Q_n(t)dt

Meaning we can combine integrals to write the difference as an integral, then split it up! (where M=supf(x)M = \sup |f(x)|)

Pn(x)f(x)=11[f(x+t)f(t)]Qn(t)dt11f(x+t)f(t)Qn(t)dt2M1δQn(t)dt+ϵ2δδQn(t)dt1+2Mδ1Qn(t)dt\begin{aligned} |P_n(x) - f(x)| &= \left|\int_{-1}^{1} [f(x+t) - f(t)]Q_n(t)dt\right| \\ &\le \int_{-1}^{1} \left|f(x+t) - f(t)\right|Q_n(t)dt \\ &\le 2M \int_{-1}^{-\delta} Q_n(t)dt + \frac{\epsilon}{2} \underbrace{\int_{-\delta}^\delta Q_n(t)dt}_{\le 1} + 2M\int_{\delta}^{1} Q_n(t)dt \\ \end{aligned}

Here's where our choice of QnQ_n pays off, for large enough nn both 2M2M integrals become less then ϵ/2\epsilon/2 meaning we have Pn(x)f(x)<ϵ|P_n(x)-f(x)| < \epsilon as desired.

How would you have came up with this? Well, if you notice that writing PnP_n as an integral allows us to view the error in a nice form you might be able to guess QnQ_n to make the proof work.

Writing the above took too long, it's 11pm now I should be in bed. I found some neat stuff to study tomorrow though