<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Joseph Jojoe on Medium]]></title>
        <description><![CDATA[Stories by Joseph Jojoe on Medium]]></description>
        <link>https://medium.com/@josephjojoe?source=rss-ffba03e7e94d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*F1vrxrOhQQ9u3Iiiz3yUgg@2x.jpeg</url>
            <title>Stories by Joseph Jojoe on Medium</title>
            <link>https://medium.com/@josephjojoe?source=rss-ffba03e7e94d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:50:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@josephjojoe/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[On Learning]]></title>
            <link>https://josephjojoe.medium.com/on-learning-ef2e4d05208e?source=rss-ffba03e7e94d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef2e4d05208e</guid>
            <category><![CDATA[education]]></category>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[opinion]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <dc:creator><![CDATA[Joseph Jojoe]]></dc:creator>
            <pubDate>Sat, 21 Oct 2023 22:51:49 GMT</pubDate>
            <atom:updated>2023-10-23T17:19:47.388Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L9EcBNcYoLalr67fVzgWVQ.jpeg" /><figcaption>A view of Columbia University on my first day.</figcaption></figure><p>October 2023</p><p>I’m a freshman at Columbia University now. One interesting quirk of this is that my autocorrect is now set to American English. An institutionally flavored curiosity is our Core Curriculum — it’s a selection of ‘general education’ <strong>[1]</strong> classes that every student here must take. The specifics vary by school: my friends at Columbia College end up doing a lot more literature, and I’ll have to do a great deal more calculus in Columbia Engineering, but the hope is the same. No matter what a Columbia student chooses to specialize in down the line, they’ll be competent in adjacent subjects, and ideally knowledgeable about countless others.</p><p>Working through Columbia and its Core Curriculum <strong>[2]</strong> has made me think about learning. Although our current leader has reform on his mind, the British system is undeniably more narrow. Students in the UK choose three or four subjects to study in depth during their last two years of high school, then apply to specific courses at universities where they will only (with startlingly few exceptions) take classes in those subjects for the following three or four years. There’s no emphasis on broad learning. In contrast, I applied to Columbia as an undecided major student, and I will take both technical and non-technical <strong>[3]</strong> classes before finally deciding on my field of study in sophomore year.</p><p>Learning seems to have different objectives and outcomes in these two systems. The British system expects you to have a fully formed idea of what you want to be and do in your life while putting you on the highway to doing the same. This is not asked of a typical American student in the same sense. Though elite colleges will certainly hope for a narrow extracurricular focus relating to some particular subject that a student might want to study, and many of my peers would agree that their high schools facilitate that environment, there is still a relatively broad range of qualifications and classes undertaken before young Americans head off to college. High school is a place to explore subjects and develop those budding interests. While I delved deep into mathematics, computer science, and physics through my four A Levels, my friends here have taken ten or eleven AP classes over a far wider spectrum of knowledge, and have accomplished this while sacrificing less depth than you might expect. After all, we’ve still placed into the same classes.</p><p>The outcomes of these two systems are different too. Britain is perhaps the only country that can conceivably stand up to America in higher education — Oxford, Cambridge <strong>[4]</strong>, Imperial College London, and UCL are a few notable institutions — but this isn’t always apparent in the accomplishments of students that attend them. The United States has about 600 unicorns, while the UK has 90. Heck, the entirety of Europe only has 150. Even adjusted for population size, America clearly exerts outsized influence in entrepreneurship.</p><p>It might be unwise to solely attribute this disparity to education — brain drains in Europe, lower taxation, and significantly higher appetite for risk in America also matter — but it’s a large factor. A culture that values broad intellectual exploration will always prevail, because it ferments ambition in curious students who don’t have to shoebox themselves into what they thought they liked at some arbitrary prior age and can instead pick and choose the topics they find especially engaging to work with. I admire Columbia and similar colleges for facilitating this through the sheer abundance of opportunities for growth: when’s the last time you saw a Cambridge dropout build a startup? Unicorn hunting starts with a love of knowledge and domain agnosticism that transcends schooling <strong>[5]</strong>.</p><p>A few important questions are raised here. Given the breadth of outcomes, which objective function are we currently maximizing in education? What do we care about most: graduation rate, GPA, job placements, creativity, income, unicorns created, social mobility, papers written, Nobel prizes, or something else entirely? Which objective function should we be maximizing? How can we accomplish this with limited resources across diverse demographics and geographies?</p><p>I cannot say I have all the answers. The last question particularly has been on the minds of educators and legislators since time immemorial: it’s ever-present in school district budget meetings across this nation. But I do hope I can provide some insight on the first few, because it is evident that education today does not adequately serve ambitious <strong>[6]</strong> individuals. Finding the right objective function could produce social change on a national scale and fulfillment on an individual one.</p><p>My first thought is that we are currently maximizing graduation rate and GPA. In theory, these are great proxy measures for success: all things held equal, more students graduating with a higher GPA should mean smarter students on average. The unfortunate truth is that all things are decidedly not held equal, however. Such a system creates a perverse incentive for GPA-boosting ‘easy A’ classes, and situations where faculty are incentivised to push forth no-zero grading policies to appease angry parents and frustrated students alike.</p><p>My second thought is that we should be maximizing creativity and curiosity. The American collegiate style of learning is a bit like building a start-up. Maybe that’s why the two are so closely and successfully interlinked. Assuming you have a liberal arts experience, there’s no compulsion to stick to a subject for three or four years if you dislike it. Conversely, you’re allowed to dive deeper into topics you do enjoy by taking advanced classes, working on research with your professors, and building projects with your peers. That’s conducive to building deep curiosity about a subject — creativity flows from loving what you do and working concretely on it, and there’s no reason we can’t implement this system in some iteration for high schoolers <strong>[7]</strong>. The Nobel prizes, job placements, and social mobility will follow. On a personal level, you can adapt this by giving your present self the freedom to decide what you want to do. The opinions of your past self on what you should do now was naturally determined by what you knew at the time. You know more than your past self now, so let the foresight of how your past plans worked out guide where you go next.</p><p>A small aside — I think that gifted education is severely lacking in secondary education. Wherever you go, it always seems to fall into the pitfall of “just do more”. I remember finishing my workbook in second grade math and being told to do harder sums, then geometry, then algebra, but in any case it never seemed to end. There was just a deluge of knowledge that threatened to confuse and terrify. The benefit of this approach was that I learned a lot more than I would have in ordinary class, but it seemed to be at the expense of breadth. When you don’t stop to smell the flowers every once in a while, you don’t have time to appreciate the subject for what it is and form wider mental links between disciplines. ‘Move fast and break things’ at least implies you had time to build something in the first place. Learning shouldn’t be taken at breakneck speed in a straight direction nor at a leisurely pace — think of your intellectual journey as water flowing down a steep hill. It moves quickly but traces contours near and far <strong>[8]</strong>.</p><p>My last thought on the education system is that of accountability and oversight. Secondary education is scripted and top-down: students do what teachers say, teachers do what principals say, and principals do what superintendents say. Needless to say, this chain of command is extremely unhelpful for getting anything of substance done: every request goes up and down the hierarchy before it can be approved, with a single ‘no’ at any stage killing the proposal entirely. It’s a great system for balancing books and coordinating action across public schools, but this neglects the variation between each institution — even each classroom — which is so nuanced that one superintendent could not possibly know the ins and outs of every single circumstance under their remit. Ambitious students are harmed by initiatives which do not recognize and sustain their rapidly changing needs. On the flip side, students do need to take more initiative in developing their own love of learning outside of rigid schooling; having gone through the process myself, I can say that the hypercompetitive nature of American college admissions is terrible both for wellbeing and curiosity. Knowledge for a fixed endpoint, be it admissions or achievement, is unsustainable in that its utility diminishes as soon as that milestone is reached. Knowledge that results in innovation has no fixed endpoint by nature — it sustains itself through the constant iteration and refinement of new ideas that spring from exploring the steep hill on whose surface we flow. Love of knowledge without externalities is a powerful driver.</p><p>We can now wonder how to adopt this better perspective on knowledge. I presume you want to build great things and make the most of your talents, so we can shift that paradigm to be a little bit more practical and consider how we can develop our perspective on learning. The natural answer might seem to be ‘go to an American high school/college’, but that’s not exactly accurate or easy either. There are only a few schools with such diversity of talent and innate drive as Stanford and MIT, and they take very few students relative to the sizable applicant pool. Only a few private colleges in the United States follow this true liberal arts model in the first place: many still require you to at least indicate the majors you are considering or apply to a school which restricts you to a certain selection, from which internal transfers can range from fairly straightforward to downright impossible. Your environment does, for better and worse, greatly influence your chances of exposure to different knowledge domains and therefore success.</p><p>In light of that reality, think of this loosely as a Java interface: I’ll show you some methods and attributes that I believe a good learner should have, and you can implement them as you see fit. The key part of this analogy is that any class which implements an interface in Java must implement all of its attributes and methods — there’s no picking and choosing here.</p><p>Let curiosity guide you. There will always be things you must do — file taxes, eat, drink, sleep, and so on — and there will probably be things you should do, like completing your assignments or walking your dog. A lot of people seem to think that great work comes from forcing it into your ‘must do’ pile — to sustain this, they advocate for cold showers, timetables, and habits of work in order to build consistency. Consistency trumps motivation, they say. While it is true that being consistent is important in general, this discounts the fact that humans (much like everything else) are disinclined to do things which are hard, painful, or boring. Consistency might get you to an MVP, but it’s not going to incentivize you to put in extra hours when it counts. It won’t lead the way to your Next Big Thing to Work On and it certainly won’t make you love what you do. For that, you need passion, which brings us to my next point.</p><p>Find your intellectual passion. Not a passion for intellect — that’s just curiosity, which I hope you have by now. Find a specific topic or subject that excites you and makes you feel as though you could spend a day reading about it in a library, flicking through and diving deep into texts to your heart’s content. Just a day for now, your life’s work will come later. Paul Graham would say this is the first part of superlinear returns — you don’t need to commit your entire world and soul to this yet, but the most dangerous part is that this might end up going that way if you genuinely fall in love with what you do. It’s dangerous in the sense of dangerously exciting, because you don’t know where this will go, but it might just change your life.</p><p>Once you’ve found this passion, explore it. Be the water flowing down a steep hill — pool your knowledge in places where it sticks, but weave through the grass quickly, moving to and fro on your way. Perhaps you’ll encounter some other problems to set store by. Maybe you’ll be accompanied on your journey, for which some tortured water analogy probably exists. In any case, finding something you love working on will trump both consistency and motivation. Don’t be afraid to pivot away if you see greener pastures elsewhere, but finding that first intellectual love — even if it doesn’t end up sticking — will do more for your development than a thousand cold showers. Hating or even tolerating what you do will never get you anywhere. You must learn to love what you do or go and find something else entirely.</p><p>My final reflection is on arrogance. I believe there are two broad types of it. The kind that makes you think you can do anything, and the kind that makes you think that you don’t need anyone else to do anything. Call those internal arrogance and external arrogance, or weak and strong arrogance if you will. Weak arrogance is extremely helpful for anyone who wants to learn and build <strong>[9]</strong>. Problems are always a lot harder than they seem — the benefit of this youthful sort of arrogance is that you naively believe you can do it all, just because you’ve never been told you can’t do it all. That’s unorthodoxy in a nutshell. Strong arrogance on the other hand is fatal. Very few great things have come out of unbridled individualism and hubris. I advise against embodying strong arrogance, because you will fail and it will probably be quite embarrassing. Weak arrogance will make you a better learner and a better person. It will give you the tenacity to work hard but tolerate the humility to ask for help from those who have seen more than you when you need it. Ambition moderated by humility is all you need.</p><h4>Notes</h4><p><strong>[1]</strong> I place ‘general education’ here in quotes because it is very much a misnomer. Exposure to various subjects spurns innovation just as much as practicing math problems makes you better at math. I would wager a not-insignificant amount that a good amount of new development comes from people applying discoveries from other subjects to their own fields of expertise.</p><p>Don’t let that fool you into thinking that you should only study the sciences if you’re a scientist, or the great works of Plato and Aristotle if you’re considering anthropology. As scientists need to communicate well with legislators and private entities to get their ideas heard and scaled, writers must be logical and true to the world they wish to portray. Perhaps the latter is a somewhat weaker sounding assertion, but I would hold that it’s correct nonetheless. Non-fiction books must be factual by nature for the most part, but fiction is only as believable as it can conceivably be tied to some phenomenon or behavioral mechanism that humans can identify with. The framework within which the story operates need not be true — it certainly must be consistent. That’s why Harry Potter works.</p><p><strong>[2]</strong> I’m only doing one Core class this semester — the venerable Art of Engineering, often thought of as the keystone of the Columbia Engineering freshman experience. Think practical projects, lectures from faculty and external speakers on contemporary science and futurism, and a little introductory data science thrown in for good measure. Friday sleep schedule permitting, I always enjoy these lectures. Our professor politely requested we bring our resumes to the first one, where he promptly shredded them in a proclamation that ‘none of this really matters!’. I’d like to say I agree. Too much store is set by abstract lists of achievements. I see it with my peers scouting for internships when they should be exploring what intrigues them. I see it with myself when I apply to a myriad of clubs because I know they’ll put me in good stead for applying to the same next year. Maybe I’ll take this summer off*, as a form of counter-protest against the dark and mysterious forces in higher education that cause this almost unbearable desire to head immediately into the workforce.</p><p>*Off doesn’t mean off. More precisely, off doesn’t mean switching off completely. There’s a difference between wasting time and choosing to do something a little less browbeating. I’d like to get into entrepreneurship this summer — I’ve already been working on a few things, mostly in biotech and AI, but I’m constrained by (a) my F-1 visa which prevents work and (b) a lack of pre-seed funding which would allow me to work and study in the United States under the International Entrepreneur Rule. On that note, if you’re an angel investor or know one, let me know.</p><p><strong>[3]</strong> Columbia effectively means the humanities. Given [1] I’m sure you’ll appreciate that I don’t necessarily consider these courses to be non-technical in the sense of easy.</p><p><strong>[4]</strong> Often shortened to Oxbridge. I read a book once which christened their union Camberford. That was both amusing and terrible.</p><p><strong>[5]</strong> It’s therefore a little ironic that this same mindset is cultivated by schools themselves. I find that it doesn’t occur at the institutional level — professors and deans are still concerned with making sure students pass classes and graduate. That’s probably for the better, in fact.</p><p>This mindset actually stems from the students around you, and that’s where I believe the real value of an Ivy League or comparable education lies. There’s no real benefit in taking a math class at Harvard versus School X, where the latter isn’t as closely associated with prestige — sure, Harvard might cover content a little more rigorously, and you’ll probably have access to better TAs, but fundamentally you’re learning virtually identical material anyways. The same student would do just as well in a Harvard math class as in a math class at School X nine times out of ten, I’d imagine.</p><p>The difference comes when you examine what that same student might do outside of class. School X might not have much in the way of clubs, or start-up accelerators, or peers who are just as hungry to innovate and build new products. Harvard is bursting at the seams with all of the above. The resources and networks that an elite college facilitates justifies the sticker price to ambitious individuals. They might be able to do just as well elsewhere through their own tenacity, but it’s a lot easier when you’re starting out in the right environment. That’s why a lot of successful founders went to a relatively unknown school for their undergraduate education, but generally ended up either dropping out, transferring to a better college, or going to an elite university for their graduate studies.</p><p><strong>[6]</strong> Note that I intentionally did not specify the type of ambition. That might include founders, entrepreneurs, programmers, scientists, artists, painters, actors, musicians, writers, mathematicians, philosophers, or underwater basket weavers. Their particular interests are not of importance. What’s important is that they are supported to realize their goals. Far too often that is restricted to ‘STEM nerds’.</p><p><strong>[7]</strong> This is why I like Khan Academy. A broad selection of subjects with the depth to back them up. Pivot at will.</p><p><strong>[8]</strong> Sometimes you’ll see pools forming in little dips. Keep knowledge in domains that are interesting to you but move forward and explore widely.</p><p><strong>[9]</strong> I had a friend who once told me his goal was to become the first trillionaire. That caught me off-guard, but I heard him out and thought he had some nice ideas. He ended up closing a seed round deal for the start-up he co-founded for about $2.5m a few weeks ago. Weak arrogance was his ambition to become a trillionaire, but his tenacity and humility in working extremely hard, finding co-founders who were just as talented, and asking for help from investors and academics alike were what brought him that deal. I have a lot to learn from him and admire him greatly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef2e4d05208e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Brief History of Mathematical Logic]]></title>
            <link>https://josephjojoe.medium.com/a-brief-history-of-mathematical-logic-7ec7a69e7862?source=rss-ffba03e7e94d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ec7a69e7862</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[logic]]></category>
            <category><![CDATA[classics]]></category>
            <category><![CDATA[history]]></category>
            <category><![CDATA[philosophy]]></category>
            <dc:creator><![CDATA[Joseph Jojoe]]></dc:creator>
            <pubDate>Sat, 31 Dec 2022 14:11:50 GMT</pubDate>
            <atom:updated>2022-12-31T14:11:50.039Z</atom:updated>
            <content:encoded><![CDATA[<p>Logic formalises the concepts we often take for granted in mathematics: <strong>proofs</strong>, <strong>truth</strong>, and <strong>statements</strong> are some of these core foundations, upon which we build all mathematical research. This article explores the history of mathematical logic ― we trace a path from the work of ancient scholars to our present, diverse branches of study.</p><h3>The Ancient East</h3><p>Developments in Ancient Eastern mathematical logic were largely clustered in just two countries, <strong>China</strong> and <strong>India</strong>.</p><blockquote>“Who really knows?<br>Who will here proclaim it?<br>Whence was it produced? Whence is this creation?<br>The gods came afterwards, with the creation of this universe.<br>Who then knows whence it has arisen?”<br>― Nasadiya Sukta, on the origins of the universe</blockquote><h4>India</h4><p>Indian logicians were generally motivated by religion. <strong>Vaisheshika</strong> and <strong>Nyaya</strong> were two of six contemporary Hindu schools of philosophy; Vaisheshika proposed that all objects in the universe were reducible to a finite number of atoms, much like how complex plane Euclidean geometry theorems are constructible from just five fundamental axioms, while the Nyaya school distinguished itself by accepting testimonies and analogies as valid in logical argument. <strong>Catuṣkoṭi</strong>, also known as the <strong>tetralemma</strong>, was a system refined by the Buddhist philosopher Nagarjuna and was a predecessor of our modern Boolean logic. <strong>Jain</strong> and <strong>Buddhist</strong> logic tended to be concerned with the nature of knowledge ― <strong>how is knowledge derived</strong>, and <strong>when is it reliable?</strong></p><h4>China</h4><p>In China, the <strong>Mohist</strong> school of thought reigned supreme. Founded by the philosopher Mozi, it dealt with issues relating to <strong>valid inference</strong> and the <strong>conditions of correct conclusions</strong>. Mohism was special in its preference for <strong>rhetorical analogies</strong> over mathematical reasoning; persuasive arguments and speech were preferred over drawing conclusions from the rigorous examination of evidence, which may sound familiar to the politically astute reader of the present. Later on, the <strong>Logicians</strong> grew out of Mohism ― they’re often credited with discovering <strong>formal logic</strong>, which abstracted away finnicky particulars and allowed a mathematical study of reasoning for the first time.</p><h3>The Ancient West</h3><blockquote>“Valid reasoning has been employed in all periods of human history.” ― Wikipedia</blockquote><h4>Egypt and Babylon</h4><p>The origins of mathematical logic in the West can be reasonably traced back to <strong>geometry</strong>. The word stems from the <strong>ancient Greek</strong> γεωμέτρης, meaning ‘<strong>land measurers</strong>’, which speaks to the practical testing of geometric formulas which were being discovered at the time ― logic may have developed as a more abstract version of this demonstration to show the <strong>validity</strong> of conclusions.</p><p>Equally, skilled mathematicians in <strong>ancient Egypt</strong> and <strong>Babylon</strong> may have developed precursors to modern mathematical logic. <strong>Esagil-kin-apli</strong>, the chief scholar of a Babylonian king in the 11th century BCE, produced a medical diagnostic handbook based on assumptions that we would now generally refer to as <strong>axioms</strong>. At the same time, <strong>Babylonian astronomers</strong> were using internal logic ― collections of consistent rules and reasoning ― to predict where planets would be in the night sky.</p><h4>Mathematical Logic in Greece</h4><p><strong>Ancient Greece</strong> heralded the start of empirical methods being replaced with actual proof. <strong>Thales</strong> and <strong>Pythagoras</strong> were Greek philosophers who emphasised the connection between proving concepts and <strong>mathematical development</strong>: once you could prove abstract mathematical truths, it was acceptable to use those theorems to prove more complex ideas. This idea was very similar to the concept of <strong>deductive systems</strong>, in which one starts with given truths and considers what can be worked out.</p><p>Fragments of early proofs are still preserved in the works of Euclid:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6OL4HQlbPRnLGAW3.jpg" /><figcaption>A fragment of Euclid’s Elements, one of the seminal mathematical texts of classical antiquity. (Wikipedia)</figcaption></figure><p><strong>Euclid of Alexandria</strong> came up with three basic principles of geometry, the abstraction of which forms a basis for mathematical logic:</p><ul><li>Certain propositions (statements) <strong>must be accepted as true without demonstration</strong>; such a proposition is known as an <strong>axiom</strong> of geometry.</li><li>Every proposition that is not an axiom of geometry must be <strong>demonstrated as following from the axioms</strong> of geometry; such a demonstration is known as a <strong>proof</strong> or a “derivation” of the proposition.</li><li>The proof must be <strong>formal</strong>; that is, the derivation of the proposition must be <strong>independent of the particular example</strong> in question.</li></ul><blockquote>“<strong>Let no one ignorant of geometry enter here.</strong>”<br> — Inscribed over the entrance to Plato’s Academy.</blockquote><p><strong>Plato</strong> was a fourth-century philosopher raised three questions about philosophical logic:</p><ol><li>What is it that can properly be called <strong>true</strong> or <strong>false</strong>?</li><li>What is the nature of the connection between the <strong>assumptions</strong> of a valid argument and its <strong>conclusion</strong>?</li><li>What is the nature of <strong>definition</strong>?</li></ol><p>Plato suggested that the necessary connection between the assumptions of a valid argument and its conclusion corresponds to a necessary connection between “forms”, expanded upon in a philosophical concept aptly named the <strong>Theory of Forms</strong>. His works generally concern the search for a definition of some important concept — justice, peace, goodness, for example — and it is likely that he was impressed by how important definitions were in mathematics. Plato considered every definition to be a <strong>Platonic Form</strong>: the common nature present in different particulars. In mathematical logic, we understand this idea to be linked to abstraction; a theorem, once proved, can be applied to any appropriate context.</p><h4>Aristotle</h4><p>The work of <strong>Aristotle </strong>have had enormous influence in contemporary Western thought, being translated into Latin in the Middle Ages and employed as standard texts in many of Europe’s universities. He was the first <strong>formal logician</strong>,<strong> </strong>demonstrated the principles of reasoning by employing <strong>variables</strong> to show the underlying logical form of an argument.</p><p>“If it is rainy, then I will get wet if I’m outdoors” becomes “A implies B”; A and B are the variables corresponding to these statements, allowing a further abstraction that allows us to consider the logical argument context-free. He was also the first to distinguish the <strong>validity</strong> of these relations from the <strong>truth of the premises themselves</strong>, which could be false — as long as the reasoning is consistent, we consider the statements to be sound.</p><p>In addition, he produced a collection of logical works called the <strong>Organon</strong>, the earliest formal study of logic, discussed and analysed what makes a <strong>syllogism</strong> (a valid argument), and considered non-formal logic — the study of constructs including <strong>fallacies</strong>, which are invalid deductive arguments.</p><h4>Medieval Europe and the Middle East</h4><p>The works of <strong>Al-Kindi</strong>, <strong>Al-Farabi</strong>, <strong>Avicenna</strong>, <strong>Al-Ghazali</strong>, <strong>Averroes</strong> and other Muslim logicians were based on Aristotelian logic and were important in communicating the ideas of the ancient world to the medieval West. They explored <strong>conditional syllogisms</strong>, which were forms of valid argument based on conditions.</p><blockquote><em>If I don’t wake up, then I can’t go to work. If I can’t go to work, then I won’t get paid. Therefore, not waking up means that I won’t get paid.</em></blockquote><p>In Medieval Europe, Aristotle’s work was also the foundation of new insights. Christian philosopher <strong>Boethius</strong> contributed heavily to the development of <strong>Scholastic logic</strong>, a form of Aristotelian logic that was developed between 1200 and 1600 CE. Because Christianity was widespread at the time, these developments led to the application of logical techniques to attempt to prove <strong>theological concepts</strong> such as the <strong>existence of God</strong>.</p><h4>The Rise of Modern Logic</h4><p>In the <strong>mid-19th century</strong>, inspired by the methods of proof used in mathematics, there was a renewed interest in logic. <strong>Rigor</strong> was at the heart of this renaissance, leading to the names “<strong>symbolic</strong>” or “<strong>mathematical</strong>” logic that we employ today.</p><p>Modern logic’s rules of operation are determined only by the <strong>axioms</strong> and <strong>rules of valid inference</strong> we apply to them; we don’t start with ordinary language and try to find an equation which matches it — <strong>we start with abstract mathematics</strong>, draw conclusions, and then try to express our conclusions in ordinary language.</p><p><strong>World War II</strong> led to an explosion of mathematical logic. It was too large and burgeoning to contain within just one field; logic diversified into<strong> model theory</strong>, <strong>proof theory</strong>, <strong>computability theory</strong>, and <strong>set theory</strong>, leading to a picture of logic today that is the composite of various intersecting disciplines.</p><h4>Further exploration</h4><ul><li><a href="https://www.mooc-list.com/course/introduction-logic-coursera">Stanford’s Introduction to Logic course</a> on Coursera</li><li><a href="https://faculty.math.illinois.edu/~vddries/main2.pdf">Notes on Mathematical Logic</a> from the University of Illinois</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ec7a69e7862" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Projection Matrices and Gram-Schmidt]]></title>
            <link>https://medium.com/intuition/projection-matrices-and-gram-schmidt-dcd79cf228c9?source=rss-ffba03e7e94d------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcd79cf228c9</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <dc:creator><![CDATA[Joseph Jojoe]]></dc:creator>
            <pubDate>Sat, 02 Jul 2022 21:13:37 GMT</pubDate>
            <atom:updated>2022-07-03T17:24:47.291Z</atom:updated>
            <content:encoded><![CDATA[<h4>Mathematics</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WhxPJAOgf1h-jG-e" /><figcaption>Photo by <a href="https://unsplash.com/@paramir?utm_source=medium&amp;utm_medium=referral">Ehud Neuhaus</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When working in finite-dimensional space, it is convenient to have a orthonormal basis; this simplifies calculations and ensures that the vectors in our set are linearly independent. Today, we explore a process called <strong>Gram-Schmidt</strong> which generates an orthonormal basis from a given set of vectors.</p><h4>A brief interlude about orthogonality, normalisation, and orthogonal matrices</h4><p>We define an operation acting on two finite vectors <strong>u</strong> and <strong>v</strong>, known as the <strong>dot </strong>or <strong>scalar product</strong>, as such:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*pYiUGiFOMwAwdL1QeOChqA.png" /><figcaption>The standard definition of the dot product.</figcaption></figure><p>The dot product produces a single number (a <em>scalar</em>, hence the alternate name) which is the sum of the corresponding elements of <strong>u</strong> and <strong>v</strong> multiplied together ― note that the vectors have to contain the same number of elements for this operation to be defined.</p><p>We sometimes write the dot product for two column vectors <strong>u</strong> and <strong>v</strong> as <strong>u</strong>ᵀ<strong>v</strong>. This allows us to use matrix multiplication to produce a 1x1 matrix, which should be considered our ‘scalar’ result from performing this operation.</p><blockquote><strong>Orthogonality</strong>: two vectors <strong>u</strong> and <strong>v</strong> are orthogonal if <strong>u</strong>.<strong>v</strong> = 0.</blockquote><p><strong>Orthogonality</strong> generalises the notion of perpendicularity to higher dimensions, such that we can work in larger spaces than R² and R³. Two vectors are orthogonal if their dot product is equal to zero, and we consider a set of vectors S = {<strong>v</strong>₁, <strong>v</strong>₂, …, <strong>v</strong>ₙ} to be <strong>mutually orthogonal</strong> if every pair of vectors in S is orthogonal, meaning that each vector in the set is perpendicular to all others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*iz6CDMlPYLSRo6edVSqwxA.png" /><figcaption>A mutually orthogonal set of vectors S in R³. Every possible pairing of the vectors gives a dot product result of 0, so we know that each vector is perpendicular to every other. This also implies that they are linearly independent and form a basis for R³ — if this is unfamiliar terminology, have a look at my article on the <a href="https://medium.com/@josephjojoe/the-four-fundamental-subspaces-74758449775d">Four Fundamental Subspaces</a>.</figcaption></figure><p><strong>Square matrices with orthogonal columns are always invertible</strong>; each column of the matrix is linearly independent of the others, so there is no non-trivial combination of the columns which equals the zero vector. (If this justification is unfamiliar, read my article about the Four Fundamental Subspaces <a href="https://medium.com/@josephjojoe/the-four-fundamental-subspaces-74758449775d">here</a>; it covers linear independence in much more detail.)</p><blockquote><strong>Norm</strong>: a function from a real (or complex) vector space to the non-negative real numbers, acting as a measure of distance from the origin.</blockquote><p>Vector spaces can be endowed with a <strong>norm</strong>, a function that tells us how far a vector is from the origin; this allows us to deal with the notion of ‘length’ in higher dimensions. A vector space with an attached norm is, unsurprisingly, called a <strong>normed vector space</strong>. Norms merit a future article in their own right, especially for complex and more general vector spaces, so today we are going to focus on a specific norm which is commonly used to calculate length in vector spaces ― the <strong>L² norm</strong>, which extends the Pythagorean theorem into finite-dimensional vector spaces of any size.</p><p>We calculate the L² norm of a vector <strong>v</strong>, denoted as |<strong>v</strong>|, by taking the square root of the sum of each of its components squared.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*eDot0YWMwxpMGxwexf8EdA.png" /><figcaption>The definition of the L² vector for real vectors. We square each component, add the squares together, and take the square root.</figcaption></figure><p>A little mathematical shuffling shows us that this definition is equivalent to stating that we can define the magnitude of a vector as the square root of the dot product applied on itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*chiF2zThNRTNiTyn_zhnKA.png" /><figcaption>The L² norm of a vector <strong>v</strong> is equal to the square root of the dot product of <strong>v</strong> with itself.</figcaption></figure><p>We say that a vector is <strong>normalised</strong> when the L² norm is equal to one, meaning that the vector has a length of one unit; to normalise a vector <strong>v</strong>, divide it by its magnitude |<strong>v</strong>|. Normalised vectors are useful for determining which direction a vector points in; every vector that points in the same direction will have the same normalised representation, and this allows us to easily compare different vectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*Q5QvvItS7RQqiqYrGHQ3RA.png" /><figcaption>Two vectors u and v with the same normalised form, showing that they both point in the same direction.</figcaption></figure><blockquote><strong>Orthonormal</strong>: a set of vectors is orthonormal if every vector is normalised and the vectors are mutually orthogonal.</blockquote><p>An <strong>orthogonal matrix</strong>, usually denoted as <em>Q</em>,<strong> </strong>is a real square matrix in which the column vectors are orthonormal. They have several interesting properties: orthogonal matrixes are <strong>always invertible</strong>, their inverse matrices are their <strong>transpose</strong>, and the determinant of an orthogonal matrix is always either <strong>+1 </strong>or<strong> -1</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*SPHIsdxJ7ZKXWOMcQyiowQ.png" /><figcaption>A few interesting examples of orthogonal matrices; the identity matrix, rotation matrices, and permutation matrices are all orthogonal.</figcaption></figure><h4>Projection</h4><p>To introduce us to the concept of <strong>projection</strong>, I will borrow the opening statement from <a href="https://ocw.mit.edu/courses/18-06sc-linear-algebra-fall-2011/00e9c8f0eafedeab21a3d079a17ed3d8_MIT18_06SCF11_Ses2.2sum.pdf">Lecture 15</a> of 18.06Sc Linear Algebra. (This section will be largely guided by the train of thought that is presented in the lecture, so I highly recommend you supplement this article with it.)</p><blockquote>If we have a vector V and a line determined by a vector <strong>A</strong>, how can we find the point on the line which is closest to <strong>V</strong>?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*hRt2hL_Y_nLKOgvqlShWiw.png" /><figcaption>Our problem — given a line (red) and a vector (blue) , how do we find the point on the line which is as close as possible to the tip of our vector?</figcaption></figure><p>The point on the red line determined by <strong>a</strong> which is closest to <strong>v</strong> is the intersection of a line passing through <strong>v</strong> which is orthogonal to <strong>a</strong>. We can think of the green vector <strong>p</strong> as an approximation to <strong>v</strong>, and thus of the vector <strong>e</strong> = <strong>v </strong>- <strong>p</strong> (shown in dotted green) as the error of our approximation.</p><p>As <strong>p</strong> lies on the line spanned by <strong>a</strong>, we can say that <strong>p</strong> = <em>x</em><strong>a</strong> for some scalar value <em>x</em>. From our diagram, we also know that <strong>a</strong> is perpendicular to <strong>e</strong> (= <strong>v </strong>-<strong> p</strong> = <strong>v</strong> - <em>x</em><strong>a</strong>), so the dot product of <strong>a</strong> and (<strong>v</strong> - <em>x</em><strong>a</strong>) must equal zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/1*5Czd8BRGE_nPIcfCuPAw6Q.png" /></figure><p>With a little expanding and rearranging, we have worked out how to express <strong>p</strong> in terms of <strong>a</strong> and <strong>v</strong>. The vector <strong>p</strong> is what we get when we project <strong>v</strong> onto the line determined by <strong>a</strong>.</p><h4>The Gram-Schmidt process</h4><p>Now that we’ve covered the scalar product, orthonormality, and the projection of vectors, we have a solid foundation that will help us to understand the <strong>Gram-Schmidt process</strong>. Given any set of vectors S which spans a particular vector space V, we can use this to generate an <strong>orthonormal and linearly independent basis</strong> for V.</p><p>Before we get started, there is some notation which you will need to accustom yourself to. We will use lower case letters {<strong>a</strong>, <strong>b</strong>, …, <strong>z</strong>} for vectors in our original (not orthonormal) set of vectors, capital letters {<strong>A</strong>, <strong>B</strong>, …, <strong>Z</strong>} for the orthogonal vectors we’ll generate in an intermediate step, and finally {<strong>q</strong>₁, <strong>q</strong>₂, …, <strong>q</strong>ₙ) for our orthonormal vectors.</p><p>Let’s begin with a three-dimensional example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*IkonmWDMf4clYWrdBoCzzQ.png" /><figcaption>Our set S of vectors; the vectors are neither orthogonal nor normalised.</figcaption></figure><p>We will first find orthogonal vectors which span the same space as S. Let our first orthogonal vector <strong>A</strong> = <strong>a</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*oRmYvhfC5An1Gu4U0TROLA.png" /></figure><p>To find a vector orthogonal to <strong>A</strong>, we project <strong>b</strong> onto <strong>A</strong> and let <strong>B</strong> = <strong>b</strong> - <strong>p</strong>. <strong>B</strong> is what we previously referred to as <strong>e</strong>; the error vector is orthogonal to <strong>A</strong>, so we can use it as the second vector in our orthogonal set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*ciVtuv35eDisE_c8p9HPPw.png" /></figure><p>Finally, we must calculate the vector <strong>C</strong> which is orthogonal to both <strong>A</strong> and <strong>B</strong>. To do so, we take our original vector <strong>c</strong> and subtract its components in the <strong>A</strong> and <strong>B</strong> directions; we find those by projecting <strong>c</strong> onto <strong>A</strong> and <strong>B</strong> in turn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*8464vdSf1EVnN_XRD2LDQA.png" /></figure><p>Finally, we divide each of <strong>A</strong>, <strong>B</strong>, and <strong>C</strong> by its length to give us our orthonormal vectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*9Zb9V7xlDAuHFRHcXX-pqw.png" /></figure><p>This process can be extended to <strong>any number of dimensions</strong>, and thus an arbitrarily large set of vectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*rRRBp4CMGY4M3y0_zbNsHg.png" /><figcaption>For an arbitrarily large set of vectors, we can apply Gram-Schmidt to generate an orthonormal basis for the space our original set spans.</figcaption></figure><p>Through Gram-Schmidt, we effectively ‘strip away’ any <strong>dependencies</strong> which exist between the vectors ― in the extreme case of a vector in our set being composed of a <strong>linear combination of the other vectors</strong> in the set, it will be completely reduced down to the <strong>zero vector</strong>. This implies that there is no independent/orthogonal part of the vector which would remain, hence it can be omitted from our final set; Gram-Schmidt always gives a basis for the space spanned by the original set of vectors.</p><h4>Further exploration</h4><p><a href="https://ocw.mit.edu/courses/18-06sc-linear-algebra-fall-2011/resources/mit18_06scf11_ses2-4sum/">Orthogonal Matrices and Gram-Schmidt</a> from MITOpenCourseWare.</p><p>The <a href="https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process">Wikipedia page</a> for the Gram-Schmidt process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcd79cf228c9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intuition/projection-matrices-and-gram-schmidt-dcd79cf228c9">Projection Matrices and Gram-Schmidt</a> was originally published in <a href="https://medium.com/intuition">Intuition</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You should study Linear Algebra.]]></title>
            <link>https://josephjojoe.medium.com/you-should-study-linear-algebra-eeadd1820946?source=rss-ffba03e7e94d------2</link>
            <guid isPermaLink="false">https://medium.com/p/eeadd1820946</guid>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Joseph Jojoe]]></dc:creator>
            <pubDate>Sat, 25 Jun 2022 19:19:55 GMT</pubDate>
            <atom:updated>2022-06-26T07:57:07.448Z</atom:updated>
            <content:encoded><![CDATA[<p>Linear algebra lies at the heart of mathematics. It allows us to construct and solve systems of linear equations, unifying otherwise disparate topics (read: <a href="https://en.wikipedia.org/wiki/Functional_analysis">functional analysis</a>, <a href="https://www.math.uni-bielefeld.de/~hemion/Linear_Algebra_in_Physics/LinearAlg.Physics.pdf">physics</a>, <a href="https://medium.com/@josephjojoe/regression-with-linear-algebra-f235755d753c">regression</a>) through a common set of guiding principles and applicable techniques.</p><p>A typical introductory course introduces matrices and vectors, finding the four fundamental subspaces of a matrix (check out my article on that topic <a href="https://medium.com/@josephjojoe/the-four-fundamental-subspaces-74758449775d">here</a>), solving systems of linear equations, and modelling problems from related fields, among many other interesting concepts. In this article, we’ll explore why you should start learning linear algebra today.</p><h4>So, why should you study linear algebra?</h4><p>From a practical perspective, it’s a topic which transcends mathematics and the physical sciences ― many applied fields, including hot-topic disciplines such as data science and machine learning, all utilise aspects of linear algebra in their practice. Although finding a reformulation isn’t always obvious, there are hundreds of processes and techniques which can be rewritten in a format that’s compatible with a linear algebra approach; this allows us to then apply our mathematical knowledge to unfamiliar situations and more easily produce meaningful results. <strong>Linear algebra helps you to solve difficult problems.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*zq_feWhW5oBZVbAJrBOU8A.png" /><figcaption>The classic linear algebra problem — finding intersections of lines in R².</figcaption></figure><blockquote><strong>Linear algebra</strong>: the study of linear equations and linear transformations, and their representation through vectors and matrices.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*2Vgj_PCmSk3IgydEDu5g7A.png" /><figcaption>Differential equations are another example of the complex problems that linear algebra can be applied to. Given an initial condition and rates of change, we can construct matrices to describe the system and use our knowledge of Taylor series to find the ‘final state’.</figcaption></figure><blockquote><strong>Who uses linear algebra?</strong>: Mathematicians, physicists, engineers, biologists, economists, AI/ML engineers, data scientists, and many more ― all in all, a significant part of the skilled labour market.</blockquote><p><strong>Linear algebra also helps you in the modern job market.</strong> Machine learning engineers construct AI models in which data and weights are stored as vectors and matrices, opening up an arsenal of matrix operations for model inference; computing a forward pass on a trained model is akin to matrix multiplication, and the backpropagation algorithm stores partial derivatives as a vector. Data scientists use matrices as a convenient data structure for holding thousands or even millions of data points efficiently, and economists need systems of linear equations to model macroeconomics and economic policy.</p><p>Linear algebra is everywhere, and studying it will make you stand out among other candidates applying to the same job ― showing that you can work fluidly with underlying theory and self-study content are skills that employers value. The independence, creativity, and attention to detail developed through studying linear algebra are ‘soft skills’ which will augment your CV and profile immensely, just as much as the mathematical techniques you’ll encounter and learn to use.</p><blockquote><strong>Mathematical rigour</strong>: explicitly stating assumptions, constructing conclusions and theorems from a set of given truths, and proving their truth (or lack thereof) in a comprehensive manner.</blockquote><p><strong>Linear algebra makes you a better thinker.</strong> In high school, mathematics courses are generally computation-based; students learn techniques and use them with different numbers in questions, with formal examinations following the same format. Rote memorisation and consistency are prioritised over problem solving ability ― a test paper only cares about candidates finding the correct result and demonstrating the ‘right’ method for high marks to be awarded.</p><p>Learning linear algebra at a university-level standard is <em>completely</em> different. Most courses emphasise understanding over parroting information, promoting a deep appreciation of mathematics which stands in stark contrast to the dull, and unfortunately all too common, routine of blindly reciting theorems and formulae. We learn to prove, not take for granted, which ultimately improves our ability to solve problems and independent reasoning skills.</p><p>Real life problems don’t usually arrive as different numbers packaged into a common format; it’s a luckless fact of life that at one point or another you’ll be expected to work on complex tasks in your job with little supervision (blame corporate work culture for that), and being unprepared for such responsibility is a recipe for disaster. Almost any undergraduate mathematics course would suffice to acquaint you with rigour, but <strong>taking a linear algebra course exposes you to developing independent and logically sound thinking without unnecessarily sophisticated mathematics</strong>.</p><blockquote>There is hardly any theory which is more elementary [than linear algebra], in spite of the fact that generations of professors and textbook writers have obscured its simplicity by preposterous calculations with matrices. ― Jean Alexandre Eugène <strong>Dieudonné</strong></blockquote><p>There’s a myriad of <a href="https://math.mit.edu/academics/undergrad/roadmaps.php">weird and wonderful</a> module options in a standard mathematics undergraduate degree, but the vast majority are inaccessible to interested readers without having worked through months or even years of prerequisite materials. Linear algebra, on the other hand, is commonly taught as one of the first courses that mathematics students <em>ever take</em> in university. As long as you’re comfortable with high school maths, it’s a great starting point!</p><h4>Getting started with linear algebra</h4><p>If you’re now thoroughly convinced that linear algebra is the right course for you, I highly recommend MITOpenCourseWare’s <a href="https://ocw.mit.edu/courses/18-06sc-linear-algebra-fall-2011/">18.06Sc</a> course for getting to grips with the basics. Gilbert Strang’s style of lecturing is incredibly intuitive and informative, and is also the primary resource from which I first started to learn about this fascinating subject.</p><p>Georgia Tech also has a brilliant online <a href="https://textbooks.math.gatech.edu/ila/">interactive linear algebra textbook</a>, replete with a vast amount of exercises; I recommend working through 18.06Sc and supplementing it with as many exercises as you can reasonably work through.</p><p>Finally, I also regularly publish articles about linear algebra here on my <a href="https://medium.com/@josephjojoe">Medium page</a>; I usually cover topics which I find particularly interesting, and they might be of use to you for building up a more thorough intuition and understanding of foundational theory and certain techniques.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eeadd1820946" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Four Fundamental Subspaces]]></title>
            <link>https://josephjojoe.medium.com/the-four-fundamental-subspaces-74758449775d?source=rss-ffba03e7e94d------2</link>
            <guid isPermaLink="false">https://medium.com/p/74758449775d</guid>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Joseph Jojoe]]></dc:creator>
            <pubDate>Thu, 23 Jun 2022 16:50:20 GMT</pubDate>
            <atom:updated>2022-06-27T17:18:03.491Z</atom:updated>
            <content:encoded><![CDATA[<p>Each matrix has four very important vector spaces attached to it. In this article, we explore the column space, row space, null space, and left null space ― finding basis vectors for these spaces, and determining whether or not a given vector is part of a particular space, is crucial to understanding whether systems of linear equations are solvable. Knowledge about these vector subspaces will inform us about why <em>A</em><strong>x</strong> = <strong>b</strong> and <em>A</em><strong>x</strong> =<strong> 0</strong> often have solutions, but sometimes don’t.</p><h3>Before we go further…</h3><h4>Representing matrix multiplication with linear combinations of columns</h4><p>Matrices and vectors can be represented in a wide range of formats: using column vectors is a succinct way to write out matrix multiplications.</p><figure><img alt="Matrix multiplication can interpreted as taking linear combinations of columns." src="https://cdn-images-1.medium.com/max/290/1*Y4hFJNKYhpyIVSb9INzsxA.png" /><figcaption>The column picture — matrix multiplication can interpreted as taking linear combinations of columns.</figcaption></figure><blockquote><strong>Linear combination</strong>: an expression constructed from a set of terms by multiplying each term by a constant and adding the results. (Wikipedia)</blockquote><p>The sum <em>x</em><strong>c</strong>₁ + <em>y</em><strong>c</strong>₂ is a <strong>linear combination</strong> of the columns of <em>A</em>; it’s a ‘weighted sum’ which is encountered whenever we multiply matrices together with vectors, and is an alternative interpretation to the ‘row-column’ method of matrix multiplication commonly taught in high school.</p><p>By the way, the numbers <em>x</em> and <em>y</em> have a special name ― they’re called <strong>scalars</strong>, because they ‘scale’ vectors in magnitude without changing their fundamental direction.</p><h4>Linear independence and basis vectors</h4><p>Taking linear combinations leads to the notion of <strong>linear independence</strong>; a set of vectors is linearly independent if there aren’t any vectors in the set which can be rewritten in terms of a linear combination of the other vectors. What a mouthful!</p><p>It might help to visualise linear independence geometrically ― vectors are usually independent when they point in different directions, although it’s worth noting that this notion becomes sketchier in more than two dimensions. As our linear algebra knowledge grows, we will tend to simply consider the different linear combinations that can be formed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*zH2W3HcE8UpKthdtbywBSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*olJOM5iXDXQ4kh6t1I5YhQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*ODydHgFZu65dfmJZpdfzog.png" /><figcaption>Dependent, independent, and wacky independent vectors for 2D space. Notice that dependent vectors lie on the same line and independent vectors aren’t necessarily perpendicular.</figcaption></figure><p>The first set of vectors (red and blue) aren’t linearly independent because they lie on the same line; in fact, multiplying either one of the vectors by -1 gives the other. They are <strong>linearly dependent</strong>; at least one of the vectors in this set can be written in the form of a <strong>linear combination of the other vectors</strong>. We only had to take a scalar multiple of one vector to produce the other in this example ― in most cases, you’ll need a weighted sum of several vectors to find linear dependency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*sWvj3X_ZhGMv_WW5bc0WrA.png" /><figcaption>The purple vector can be formed by a linear combination of the blue and red vectors — it’s unnecessary as it doesn’t add anything new to our basis.</figcaption></figure><p>The purple vector <strong>p</strong> in this diagram isn’t a scalar multiple of either of the other two vectors, but it is a linear combination; adding the blue and red vectors <strong>b</strong> and <strong>r</strong> produces the purple vector, producing the important substitution <strong>p</strong> =<strong> b</strong> + <strong>r</strong>. Eliminating <strong>p</strong> in this manner shows that it was redundant ― we <strong>already had two independent vectors</strong> for this two-dimensional space which could produce <strong>any other vector in this space</strong> through linear combinations, so including a third vector was a doomed prospect from the start.</p><p>We could have chosen to eliminate any one of the vectors in our linearly dependent set of three, although constructing a linear combination to produce <strong>b</strong> or <strong>r</strong> would be more difficult. When given a set of linearly dependent vectors, you should exercise good judgement in first eliminating vectors that are easy to find combinations for.</p><blockquote><strong>Linear dependence</strong>: a set of vectors is said to be linearly dependent if there is a nontrivial linear combination of the vectors that equals the zero vector. (Wikipedia)</blockquote><p>Although it might not seem like it, this definition is in fact equivalent to our own. We said that a set of vectors {<strong>v</strong>₁, <strong>v</strong>₂, …, <strong>v</strong>ₙ} is linearly dependent if a vector <strong>v</strong> from the set can be written in terms of a linear combination of the other vectors. Putting that into equation form, <strong>v</strong> = (<em>b</em><strong>v</strong>₁ + <em>c</em><strong>v</strong>₂ + … + <em>z</em><strong>v</strong>ₙ) for some scalar values <em>b</em>, <em>c</em>, …, <em>z</em>. We then put a scalar <em>a</em> in front of <strong>v</strong> without loss of generality (after all, <em>a</em> could equal 1) to give us our principal equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*WYMnYtLAs-mSSLE8DxcYwA.png" /><figcaption>Our linear dependence equation.</figcaption></figure><p>Wikipedia states that a set of vectors is linearly dependent when a nontrivial (i.e., no cheating; you can’t set all the scalars to zero) linear combination of the vectors equals the zero vector. Putting <em>that</em> into an equation, we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*odyeAGEZ6d8qZieT3WlkNw.png" /><figcaption>Wikipedia’s linear dependence equation. The boldness on 0 indicates that we are referring to the <strong>zero vector</strong>, not the number. Thankfully, the zero vector is simply filled with zeroes anyways, so you’ll often see 0 used to refer to the number and vector interchangeably. Look at the context to work out what 0 means!</figcaption></figure><p>Now, it takes a simple proof to show that the two statements are one and the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*YHBewKf8j16fKJqFXEKzIQ.png" /></figure><p>It’s important to know that <strong>matrices containing dependent columns are not invertible</strong>; there are multiple linear combinations that equal the zero vector, so there’s no way to get back to a particular vector input.</p><p>In general, <strong>n-dimensional space requires n linearly independent vectors</strong> for linear combinations to be able to produce any vector in that space. Less than n, and you won’t have enough ‘degrees of freedom’ to be able to explore the space fully. More, and you can eliminate dependent vectors until you’re left with just n.</p><p>A set of n linearly independent vectors for n-dimensional space has a special name: we call it a <strong>basis</strong>. Finding a basis can be a difficult task in itself, but processes like <a href="https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process">Gram-Schmidt</a> exist to generate bases from a given set of vectors. Alternatively, we can use mathematical intuition to build up a basis; <strong>unit vectors</strong> along coordinate axes would suffice, for example.</p><h4>What’s a vector space?</h4><p>A ‘space’ in mathematics generally refers to a collection, or <strong>set</strong>, of objects ― we’ll be working with vector spaces, where the objects in question are vectors. More exotic spaces (read: <a href="https://en.wikipedia.org/wiki/Function_space">function</a>, <a href="https://en.wikipedia.org/wiki/Hilbert_space">Hilbert</a>, <a href="https://en.wikipedia.org/wiki/Metric_space">metric</a>) also exist, but are worth exploring in their own right in future articles.</p><p>Vector spaces also have <strong>operations</strong> attached to them. In the context of linear algebra, an operation acts on two vectors and produces another vector ― we will define two operations on our vector space: vector addition and scalar multiplication.</p><figure><img alt="We define vector addition and scalar multiplication as such." src="https://cdn-images-1.medium.com/max/303/1*rQgTLJsA_JwL1GSYaKz8Rg.png" /><figcaption>We define vector addition and scalar multiplication as such.</figcaption></figure><p>One important property of vector spaces is that they are closed under these operations. <strong>Closure</strong> is the concept that applying these operations to an object in a particular space cannot produce another object that lies outside of the space ― a familiar example is that of the real numbers, as performing addition, subtraction, multiplication, or division on reals will never produce a non-real number. Similarly, we define a <strong>vector space</strong> to be a collection of vectors, such that scalar multiplication and linear combinations cannot produce a vector outside of our initial space.</p><blockquote><strong>Vector space</strong>: a set of vectors that is closed under scalar addition, scalar multiplications, and linear combinations.</blockquote><p>An interesting consequence of closure is that <strong>all vector spaces contain the zero vector</strong>. If they didn’t, the linear combination (<em>0</em><strong>v</strong>₁ + <em>0</em><strong>v</strong>₂ + … + <em>0</em><strong>v</strong>ₙ) for a particular basis {<strong>v</strong>₁, <strong>v</strong>₂, …, <strong>v</strong>ₙ} would produce it for us, and closure thus demands that it be included in our space.</p><h4>Vector subspaces, with a quick set theory refresher</h4><p>A <strong>set</strong> is just a collection of objects. The natural numbers from 1 to 5, a list of people born in Connecticut, and the registration plates of every Toyota in existence are all sets.</p><p>Some sets are short enough that we can define them through writing down each member, such as S₁ = {1, 2, 3, 4, 5}; others use <strong>set-builder notation</strong>, which saves us from having to list each element (there are a <em>lot</em> of people in Connecticut).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*X5PLP5WPn-pE5dVQIlmTPQ.png" /><figcaption>Set-builder notation in action — x refers to a <strong>generic member</strong> of our set and after the colon (meaning ‘such that’) we place our conditions of membership, usually known as <strong>rules</strong> or <strong>predicates</strong>.</figcaption></figure><p>A <strong>subset</strong> is a set A whose elements are all also elements of some other set B; we say that B is a superset of A, correspondingly, although we won’t be using the latter term when referring to vector subspaces. Every set is also a subset of itself, as every element contained in a particular set is also an element of that same set by definition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Dqmt1PU8wN4Mj83MbSkGBQ.png" /><figcaption>A is a subset of B in this diagram. (Wikipedia)</figcaption></figure><p>A <strong>vector subspace</strong>, also known as a <strong>linear subspace</strong>, is a vector space which is a subset of some larger vector space. By our earlier definition of what a subset is, this also means that every vector space is a subspace of itself! The zero vector is a key example of a vector subspace; it fits all of our criteria for being a vector space, given that it is closed under linear combinations (try making something non-zero with just the zero vector!), and it is a subset of every other vector space.</p><blockquote><strong>Span</strong>: the vector space formed by the set of all linear combinations of elements of a set of vectors S.</blockquote><p>Closely linked to subspaces is the idea of <strong>span</strong>, the smallest linear subspace (i.e., another vector space) which contains the set of all linear combinations of elements of S. We’re steering dangerously close to mathematical word soup, so I’ll illustrate with some 2D examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*1BlqzKhTR0WgGgWY5__mQA.png" /><figcaption>The red vector and blue vector form a set S. Their span is a one-dimensional linear subspace (dotted green line) in two-dimensional vector space.</figcaption></figure><p>Take these two vectors, for instance. We’re working in a 2D surface, so each vector is also 2D ― they both have two components (x and y) to indicate their direction. However, this set of vectors is linearly dependent; they both lie on the same line, thus linear combinations can only produce a <strong>1D linear subspace</strong> of the 2D plane. In fact, we could even eliminate one of the vectors to give us a basis for this 1D subspace, because we only need one vector to be able to produce a 1D line through scalar multiplication.</p><p><strong>Not all spanning sets for a subspace are bases, but all bases are spanning sets.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*zn6G0dpYmPcOmpJKXqJ8hQ.png" /><figcaption>A spanning set for 2D space. It’s not a basis, but the set of all linear combinations of these vectors fills R²; another way of saying this is that the <strong>space spanned by these vectors</strong> is R².</figcaption></figure><h4>Transpose of a matrix</h4><p>Transposing a matrix simply means that we exchange rows and columns ― the first row of our original matrix <em>A</em> becomes the first column of our transposed matrix <em>A</em>ᵀ, the second row of <em>A</em> becomes the second column of <em>A</em>ᵀ, and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*MqJ7GLRP3p2u9FHEFvSi1w.png" /><figcaption>Examples of matrix transposition.</figcaption></figure><h3>The Four Fundamental Subspaces</h3><p>Now that we know about linear combinations, linear independence, bases, vector spaces and subspaces, span, and the transpose, we can finally explore the four fundamental subspaces that every matrix possesses.</p><h4>Column space, C(A)</h4><p>The <strong>column space</strong>, denoted as C(<em>A</em>) for a given matrix <em>A</em>, is the vector space spanned by the columns of <em>A</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*wOPUump0Q1w7jwBewjEYWQ.png" /><figcaption>Column space for different matrices. It is important to note that the column space refers to the set of <strong>all possible linear combinations</strong> of the columns, i.e. the collection of vectors produced by going through all values of a, b, and c.</figcaption></figure><p>The column space of <em>A</em> spans and is a basis for R². C(B) also spans R², but we have three vectors in our spanning set so this isn’t a basis. C(M)’s column space is somewhere in R³, but we only have two vectors in our spanning set; reminding ourselves that the number of linearly independent vectors corresponds to the ‘degrees of freedom’ our set of linear combinations has, this means that C(<em>M</em>) is actually a two-dimensional linear subspace of R³. Geometrically speaking, C(<em>M</em>) is a <strong>plane</strong> which goes through the origin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*NaLQ9muO5T10CldbLtEF8A.png" /><figcaption>C(M), a two-dimensional linear subspace of R³.</figcaption></figure><p>Remember how we previously interpreted matrix multiplication as taking linear combinations of columns? It looked very similar to our column space calculations!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*bdy3CpZBUxkRlmwhnIYgBw.png" /><figcaption>Column space expressed as matrix multiplication.</figcaption></figure><p>The column space of a matrix <em>A</em> can therefore be alternatively defined as the space spanned by the result of matrix multiplications involving <em>A</em>. In fact, the equation <em>A</em><strong>x</strong> = <strong>b</strong> is solvable precisely when <strong>b</strong> lies within C(A), such that the matrix multiplication <em>A</em><strong>x</strong> can produce it for some vector <strong>x</strong>. Marvellous!</p><blockquote>When is A<strong>x</strong> = <strong>b</strong> solvable? When <strong>b</strong> is in the column space of A.</blockquote><h4>Row space, C(Aᵀ)</h4><p>The <strong>row space</strong> of a matrix is the vector space spanned by its row vectors. It’s inconvenient to work with rows directly, so we instead transpose our matrix <em>A</em> and use its column space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*mjE4-TAsrxbUmFaPfs7VXw.png" /><figcaption>The row space C(Aᵀ) of a matrix A.</figcaption></figure><h4>Null space, N(A)</h4><p>The <strong>null space</strong> N(<em>A</em>) of a matrix, also known as the <strong>kernel</strong>, is the vector space spanned by vectors <strong>x</strong> for which <em>A</em><strong>x</strong> = <strong>0</strong>.</p><p>Earlier in this article, we explored the interpretation of matrix multiplication as <strong>linear combinations of columns </strong>and the fact that <strong>linearly dependent</strong> columns have nontrivial linear combinations that equal the <strong>zero vector</strong> ― we now put these concepts together to develop our understanding the null space.</p><p><em>A</em><strong>x</strong> = <strong>0</strong> only occurs when either <strong>x </strong>= <strong>0</strong> or when there is a linear combination of the columns of <em>A</em> which gives the zero vector, which would mean that the columns are <strong>linearly dependent</strong> and <em>A</em> is <strong>singular</strong>. If the columns of <em>A</em> are independent, making <em>A</em> <strong>invertible</strong>, the only vector that makes <em>A</em><strong>x</strong> = <strong>0</strong> true is <strong>x</strong> = <strong>0</strong>;<strong> </strong>the null space <strong>only contains the zero vector</strong>, which we deem trivial. In general, <strong>only singular matrices have a nontrivial null space</strong>.</p><p>Actually finding vectors in N(A) requires that we put A into a special format called <strong>reduced row echelon form</strong>. I’ll cover the process of finding <strong>rref(<em>A</em>)</strong> in a separate article, but it’s closely related to how we solve systems of linear equations through Gaussian elimination and very fun to carry out!</p><blockquote>When is A<strong>x</strong> = <strong>0</strong> solvable for nontrivial values of <strong>x</strong>? When the columns of A are linearly dependent, which is equivalent to saying that A is a singular matrix.</blockquote><h4>Left null space, N(Aᵀ)</h4><p>In the same way that row space is linked to column space, the <strong>left null space</strong> N(<em>A</em>ᵀ) links to null space; we define it to be the vector space spanned by vectors <strong>x</strong> for which <em>A</em>ᵀ<strong>x</strong> = <strong>0</strong>.</p><h4>A final word about orthogonal complements and subspaces</h4><p><strong>Orthogonality</strong> generalises the notion of perpendicularity to higher dimensions. Two vectors <strong>u</strong> and <strong>v</strong> are orthogonal if their dot product <strong>u</strong>.<strong>v</strong>, which we define as <strong>u</strong>.<strong>v</strong> = (<strong>u</strong>₁<strong>v</strong>₁ + <strong>u</strong>₂<strong>v</strong>₂ + … + <strong>u</strong>ₙ<strong>v</strong>ₙ), where <strong>u</strong>ᵢ means the i-th component of the vector <strong>u</strong>, is equal to zero.</p><p>The pairs [C(A), N(Aᵀ)] and [C(Aᵀ), N(A)] are very special; the subspaces in each pair are <strong>orthogonal complements</strong> of each other, meaning that every vector in one subspace of the pair is orthogonal to every vector of the other.</p><p>Finally, it’s worth noting that in n-dimensional space, the dimensions of each pair sum to n. This concept can be succinctly expressed in the phrase ‘orthogonal complements fill the whole space’ ― taking linear combinations of basis vectors from each pair member allows us to construct a complete basis for the n-dimensional vector space we’re working in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*TTrZtexe5Qpd7TzoWxhO_w.png" /><figcaption>An illustration of orthogonal complements in two dimensions; every vector on the red line is orthogonal to every vector on the blue line, regardless of magnitude.</figcaption></figure><h4>Further exploration</h4><p>I always love to recommend MitOpenCourseWare’s <a href="https://ocw.mit.edu/courses/18-06sc-linear-algebra-fall-2011/">18.06Sc Linear Algebra</a> course as a great introduction to linear algebra; it focuses on presenting key facts and teaching techniques so familiarity with writing proofs isn’t needed, but <a href="https://ocw.mit.edu/courses/18-700-linear-algebra-fall-2013/">18.700</a> might be what you’re looking for if you prefer a rigorous approach. Gilbert Strang recaps this article’s contents in his <a href="https://ocw.mit.edu/courses/18-06sc-linear-algebra-fall-2011/resources/the-four-fundamental-subspaces/">lecture on the four fundamental subspaces</a>.</p><p>If you’re interested in applying your knowledge of linear subspaces to fitting lines/curves to data, read my article on <a href="https://medium.com/p/f235755d753c">performing regression with linear algebra</a>; it introduces the concept of <strong>projection matrices</strong>, which allows us to solve <em>A</em><strong>x</strong> = <strong>b</strong> by finding the closest vector to <strong>b</strong> which lies in C(<em>A</em>).</p><p>Georgia Tech’s <a href="https://textbooks.math.gatech.edu/ila/subspaces.html">interactive article on subspaces</a>, complete with theorems and plenty of examples, is great for recapping the concepts we learned today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74758449775d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regression with Linear Algebra]]></title>
            <link>https://josephjojoe.medium.com/regression-with-linear-algebra-f235755d753c?source=rss-ffba03e7e94d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f235755d753c</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Joseph Jojoe]]></dc:creator>
            <pubDate>Mon, 20 Jun 2022 21:14:42 GMT</pubDate>
            <atom:updated>2022-06-23T11:13:38.997Z</atom:updated>
            <content:encoded><![CDATA[<p>Linear algebra is a powerful tool in any mathematician’s arsenal; today, we explore how matrices can be used to plot lines and curves of best fit for a given set of data points.</p><h3>Motivation</h3><p>Regression is intimately tied to the idea of <strong>projection matrices</strong> ― a projection matrix <strong><em>P</em></strong> maps a vector <strong>b</strong> onto the space spanned by the columns of <strong><em>A</em></strong>.</p><figure><img alt="Formula for the projection matrix P" src="https://cdn-images-1.medium.com/max/267/1*u2kpXipw5uJxuKWAk4soXA.png" /><figcaption>Pre-multiplying a vector b by P projects it onto the column space of a given matrix A.</figcaption></figure><p>For a given set of data points, there may not be a straight line that passes through each point ― it is far more likely that we can only produce a ‘line of best fit’, which minimises the distance between the line and each point of our dataset.</p><figure><img alt="A tentative line of best fit for the points (0,0), (1,1), and (2,1)." src="https://cdn-images-1.medium.com/max/320/1*yce2Q0TI0dL67QTBQgpd0g.png" /><figcaption>A tentative line of best fit for the points (0,0), (1,1), and (2,1). Notice how the line does not pass through any of the data points.</figcaption></figure><p>In matrix form, this means that <em>A</em><strong>x</strong> <strong>= b</strong> is not solvable, as there is no straight line that can pass through every point and satisfy each equation. Instead, we will project the vector <strong>b</strong> onto the column space C(<em>A</em>) of <em>A</em>, forming a vector <strong>p</strong>, and solve for coefficients of our line of best fit which will be able to produce the vector <strong>p</strong>.</p><p>The projection is orthogonal, meaning that <strong>b</strong> is projected to the point of C(<em>A</em>) which is closest to it. This allows us to assert that the line produced by the coefficients found through this method is indeed the ‘best fit’; the orthogonal projection of <strong>b</strong> onto C(<em>A</em>), which we name <strong>p</strong>, is the closest that <em>A</em><strong>x</strong> can get to the original vector <strong>b</strong>.</p><p>Proving that a given line is the ‘best’ line for a dataset, or alternatively finding the coefficients of the line of best fit for a set of points, is the task of <strong>regression</strong>. We find these coefficients by minimising the error, defined as the sum of the squares of the vertical distances between each point and the line ― producing the lowest value of the sum of the squared distances leads to the name for this method, <strong>least squares</strong>.</p><figure><img alt="We minimise the sum of the squared errors (shown in red) to produce a line of best fit; this is the foundational principle of least squares regression." src="https://cdn-images-1.medium.com/max/320/1*gRqI7aIMAbvvWi8MzXY6IA.png" /><figcaption>We minimise the sum of the squared errors (shown in red) to produce a line of best fit; this is the foundational principle of least squares regression.</figcaption></figure><h3>Example: Linear Regression with Least Squares</h3><p>We will now produce a line of best fit of the form y = Ax + B for the given points (1, 1), (2, 1), and (3, 2).</p><p>If the line went through all three points, we would have three equations which we could solve simultaneously to find M and C.</p><figure><img alt="The system of linear equations formed by our generalised line of best fit equation and supplied data points." src="https://cdn-images-1.medium.com/max/169/1*xwbamUQxslqUSff2TaVHzQ.png" /><figcaption>The system of linear equations formed by our generalised line of best fit equation and supplied data points.</figcaption></figure><p>This is a <strong>system of linear equations</strong>, which we can now write in the language of linear algebra using matrices and vectors.</p><figure><img alt="Our system of linear equations, now in matrix form." src="https://cdn-images-1.medium.com/max/282/1*i0QNS2M7CtkOgEc7S5PNpA.png" /><figcaption>Our system of equations, now in matrix form.</figcaption></figure><p>We describe this system as <em>A</em><strong>x</strong> = <strong>b</strong>; a matrix of coefficients <em>A</em> is applied to a vector of unknowns <strong>x</strong>, producing a solution vector <strong>b</strong>. Unfortunately, the matrix <em>A</em> is rectangular and thus singular ― we cannot solve this system directly.</p><p>Instead, we solve the related equation:</p><figure><img alt="The first equation is not solvable, so we instead pre-multiply by the transpose of A on both sides and solve the second equation for the best possible values of the solutions vector x." src="https://cdn-images-1.medium.com/max/191/1*-aUpSLCTWKILVJP9tbM-7A.png" /><figcaption>The first equation is not solvable, so we instead pre-multiply by the transpose of A on both sides and solve the second equation for the best possible values of the solutions vector x.</figcaption></figure><p><em>A</em>ᵀ<em>A</em> is a square matrix and invertible as long as <em>A</em> has <strong>independent columns</strong>; this is true for our matrix <em>A</em>, so we can now multiply both sides of the second equation by the inverse of <em>A</em>ᵀ<em>A</em> to solve for the coefficients. In fact, this second equation relates to projecting <strong>b</strong> onto the column space of <em>A</em>; this is what ensures that the coefficients we find will indeed produce the line of best fit.</p><p>Note the caret (hat) over <strong>x</strong> in the image ― this is to emphasise that while this is our <strong>best possible</strong> solution, it is still not a perfect match for our original matrix equation. This corresponds to our geometric intuition of a straight line not always being able to pass through every point contained within a dataset.</p><figure><img alt="We finally solve for our best possible coefficients A and B." src="https://cdn-images-1.medium.com/max/284/1*q2zbvPFtO-_0irhWULKJQw.png" /><figcaption>We finally solve for our best possible coefficients A and B.</figcaption></figure><p>This gives us A = 1/2 and B = 1/3, which we now substitute into our original line of best fit equation, y = Ax + B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*pgaQKNoM8-BSAHXvntMwEA.png" /><figcaption>The line of best fit with coefficients A = 1/2 and B = 1/3.</figcaption></figure><p>The error for each point is extremely small, and it is reasonable to conclude from our work and prior assertions that the sum of our squared errors has indeed been minimised. Our least squares linear regression is complete.</p><h3>Is non-linear regression possible?</h3><p>Yes! In our example we chose to fit points to the function y = Ax + B, but we equally could have chose y = Ax² + Bx + C, or nearly any other function for that matter. Substituting (x, y) pairs into our desired function almost always still gives systems of linear equations, and thus we can utilise the same least squares method to solve for coefficients.</p><figure><img alt="An example of least squares regression with a quadratic curve of best fit." src="https://cdn-images-1.medium.com/max/320/1*M4UVFL0a78ULEC2l7JJATQ.png" /><figcaption>An example of least squares regression with a quadratic curve of best fit.</figcaption></figure><h3>Further Exploration</h3><p>Lecture 16 of 18.06Sc Linear Algebra ― <a href="https://ocw.mit.edu/courses/18-06sc-linear-algebra-fall-2011/pages/least-squares-determinants-and-eigenvalues/projection-matrices-and-least-squares/">Projection Matrices and Least Squares</a></p><p>US Particle Accelerator School ― <a href="https://uspas.fnal.gov/materials/05UCB/4_LSQ.pdf">Least Squares Fitting</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f235755d753c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>