[{"content":"What is Money ? An oversimplified view of the economic system goes like the following:\nWhen Fed increases the money supply, it means banks can now lend more money so loans are provided at a lower rate of interest to companies and people. A common depiction in pop culture is Powell going brrr with the money printer. When Fed reduces the money supply through Quantitative Tightening, banks find it harder to lend money and thus provide loans at a much higher rate. Meme: Money printer going brrrr during 2020\nWith the current high interest rate environment in 2024, money is kind of being de-printed (or taken out) from the economy.\nFor a better idea of this, check out these insightful videos:\nKhan Academy: M0, M1, M2, M3 Money Supply and other notes Coldfusion - What is money tradingeconomics.com: Graph showing M1 money supply of dollars. Essentially, the amount of money liquid in the banks. Every other central bank in the world, is indirectly linked to the Feds decision of money supply. This is due to the fact that the dollar is the reserve currency.\nWhy is the US Dollar the main currency? 1950s: Brenton Woods agreement made most of the major countries at the time use USD for trade. USD used to be backed by gold back then. (i.e. gold and USD could be exchanged at a fixed rate) 1970s to Now: Dollar was removed from the gold standard thus causing a bubble and unprecedented growth in the 1980s. Now, the USD\u0026rsquo;s value is now indirectly backed by a (Military + Petroleum) alliance, \u0026ldquo;Petrodollar\u0026rdquo; * which helps prevent the financial bubble from collapsing. Medium: An oversimplified example of petrodollar recycling\n*For obvious reasons, military-oil alliances aren\u0026rsquo;t particularly discussed in economic textbooks. However, folks can draw their own inferences by reading news sources and from the reasons for the US interventions in Libya, Iraq etc.\nWhy is analyzing money/financial instruments important? Throughout history, innovations in financial instruments and institution have tremendously boosted the growth of countries in the past.\nFor example, Innovation of the stock market in Holland lead to the Dutch East India Company. And the financial crash of the stock market in holland, lead to the boom in the London Stock Exchange at the time. Subsequently, boosting the Britain which went on to colonize much of the world. However, the sudden growth with lack of ethical values, meant that the British companies would cause exploitation and harm to the colonies to keep the profits rolling (and to prevent the valuation bubble from collapsing).\nAnalyzing the major economic bubbles from the past we have:\nDate Economic Bubble 1630s Dutch Tulip Mania 1700s Mississippi Company and South Sea Company 1930s Great Depression 1987 Black Monday 2008 Subprime Mortgage Crises 2022 Crypto Bubble and Chinese Property Crises Numerous, sector-wise stock market bubbles keep forming from time to time.\nFinancial innovation represents the forefront of enabling new technologies, which is why most countries try to adopt new innovations in the financial system.\nSome financial innovations that lead to faster money transfers in the recent past, that are slowly being adopted across countries include:\nCard-based payment networks: VISA / Mastercard (US), JCB (Japan), Rupay (India), UnionPay (China) Fund-transfer among Banks: Real-Time Gross Settlement, Automated Clearing House Crossborder Payment Systems: SWIFT, CIPS (China), SFMS (Russia), SPFS (India), Wise, Visa B2B Smartphone P2P payments apps: PayTM/PhonePe (UPI), CashApp/ApplePay, WeChat Pay / Alipay CBDCs: Digital Yuan, E-rupee Although controversial, the book Sapiens provides useful examples of the financial bubbles in the past.\nIncentive Schemes - Why is it needed? Money is a unique and extremely useful incentive scheme since it provides,\nStore of Value - Intrinsic value provided by individuals/businesses can be quantitatively rewarded. Medium of Exchange - Rewards can be transferred. The likely fall of communism into capitalism in most countries like USSR and China, is perhaps due to the fact that there was no better incentive scheme to replace money. Communism thus providing immense short-term gain for the first 10-15 years, possible failed to keep up with a robust incentive scheme like capitalism.\nAn insightful fictional case study is that of 20th Century Motor Company from the book Atlas Shrugged. It shows how a company could fail by providing incentives that seem morally right at first. Such systems indirectly reward people who exploit the tragedy of the commons at the start, before the entire system slowly crumbles.\nSelling Louis Vuitton Bags Vs Designing Future Airplanes Clearly, money/currency is not the best indicator of driving innovation or maximizing overall happiness.\ncompaniesmarketcap.com: Luxury Goods Conglomerate LVMH Vs Aircraft Manufacturer Boeing\nA luxury goods conglomerate like LVMH which makes Louis Vuitton bags has a higher marketcap than Boeing, an aircraft manufacturer. Even though an aircraft manufacturer is likely to drive more innovation. In another sense, it could also mean more top talent could be hired for driving sales of luxury handbags instead of designing future aircrafts.\nSo then, how do we well-distribute wealth and supercharge innovation? A Foray into UBI Is giving people free money or a universal basic income, a good idea?\nSome flaws of this model would be:\nMay ultimately lead to the same economic inequality without providing any public gain like better roads, public transport etc. Also, all products consumed by the average citizen would go up in price leading directly to inflation in prices. People who perform better or provide more value won\u0026rsquo;t be adequately rewarded. (So, people may move to other countries/regions) Lots of the money may be ultimately spent on pursuing short term gains/goods, instead of longer term gains that help the economy. Most of the UBI money ends up going back in the hands of rich people who own the assets or in inflation of daily goods prices. Investopedia: Goods and services under the CPI. CPI is usually a weighted average of the price increases in each of these goods and services.\nA close real life example of UBI, is the COVID stimulus packages distributed in the U.S.\ntradingeconomics.com: US CPI Inflation Rate 2014-2024 Clearly, the COVID stimulus packages (UBI) caused very high inflation rates. Ultimately, the increase in prices of daily goods, ends up erasing all the benefits of providing money in the first place. Other approaches to UBI, like providing food rations and free education may work better in most societies.\nAnalyzing Money in a Better Way Economists would have much better techniques to analyze money but here I attempt to find simpler techniques to analyze money/incentive schemes.\nSome ways to analyze money include,\nUtility Vs Time - Shows how an asset\u0026rsquo;s price would age with time. A car would most likely be a depreciating asset with a sloping curve. Utility vs Time Curve for a flight ticket.\nRivalrousness Vs Excludability - This article from vitalik\u0026rsquo;s blog goes into much depth about it. Rivalrousness: to what extent does one person enjoying the good reduce another person\u0026rsquo;s ability to enjoy it? Excludability: how difficult is it to prevent specific individuals, eg. those who do not pay, from enjoying the good? Vitalik\u0026rsquo;s Blog: Rivalrousness Vs Excludability Chart Different concepts of money in the future Future money with expiry dates Inflation already does this to some extent even today Gift Cards and Vouchers already do this to some extent DAOs - Corporations based on group contributions. Broad ways to make money more useful could be by designing it to better, A future form of money would be more optimal in,\nReducing deadweight loss or in simpler terms, preventing any supply-demand mismatch in in products bought using money. (e.g.- Food being wasted since no one to eat it) Encouraging use of sustainable products/methods. (Possibly, the original intent of Blackrock\u0026rsquo;s ESG scores before being corrupted by politics?) Helping innovative/research companies receive adequate monetary funding till value can be provided. Further Reading In the context of nations, governments tend to focus on other aspects of money like,\nVelocity of money: How fast money is spent. The more different people it is traded with, the more people it provides value/goods/services to. How much has prices for necessary items increased for the average person (Consumer Price Index or Inflation) Numerous other indicators are available on trading economics indicators Other outlines of incentive schemes for innovation/work in the modern world:\nIncentive Example Political Power Factory Worker Vs President Work Type Work in Agriculture Vs Work in AI/ML Self Satisfaction Factory Worker Vs Sports Player Religious Ideologies Crusades and Religious Wars Utilitarian Ideologies Open Source / FOSS References\nPolitical reasons why money flows to where it does: Rules for Rulers by CGP Grey Simpler Analysis on QT/QE: Plain Bagel - Quantitative Tightening Complicated/Deeper Analaysis on QT/QE (rabbit hole): FedGuy Joshua Wang on Quantitative Tightening (Also a blog post) Econophysics: Takes various concepts from physics and applies it to economics. (Dampening factors when money echoes through markets etc.?) Sapiens - Although controversial for its factual inaccuracies, it provides good overall mental models for development and progress throughout history. Atlas Shrugged - Rather lengthy book, but first two parts provide an excellent view of the downsides of a lack of incentive schemes. Simplified overview of the recessions in the past: Slidebean - List of past recessions Modelling a DAO: Vitalik - DAOs are not corporations If you liked this post, feel free to follow me on X or LinkedIn!\n","permalink":"https://cheese-cracker.github.io/posts/money-macro/","summary":"\u003ch2 id=\"what-is-money-\"\u003eWhat is Money ?\u003c/h2\u003e\n\u003cp\u003eAn oversimplified view of the economic system goes like the following:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eWhen Fed increases the money supply, it means banks can now lend more money so loans are provided at a lower rate of interest to companies and people. A common depiction in pop culture is Powell going brrr with the money printer.\u003c/li\u003e\n\u003cli\u003eWhen Fed reduces the money supply through \u003ca href=\"https://www.youtube.com/watch?v=KTWVyFFpGXQ\"\u003eQuantitative Tightening\u003c/a\u003e, banks find it harder to lend money and thus provide loans at a much higher rate.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cdiv align=\"center\"\u003e\n\u003cimg height=\"360\" src=\"/plots/money/money_printer_go_brr.jpg\" alt=\"Money Printer going brrrr during 2020\"\u003e \u003c/img\u003e\n\u003cp\u003e\u003csmall\u003eMeme: Money printer going brrrr during 2020\u003c/small\u003e\u003c/p\u003e","title":"Reward Systems - Money and More"},{"content":"Introduction In this post, we delve into the mental model (or abstract feeling) of things being continuous Vs discrete. In the direction of continuous vs discrete ideas, we look into signal processing, numerical methods and random ideas.\nPoster originally by mathbytori.blogspot.com Throughout this post, the terms \u0026lsquo;discrete\u0026rsquo; and \u0026lsquo;continuous\u0026rsquo; are somewhat loosely defined.\nA simple intuition on continuous and discrete would give us,\nDiscrete Continuous Distinct, seperate and countable Fluid, mostly singular Dotted Line Normal straight Line Scattered Unionized Set of Integers $Z$: Distinct points on the number line Set of Real Numbers $\\Re$: Continuous line on the number line Sets not dense (in any metric space) Set is dense (in any metric space) Non-seperable Metric Space(like discrete metric space) Seperable Metric Space Discrete Probability Distribution Continuous Probability Distributions Histograms Kernel Density Estimates Digital Image Processing Analog Image Processing Discrete Delaunay Triangulations Continuous Voronoi Diagrams Discrete Time Signals Continuous Time Signals Sum of many discrete rectangles Area under a continuous curve Discrete Factorials Continuous Gamma Function Discrete Transforms Continuous Transforms Discrete Recurrence Relations Continuous Differential Equations A common trend to notice is that discrete things tend to take a finite or countable set of values.\nDiscrete Signals Vs Continuous Signals Moving to more concrete definitions, Let us take the example of Continuous vs Discrete in the context of Signals. This divides us into four parts shown below,\nClockwise: CT Analog, CT Digital, DT Digital, DT Analog\nThe differentiating factors are,\nDiscrete time (DT) Vs Continuous time (CT) Analog signal Vs Digital signal Here, digital signal and analog signals are both continuous in time but the CT digital signal has only a discrete set of values for the ouput $y(t)$.\nIn this post, the ideas of \u0026lsquo;digital\u0026rsquo; and \u0026lsquo;discrete\u0026rsquo; may be mixed because \u0026lsquo;digital\u0026rsquo; signals are still discrete in the y-axis.\nArea under a Continuous Curve Vs Sum of many Discrete Rectangles Considering the area under the curve for any continuous function $y(t)$, the area is given by $\\int_{t_0}^{t_n} y(t)$\nHowever, if we consider the digital equivalent of this function (by quantizing the input), the area under the curve can just be the sum of distinct rectangles.\nSo we get, $\\int_{t_0}^{t_n} y(t) = \\sum_{i=0}^{n-1} y(t_i)$.\nWikipedia: Riemann Sum (taking midpoints)\nTaking the value at each midpoints and summing the rectangles we get, $$\\int \\limits_a^b m(x)dx = \\lim_{n \\rightarrow \\infty} \\frac{|b - a|}{n} \\sum_{k = 1}^{n} m(a + k \\frac{|b - a|}{2n})$$ So, as we make the partition intervals smaller ($\\lim_{n \\rightarrow \\infty} \\frac{1}{n}$), this sum becomes closer to the actual integral.\nA mid-riser or mid-tread quantizer in signal processing, would be analogous to a Riemann sum except for one point. The quantizer divides the signal $y(t)$ into discrete bins (and reconstructs). However, the riemann sum would divide the input $t$ into discrete bins.\nWikipedia: Quantization of Signal with 4 Levels\nInstead of partitioning the continuous function into rectangles, we could take the function values at two points and break it into trapezoids. (Trapezoidal Rule)\nWikipedia: Trapezoidal Rule Similarly, we can approximate with even more function points to get the other Newton Cotes Formulas.\nSo, all these summations functions are approximations to integrations (each with a same or faster convergence).\nDiscrete Factorials Vs Continuous Gamma Function Considering another seqn of numbers, $$1, 1, 2, 6, 24, 120, 720 ...$$ Can you guess the sequence?\nFor any given sequence in $N$, there will always be infinitely many continuous functions in $\\Re$, that satisfy the sequence.\nBut one special function that represents this is the gamma function, $$ \\Gamma(z) = \\int_0^{\\infty} x^{z-1} e^{-x}dx$$Here, $$ \\Gamma (n + 1) = n!$$ thus captures the factorial function.\n(Note that however the gamma function is continuous only in $\\Re^{+}$.)\nFor many sequences which are a discrete recurrence relation, a continuous generating function can be also found.\nDiscrete Vs Continuous - Fourier-Like Transforms Another interesting and useful concept when dealing with signal processing, is the fourier transforms. It is a very essential way to transfer a random signal (think square, triangular, wavy, crazy or any time-based oscillation) into a mixture of sine ways of different frequencies. 3blue1brown has an amazing visual introduction to the fourier transform.\nWhen considering fourier transforms, there are numerous generalization for different signals. The types of transform depends on the 4 differentiating factors,\nDiscrete Signal or Continuous Signal Periodic Signal or Aperiodic (Infinite Period) Signal Transform or Inverse Transform (Analysis or Synthesis) Imaginary exponent Vs Complex(re + im) exponent in equation Considering the normal transform in real domain, varying points 1 and 2, we get the following table,\nFourier Series Vs Fourier Transform\nSimilar to the CTFT and DTFT, there is also inverse CTFT and inverse DTFT. This article has a nice table,\nMedium: Fourier Transform Table\n\u0026lsquo;Complex Fourier Series\u0026rsquo; is the same as \u0026lsquo;Continuous Time Fourier Series\u0026rsquo;\nSwitching the last parameter 4 from purely imaginary to complex exponents, give us two new transforms -\nLaplace Transform (Continuous Domain) Z - Transform (Discrete Domain) In the transforms, the real component gives us the $e^x$ curves and the complex exponent gives us the $e^{ix} = cos(x) + isin(x)$ curves.\nAn ugly inconsistency Considering the laplace transform to be, $$ X(s) = \\int_{-\\infty}^{\\infty} x(t) e^{-st} dt $$ An intuitive definition of Z-transform would be, $$ X(z) = \\sum_{-\\infty}^{\\infty} x[n] e^{-zn} $$ where z just like s would be defined by $z = \\sigma + i\\omega$\nUnfortunately, due to ease of usage in digital signal processing the definition of z-transform was made rather unintuitive. Hence, it is given by, $$X(z) = \\sum_{-\\infty}^{\\infty} x[n] z^{n} $$ where $z = e^{sT}$ (instead of $z=sT$)\nFrom this we see the mapping,\n$j\\omega$ axis for the Laplace transform $=$ unit circle for the Z transform\nSee this thread to know more. Another stackexchange thread, also points out why the laplace transform cannot be defined the other way around.\nDiscrete Recurrence Relations Vs Continuous Differential Equations Consider two alien species in two different planets with no natural predators and sufficient resources to grow.\nThe first alien species breeds naturally with its growth twice its current population (population growth rate 200%). The second alien species reproduces using binary fission. So, one alien essentially splits into two new alien creatures. And all the alien species undergoes this binary fission every new years\u0026rsquo; eve. Both these cases could be modelled as,\n$y' = 2y$ where $y$ is the population, and $y'$ is it\u0026rsquo;s derivative (the population growth rate). $a_n = 2 a_{n-1}$ where $a_n$ is the population in year $n$ Notice that in case of alien species no. 1 we are modelling it as a continuous differential equation whereas in the case of alien species no. 2 we are modelling it as a discrete recurrence relation.\nIn case of alien species no. 1, we have to solve the differential equation which gives us, $$y = a_0 e^{2t}$$ where $a_0$ is a constant representing the original population of aliens.\nSo if there where 1 million aliens, originally, there would $e^2 \\approx 7.34$ million aliens after just one year.\nFor alien species no. 2, it is relatively straightforward to see that a population of 1 million aliens would be 2 million after the first year.\nIt is also intuitive to notice that after any $n$ years the solution to this is, $$ a_n = a_0 2^n $$This similarity between the population growth equations can be seen better by modelling the recurrence relation as an diferential equation.\nConsider the population after 3 years, it is 4 times the population after year 1 so,\n$$a_3 = 2 * ( 2 * a_1 )$$ $$a_3 - a_1 = (2^2 - 1) a_1$$So from this we could say for any general points a_{n+k} and a_n,\n$$ \\Delta y \\approx \\Delta a_n = a_{n + k} - a_n = (2^k - 1) * a_n $$ $$ \\Delta t \\approx \\Delta n = (n + k) - n = k $$$$ \\lim_{\\Delta n \\rightarrow 0} \\frac{\\Delta a_n}{\\Delta n} = \\lim_{\\Delta k \\rightarrow 0 } \\frac{(2^k - 1) * a_n}{k}$$Taking derivative on both numerator and denominator with the El \u0026lsquo;Hospital\u0026rsquo; rule,\n$$ \\lim_{\\Delta n \\rightarrow 0} \\frac{\\Delta a_n}{ \\Delta n} = ln(2) a_n $$Modelling $a_n$ as $y$ and $n$ as $t$ we have,\n$$ y' = ln(2) y $$ $$ y = a_0 e^{ln(2) t} = a_0 2^t $$Or better expressed as,\n$$ a_n = a_0 2^n $$Another way to look at the two alien species is that,\nThe 1st alien species is a 100% compound interest which is continuous compounded. The 2nd alien species is a 100% compound interest which is compounded annually. Note that instead if we take any other coeffecient too this would work!\nFor 2nd Order and above It also works similarly for second order differential equations and second order recurrence relations. The technique to solve 2nd order ODE and 2nd order RR are the same,\nPut the solution as $y = C_0 e^{rt}$ or $a_n = \\alpha^n = e^{ln(\\alpha)n}$ Solve the quadratic equation or \u0026ldquo;characteristic equation\u0026rdquo; that transpires to get the general solution Find the particular solution, this could be with the help of specific boundary conditions etc. and combine. Without getting into too much detail, For the general solution of 2nd order ODE with distinct roots, $$ y = C_1 e^{r_1 t} + C_2 e^{r_2 t}$$ and for repeated root, $$ y = C_1 e^{r_1 t} + C_2 t e^{r_2 t}$$For the general solution of a 2nd order recurrence relation with distinct roots, $$ y = C_1 r_1^n + C_2 r_2^n = C_1 e^{ln(r_1) n} + C_2 e^{ln(r_2) n}$$ and for repeated root, $$ y = C_1 r_1^n + C_2 n r_2^n = C_1 e^{ln(r_1) n} + C_2 n e^{ln(r_2) n}$$Other Interesting References Can\u0026rsquo;t find a generating function for factorials A philosophical and cognitive science view of analog, digital, continuous and discrete. Baby Steps of Statistics Fourier Transforms 101 For mental models in other domains, refer Farnam Street Blog or Super Thinking Book Try to find an anology for discrete vs continuous, with separable and non-separable spaces. Good Resources: Separable Spaces, Discrete-like non-separable subspaces in separable spaces, Database of Topological Counterexamples ","permalink":"https://cheese-cracker.github.io/posts/discrete-vs-continuous/","summary":"\u003ch2 id=\"introduction\"\u003eIntroduction\u003c/h2\u003e\n\u003cp\u003eIn this post, we delve into the \u003cstrong\u003emental model\u003c/strong\u003e (or abstract feeling) of things being \u003cstrong\u003econtinuous Vs discrete\u003c/strong\u003e.\nIn the direction of continuous vs discrete ideas, we look into signal processing, numerical methods and random ideas.\u003c/p\u003e","title":"Discrete Vs Continuous"},{"content":"Key Resources Textbook: Computational Geometry - Algorithms and Applications Coursera Course: For the Problemset and Implementations (Till Part 5) Philipp Kindermann\u0026rsquo;s Lectures Series (Part 6 and Onwards) Various Random Resources found on the internet! Geom Algorithms CP Algorithms Further Reading / Interesting Resources ObservableHQ - Infinity and Back Again: Voronoi Diagrams for Infinite Polygons Book: Foundations of Multidimensional and Metric Data Structures - Hanen Samet (2006) Josh Hug\u0026rsquo;s Lectures on Multidimensional Data: Good intuition on k-d trees and quad trees. TestGen: Voronoi Diagrams and Delaunay Tetrahedralizations for 3D Points. Software Generalization of Voronoi Diagrams: Originally from a book on (Geometric Data Structures for Computer Graphics, 2005) Overview To learn computational geometry, these are the steps/resources I used,\nWeek 1 - Week 5: Coursera - Computational Geometry For theory, read from book and/or random resources off the internet. Philipp\u0026rsquo;s lectures are also available for this. Focus on the problemset for the course. Recommended Prerequisite: Good understanding and practice of DSA. Some of the problems have tons of edge cases! Week 6 - Week 10: Philipp Kindermann\u0026rsquo;s Lecture Series This part is more theory oriented and covers Voronoi Diagrams, Delaunay Triangulations too. Again some parts can be followed up from the book as well. Recommended Prerequisite: Basic graph theory (maximal planar graph, duals), basic DSA (analyzing time complexity) General Implementation Aspects Use slope pairs Triangle orientation check (sign of area) Sum of area of triangles to form interior Ray out of a point inside intersects polygon odd times Check line segment intersections by checking orientation of each of the four points (not two!) It also helps to plot sample testcases for debugging Modulo to cyclicly iterate through points of a Polygon Carefully inspect, input/output format as well as edge cases // My Header - (Used mostly STL instead of OOP) #define ll long long #define x first #define y second typedef pair\u0026lt;ll,ll\u0026gt; vertex; typedef pair\u0026lt;ll,ll\u0026gt; point; typedef pair\u0026lt;double, double\u0026gt; ppoint; const ppoint INF_POINT = {2e9, 2e9}; const double EPS = 1e-16; Week 1 1. Point and Vector (Triangle Sign Check)\nThis will be used in most future problems as well. The most generalized template is below. Note that area is actually twice the actual area.\nint trisign(ppoint a, ppoint b, ppoint pt){ double area = a.x * b.y + b.x * pt.y + pt.x * a.y - a.y * b.x - b.y * pt.x - pt.y * a.x; if(area \u0026gt; EPS){ return 1; }else if(area \u0026lt; -EPS){ return -1; } return 0; } 2. Point in Triangle\nPrinciple is the sum of the 3 individual triangles (2 vertices, 1 point) would be equal to total area (3 vertices).\n3. Point in Polygon\nTake ray from point to infinity Check intersection with each line segment O(N) Parity of the number of intersection determine inside(odd) or outside(even) Ignore if line segment coincides with the ray. This is used again in future problems like 4-1/4-2. Draw a ray from P to INF_POINT. Check the if the no. of intersections are odd or even. Make sure an endpoint is not counted twice - that\u0026rsquo;s why semi-open interval is checked (semi_check_intersect).\nbool inbetween(ppoint a, ppoint midd, ppoint b){ double minx = min(a.x, b.x); double miny = min(a.y, b.y); double maxx = max(a.x, b.x); double maxy = max(a.y, b.y); return (minx \u0026lt;= midd.x \u0026amp;\u0026amp; midd.x \u0026lt;= maxx) \u0026amp;\u0026amp; (miny \u0026lt;= midd.y \u0026amp;\u0026amp; midd.y \u0026lt;= maxy); } // Only check semi-interval [s1, s2) intersection [d1, d2] bool semi_check_intersect(ppoint d1, ppoint d2, ppoint s1, ppoint s2){ int s1_side = trisign(d1, d2, s1); int s2_side = trisign(d1, d2, s2); int d1_side = trisign(s1, s2, d1); int d2_side = trisign(s1, s2, d2); if(s1_side*s2_side == 0 \u0026amp;\u0026amp; d1_side*d2_side \u0026lt;= 0){ // If segment lies completely inside we can ignore it; So check if strictly only s1 is present return (inbetween(d1, s1, d2) \u0026amp;\u0026amp; !inbetween(d1, s2, d2)); }else if(s1_side*s2_side \u0026lt;= 0 \u0026amp;\u0026amp; d1_side * d2_side \u0026lt;= 0){ return 1; } return 0; } bool point_in_polygon(vector\u0026lt;vertex\u0026gt;\u0026amp; poly, pair\u0026lt;double, double\u0026gt; p){ int ray_intersects = 0; int n = (int)poly.size(); for(int k = 0; k \u0026lt; n; ++k){ ray_intersects += semi_check_intersect(p, INF_POINT, poly[k], poly[(k+1) % n]); } if(ray_intersects % 2 == 0){ return 0; }else{ return 1; } } 4. Points in Convex Polygon\nThe steps I used were as follows -\nGet Centroid: Choose 3 non-colinear points (trisign) Sort by Angle: Array of pairs slope_pairs which stores {atan2(points[i].y - centroid.y, points[i].x - centroid.x), i} and then sort. Binary Search by Angle (Helper Function): pair\u0026lt;ll, ll\u0026gt; binsearch_angle(vector\u0026lt;pair\u0026lt;double,ll\u0026gt;\u0026gt;\u0026amp; angle_pair, double angle_val) gives the pair of indices of the two vertices. Check in triangle: Use the previous part to check if point in the triangle given by binsearch_angle Week 2 Convex Hull Algorithms\nGraham Scan\nInitialize a pair of points in S Add new point Check if orientation of (n-2)nd point with ((n-3)rd, nth) point is left(ccw)/right(cw) (and 0) Else pop the 2nd last point Andrew\u0026rsquo;s (Preferred - NlogN for sort)\nTake line (leftmost or minx) point \u0026amp; (rightmost or maxx) point Sort Points in x-coords Partition all other points (by orientation) into Lower or Upper according to below/above the partition line. (stable or resort) Run Graham Scan and pop 2nd last element if right(for Upper Partition) or left(for Lower Partition) Points to Note: - Andrew\u0026rsquo;s Scan can also be thought similar to a sweep line - At every event point(p) check orientation of last point in S(n) wrt to S(n-1) and p - Convex Hull can also be used for other polygons (see Unit Circle\u0026rsquo;s questions)\nJarvis March Take lowest point in H Take 2nd point with smallest polar angle in H Take last (n-1) and (n-2) points as line Find smallest polar angle point wrt. this line Repeat till 1st point is found 1. Convex Polygon Check\nCheck if polygon is convex. Stable Partition points to upper part and lower part (like Modified Graham\u0026rsquo;s). Check (convex_check) if all Up points have no lefts. Check again if all Down points have no rights.\nbool convex_check(vector\u0026lt;pair\u0026lt;ll,ll\u0026gt;\u0026gt;\u0026amp; points, int invsign){ ll sz = points.size(); for(int i = 0; i \u0026lt; sz-2; ++i){ // NO Left(\u0026gt;0) if Down, NO Right(\u0026lt;0) if Up if(trisign(points[i], points[i+2], points[i+1]) == invsign){ return 0; } } return 1; } invsign is an integer which is 1 or -1, depending on lower or upper hull.\n2. Convex Hull\nConvex hull follows similar to the convex hull check. For each vertex, we check while(hull_size + 1 \u0026gt;= 3) If trisign(hull[hull_size - 2], points[i], hull[hull_size -1]) matches our invsign then pop the 2nd last vertex, Or else break out of the while loop to check the next vertex. Function Header: void construct_convex_hull(vector\u0026lt;pair\u0026lt;ll,ll\u0026gt;\u0026gt;\u0026amp; points, vector\u0026lt;pair\u0026lt;ll,ll\u0026gt;\u0026gt;\u0026amp; hull, int invsign); After construct_convex_hull for both partitions, we zip the upper and lower Hulls. Thus forming the CCW convex hull. 3. Tangents to Polygon\nSee geomalgorithms.com for excellent explaination of technique. As stated, we need sign(left point) != sign(right point) for tangent In our case to find left and right tangents, we can put a condition like this, inside our loop iterating through each point.\nint signl = trisign(left_pt, points[i], pt); int signr = trisign(points[i], right_pt, pt); if(signl != signr){ // CCW =\u0026gt; pt lies L/R wrt. leftpt if(signl == sign || signr == -sign){ return points[i]; } } where sign is given by whether we want left or right tangent.\n4. Union of Convex Hulls\nTake any point Z inside Convex Polygon A. If Z is also inside B, sort the points by angle and apply graham scan. If Z is not inside B, remove inner chain and apply Graham\u0026rsquo;s Scan on outer chain. OR Just apply Graham\u0026rsquo;s Scan to all the points since both algorithms have worst case, NlogN. This may however be slightly less optimal. (But it works :-))\nWeek 3 1. 2 Line Segment Intersections\nSee CP Algorithms for technique. Helper functions for this include, trisign, inbetween, determinant are used. Remember to check for \u0026lsquo;No Common Points\u0026rsquo; for both determinant = 0 and not. Watch out for corner cases. (Tons of them!)\n2. Polygon Intersection\nEither Clipping (Sutherland Hodgman) or Line Sweep (Shamos-Hoey) could be used. For clipping, see G4G. The Algorithms are as follows,\nSutherland-Hodgman\nFirst choose a polygon Cut out 2nd polygon from first (check orientation at each line and split half-plane) Go through the vertices of the 2nd polygon and check if next vertices crosses the line or not. ~O(NM) time Also, for convex + non-convex Shamos-Hoey (Sweep-Line Like) - (N + M) vertical lines from vertices - Obtain inner fragment at each line (inner up and inner down) - 4 lists of vertices (upper, lower) - Only for convex + convex\nWithin the same TC but slightly less optimal, a simpler approach using all the previous functions can be used. Simply, find all line segment intersections and check point in polygon for each vertex. Then just order points cw / ccw by sorting by angle from centroid. See D3 Mike\u0026rsquo;s ObservableHQ for an awesome visualization.\n3. Intersection of Horizontal and Vertical Segments\nThis is briefly discussed in \u0026lsquo;Competitive Programming Handbook by Antti\u0026rsquo;. Scan the the edges and classify and store as horizontal/vertical segments. Store in start, tuples of the form\n{x1, 2, vptr} for vertical segments {xmin, 1, hptr} and {xmax, 3, hptr} for horizontal segments The operations are 1(Add eventpt), 2(Intersect with vertical), 3(Remove Endpoint). Sort the start array, and perform a line sweep over it. Use order-statistic tree (policy-based ds) for the status. (or implement similar RBT using nodes) // Horizontal Segment (height) vector\u0026lt;ll\u0026gt; hzlevel; // Vertical Segment (height, range) vector\u0026lt;pair\u0026lt;ll,ll\u0026gt;\u0026gt; vlevel; // Starting Point Tuples (xcoord, operation, index) vector\u0026lt;vector\u0026lt;ll\u0026gt;\u0026gt; start; // In operation 2 we check intersects like this, lo = status.order_of_key(vlevel[ix].first); hi = status.order_of_key(vlevel[ix].second+1); intersects += hi - lo; 4. Intersection of Set of Segments\nClassic Sweep Line for Segment Intersections\nConsists (key vars)\nEvent Point Upper (or left) Endpoint of Segment is p (U(p)) Lower Endpoint of Segment is p (L(p)) Intersection/Internal Point of segment is p (C(p)) (Q) Event Queue of found event points (S) Set of of all Segements (Array) (T) Set of Status (RB Tree?) Event Queue set to check if already present? FindIntersection(S)\nInitialize Q and T Push first U( p ) endpoint (and corresponding line segment/index) in Q While Q non-empty, HandleEventPoint HandleEventPoint(p)\nConsists of U, L, C Generate L( p ) and C( p ) from adjacent segments in T Segments of $L(p) \\cup U(p) \\cup C(p) \\geq 2$ Report intersection p Delete L( p ) since segment ends Delete C( p ) to swap (2nd priority to U) Insert U( p ) Insert Back C( p ) (finish swap) If there is no U( p ) and no C( p ) FindEventPoints(sl, sr, p) where sl, sr are the adjacent segments of p in T Else Take leftmost segment of U( p ) union C( p ), ie (topmost priority) as sl Take left neighbour of sl in T, s1 FindEventPoints(sl, s1, p) // top Segments intersections Take rightmost segment of $U(p) \\cap C(p)$, ie (least priority) as sr Take right neighbour of sr in T, s2 FindEventPoints(sr, s2, p) // bottom Segments intersections Key Features for any Sweep Line\nEvent Point (often coordinate-compressed) Status Set containing elements important for current event point Line sweeps across some direction (Obvious!) Unfortunately, I wasn\u0026rsquo;t able to code this one up. However, geom algorithms explains with code the approach to doing this.\nWeek 4 1. Diagonals of any Simple Polygon\nFor diagonals, one technique is to first check if diagonal intersects with any other polygon line segment. Then check if Point-in-Polygon for the midpoint, to know if it is inside/outside. So, trisign, inbetween, semi_check_intersect, check_intersect and point_in_polygon are needed. Note that check_intersect includes endpoints unlike semi_check_intersect.\nintersect diagonal_check(vector\u0026lt;vertex\u0026gt;\u0026amp; poly, ll i, ll j){ int n = (int)poly.size(); // Check Intersections for(int k = 0; k \u0026lt; n; ++k){ if(k == i || k == j || (k+1) % n == i || (k+1) % n == j) continue; int res = check_intersect(poly[i], poly[j], poly[k], poly[(k+1)%n]); if(res == 1) return crossing; } // Check if Midpoint in polygon. Assumption: diagonal does not intersect pair\u0026lt;double, double\u0026gt; midd = {(poly[i].x + poly[j].x)/2.0, (poly[i].y + poly[j].y)/2.0}; if(point_in_polygon(poly, midd)){ return inner; }else{ return outer; } } 2. Ear-Cutting Algorithm for Triangulation of Convex Polygons\nSteps -\nPreprocess: If for every vertex, adjacent vertices form inner diagonal. Mark as Ear. ~O($N^2$ for diagonal_check) Start processing ears in-order from a starting vertex (Try to maintain order in which they are checked) Delete Current Ear Vertex from the polygon (\u0026amp; is_ear) vector. Insert (diagonal with adjacent verts and the pt) as a triangle. Check if vleft, vright is a ear (~O(N)) Stop when ear-list is empty or polygon has less than 3 vertices (all vertices are done!) Time: $O(N^3)$ (Sum of $N^2$ operations)\nAfter preprocessing the ears in the is_ear array, the algorithm proceeds as follows,\n// Set start point int st = 0; while(n \u0026gt; 3){ // Start loop at previous triangle endpoint for(int j = st; j \u0026lt; st + n; ++j){ int i = j % n; if(is_ear[i]){ // Find First Ear and Delete vector\u0026lt;vertex\u0026gt; res_triangle = { poly[(i - 1 + n) % n], poly[i], poly[(i + 1) % n] }; triangles.pb(res_triangle); is_ear.erase(is_ear.begin() + i); poly.erase(poly.begin() + i); // Update Polygon and check ears n = (int)poly.size(); // Lower Vertex is_ear[(i-1 + n) % n] = check_ear(poly, (i-1 + n) % n); // Upper Vertex (new index -\u0026gt; i % n) is_ear[i % n] = check_ear(poly, i % n); // Set start of next iteration st = i; break; } } } Finally, add remaining polygon into triangles. The check_ear functions checks diagonal_check(from 4-1) on the neighbouring vertices. It also helps to plot testcases like this,\n3. Monotone Polygon Triangulation\nTriangulation of strictly y-monotone polygons. See MCS481 Slides for a pretty good psuedocode or the Book is also great. For Diagonal check part, time complexity would be high therefore it is better to use Concavity Check with trisign instead. Remember to add diagonals from last (lowermost) vertex also. sidemap is used to store Left/Right and vertex is the merged sorted vertex list.\nvoid triangulate_monotone(vector\u0026lt;point\u0026gt;\u0026amp; verts, map\u0026lt;point, bool\u0026gt; sidemap, vector\u0026lt;polygon\u0026gt;\u0026amp; diags){ int sz = (int)verts.size(); deque\u0026lt;point\u0026gt; rack = {verts[0], verts[1]}; for(int j = 2; j \u0026lt; sz-1; ++j){ point vlast = rack.back(); // Process Vertex if(sidemap[verts[j]] != sidemap[rack.back()]){ // Opposite Sides while((int)rack.size() \u0026gt; 1){ diags.pb(vector\u0026lt;point\u0026gt;{rack.back(), verts[j]}); rack.pop_back(); } rack.pop_back(); rack.push_back(vlast); }else{ // Same Side rack.pop_back(); // rack.back() should be inward wrt. vlast and verts[j] -\u0026gt; i.e, match sign of side of vlast while(rack.size() \u0026amp;\u0026amp; check_concave(vlast, rack.back(), verts[j], sidemap[verts[j]])){ diags.pb({verts[j], rack.back()}); vlast = rack.back(); rack.pop_back(); } rack.push_back(vlast); } rack.push_back(verts[j]); } // Add diags from all verts in stack (except top and bottom) to lowermost vertex rack.pop_front(); rack.pop_back(); for(auto v: rack){ diags.push_back(vector\u0026lt;point\u0026gt;{verts[sz-1], v}); } } 4. Number of Triangulations of a Convex Polygon\nFrom the wikipedia page, A convex polygon with n + 2 sides can be triangulated to n triangles by non-crossing lines. Number of different ways of triangulation is Catalan Nos. For any triangulation, there would be exactly 2 vertices that don\u0026rsquo;t need to be joined by a diagonal.(or whose degrees stay the same!) So, catalan nos. is on the $n-2$ vertices connected by diagonals. The $\\sum c_i c_{n-i}$ Form: Recurrence relation is the breaking of the polygons by one of the diagonals. Week 5 k-D Trees\nBase Structure: BST Stores values like BST, but instead of ordering only by value like BST, it needs to order by k params. This is done by selecting a splitting criteria, like for 2D: alternate between \u0026lsquo;X\u0026rsquo; and \u0026lsquo;Y\u0026rsquo; parameters based on whether the depth is even/odd. 2D Layered Range Trees\nBase Structure: Red-Black Tree or balanced BST See differences between some well-known trees. 2D Layered Range tree stores points in its associated array, and optimized for \u0026ldquo;which points fall within a given interval\u0026rdquo; queries. The assoc array of point v is the two-pointer zip (merge-sort) of 2v and 2v+1 vertices. It can be represented similar to 2D segment tree, but value contains \u0026ldquo;the points themselves\u0026rdquo;. (segtree consists of sum of no. of points) Both 2D layering range tree and segment trees can be used interchangeably. Fractional Cascading is technique to store binary_searched index of the element as pointer. So $O(logN)$ extra factor isn\u0026rsquo;t needed. Each element of assoc array of point v also contains pointers to 2v and 2v+1 nodes arrays\u0026rsquo; binary_searched(lower_bound) index. 2D Priority Search Tree\nBase Structure: Binary Heap or Priority Queue (Scaled up to 2D). Shows one-sided unbounded range of values. 1. Closest Point\nSimple binary-search implementation as points have only 1 parameter.\n2. Number of Points in Rectangle\nThe easiest implementation in via a Cartesian Tree. (similar to Kdtree) My code is a 2D Segment Tree however I recommend using an OOP approach with Cartesian Tree instead!\nThis is was approximate workflow while designing 2D Segment Tree. See CP Algorithms\u0026rsquo;s compression of 2D segment tree for ideas. Fractional Cascading for speeding up!\nBelow are the design notes for the code.\nGeneral Design - - buildx, buildy, queryx, queryy - Range compression (See cp-algorithms.com tips) - NlogN memory and (logN)^2 time per query Construction - - Vector with all x-coords sorted - Vector with all y-coords sorted for each node of segtree[x] to lowerbound/upperbound y indices - Within each node of segtree[x], store `segtree[][y]` with compressed size 4*log(Sumx_r - Sumx_l) Query - - Search equivalent indices for x-coords in vec - Get each node from segtree query - Search equivalent indices for y-coords in each vvec[v_x] - Get each node sumval from segtree[v_x] query Variable Names- - v -\u0026gt; root vertex - l, r -\u0026gt; current left/right segment of coords - L, R -\u0026gt; required left/right segment - Lyc, Ryc -\u0026gt; c indicates coordinate and not index Current Progress - - Correct Answer and correct Memory Limit - Time Limit Exceeded in Building Segtree - Building Time: ~ 4min 45 seconds - Query Time(for 30000 queries): ~ 5min (9 min 45s in total) Optimization - - Get rid of binary search for both x \u0026amp; y and instead check coord value - Remove coord compression but keep construct_order_y - Make D\u0026amp;C of segment tree run on array with unique elements (order_x, order_y) instead - Fractional Cascading: - Store relation(starts) between unique array (order_x) and points - So, construct_order_y does not require to binary search index (remove extra logN factor) The Segment Tree is built on the unique x-coordiniates (order_x) array and 2nd dimension in unique y-coordinates (order_y). It assumes that points do not repeat!\nCTags-like Overview of global variables,\nconst ll SZX = 30001; const ll INF = 1.5e9; // Segment Tree : 4*SZX and 4*SZY (still only NlogN memory since dynamic length arrays!) vector\u0026lt;ll\u0026gt; segtree[4*SZX]; // Unique x-coordinates of points vector\u0026lt;ll\u0026gt; order_x; // Unique Y-coordinates of (vx)th segment tree (4*SZX and SZY) vector\u0026lt;ll\u0026gt; order_y[4*SZX]; // List of all points in sorted x-coordinate order vector\u0026lt;pair\u0026lt;ll, ll\u0026gt;\u0026gt; points; // Fractional-Cascading like map of unique x indices of order_x to non-unique coordinates\u0026#39; indices in points ll starts[SZX]; Overview of Functions,\n// Query the (vx)th segment tree ll queryy(ll vx, ll vy, ll ly, ll ry, ll Lyc, ll Ryc); // Build (vx)th segment tree on the basis of y-coords (USES queryy for 2*vx, 2*vx+1 segment tree values) void buildy(ll vx, ll lx, ll rx, ll vy, ll ly, ll ry); // Construct the base array for the (vx)th segment tree (Called within buildx) size_t construct_order_y(ll vx, ll lx, ll rx); // Builds the segment tree and proceeds to call construct_order_y and buildy void buildx(ll vx, ll lx, ll rx); // Query the x-coordinate and proceed to call queryy ll queryx(ll vx, ll lx, ll rx, ll Lxc, ll Rxc, ll Lyc, ll Ryc); The start array is constructed in preprocessing stage before buildx. construct_order_y uses start array for copying y-coords of original array (so no logN factor from lower_bound).\nBuilding: buildx -\u0026gt; construct_order_y -\u0026gt; buildy -\u0026gt; (either fill value 1 or queryy)\nQuery: Format input to lower/upper endpoints -\u0026gt; queryx -\u0026gt; queryy At both queryx and queryy(similar but with lxy rxy), ll lxc = order_x[lx], rxc = order_x[rx]; line is used. The lxc rxc (coordinates of query points) are used for all comparisons except for calculation of midpoint where lx rx (positions) are used.\n3. Closest Pair of Points\nK-D Tree Implementation. See Rosetta Code or Stanford ACM\u0026rsquo;s Notebook. For intuition on K-D Trees see Josh Hug\u0026rsquo;s lectures General Parameters that can be tuned,\nDistance Metric Euclidean Metric Chessboard Metric (Used for this problem) Manhattan Metric Splitting Criteria (X or Y based) Parity of Depth/Height of current node Larger of Width or Height of bounding box of current node Week 6 - Point Location and Trapezoid Maps Lec 1 - \u0026ldquo;Where the hell am I?\u0026rdquo;\nPlanar Subdivision: A set of polygons that form a large polygon.(Like a map of states of a country) Partition into vertical lines or slabs at every vertex (like Shamos Hoey) Naive Implementation Query: Traverse two binary search trees - find vertical lines (bound on x), find region (bound on y); Space Complexity can be n^2 if two full BST Lec 2 - Decreasing Space Complexity\nRefinement: The Partition of Planar Subdivision S into Slabs induced by vertices. These Partitions would be trapezoids (or degenerate ones). Trapezoidal Map: Splits the trapezoids of a refinement. Very useful technique for space partitioning or mapping regions in general. Unlike the previous partition by vertical lines, this partition only has lines that end at another edge or outer rectangle. Side: Segment of max length contained in boundary of face of trapezoid Trapezoidal partition with $n$ segments have, $T(S) \\leq 2n + 2*2n + 4$(segment endpoints, vertical lines, boundary rectangle) vertices and trapezois $\\leq 3n + 1$ Constructing Trapezoid - Find each up, down left, right endpoints for each trapezoid. Time: 3N + 1 = O(N) Below is an image of a trapezoidal map of \u0026rsquo;line segments\u0026rsquo; from this GAS, the same can be done for polygons as well.\nLec 3 - Randomized-Incremental Algorithm:\nO(NlogN) expected preprocess time O(logN) query time (not worst case optimal but randomized) Expected Query Time by Backward Analysis (See Lec04 of series) Lec 4 - Data Structure Trapezoid Cartesian DAG\nTrapezoidal Map Data Structure For 2D: Cartesian D.A.G. Make sure to split Trapezoid on map (so it isn\u0026rsquo;t n^2 time) Unlike Tree, Cartesian DAG will just have pointer to that trapezoid Lec 5 - Query Time for Trapezoid Cartesian DAG\nLogN Query time (Amortized) Backward Analysis (summation 1/i) Size: O(N + 13N) = O(N) (13N comes from $\\sum(3i + 1)*(4/i)$) Construction: NlogN Week 7 - Voronoi Diagrams \u0026amp; Post Office Problem Lec 1 - Post Office Problem\nPost Office Problem: Which is the closest Post Office to place P? Answer: Voronoi Diagram with Euclidean Distance Metric. (Map of region closest to that point) Lec 2 - Definitions in Voronoi Diagrams\nVoronoi Cell: $$ V(p) = { x \\in R^2: d(x, p) \u003c d(x, q) \\forall q \\in P\\ - {p}} $$ For Voronoi Cell, Think of definition of Ball in Topology but using relative distances instead of a constant epsilon Voronoi Edge: $$ V(p) = { x \\in R^2: d(x, p) == d(x, q) \\forall q \\in P\\ - {p}} $$ Lec 3 - Overall Shape of Voronoi Diagrams\nLemma: Vor( P ) consists of atmost (2n - 5) vertices and (3n - 6) edges Proof of Lemma from Euler\u0026rsquo;s Polyhedra Formula (Dual is Delaunay Triangulation and Maximal Planar Graph =\u0026gt; 3n - 6) For infinite voronoi diagrams, set dummy vertex at infinity NOTE: Voronoi Vertices != Voronoi Cells (or Faces or Sites) Voronoi Vertex: Circle at vertex \u0026lsquo;x\u0026rsquo; has atleast 3 points on it\u0026rsquo;s largest (circumcircle which does not contain a site/face) $$|C_p(x) \\cap P| \\geq 3$$ Voronoi Edge: For edge P to P\u0026rsquo;, there is a vertex \u0026lsquo;x\u0026rsquo; which has P and P\u0026rsquo; on it\u0026rsquo;s largest (circumcircle which does not contain a site/face) $$\\exists x \\in E(P, P') st.,\\ \\ |C_p(x) \\cap P| = \\{P, P'\\}$$ Lec 4 - Computing Voronoi Diagram\nBF: Line Segment Intersection, Half Plane Intersections \u0026gt; $O(N^2)$ time Naive Line Sweep: Event Points are not known before swept Fortune\u0026rsquo;s Algorithm or Optimized Line Sweep: Parabolas at the visited vertices form the equidistant line Directrix is the Line Sweep at point P, and focus is the visited vertices Beachline($\\beta$): The lowerbound of each of the parabolas (from the visited vertices so far) merged together. The intersection points of the parabolas as the line is swept form the edges of the voronoi diagram. See this for demo. Also, this post for explaination. Beachline Event Points Site(Face) Event: New Sitepoint is found =\u0026gt; New Arc is created Circle Event: Sweep Line reaches lowest point of circle containing 3 Site Points =\u0026gt; Arc of the inner site point is deleted. Voronoi Points are the centre of the circle formed. Lec 5 - Fortune\u0026rsquo;s Line Sweep Algorithm\nSee PVigier\u0026rsquo;s Blog for implementation resources. Also see this post by Jacques Key Functions Find New Circle Event Points (Site Event Points are already known) Handle Circle Event (once processed; calls findNewCircleEvent) Handle Site Event (once processed; calls findNewCircleEvent) Week 8 - Delaunay Triangulations Lec 1 - Height Interpolation\nTriangulation: Planar subdivision with all inner faces triangles and outer face is Convex Hull Since Maximal Planar Graph =\u0026gt; (3n - 6) edges. But outer face is CH and needs triangulation (3 - h) edges =\u0026gt; 3n - 3 + h edges in total Lec 2 - Angle-Optimal Triangulation\nHeight Interpolation Optimization by choosing a better triangulation Angle-Optimal Triangulation to avoid skinny triangles (this causes disparity in length Vs width - based height interpolations) Angle vector $A(T)$ of Triangulation $T$ is the angles of all triangles in sorted order A Triangulation is more optimum if Angle vector is lexicographically better than the other. i.e., $A(T_{optimal}) \u003e A(T)$ The best triangulations are called Angle-Optimal. Lec 3 - Edge-Flips \u0026amp; Legal Triangulations\nEdge e is illegal in Triangulation T if triangulation obtained by flipping edge e, T\u0026rsquo; has $A(T') \\\u003e A(T)$ Use Extended Thales Thm (Thales++), i.e., check angles by taking circumcircle around edge e Angle-Optimal is always legal. A triangle is legal iff it has no illegal edge Lec 4 - Voronoi Diagram \u0026amp; Delaunay Triangulation\nDelaunay Triangulation: Straight Line Drawing of the Dual Graph of Voronoi Diagram Proof Take circumcircle on any point in edge between sites p-q in Vor(P) Consider another edge u-v and show crosses lead to contradiction Alt Definition: Delauanay Triangulation iff $\\forall \\Delta \\in T : int(C(\\Delta) \\cap P) = \\phi$ AKA: Empty Circumcircle property of D.T. Lec 5 - Correctness and Computation\nA triangulation is legal iff it is Delaunay Proof Back Relation: By Empty Circumcircle Property and Thales++, D.T. is legal Forward Relation: By Contradiction, Take a triangle p-q-r and circumcircle. where T is legal Take point s in circumcircle. Now, we need to maximize angle of chord at s. (p-s-q) Take neighbouring triangle p-q-t, t lies outside circumcircle. Get contradiction: angle q-s-t \u0026gt; angle p-s-q (but this is maximal) If pointset P is general position(i.e. No 4 points lie on an empty circle) then D.T. is unique and angle-optimal. If pointset P is not general position, then all D.T. have same minimum angle but may not be angle-optimal. D.T. can be constructed in $O(NlogN)$ Angle-Optimal Triangulation in non-general position P, can be constructed in $O(N^2)$ time. Holes (4+ points on empty circle) can be filled by trying out each flip. Below is an image also showing weighted voronoi diagrams and their corresponding delaunay triangulations, Week 9 - Convex Hull in 3D Lec 1 - Complexity and Visibility of CH\n(Upper Bound Theorem) General Time Complexity of Convex Hull in d dimensions: $O(N^{\\lfloor d/2 \\rfloor})$ In 3D, Surface of the Polyhedra forms a Planar Dual Graph =\u0026gt; atmost (3n-6) edges and hence linear complexity. Similar for higher dimensions. Construction by Random-Incremental Algorithm Visibility: If we project rays from point P to Convex Polytope. The project rays that are 3D Tangent to the polytope form a ring/shadow, the point that form this is called Horizon.(Last visible edges) Region facing towards P bounded by Horizon is the Visible region. Define Conflict Graph and create bipartite relation of points with facets. And mark out which facets are visible. Lec 2 - Randomized Incremental Algorithm\nPseudocode/Approach of adding vertex to CH3 TC: $O(N^2)$ (Randomized from $O(N^3)$; not worst case optimal) Lec 3- Analysis\nExpected No. of Facets Created by CH are bounded to atmost (6n - 20) Degree bounded by 6 for the vertices other than initial 4-point CH3, so 6*(n-4) + 4 See this Tutorial on 3D CH for simple implementation as well as some optimized version. Can be further optimized with Configuration Spaces Higher Degree CH are worst case optimal accordingly with Upper Bound Thm. Lec 4- Convex Hull \u0026amp; Half-Plane Intersections\nAssume a mapping/relation from spaces P1 and P2, where (\u0026lsquo;primal is the dual of the dual!\u0026rsquo;) Line in P1 -\u0026gt; point in P2 (P1 is Dual of P2) Line in P2 -\u0026gt; line in P1 (P2 is Dual of P1) Convex Hull of a point set in P1 =\u0026gt; Set of Lines in P2 Traversing the lines corresponding to Lower Hull of P1 alongside intersections, give the Upper Envelope. Similarly for Upper CH. Incidence Preserving: Every point in P1 gives Line in P2. So CH region gives area bounded by upper and lower envelope. Order Preserving: Maintains an ordering through the mapping. Scaling to 3D: CH3 of points gives 3D Wrapping/Envelope of 3D Lines Lec 5- Voronoi Diagrams Revisited\nDistance to Unit Parabola (From Projection of point q to tangent at p\u0026rsquo;) = intercepts $(pq)^2$ Take: A (set of planes/halfplanes) have an Upper Envelope (or Supremum or Least Upper Bound 3D Parabola). The planes are thus 3D Tangents to the 3D Parabola or Envelope. When this is projected to the plane, Voronoi Centres/Faces/Sites = (Intersection points of Planes and 3D Parabola) Voronoi Edges = (Line Segments that for the Intersection of Planes) Voronoi Vertices = (Intersection of 3 or more Planes) Take: 3D Convex Hull of (Intersection of Planes and 3D Parabola). The 3D Parabola is now the Lower Envelope (or Infimum or Greatest Lower Bound) of the (3D Convex Hull). When this projected to the plane, Delaunay Vertices = (Intersection of Planes and 3D Parabola) or (Points of 3D Convex Hull) Delaunay Edges = (Edges of 3D Convex Hull) See Video for Demo Below image is from DesignMentor, showing delaunay triangulation as a projection of a 3D Convex Hull\nWeek 10 - Motion Planning Lec 1 - Point Shaped Robots\nTrapezoidal Map for Path with Obstacles. Finding Path: O(NlogN) Construction and O(N) query Lec 2 - Configuration Space\nDegrees of Freedom: 2D(2 translation x, y + 1 rotation \\theta) = 3, 3D(3 translation x,y,z + 2 rotation $\\theta, \\phi$) = 5 Configuration Polygon: Polygon s.t. foreach point in ConfPol, Robot at point (x, y) (R(x, y)) intersects with obstacle polygon(Pi). (If point robot, then this is just the obstacle polygons.) $$ CP*i = \\{(x, y): R(x, y) \\cap P*{i}\\} $$Lec 3 - Characterizing Configuration Spaces\nMinkowski\u0026rsquo;s Sum (For Polygon!): $S_1+S_2=\\{p + q : \\forall p \\in P, q \\in Q\\}$ where p, q are point vectors Geometric Representation: Replace Copy of S1 in every point of S2 to form the new shape. (or Vice versa; commutative) Inversion in Polygon Algebra: Rotate polygon by 180 around origin. $S2 =-S1=\\{-p : \\forall p \\in P\\}$ Configuration Polygon: $CP = P + (- R(0, 0))$ (where \u0026lsquo;+\u0026rsquo; is minkowski sum) Lec 4 - Complexity and Computation\nAtmost n+m edges in minkowski sum(S) of P (n edges) and Q (m edges) We can define a map of each edge of S to a pair (i, j) of the edges in P, Q. Quadratic Algorithm: Convex Hull of points where at each corner of P, Try every rotation of Q Linear Algorithm: (Two-Pointers-like) Choose Bottom-Right most point for both. And move p_ptr or q_ptr based on which has a smaller angle. Lec 5 - Pseudodisks\nDef: Pair of Planar Objects (P1, P2) form a pseudodisk if (bound-\u0026gt; boundary, int-\u0026gt;interior), $bound(O1) \\cap int(O2)$ is connected $bound(O2) \\cap int(O1)$ is connected Consider 2 convex polygons with disjoint interiors. Let d1 -\u0026gt; direcion where P1 more extreme, similarly d2. Then P1 is more extreme in [d1, d2] or [d2, d1]. Or in a circle, one boundary part has P1 more extreme and other with P2. For P1, P2, take CP1 = P1 + R, CP2 = P2 + R. Then proof by contradiction. So (CP1, CP2) have to be pseudodisks. Lec 6 - Union Complexity\nFor Convex Polygons P, Q, R,.., the total union has atmost 2*(n+m+l+..) vertices. (since every (two or less) crossings can be mapped to a vertex) For constant complexity convex robot R, translating among S disjoint objects with N edges. We can preprocess in $O(N (logN)^2)$ and compute collision-free path in O(N) Approach Triangulate Polygons if Not-Convex to make it convex (NlogN) Compute ConfPol for each Obstacle Polygon (N) Compute Union of Obstacles by sweep line (N $(logN)^2$) Mark out Trapezoidal Maps etc. Query: Find path in complement of unionConfPol with help of Trapezoidal Map ","permalink":"https://cheese-cracker.github.io/posts/compgeom/","summary":"\u003ch2 id=\"key-resources\"\u003eKey Resources\u003c/h2\u003e\n\u003col\u003e\n\u003cli\u003eTextbook: Computational Geometry - Algorithms and Applications\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.coursera.org/learn/computational-geometry\"\u003eCoursera Course\u003c/a\u003e: For the Problemset and Implementations (Till Part 5)\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.youtube.com/channel/UCuAzKw_VngkAsQh7ummYq0A/playlists?view=50\u0026amp;shelf_id=1\"\u003ePhilipp Kindermann\u003c/a\u003e\u0026rsquo;s Lectures Series (Part 6 and Onwards)\u003c/li\u003e\n\u003cli\u003eVarious Random Resources found on the internet!\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://geomalgorithms.com/\"\u003eGeom Algorithms\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://cp-algorithms.com/\"\u003eCP Algorithms\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch4 id=\"further-reading--interesting-resources\"\u003eFurther Reading / Interesting Resources\u003c/h4\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://observablehq.com/@mbostock/to-infinity-and-back-again?collection=@observablehq/algorithms\"\u003eObservableHQ - Infinity and Back Again\u003c/a\u003e: Voronoi Diagrams for Infinite Polygons\u003c/li\u003e\n\u003cli\u003eBook: Foundations of Multidimensional and Metric Data Structures - Hanen Samet (2006)\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.youtube.com/playlist?list=PL8FaHk7qbOD4F7nPFfgD0dGdLos1uhUPg\"\u003eJosh Hug\u0026rsquo;s Lectures on Multidimensional Data\u003c/a\u003e: Good intuition on k-d trees and quad trees.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.wias-berlin.de/software/tetgen/features.html\"\u003eTestGen\u003c/a\u003e: Voronoi Diagrams and Delaunay Tetrahedralizations for 3D Points. Software\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://flylib.com/books/en/2.587.1.38/1/\"\u003eGeneralization of Voronoi Diagrams\u003c/a\u003e: Originally from a book on (Geometric Data Structures for Computer Graphics, 2005)\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2 id=\"overview\"\u003eOverview\u003c/h2\u003e\n\u003cp\u003eTo learn computational geometry, these are the steps/resources I used,\u003c/p\u003e","title":"Computational Geometry"},{"content":"Resources Jacob Bishop\u0026rsquo;s Tutorials Part 5-7 covers most topics Gauss Quadrature Vs Newton Cotes\u0026rsquo; Visualization Check Calculator function input for Iterative Approximation Methods( Newton-Rhapson, Fixed Point Iteration etc.) Basic Analysis Catastrophic Cancellation Significant Digits Vs Decimal points Sum for minimal error, rounding/chopping Taylor Series\u0026rsquo; Approximation and Error Iterative Methods Bisection Regula Falsi (Method of Chords) Secant Swap to whichever is close Fixed Point Iteration Order of convergences Uniqueness Error Analysis Newton Raphson Order of convergences Matrix Techniques Pivoting (Partial Pivoting = Every Step) Scaling First before Pivoting Matrix Norms Norm_1(A) = max(col sum) Norm_inf(A) = max(row sum) Norm_2(A) = Spectral Norm = $\\sqrt \\lambda$ for eigenvalue Norm_F(A) = root of(Sum of all a_ij^2) = Frobenius Norm Conditional No. = ||A|| * ||A^-1|| Matrix Iterative Methods In order to solve, systems of equation we have Gauss-El-M, Gauss-Jacobi and Gauss-Siedel. Jacobi and Siedel is mostly used for sparse arrays where G-El-M is highly ineffecient. Newton-Raphson, Fixed Point are iterative methods also work while finding solution.\nGaussian Elimination G-Jacobi\u0026rsquo;s G-Jacobi\u0026rsquo;s Matrix Version G-Siedel G-Siedel Matrix Version Fixed Point (Matrix) Newton-Raphson (Matrix) Points to note\nMatrix must be Diagonally Dominant (see thm) for Jacobi/Gauss-Siedel Interpolation Methods Polynomial Lagrange Error Newton Divided Difference Newton Forward Difference* Newton Backward Difference* Hermite Oscullatory (generalized Hermite) NBD, NFD is only for equally spaced Table for N.D.D-like Interpolation NDD : $\\frac{f_2 - f_1}{x_2 - x_1}$ for each el NFD: $f_2 -f_1$ Only NBD: Start Reverse and Take Bottom Row; Same table as NFD $f_2 - f_1$; HERM: Repeat each entry twice; $\\frac{f_2 - f_1}{x_2 - x_1}$ if different or differentiation if same OSC: Repeat based on no. of available vals in x, y, y\u0026rsquo; ..; $f_2 - f_1$ Approximation for Integration In order of specific to generalized.\nNewton Cotes\u0026rsquo; Formula - Approximate function as polynomial and find area. Trapezoid Rule (n = 1 approx:2 data points linear Pn) Simpson\u0026rsquo;s 1/3 Rule (n = 2 approx:3 data points quadratic Pn) Simpson\u0026rsquo;s 3/8 Rule (n = 3 approx:4 data points cubic Pn) Generalized Newton Cotes' Gaussian Quadrature Method (Method of Undetermined Coeffecients) - Choose points that make the equivalent polygon (may not be contained) Gauss-Chebyshev, Gauss-Legendre, Gauss-Hermite with different weight functions Approximations for Initial Value Problems Use Taylor Series to derive the equations! Useful predictor methods also,\nEuler\u0026rsquo;s Method (RK 1st Order) Modified Euler Method (RK with 2nd Order AKA Heun\u0026rsquo;s Method) Runge Kutta(RK) Schemes: Move along the slope(which is approximated by the order) from one point to the next point Taylor Series Expansion See Use of Butcher Table also and RK in 2 variable (using 2 variable Taylor Series)!\nMulti-Step Method\nPredictor: Adams-Bashforth (Derived from previous m+1 points NBD Polynomial approx) Corrector: Adams-Moulton (Derived from previous(and including) m +2 points NBD Polynomial) Milne\u0026rsquo;s Predictor Formula (Generalized Adams-Besforth by changing limits of integration)\nApproximating System of ODEs Runge-Kutta 2 variable method Implicit Euler\u0026rsquo;s Milne\u0026rsquo;s Method Approximations for Boundary Value Problems Finite Difference Method Finite Element Methods Collocation Method Rayleigh Ritz Method Galerekin\u0026rsquo;s Weighting Function Method ","permalink":"https://cheese-cracker.github.io/posts/numan/","summary":"\u003ch3 id=\"resources\"\u003eResources\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://www.youtube.com/user/kvyi/playlists\"\u003eJacob Bishop\u0026rsquo;s Tutorials\u003c/a\u003e Part 5-7 covers most topics\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.youtube.com/watch?v=EG62xCOdLLA\"\u003eGauss Quadrature Vs Newton Cotes\u0026rsquo; Visualization\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eCheck Calculator function input for Iterative Approximation Methods( Newton-Rhapson, Fixed Point Iteration etc.)\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2 id=\"basic-analysis\"\u003eBasic Analysis\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003eCatastrophic Cancellation\u003c/li\u003e\n\u003cli\u003eSignificant Digits Vs Decimal points\u003c/li\u003e\n\u003cli\u003eSum for minimal error, rounding/chopping\u003c/li\u003e\n\u003cli\u003eTaylor Series\u0026rsquo; Approximation and Error\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch3 id=\"iterative-methods\"\u003eIterative Methods\u003c/h3\u003e\n\u003col\u003e\n\u003cli\u003eBisection\u003c/li\u003e\n\u003cli\u003eRegula Falsi (Method of Chords)\u003c/li\u003e\n\u003cli\u003eSecant\n\u003cul\u003e\n\u003cli\u003eSwap to whichever is close\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eFixed Point Iteration\n\u003cul\u003e\n\u003cli\u003eOrder of convergences\u003c/li\u003e\n\u003cli\u003eUniqueness\u003c/li\u003e\n\u003cli\u003eError Analysis\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eNewton Raphson\n\u003cul\u003e\n\u003cli\u003eOrder of convergences\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch3 id=\"matrix-techniques\"\u003eMatrix Techniques\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003ePivoting (Partial Pivoting = Every Step)\u003c/li\u003e\n\u003cli\u003eScaling\n\u003cul\u003e\n\u003cli\u003eFirst before Pivoting\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eMatrix Norms\n\u003cul\u003e\n\u003cli\u003eNorm_1(A) = max(col sum)\u003c/li\u003e\n\u003cli\u003eNorm_inf(A) = max(row sum)\u003c/li\u003e\n\u003cli\u003eNorm_2(A) = Spectral Norm = $\\sqrt \\lambda$ for eigenvalue\u003c/li\u003e\n\u003cli\u003eNorm_F(A) = root of(Sum of all a_ij^2) = Frobenius Norm\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eConditional No. = ||A|| * ||A^-1||\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch3 id=\"matrix-iterative-methods\"\u003eMatrix Iterative Methods\u003c/h3\u003e\n\u003cp\u003eIn order to solve, systems of equation we have Gauss-El-M, Gauss-Jacobi and Gauss-Siedel. Jacobi and Siedel is mostly used for sparse arrays where G-El-M is highly ineffecient.\nNewton-Raphson, Fixed Point are iterative methods also work while finding solution.\u003c/p\u003e","title":"Numerical Analysis"},{"content":"Important Topics Routh Hurwitz Test Matrix of Variation/Jacobian of dx/dt (and dy/dt) Stability of solution Local Stability (Matrix of Variation) Eigenvalues Positive Definate : Unstable Negative Definate : Local AS Imaginary Eigenvalues: Spiral Global Stability (Appropriate Lyaponov Function) Test stability by Lyapunov Funcn or any other (V) has derivative negative definate $$V(x) = x - x^* - x^* ln(\\frac{x}{x^*}) \\frac{k_1}{2}(T- T^*)^2 + \\frac{k_2}{2}(U-U^*)^2$$$$\\frac{dV}{dt} = \\frac{\\dot{x}}{x}( x - x^*) + other$$ Quick Finding of Eigenvalues (see Prerequisites) Complex Eigenvalues and Calculation of Spiral Linearization of Solution Logistic regression Model $$ \\frac{dx}{dt} = rx(1 - \\frac{x}{k})$$ Persistance / Permanance of Solution Picard-Landlof Theorem - Existence of Solution Sylvester\u0026rsquo;s Criteria - b^2 - 4ac conditions Hamiltonian $$ H(x, t, u, \\lambda) = g*{divident}(x, t, u) + \\lambda f*{capital\\ assets}(x, t, u) $$ Pontrayagin\u0026rsquo;s Maximum Principle $$ \\frac{d\\lambda}{dt} = -\\frac{dH}{dx}$$ Bang-Bang and Singular Control (Control Theory) De Carte\u0026rsquo;s Rule of Sign Dulac Bendixson Criteria for periodicity of soln Bionic Equilibrium Conditions (for Optimal Harvesting) Hopf Bifurcation: The point where behavior of system stability changes. Opposite stability before and after critical value. Lebesgue Cycle Stability Basic Reproduction No. LimSup Method for showing boundedness Standard Comparison Theorem, Amax \u0026gt; Bmin, well-posedness \u0026hellip; Models Malthusian Growth Model $$ dx/dt = rx$$ Logistic Growth Model (inter-specific interference) Resource-Consumer and similar models - Prey-Predator Model (or Resource Consumer) specialized prey-predator generalized prey-predator Competetive Model Cooperation Model 3 Species Food Chain Model (Logistic Growth with interspecie interface) Opimal Harvesting (fish) Model - Max Sustainable Yield Migration of Fishes Model Pollution Toxicant Models- 2D Model 3D Model - Uptake of Conc (POST-Midsem) Susceptible-Infected and variant models SI Model SIS Model(with immunity) SIR Model(with complete cure forever) SEIR Model(Both Exposed and Recovery types) Analysis of Solution Boundedness Positivity and Solution Space $\\Omega$ Persistance of Solution (Show Lower Bound) Periodicity or not (Dulac Bendixson Criteria) Equilibrium Points Local Stability Analysis Linearize solution and then find values OR\u0026hellip; Use generalized matrix of variation and plug in values Global Stability Analysis Choose Lyapanov Function and terms based on Logistic Growth or not Differentiate and show Negative Definate Use Sylvester\u0026rsquo;s Criteria and compare terms using Routh-Hurwitz Criteria Routh Array to show stability Other Analysis Techniques Rate $\\dot{r}$ for growth and $\\dot{\\theta}$ for clockwise/anticlockwise in spirals Lebesgue Cycle stability in spirals Critical points in Hopf Bifurcation and stability chart Basic Reproduction Number Calculation Sample Model to check equilibrium points graph TD A[Formulate the Rate Diffn Equations] --\u003e AB AB[ Find Omega. Check if bounded with limsup and show positive also. Check Persistance/Periodicity] --\u003e B B[Find equilibrium points where rate = 0] --\u003e C C[Local Stability. Get matrix of variation/Jacobian at these points] --\u003e D C --\u003e E[Get Char Eqn with Eigenvalue] E --\u003e F[Use Routh Hurwitz to get roots' sign] F --\u003e G[From sign of eigenvalues determine stability of Local Solution] D[Get Eigenvalues of the matrix of variation] --\u003e G G --\u003e H H[Global Stability. Use Lyapunov function variants Derivative] --\u003e I[Check if negative definate by adding/subtracting] Harvesting Model Sample Flow Steps for Solving\nFormulate the Rate Diffn Equations Find the equilibrium points and conditions Plug x* value in harvesting rate equation qEx Get max E by finding minima at x* and put the value into harvesting rate For optimal harvesting policy,\nFind hamiltonian with - f as net revenue in continuous time stream - g as rate of change of assets $$ H = e^{-\\delta t}(pqx-c)E + \\lambda_1 \\frac{dx}{dt} +\\lambda_2 \\frac{dy}{dt}$$ Find minima of H wrt. E .Get switching func and equate to 0 for singular control Apply Pontrayagin\u0026rsquo;s Max Principle Condition and use with step 6. Find discount value and check notes of these points Bionic Equilibrium is value of E at $$\\dot{x} = \\dot{y} = 0$$ SIR Model Steps for Solving,\nShow Bounded by taking sum of population(N) and finding LimSupN(t) will be const Take S(t) and with Comparison Theorem, show \u0026gt;=0 Use Dulac Bendixson with H = 1/SI, and show no sign change so not periodic Find Equilibrium Points (approx E*) with reproduction no. \u0026lsquo;R\u0026rsquo; Matrix of Variation with \u0026lsquo;R\u0026rsquo; cases Lyapunov Function and one term will not allow sylvester\u0026rsquo;s criteria Choose C = S* to get, $$ \\dot{V} = -\\beta I (S - S^*) -\\beta S^* (I-I^*)( S - S^* ) \u003c 0 $$ Other Useful Prerequisites Green\u0026rsquo;s Thm\nStoke\u0026rsquo;s Thm\nGauss Divergent Thm\nFinding Eigenvalues fast $$ \\lambda^2 - Tr(A)\\lambda + Det(A) $$ Trace is sum of diagonal entries\nRouth Hurwitz Criteria See Routh Hurwitz Test - Conditions - All positive coeff always - All minors must be positive - 2nd Degree: no more conditions - 3rd Degree a1*a2 - a3*a0 \u0026gt; 0 (for 3 degree see below)\n$$ Routh\\ Array = \\begin{bmatrix} a_{N} \u0026 - a_{N-2} \\\\ a_{N-1} \u0026 a_{N-3} \\\\ \\end{bmatrix} $$ Another view to understand Routh Hurwitz Graphical\nBackground If one sign different =\u0026gt; one is positive. Hence unstable. If all negative =\u0026gt; same as all positive coeff ","permalink":"https://cheese-cracker.github.io/posts/mmodelling/","summary":"\u003ch3 id=\"important-topics\"\u003eImportant Topics\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://www.math24.net/routh-hurwitz-criterion/\"\u003eRouth Hurwitz Test\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMatrix of Variation/Jacobian of dx/dt (and dy/dt)\u003c/li\u003e\n\u003cli\u003eStability of solution\n\u003cul\u003e\n\u003cli\u003eLocal Stability (Matrix of Variation) Eigenvalues\n\u003cul\u003e\n\u003cli\u003ePositive Definate : Unstable\u003c/li\u003e\n\u003cli\u003eNegative Definate : Local AS\u003c/li\u003e\n\u003cli\u003eImaginary Eigenvalues: Spiral\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eGlobal Stability (Appropriate Lyaponov Function)\n\u003cul\u003e\n\u003cli\u003eTest stability by Lyapunov Funcn or any other (V) has derivative negative definate\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n$$V(x) = x - x^* - x^* ln(\\frac{x}{x^*}) \\frac{k_1}{2}(T- T^*)^2 + \\frac{k_2}{2}(U-U^*)^2$$$$\\frac{dV}{dt} = \\frac{\\dot{x}}{x}( x - x^*) + other$$\u003cul\u003e\n\u003cli\u003eQuick Finding of Eigenvalues (see Prerequisites)\u003c/li\u003e\n\u003cli\u003eComplex Eigenvalues and Calculation of Spiral\u003c/li\u003e\n\u003cli\u003eLinearization of Solution\u003c/li\u003e\n\u003cli\u003eLogistic regression Model\n\n$$ \\frac{dx}{dt} = rx(1 - \\frac{x}{k})$$\u003c/li\u003e\n\u003cli\u003ePersistance / Permanance of Solution\u003c/li\u003e\n\u003cli\u003ePicard-Landlof Theorem - Existence of Solution\u003c/li\u003e\n\u003cli\u003eSylvester\u0026rsquo;s Criteria - b^2 - 4ac conditions\u003c/li\u003e\n\u003cli\u003eHamiltonian\n\n$$ H(x, t, u, \\lambda) = g*{divident}(x, t, u) + \\lambda f*{capital\\ assets}(x, t, u) $$\u003c/li\u003e\n\u003cli\u003ePontrayagin\u0026rsquo;s Maximum Principle\n\n$$ \\frac{d\\lambda}{dt} = -\\frac{dH}{dx}$$\u003c/li\u003e\n\u003cli\u003eBang-Bang and Singular Control (Control Theory)\u003c/li\u003e\n\u003cli\u003eDe Carte\u0026rsquo;s Rule of Sign\u003c/li\u003e\n\u003cli\u003eDulac Bendixson Criteria for periodicity of soln\u003c/li\u003e\n\u003cli\u003eBionic Equilibrium Conditions (for Optimal Harvesting)\u003c/li\u003e\n\u003cli\u003eHopf Bifurcation: The point where behavior of system stability changes. Opposite stability before and after critical value.\u003c/li\u003e\n\u003cli\u003eLebesgue Cycle Stability\u003c/li\u003e\n\u003cli\u003eBasic Reproduction No.\u003c/li\u003e\n\u003cli\u003eLimSup Method for showing boundedness\u003c/li\u003e\n\u003cli\u003eStandard Comparison Theorem, Amax \u0026gt; Bmin, well-posedness \u0026hellip;\u003c/li\u003e\n\u003c/ul\u003e\n\u003chr\u003e\n\u003ch3 id=\"models\"\u003eModels\u003c/h3\u003e\n\u003col\u003e\n\u003cli\u003eMalthusian Growth Model\n\n$$ dx/dt = rx$$\u003c/li\u003e\n\u003cli\u003eLogistic Growth Model (inter-specific interference)\u003c/li\u003e\n\u003cli\u003eResource-Consumer and similar models -\n\u003cul\u003e\n\u003cli\u003ePrey-Predator Model (or Resource Consumer)\n\u003cul\u003e\n\u003cli\u003especialized prey-predator\u003c/li\u003e\n\u003cli\u003egeneralized prey-predator\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eCompetetive Model\u003c/li\u003e\n\u003cli\u003eCooperation Model\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003e3 Species Food Chain Model\n(Logistic Growth with interspecie interface)\u003c/li\u003e\n\u003cli\u003eOpimal Harvesting (fish) Model - Max Sustainable Yield\u003c/li\u003e\n\u003cli\u003eMigration of Fishes Model\u003c/li\u003e\n\u003cli\u003ePollution Toxicant Models-\n\u003cul\u003e\n\u003cli\u003e2D Model\u003c/li\u003e\n\u003cli\u003e3D Model - Uptake of Conc (POST-Midsem)\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eSusceptible-Infected and variant models\n\u003cul\u003e\n\u003cli\u003eSI Model\u003c/li\u003e\n\u003cli\u003eSIS Model(with immunity)\u003c/li\u003e\n\u003cli\u003eSIR Model(with complete cure forever)\u003c/li\u003e\n\u003cli\u003eSEIR Model(Both Exposed and Recovery types)\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch4 id=\"analysis-of-solution\"\u003eAnalysis of Solution\u003c/h4\u003e\n\u003cul\u003e\n\u003cli\u003eBoundedness\u003c/li\u003e\n\u003cli\u003ePositivity and Solution Space $\\Omega$\u003c/li\u003e\n\u003cli\u003ePersistance of Solution (Show Lower Bound)\u003c/li\u003e\n\u003cli\u003ePeriodicity or not (Dulac Bendixson Criteria)\u003c/li\u003e\n\u003cli\u003eEquilibrium Points\u003c/li\u003e\n\u003cli\u003eLocal Stability Analysis\n\u003cul\u003e\n\u003cli\u003eLinearize solution and then find values OR\u0026hellip;\u003c/li\u003e\n\u003cli\u003eUse generalized matrix of variation and plug in values\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eGlobal Stability Analysis\n\u003cul\u003e\n\u003cli\u003eChoose Lyapanov Function and terms based on Logistic Growth or not\u003c/li\u003e\n\u003cli\u003eDifferentiate and show Negative Definate\u003c/li\u003e\n\u003cli\u003eUse Sylvester\u0026rsquo;s Criteria and compare terms using Routh-Hurwitz Criteria\u003c/li\u003e\n\u003cli\u003eRouth Array to show stability\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch4 id=\"other-analysis-techniques\"\u003eOther Analysis Techniques\u003c/h4\u003e\n\u003cul\u003e\n\u003cli\u003eRate $\\dot{r}$ for growth and $\\dot{\\theta}$ for clockwise/anticlockwise in spirals\u003c/li\u003e\n\u003cli\u003eLebesgue Cycle stability in spirals\u003c/li\u003e\n\u003cli\u003eCritical points in Hopf Bifurcation and stability chart\u003c/li\u003e\n\u003cli\u003eBasic Reproduction Number Calculation\u003c/li\u003e\n\u003c/ul\u003e\n\u003chr\u003e\n\u003ch4 id=\"sample-model-to-check-equilibrium-points\"\u003eSample Model to check equilibrium points\u003c/h4\u003e\n\u003cdiv class=\"mermaid\"\u003e\ngraph TD\nA[Formulate the Rate Diffn Equations] --\u003e AB\nAB[ Find Omega. Check if bounded with limsup and show positive also. Check Persistance/Periodicity] --\u003e B\nB[Find equilibrium points where rate = 0] --\u003e C\nC[Local Stability. Get matrix of variation/Jacobian at these points] --\u003e D\nC --\u003e E[Get Char Eqn with Eigenvalue]\nE --\u003e F[Use Routh Hurwitz to get roots' sign]\nF --\u003e G[From sign of eigenvalues determine stability of Local Solution]\nD[Get Eigenvalues of the matrix of variation] --\u003e G\nG --\u003e H\nH[Global Stability. Use Lyapunov function variants Derivative] --\u003e I[Check if negative definate by adding/subtracting]\n\u003c/div\u003e\n\u003ch4 id=\"harvesting-model-sample-flow\"\u003eHarvesting Model Sample Flow\u003c/h4\u003e\n\u003cp\u003eSteps for Solving\u003c/p\u003e","title":"Math Modelling"},{"content":"Introduction These are my notes for POE. The notes were written using markdown and vim (see iamcco/markdown.nvim plugin) and Pandoc (with eisvogel template). Feel free to collaborate to the Online Version of POE Notes. These are only supplementary notes and NOT Lecture Notes. Some useful resources.\nACDC ECON Tutorials by Jacob Cliffords for both Micro and Macro Khan Academy - Microeconomics Elasticity Curves Part Elasticity : % change quantity / % change price $$\\epsilon = \\frac{ \\% \\Delta Q}{\\% \\Delta P}$$(Similar to sensitivity)\nInelastic\nmonopoly necessity small E = Not much choice E \u0026lt; 1 ( or slope \u0026gt; 45) TR decreases for increase in quantity Elastic\nperfectly competetive large E = plenty choice E \u0026gt; 1 ( or slope \u0026lt; 45) TR increases for increase in quantity Types of Elasticity Cross Price Elasticity sensitivity of A has, $\\epsilon_{cross\\ price} = \\frac{ \\% \\Delta Q\\ of\\ B}{ \\% \\Delta P\\ of\\ A}$ Income Elasticity $\\epsilon_{income} = \\frac{ \\% \\Delta Q}{ \\% \\Delta Income}$ Other Terms Consumer Surplus = Buyer\u0026rsquo;s Max - Price (Upper Triangle) Producer Surplus = Price - Seller\u0026rsquo;s Min (Lower Triangle/Part) See CH-13 Monopoly and Antitrust for Graph and Explaination\n6 - Household behavior and Customer Choice Household Demand Factors- Price, Income, relative prices preferences Budget Constraint (Eqn) Utility\nRule of Diminishing Marginal Utility, Saturating curve of TU Utility Maximizing Rule $\\frac{MU}{Price}$ Diamond-Water Paradox Water becomes granted so diminishing MU and downward-sloping (double derivative +ve) Income and Substitution Effect\nIncome effect is the change in consumption of a product due to the relative change in price of product (well-being) Parallel Shift of Budget Constraint Substitution effect is the relatively cheap as compared to competitors hence shift in purchasing towards that product (not substitutes) Angle turn along the Indifference Curve Income Effect on Labour Supply Curve Labour Supply Curve is Backward Sloping Curve\nSubstitution is upward slope part you have to work hard coz you earn more now\nIncome Effect is reverse slope part\nif you become rich, then you wanna party and do play!\nIndifference Curves\nCurve that yields same total utility consumer is indifferent between any points on curve\nDiminishing MRS (law of diminishing utility) that\u0026rsquo;s why it slopes asymptoetically\nChooses highest curve touching budget constraint slope of indifference curve = slope of budget line\n7 - Production Process: behavior of Profit-Maximizing Firms Analagous to Chapter 6 but slightly different. Production process is in terms of inputs and outputs. K(capital)-L(labour) is the new Price-Quantity with MRTS slope\nBehavior of Profit Maximizing Firms\nhow much output to supply how to produce that output how much of each input demand Profit and Economic Costs\nTotal Revenue, Total Cost, Economic Profit Most Important factor of production for opportunity cost = capital Rate of return : annual net income % of total income (breaks into shares?) so it\u0026rsquo;s just enough to keep owners happy (like risk-free bonds) Normal Rate of Return = zero profit equilibrium point Input Type Fixed Variable Short Run and Long Run\nshort run : fixed rate of production (no scaling up/down or no exiting/entering) long run : firms can choose to expand or contract Others-\nSee Optimal method of production chart in CH-8 below\nProduction Process\nTotal, Average and Normal Product of Labour. See Curves in CH-8\nEquivalent-Law of diminishing returns (MP of Labour)\n3 Stages of TP, AP, MP Curve-\nMP reaches maximum (double derivative 0) AP = MP MP = 0 and thus TP is maximum Equivalent behavior (Others)\nProducer Market Consumer Market Isoquant Indifference Curve Isocost Budget Constraint X Labour(L) Y Capital MRTS MRS Cost-Min Eq Utility-Max Eq 8 - Short Run Costs and Output Decisions TC (overhead), TFC, TVC, AFC, AVC, MC (=MVC), AP, MP See Curves.\nTypes of Costs\nMain Types Costs\nFixed Cost Variable Cost Analyze costs as\nTotal Cost Average Cost = $\\frac{TC}{Q}$ where Q is quantity at that time Marginal Cost = increase in TC for production of 1 more unit output Cost Curves\nVariable costs depends on - techniques of production prices of inputs required Plot has x-axis = Output and y-axis = type of cost Fixed Cost Curves\nSpreading Overhead\nFall of total fixed cost by increasing quantity (small cost per quantity; down asymptoete) TFC still remains line parallel x-axis(Output) Variable Cost Curve\nIncreases with quantity\nMarginal Cost Curve\nslight decrease till max then increase all the way\nMarginal Cost increases with output (since no change in scale of production diminshing returns = increasing marginal cost Notes on Curves\nMarginal Costs is slope of TVC The dip point (minima) of MC is the inflection point of TVC MC cuts AVC at min of AVC and ATC at min of ATC Short Run Curves Where MC crosses is where others stop falling\nOutput Decisions and Summary\nMarginal Revenue Curve and Demand Curve identical in a perfectly competetive market Profit Maximizing- Take $MR = MC$ (where Price from Demand Curve cuts MC for competetive) Firms will produce only as long as MR \u0026gt; MC Profit Maximizing Rule is the Loss Minimizing Rule Types of Questions-\nTable-based question (fill the table of TFC, TVC, AVC, MC\u0026hellip;.) Equation of TC in Q given Sketch graphs for different situations 9 - Long Run Costs and Output Decisions Terms Shutdown Point TR \u0026lt; TFC (or P \u0026lt; AVC) Long term contraction if TR \u0026lt; TC (Contracts and then exits) Operating Profit: TR - TVC (may be losses!) Economic Profit Vs Accounting Profit at 0-profit point Long Run Average Cost Curve The graph is split into 3 parts-\nEconomies of Scale (Beginning Drop) : More Cost but More Quantity = Less ATC Constant Returns (Constant Line at Min) : Same as short run Diseconomies of Scale (Upward after Dip) : More Cost but not much more Quantity = More ATC Long Run Industry supply Curve Decreasing Cost Industry Above\nLRIS Calculation\nDemands expands to D2 Prices Rise to P1' New Firms enter and supply shifts to SRS3 Price goes down to P3 Based on decrease in price (Decreasing cost) or increase (Increasing Cost) Since P3 \u0026lt; P0 so LRAC decreases and Decreasing Cost-Ind 10 - Labour and Land Markets Shifts in Input Demand Curves Demand for Outputs Quanitity of Complementary and Substitute Price of other inputs Technology Change Profit Maximizing Labour Market Derived Demand: Indirect demand like Labour not Goods and Services Marginal Product of Labour: Additional Output produced by adding another unit of labour Marginal Product of Labour Increases then decreases. e.g- Too many cooks, spoil the broth\u0026hellip;.. too few cooks, can\u0026rsquo;t make the broth?\nMarginal Revenue Product MRP(L): Price of output X MR(L) Market Labour Supply Curve Profit-Maximizing (from MR = MC): MRP(L) = Wage(W) In perfectly competetive firms, combine all MRP(L) have common price of output (see questions) Land Market Demand Determinant: Price determined exclusively by its demand. Supply is Fixed (perfectly inelastic). e.g - Land Pure Rent: Return to factor of production with fixed supply 11 - Capital Market and Investment Decisions Market Structures (and 15.1) Perfect Competition (E = $\\infty$) Monopolistic Competition (Not Monopoly-Like!) Oligopoly Monopoly (E = 0) 15.1 Monopolistic Competition - Industry Characterstics Large no. of firm No barriers to entry Product Differentiation 13 - Monopoly and Antitrust Marginal Revenue -\nFor Monopoly, TR is max when MR = 0 For Competetive Firm, MR = price (varied by market) MR has slope less (more -ve) coz Additional Output =\u0026gt; Lower Price for more demand. Pricing and Ineffeciencies-\nFirm produces Q at $MR = MC$ (at Q1) but prices Demand Curve (P1) Leads to Dead Weight Loss (Allocated Ineffeciency) - unecessarily less customers = A-B-C Triangle Consumer Surplus - Lost high pricing for rich customers = Triangle P1-A-F Producer Surplus - Price of good higher than cost-to-manufacture = Area of E-C-P1-A Barriers to Entry -\nEconomies of Scale - Very Large (or high advertisement costs) (Predatory Pricing \u0026hellip;See Oligopoly) Patents - (Mostly Medicine Companies) Government Rules - Laws favouring Gov Monopolies or through Lobbying Ownership of Exclusive Capital - Own Diamond Mines etc. Network Externalities - Dependant on the popularity of the product Social Costs of Monopoly -\nDeadweight Loss (Depriving Customers of the product) Rent-Seeking behavior (through lobbying and building Barriers) 14 - Oligopoly Measures for Oligopoly\nHHI = Sum of Squared-Market-Shares (\u0026gt;1,800 for High) CR (Conc. Ratio) = % Share of top n companies (\u0026gt;80% for High) Types of Oligopoly\nNon-Collusive Cournot\u0026rsquo;s Duopoly Collusive (Can be Tacit or Non-Tacit) Price Leadership Cartels and Collusion Price Leadership - Dominant Firm decides market price for smaller firm.\nPredatory Pricing - Temporarily selling at artificially low price to kill competitors\nCartel Duopoly - Use like monopoly with $MR = MC_1 = MC_2$\nCournot\u0026rsquo;s Model Assumptions- Identical Firms with homogenous products Response Func = Func of output of a Firm Inverse Demand Func - price of product Same Equilibrium for both firms Steps to solve Equate $MR = MC$ for each firm Output of each firm as func of other firm (Response Func) Intersection of Responses (Can be plotted) is the Nash Eq. Game Theory Dominant Strategy - Player has a strategy which is better irrespective of the other\u0026rsquo;s solution Nash Equilibrium - All players play their best strategy (Need not be dominant-dominant!) Maximin Strategy - Low risk to maximize the min gain (opposed to minmax) Tit-for-tat Strategy - Response Based Strategy Prisoner\u0026rsquo;s Dilemma (see above) - Dominant-Dominant is not Nash Eq. (or best strategies) 20 - Intro to Macro Aggregate: To refer to sums only Recession/Slump or Expansion/Boom Depression = Long lasting depression Business Cycle: One cycle of slight recession and expansion Macroeconomic Concerns Output Growth: Aggregate Output Unemployment: unemployment rate not too low(business will not have labour) and not too high (jobless people) Inflation and Deflation: Mild Inflation rate is required - Hyperinflation: rapid and devaluation (Venzuala, Turkey..) - Deflation: Nobody buys anything = No businesses (Japan) Circular Flow Diagram between Household, Gov, Firms, World Class Notes Terms Goods and Services Market Financial Markets - Trading Securities (equities Money Markets Policies,\nFiscal Policy - Tax \u0026amp; Spending policies of Gov Monetary Policies - CRR: Cash Reserve Ratio (~4%) SLR: Statutory Liquidity Ratio (~19.4%) Repo Rate: Repurchase Agreement Reverse Repo Rate: Reverse Repurchase Agreement 21 - Measure Outputs and Income (National) Domestic Vs National : Region-based Vs Nationality(citizenship) based. See Honda Plant in Nagpur Example Gross Vs Net: Without Depreciation Vs True with Depreciation Note that depreciation is mostly considered only for net domestic-private investments and not others Exclusions to GDP Final Goods and Services only not intermediate Value added method for calculating GDP Exclude Used Goods - No new production or revenue generation (except rent) Exclude Paper Transactions (like stocks and bonds but not broker fees) - No new production and only exchanges. Only domestically owned production - Only region based and not on citizenship (see GNP). Expenditure Approach $$GDP = C + I + G +(Ex -Im)$$ Personal Consumption C: Household spending on goods and services\nDurable: Furniture, cars\u0026hellip;(longer lasting) Nondurable: Food, clothing, gasoline..(short lived) Services: Doctors, Educations\u0026hellip; Gross Private Domestic Investment I: Purchase of new capital like\nResidential: Houses etc. Non-Residential: Machines, Tools, Plants Change in Business Inventory: Goods produced for later sale in inventories Government Consumption and Gross Investment G: Goods (schools, government programmes, institutions\u0026hellip;) and services (military salaries\u0026hellip;)\nCentral (or Federal) State Net Exports (Ex - Im):\nExports by the country shows production Imports is production from other countries Income Approach This approach to GDP is from National income which is in decreasing order of magnitude from,\nCompensation of Employees Proprietors\u0026rsquo; Income (Uncorporated businesses\u0026rsquo; income) Rental Income Corporate Profits Net Interest (!only interest from businesses) Indirect Taxes minus subsidies Net Business Transfers Payments by Businesses Surplus from Government Institutions (often -ve unlike others) National Income to Personal Saving Nominal Vs Real GDP Real GDP = Nominal GDP adjusted for price change Real Vs Nominal Output Fixed-Weight Procedure: Prices in base year as weights for reference GDP Deflator Method - Using series of % changes to measure overall price Problems of fixed-weight procedure Limitations GDP does not reflect crime rate, increase in leisure time, pollution, domestic work and social ill. Informal Economy - illegal transactions and tax evasion Gross National Income per Capita as measure 25(.1, .2) - Money and Banks Khan Academy - Money and Banking\nMoney as,\nMedium of Exchanges (Not like barter, where we trade goods like cocoa) Store of value - Asset that can be used to transport purchasing power (you can save for now and still spend later) Unit of account (compare price of pizza and banana) Commodity Monies - Using cigerretes / Ramen as money in Jails.\nFiat Money / Token Money - Money that is intrinsically useless (paper of rupee notes aren\u0026rsquo;t useful)\nLegal tender - What RBI says can be accepted as \u0026lsquo;money\u0026rsquo; (ONLY currency!) see 51% torn part of dollar bill is legal tender in US\nCurrency Debasement - Hyperinflation of currency value due to too much supply of currency (zimbabwe, post-war Germany, Venzuala\u0026hellip;)\nMeasuring Money Supply? Money Supply = Currency + Deposits\nTypes of Money\nM1 = Currency + Demand Deposits + Other Deposits M2 = M1 + Saving Deposits with Post Office M3 = M1 + Time Deposits with Bank ( Most Useful ) M4 = M3 + Total Deposits with Post Office Saving Organization (excluding NSC) Creation of Money by Banks (See Table 25.3 of Textbook for better understanding)\n","permalink":"https://cheese-cracker.github.io/posts/poe/","summary":"\u003ch3 id=\"introduction\"\u003eIntroduction\u003c/h3\u003e\n\u003cp\u003eThese are my notes for POE. The notes were written using markdown and vim (see iamcco/markdown.nvim plugin) and Pandoc (with eisvogel template).\nFeel free to collaborate to the \u003cstrong\u003e\u003ca href=\"https://hackmd.io/PtXbIdS-R52MuXXW6gc9uA?both\"\u003eOnline Version of POE Notes\u003c/a\u003e\u003c/strong\u003e.\nThese are only supplementary notes and NOT Lecture Notes.\nSome useful resources.\u003c/p\u003e","title":"Principles of Economics"},{"content":"List of Algorithms Minimum Spanning Trees\nKrusikal\u0026rsquo;s (Any point but min with no cycle) Prim\u0026rsquo;s (From starting point) Graph Traversal Techniques\nBFS DFS Djkstra\u0026rsquo;s Shortest Path Apply DFS for checking cut vertex Eulerian/Hamiltonian Graphs\nEulerian Graph even degree Fleury\u0026rsquo;s Algorithm Closure of Graph Sufficient conditions of Hamiltonian Graph (and Restricted Hamiltonian Algo) Travelling Salesman Problem\nTSP1- From weight matrix, draw tables TSP2 - Take min span, DFS from leaf node and join all endpoints Network Flow Algo - MaxFlow Mincut\nResources D3 Graph Theory Algebraic Graph Theory Courses by Dan Spielman and his Miracles video Spectral Graph Theory Course and sources from Dan\u0026rsquo;s Course Recommended Papers for Eigenvalues of Graphs with applications by Dan Proof/Question Hints graph TD A[Proof Types in Graphs and Networks] --\u003e B[Contradiction] A --\u003e C[Construction or deletion] A --\u003e D[Induction] Induction is by far the most popular. Contradiction is sometimes used with a construction\nTake Longest path in graph (delete or not) Check type of cycles in graph Adjacency Matrix, Caylay Matrix, Graph Laplacian and Incidence Matrix based approach Number of components more or less (cut-edge, hamiltonian\u0026hellip;) If cycle length 2, Bipartite Planar = draw planar drawing Non-planar Euler\u0026rsquo;s Formula or 5-degree or variants(girth-analysis) Check any Subgraph non-planar Kuratowski and/or Wagner If no triangles, then relation between q \u0026amp; r (where q unrestricted) List of Theorems Isomorphic if complement is isomorphic Every tree (with \u0026gt;= 2 vertices) has \u0026gt;=2 leaves Simple G with n vert, k components, has atleast n-k edges Characterstics of Tree If G has walk, G contains path Every closed odd walk contains odd cycle Bipartite iff no odd cycle Kirchoff\u0026rsquo;s Matrix-Tree Thm Caylay Thm Euler even degree (and disjoint cycle) thm Whitney\u0026rsquo;s Thm Euler\u0026rsquo;s Planar Graph Formula and Thm Max Planar Graph thms using Girth Formula Planarity of Graphs - Kuratowski and Wagner Thms Graph Coloring Simple graph with K-blocks has max chromatic no. of blocks For any simple graph, max chromatic no. \u0026lt; max degree + 1 Five Color Theorem (Step towards of 4 Color Thm) Week Wise Review Week 1 Types of Graphs Graphical Sequence Algorithm Degree Sum and Edges relation Neighbourhood (open/close) k-regular graphs Isomorphic or not Subgraphs and Induced Subgraphs Types of Graphs Null Complete Bipartite Complete Bipartite Cycle Path (Graphs n = 1, 2 vertices) (self-compliment Graphs) (planar graphs) Week 2 graph TD A[Walk] --\u003e B[Trails] A --\u003e C[Closed Walk] B --\u003e D[Paths] B --\u003e E[Circuits] C --\u003e E E --\u003e F[Cycle] See Examples for each Case!\nwalk :: anything from start_vertex to end_vertex\ntrail :: edges distinct\npath :: vertices distinct\nclosed walk :: start_vertex = end_vertex\nConnectivity, Components\nCut-Edge, Cut-Vertex\nContraction of graph, minor of a graph (Contraction)\nWeakly/Strongly Connected\nIsomorphic Graphs graph LR A[Degree Sequence] --\u003e B[Degrees of connection of those vertices] B --\u003e C[Find Points Mapping] Odd/Even Cycles and/or biparitite Compliment Isomorphism Week 3 Trees, Forests (star, path) Represent arithematical equations graphically Every tree has k leaves G contains atleast $E - V + 1$ cycles Characterstics of Tree (see proof) distance: shortest u,v path in tree (don\u0026rsquo;t count start!) eccentricity: max of distance between all u-v path for u diameter: max of eccentricites of all vertices (farthest two points) center: point with min eccentricity radius: min of eccentricities (or eccentricity of center) rooted trees, ordered rooted trees, parent, child, ancestor, descendants, siblings Binary trees, Regular binary trees (deg 3 or less) Week 4 wiring, spanning trees, spanning forests Three main types of Matrices Adjacency Matrix: (V, V) based and shows no. of edges between each pair of vertices (1 or 0 only for simple graphs) Incidence Matrix: which edges are incident for each vertex (V, E) Graph Laplacian: Degree of vertices along diagonal. -1 wherever edge. 0 wherever no edges. See graph laplacian video Kirchoff\u0026rsquo;s Matrix-Tree Thm Minimum Cost Spanning Trees, Weight Func Krusikal and Prim\u0026rsquo;s Min Spanning Tree finding algo Week 5 Edge Based eulerian trail( n-2 even 2 odd ) eulerian circuit (all even) eulerian graph (contains eulerian circuit) Euler-Path finding algorithm (and proof of even degree) Fleury\u0026rsquo;s Algo Hamiltonian path, hamiltonian graph, sufficient conditions for hamiltonian graph Hamiltonian Cycle is just another way of saying subgraph Cn!\nHamiltonian closure and finding hamiltonian graphs TSP1 and TSP2 graph algos Week 6 Connectivity, edge cuts, k-edge-connected(returns bool), edge-connectivity (returns int connectivity) Vertex Connectivity, Vertex-Cut Set, min degree, max degree Whitney\u0026rsquo;s Thm Network Flows and Related Topics (Week before Midsem) Flow - flow, capacity, source, sink Maximum Flow Problem :: Ford-Fulkerson Algo, Residual Graph, Augmented Paths Min Cut Problem :: S-T cut, Cap(A, B), Cut where Residual Graph paths end Flow value Lemma (same as out of source) Max-Flow Min-Cut Thm $$ val(f) = \\sum*{out\\ of\\ a} f(e) - \\sum*{in\\ to\\ a} f(e) = \\sum\\_{out\\ of\\ a} f(e) = cap(A, B)$$ Disjoint Paths - Ford-Fulkerson with capacities all 1 Menger\u0026rsquo;s Thm - Min no. of vertices required to be removed to disconnect u-v path k-connected k-vertex disjoint paths Blocks and Block Diagrams graph TD A[Find all cut vertices] --\u003e B[Mark out Blocks such that one not contained in other] B --\u003e C[Draw Graph with block dots and cut vertex dots] Week 7 Planar Graphs, Planar Embeddings Planar Drawing Face, Boundary Euler\u0026rsquo;s Graph Formula p - q + r = 2 Maximal Planar Graphs and Girth Formula $$ \\frac{g(n-2)}{g-2}$$ Homeomorphic and Subdivisions Kuratowski and Wagner Thms Duality / Dual Plane Crossing Number Kuratowski/Wagner Thm graph LR; A[Indentify partition of vertices] --\u003e B[Delete Edges to trim down to Bipartite]; Week 8 Chromatic Number of Graph, k-colorable Chromatic No. of Blocks thm and max degree + 1 thms Booke\u0026rsquo;s Thm Neither Complete nor odd cycle \u0026lt; max degree 5 Color Thm (Towards 4-color) Edge Chromatic No. and Thm for Bipartite graphs and simple graph Graph Numbers and their relations ","permalink":"https://cheese-cracker.github.io/posts/graphsnetworks/","summary":"\u003ch3 id=\"list-of-algorithms\"\u003eList of Algorithms\u003c/h3\u003e\n\u003col\u003e\n\u003cli\u003e\n\u003cp\u003eMinimum Spanning Trees\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eKrusikal\u0026rsquo;s (Any point but min with no cycle)\u003c/li\u003e\n\u003cli\u003ePrim\u0026rsquo;s (From starting point)\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eGraph Traversal Techniques\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eBFS\u003c/li\u003e\n\u003cli\u003eDFS\u003c/li\u003e\n\u003cli\u003eDjkstra\u0026rsquo;s Shortest Path\u003c/li\u003e\n\u003cli\u003eApply DFS for checking cut vertex\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eEulerian/Hamiltonian Graphs\u003c/p\u003e","title":"Graphs and Networks"},{"content":" \u0026#x1f44b; Hi, I am Chinmay Hebbar!\n| LinkedIn | GitHub | Instagram | CodeForces | LiChess | Telegram | X |\nAbout Me Hi, I\u0026rsquo;m a Maths and Electonics \u0026amp; Instrumentation student at BITS Pilani Founding Engineer at an AI-enabled B2B Marketing Platform.\nIn the past, I have worked on interesting personal and professional projects.\nExperimenting with new software and learning new things like polyphasic sleeping, computational geometry and accounting 101 interest me!\nHopefully, this site will prove useful in sharing ideas and notes.\nFeel free contact me via email account. Or better yet, hit me up on Telegram!\n\u0026#x1f4bb; = ArchLinux + XFCE + awesome + awesome-copycats + KDE + nvim\nProjects WebGPLAN: A web based Graph to Rectangular Floor Plan research tool built on GPLAN. Logistic Growth based Game of Life: Simulates the logistic growth of cells (according to eqn) by a modified set of instructions on Conway\u0026rsquo;s Game of Life. (Check out the demo here!) EMRLite: A complete Hospital Billing and Management Web Portal currently in use at the Le\u0026rsquo; Nest Hospital tray: A task tracker in two layers — a garage for one-line thoughts, and a tray for the few tasks you actually pick up. Terminal-first, plain files on disk. Posts Discrete Vs Continuous Blogpost: Exploring the concept of discrete and continuous as a mental model. Computational Geometry Notes: Complete week-wise notes and resources for Computational Geometry! Unix SIG Slides: Presentation on the unix command line. BITS-ACM Blog - Command Line Apps: Post highlighting useful command line programs, for better productivity on the terminal. Principles of Economics Notes: Simple notes outline the important concepts in the POE course. ","permalink":"https://cheese-cracker.github.io/about/","summary":"\u003cdiv align=\"center\"\u003e\n\u003cimg height=\"250\" src=\"/img/ChinmayPhotoNew.jpg\" alt=\"My Photo\"\u003e \u003c/img\u003e\n\u003cp\u003e\u0026#x1f44b; Hi, I am Chinmay Hebbar!\u003c/p\u003e\n\u003c!-- Social Icons --\u003e\n\u003cp\u003e| \u003ca href=\"https://www.linkedin.com/in/chinmay-hebbar/\" class=\"btn btn-sm btn-primary\"\u003e LinkedIn \u003c/a\u003e\n| \u003ca href=\"https://github.com/cheese-cracker\" class=\"btn btn-sm btn-primary\"\u003e GitHub \u003c/a\u003e\n| \u003ca href=\"https://www.instagram.com/ch.nm.y/\" class=\"btn btn-sm btn-primary\"\u003e Instagram \u003c/a\u003e\n| \u003ca href=\"https://codeforces.com/profile/cheese-cracker\" class=\"btn btn-sm btn-primary\"\u003e CodeForces \u003c/a\u003e\n| \u003ca href=\"https://lichess.org/@/cheese-cracker\" class=\"btn btn-sm btn-primary\"\u003e LiChess \u003c/a\u003e\n| \u003ca href=\"https://t.me/cheese_cracker\" class=\"btn btn-sm btn-primary\"\u003e Telegram \u003c/a\u003e\n| \u003ca href=\"https://x.com/chinmayhebbar\" class=\"btn btn-sm btn-primary\"\u003eX\u003c/a\u003e\n|\u003c/p\u003e","title":"About"}]