Is there an equation for a triangle?

Поделиться
HTML-код
  • Опубликовано: 27 дек 2024

Комментарии • 2,8 тыс.

  • @standupmaths
    @standupmaths  3 года назад +907

    I'd like to reiterate that unlike Manim and GeoGebra: Mattim is not open-source. But you can get an SUM xmas card which was made in Mattim and contains an infinite amount of detail!* Just sign up before 10 Dec: patreon.com/standupmaths
    •not all of which is printed.

    • @MathVisualProofs
      @MathVisualProofs 3 года назад +11

      I'd give "Mattim" a try if you let me :)

    • @russelleaston1832
      @russelleaston1832 3 года назад +44

      Mattim is like the Parker Square of maths code.

    • @gizatsby
      @gizatsby 3 года назад +1

      Made a relation similar to your sign function trick a while back that switches customizable grid squares on/off to effectively draw anything you want (I used it to write my friends' names in a single relation). It used floor and ceiling functions though (idk if that "counts").

    • @MathVisualProofs
      @MathVisualProofs 3 года назад +1

      @@russelleaston1832 nothing wrong with something that is close to what you want. ;)

    • @IbadassI
      @IbadassI 3 года назад

      The easiest way to get absolute values or negative or positive only values (sign) is to square and square-root the number then multiply by -1 if you want negative only. Why didn't you mention this?

  • @PrimerBlobs
    @PrimerBlobs 3 года назад +1859

    I was indeed annoyed. A pleasure as always, Matt.

    • @claymeistereu
      @claymeistereu 3 года назад +7

      Love your vids man!
      If only there were more!

    • @Lyk0ss
      @Lyk0ss 3 года назад +7

      Eyy it's primer

    • @Szibenwaro
      @Szibenwaro 3 года назад +3

      Simply cannot wait for your next video 😁

    • @chair547
      @chair547 2 года назад +2

      Love your work

    • @fatitankeris6327
      @fatitankeris6327 2 года назад +4

      Blob

  • @jkobain
    @jkobain 3 года назад +2111

    Loved the fact that Matt cares for all of his viewers to be equally annoyed.
    This alone is a universal equation already!

    • @TrimutiusToo
      @TrimutiusToo 3 года назад +11

      You are mixing up "equality" and "equation". Similar concepts, but not exactly same thing, even though both are denoted by "=" sign...

    • @jkobain
      @jkobain 3 года назад +19

      @@TrimutiusToo yes, pun intended. Thanks.

    • @singerofsongss
      @singerofsongss 3 года назад +9

      the only truly universal thing in math is that people will argue about it :)

    • @jkobain
      @jkobain 3 года назад +2

      @@singerofsongss totally agree! (%

    • @CheatahX
      @CheatahX 3 года назад +5

      But because you seem to love that fact, I feel that you are slightly less annoyed than many other viewers. Which kind of annoys me. So I doubt this is a fair equilibrium :(

  • @ericeaton2386
    @ericeaton2386 2 года назад +864

    The Sign Function is perfectly legitimate. The history of math is littered with mathematicians making up functions as needed to complete a task. I was in the "obviously not" camp, but it turns out a triangle does have an equation!

    • @damnnits
      @damnnits 2 года назад +14

      is "if" a part of math?

    • @vumixe
      @vumixe 2 года назад +40

      yeah isnt the sign function the derivitive of |x|?

    • @WaluigiisthekingASmith
      @WaluigiisthekingASmith 2 года назад +54

      @@vumixe well technically no. Technically its the |x|/x thing he was talking about because it has a discontinuity at 0

    • @berylliosis5250
      @berylliosis5250 2 года назад +19

      You can easily argue that the sign function is a "more fundamental" source of discontinuity than absolute value, cause absolute value (and many other discontinuous functions) can easily be defined in terms of sign.
      Abs already has very inconvenient properties (rip possibly-decidable integration), sign doesn't make it worse

    • @BambinaSaldana
      @BambinaSaldana 2 года назад +5

      @@damnnits Yes

  • @sander_bouwhuis
    @sander_bouwhuis 3 года назад +419

    The sign() function seems perfectly legitimate to me. I absolutely love that you found a solution. Of course, this 'create a formula from pieces where everything else zeroes out' is also how the full formula of the standard model in physics works. They simply shoved everything together, and what doesn't apply 'simply' becomes zero.

    • @cimos5133
      @cimos5133 3 года назад +7

      now I may be thinking wrong here, but would x/|x| work the same way as the ‘sign(x)’ function? And as the absolute function is more widely accepted and used, this becomes a more viable equation?

    • @sander_bouwhuis
      @sander_bouwhuis 3 года назад +34

      @@cimos5133 It doesn't work for the reason also mentioned by Matt... you don't have a continuous function. When x=0 you get no solution. This would leave you with potential holes in your triangle. The sign() function would leave no holes.

    • @adarshmohapatra5058
      @adarshmohapatra5058 3 года назад +9

      Yes I also love that he found a legitimate solution that works for any type of triangle anywhere in the plane. No matter what are the 3 corners of the triangle in the coordinate plane, you can always make 3 lines through them and this method guarantees that you can make an equation that represents these 3 line segments.
      And sign function should totally be accepted. I don't see why we can't create our functions, if we're following the rules of maths. To describe the orbitals of an electron in quantum mechanivs Schrodinger used an entirely new type of operator called Hamiltonian operators.
      So why not here. As far as I see, Matt is creating new types of Math.

    • @EAdano77
      @EAdano77 3 года назад +8

      The only issue I see with sgn(x) is that it isn't an algebraic function like |x| is. That's certainly not a big deal, but asking is there a purely algebraic equation for any given triangle is an interesting question that can't be solved with sgn(x).

    • @EAdano77
      @EAdano77 2 года назад +5

      @Мамонт Yes but it isn't defined at zero, whereas typically one takes by convention sgn(0) = 0. It's been a couple of months since I watched the video, but I believe it was preferable to avoid piecewise-defined functions.

  • @ibrahimmusaddequrrahman3488
    @ibrahimmusaddequrrahman3488 2 года назад +211

    I think this method with sign functions now holds for plotting any arbitrary polygon, since you can just use more rays for each vertex. And probably any enclosed curve as we go towards infinity

    • @klingping9067
      @klingping9067 2 года назад +1

      How would you use it with a shape in which the origin angle is blocked by another side like it was around a corner

    • @sorcdk2880
      @sorcdk2880 2 года назад +5

      You just need a more complicated way to do it. Basically you just need to be able to describe a region where something applies to, and then be able to describe regions for all the pieces.

    • @RolandTitan
      @RolandTitan 2 года назад +2

      As i stated earlier. The rays are unnecessary. You can use the other lines for your bounds instead.

    • @Stratelier
      @Stratelier Год назад

      In low-level 3D rendering, there is a shape called a "triangle fan" which is any polygon you can divide into triangles that all share a single common vertex (and, typically but not strictly, all triangles exist within the polygon's interior area). The idea behind Matt's equation can be used for any such trianglefan.

  • @nightish_one6007
    @nightish_one6007 3 года назад +542

    "... I think I've got an equation for a triangle, *sort* *of* "
    The Parker Triangle jokes really write themselves huh

    • @TextiX887
      @TextiX887 3 года назад +8

      I thought the same thing xD

    • @Pascal-eu2oe
      @Pascal-eu2oe 3 года назад +28

      Yeah, he said "sort of", and I was like "yeah, we all know where this is going..."

    • @ChrisLindsley
      @ChrisLindsley 3 года назад +7

      Is ruclips.net/video/4K-Jx914NcQ/видео.html the Parker Triangle? A Triangle with rays so it isn't a triangle anymore?

    • @CraigChrist8239
      @CraigChrist8239 3 года назад +2

      I was thinking the Parker Equation :P

    • @vigilantcosmicpenguin8721
      @vigilantcosmicpenguin8721 3 года назад +13

      Parker's law: Anything can become a Parker something.

  • @spegee5332
    @spegee5332 3 года назад +259

    love to see matt expanding his own category of shapes: first the parker square and now he reveals the parker triangle

    • @Gin-toki
      @Gin-toki 2 года назад +2

      Have he not already made a parker circle? Or perhaps it was only by hand drawing and not with any definitions applied to it.

    • @CraftQueenJr
      @CraftQueenJr 2 года назад +3

      Pelle Reinke Parker circles are the circles with circumferences of the radius times any of his slightly off πs.

    • @Gin-toki
      @Gin-toki 2 года назад +1

      @@CraftQueenJr Ah yes, so we indeed already have a parker circle.and now a parker triangle and square too :D

    • @backwashjoe7864
      @backwashjoe7864 2 года назад

      @15:45 we have the debut of Parker Fractals.

    • @carlosvasquezjr92
      @carlosvasquezjr92 5 месяцев назад

      It's part of the Parker multiverse. The Parkerverse, if you will.

  • @Tigrou7777
    @Tigrou7777 3 года назад +358

    The way modern GPUs rasterize triangles is similar, using what is edge equations (the evaluation of that equations tell you which side you are and it can be done in parallel).

    • @pleasedontwatchthese9593
      @pleasedontwatchthese9593 3 года назад +21

      I want to add on to what you said. If you look up how to draw a triangle in software there are like a few depending on the property of the triangle.

    • @unvergebeneid
      @unvergebeneid 3 года назад +22

      Of course computers don't care if you define something piecewise or have conditionals, so you can do whatever.

    • @matts2956
      @matts2956 3 года назад +26

      @@unvergebeneid In addition to that, modern GPU's have the sign instruction implemented in the silicon/hardware and shader languages (shaders = programs that run on a GPU) let you access that hardware implementation directly.
      Also Matt has basically described some of the simpler techniques of "conditionless" programming which are somewhat commonly used in writing shaders since older and mobile GPUs dislike branching.

    • @Kaiasky
      @Kaiasky 3 года назад +10

      @@unvergebeneid you try and avoid conditionals whenever possible though, so a trick like this video is very common to avoid using branching

    • @ShinyQuagsire
      @ShinyQuagsire 3 года назад +9

      @@matts2956 not 100% on modern GPU rasterization, but to clarify, sign(x) is just a wire in HDL because of how floats/2s-compliment organize bits. CPUs only struggle with comparisons due to pipelining hazards (which, GPU shaders also struggle even worse with comparisons due to more pipeline stages, but the 3+ comparisons for a triangle can be done in silicon instead of microcode)

  • @Captain__Obvious
    @Captain__Obvious 3 года назад +138

    3:35 The phantom lines in the gradient appear to be a side effect of directly linearly interpolating sRGB (or HSL) color values. But sRGB values on a computer screen are logarithmic - for a correct linear gradient you need to do gamma correction. Finally to get perceptually smooth gradients you also need to take into account the fact green is brighter to the human eye (Y = 0.2126R + 0.7152G + 0.0722B).

    • @alexray4969
      @alexray4969 3 года назад +2

      @Convert No. He's just using a RGB value on a scale from 0 to 1 instead of from 0 to 255 (FF).

    • @Captain__Obvious
      @Captain__Obvious 3 года назад +8

      @Convert It's the standard CIE-XYZ luminous efficiency function in linear RGB space and if you don't recognise it that's a sign you'd also benefit from a bit of reading up on color theory 😜

    • @alexray4969
      @alexray4969 3 года назад +1

      @@Captain__Obvious I would marry CIE-LCh if I could.

    • @zhubwat
      @zhubwat 3 года назад +1

      Thanks, Captain Obvious. You're a big help. :)

    • @marcoskunrath5914
      @marcoskunrath5914 2 года назад +3

      I dab with mad plots like those too and yes, proper color interpolation makes an ocean of difference. Though, coding it is sometimes more annoying than the ghost lines.

  • @stevehorne5536
    @stevehorne5536 2 года назад +45

    Suggestion - barycentric coordinates.
    You have three ordinates, let's say u, v and w, and the constraint that u+v+w=1 (reducing the effective number of dimensions back down to two). Using an equation P=uA+vB+wC (where A, B and C are vectors for the triangle vertices), if you have 0

  • @encryptedmaze
    @encryptedmaze 3 года назад +358

    I remember posting this exact question on math stack overflow a while ago, but I didn't get a good answer. Awesome to see you covering this topic!

    • @nullumamare8660
      @nullumamare8660 3 года назад +3

      @@carina5262 yes

    • @joopie99aa
      @joopie99aa 3 года назад +15

      Time to answer your own question!

    • @tophan5146
      @tophan5146 3 года назад

      @@joopie99aa ruclips.net/video/IbDAmvUwo5c/видео.html

    • @AFastidiousCuber
      @AFastidiousCuber 3 года назад +18

      Well, the problem is that it is a bit of a nebulous question. Which functions are okay to use? If you specifically asked "Can you describe a triangle implicitly by multiplying, adding, and composing elementary functions, |x|, and sgn(x)?" then you might have gotten a better answer. Those guys at math stack exchange are always sticklers for precise questions.

    • @sodiboo
      @sodiboo 3 года назад +6

      Math stack exchange or stack overflow? On stack overflow the sign function should be allowed, you definitely have it in all programming languages, and in math stackexchange, see video

  • @antonnym214
    @antonnym214 3 года назад +112

    To avoid confusion between Sin() and Sign(), I always used the word "Signum" for the sign function, and abbreviate it as Sgn().

    • @mygills3050
      @mygills3050 2 года назад

      x/|x|!

    • @chaotickreg7024
      @chaotickreg7024 2 года назад +3

      Pretty sure Sin is short for Sinus, although it's better to abbreviate the other one

    • @skyjoe55
      @skyjoe55 2 года назад +2

      @@mygills3050 x/sqrt(x^2)

    • @styleisaweapon
      @styleisaweapon 2 года назад +2

      @@skyjoe55 that breaks when x is 0 - you got the abs(x) part right, but havent gotten sign(x) right

    • @SKotekar
      @SKotekar 2 года назад

      Shouldn't Sign(x) at x=0 should be undefined!. I think Abs(x) does not have that problem

  • @milandavid7223
    @milandavid7223 3 года назад +289

    After some thinking, I think I've come up with a solution that doesn't explode, and doesn't use piecewise function definitions.
    First let's define abs(x) = sqrt(x^2). For the lines I prefer the dot product concept, but it's essentially the same - for line[n] there's a function f[n](x,y) that returns the distance of (x,y) from the line. ( f(x,y) = abs((x-P.x)*N.x+(y-P.y)*N.y) where P is a point on the line, and N is the normal vector ) f returns 0 for points on the line, and some positive number for all other points.
    Thus the equation for the three lines combined is f1(x,y)*f2(x,y)*f3(x,y) = 0. Now we just need to chop off the unneeded line segments.
    Let C be the center of the circumscribed circle of the triangle, and g(x,y) a function, which returns negative values inside the circle, and positive ones outside. (forexample g(x,y) = (x-C.x)^2+(y-C.y)^2 - r^2 where r is the radius of this circle). Now let's take a look at this expression: abs(x) + x , this returns 0 for non-positive numbers, and 2x for positives. Let h(x,y) = abs(g(x,y))+g(x,y) , this function returns 0 inside (including the perimeter) of the circle, and some positive number outside.
    So finally, my equation is f1(x,y)*f2(x,y)*f3(x,y) + h(x,y) = 0 . (feel free to expand this lol)
    In summary:
    The first part renders the three lines, and the second part adds a positive number to the possible solutions outside the circumscribed circle, making them solutions no more. Only the line segments inside the circumscribed circle show up, these being the sides of the triangle.
    Thank you for listening o my TED talk

    • @carlosojeda4457
      @carlosojeda4457 3 года назад +19

      To make a sign function, I like to do abs(x)/x it is useful when you need to mantain a sign after squaring something.

    • @ERROR-ei5yv
      @ERROR-ei5yv 3 года назад +13

      You should make it in desmos and add a link!

    • @cparks1000000
      @cparks1000000 3 года назад +18

      The absolute value function is piecewise. (Actually, piecewise isn't a type of function. If you disagree, define it unambiguously.)

    • @colinbrown7947
      @colinbrown7947 3 года назад +22

      @@carlosojeda4457 that explodes if x=0 though

    • @Agnes.Nutter
      @Agnes.Nutter 3 года назад +39

      @@carlosojeda4457 looks like someone didn’t watch the whole video before commenting… ;)

  • @st0ox
    @st0ox 3 года назад +77

    In case you want to hide your if statements even deeper in other mathematical functions:
    abs(x) = sqrt(x*x) for x element Real
    sign(x) = x / abs(x) for x ≠ 0
    but remember, even if you hide your if statements like this, your function is still not easily differentiable, because decisions aren't. This topic plays a huge role in the backpropagation (training) of neural networks.

    • @PhyterJet
      @PhyterJet 2 года назад +1

      Exvept sqrt returns both the positive and the negative

    • @st0ox
      @st0ox 2 года назад +3

      @@PhyterJet yes you are right.
      I meant:
      abs(x) = (sqrt(x))²

    • @라디안-e9z
      @라디안-e9z 2 года назад

      Sign(x)=2floor(x/(abs(x)+1))+1

    • @angeldude101
      @angeldude101 2 года назад

      If you want x to be something other than a real number, than abs(x) changes slightly to sqrt(x*x̅). sign(x) on the other hand works completely unmodified for pretty much anything you can throw at it as long as abs is implemented.
      Depending on the exact system being used, abs(x) can be zero or even negative for certain values. The most notable example would be the split-complex/hyperbolic numbers, which can have legitimate values with a negative magnitude.

    • @jellymath
      @jellymath 2 года назад

      ​@@st0ox
      X is an element of the real number set.
      -1 is definitely a real number.
      according to you, in the comment I'm replying to, the following statement is true:
      abs(-1) = sqrt(-1)^2 = i^2 (let i = sqrt(-1))
      but i^2 is by definition equal to -1, and -1 is quite negative...

  • @yuvalne
    @yuvalne 3 года назад +8

    "No one minds that I was using the absolute value function" 11:15
    Oh, I definitely mind, Matt. I definitely mind.

    • @danielglazar6811
      @danielglazar6811 3 года назад

      Define |x| := sqrt(x^2)

    • @galo2099
      @galo2099 2 года назад +1

      @@danielglazar6811 sqrt(x^2) = +- x

    • @limeee8775
      @limeee8775 Месяц назад

      @@galo2099 square roots are a function and thus only give out one output, which is positive x

  • @MegaNardman
    @MegaNardman 3 года назад +51

    I went into this expecting the "Parker Square" of triangle formulas, but instead, was completely sold on the idea of a sign(x) function in mathematics being no weirder than the absolute value function.
    Congrats! IMO, this equation qualifies as non-Parker!

    • @RosimInc7
      @RosimInc7 3 года назад +2

      Poor Matt is now doomed not to have his successes defined by his name, since his valid formulas are deemed "non-Parker" :'(

    • @ikcikor3670
      @ikcikor3670 Месяц назад

      You can square a number and then get a square root of it and that is the absolute value, but there is no way to do the same and obtain a sign function

  • @bellsworth137
    @bellsworth137 3 года назад +500

    Hey Matt, your psychedelic triangles look a lot like optical interference patterns, specifically conoscopic interference patterns. Visually, I've seen the same effect in moiré patterns on curved surfaces.
    I accidentally discovered them in high school with a diffraction grating sandwiched between two rotated polarizers. I've since graduated university with a degree in physics and subsequently learned the name of the phenomenon, but your video has given me a discrete step in understanding how these patterns are mathematically derived. Thank you!

    • @Archiekunst
      @Archiekunst 3 года назад +7

      I was going to say the same thing. Can you explain why it looks like the interference pattern?

    • @bellsworth137
      @bellsworth137 3 года назад +58

      ​@@Archiekunst
      Matt's colored lines repeat periodically since he programmed them to do so using modular arithmetic. In modular arithmetic, numbers are constrained within a range of integers and inherently loop back around when they reach a certain value, so you'll often see them in systems that repeat or loop. Similarly, in regard to light of a single color (one specific wavelength), interference patterns repeat periodically because light interferes with itself when relevant distances/thicknesses are at specific multiples of its wavelength. If you check the wiki pages for Wave Interference, Bragg's Law, or Thin-Film Interference, you'll see equations involving sine or cosine functions, hinting at their periodic nature. At distances that are certain multiples of its wavelength, light interferes with itself constructively to make repeating bright regions, and at certain wavelength multiples in between, the light interferes with itself destructively to create repeating dark regions.
      To use thin film interference as an example, a soap bubble will look like a specific color when the bubble's wall thickness is proportional to a multiple of the incoming light's wavelength. However, a bubble's wall thickness fluctuates because of things like air currents and gravity, so it's colors will change correspondingly.
      en.wikipedia.org/wiki/Thin-film_interference#/media/File:Thinfilmbubble.jpg
      The same goes for the colors created by oil on a puddle of water: the color you see at any given point on the surface is determined by the thickness of the oil layer there.
      en.wikipedia.org/wiki/Thin-film_interference#/media/File:Dieselrainbow.jpg
      These examples are usually colorful because we normally see them under white light conditions (all colors of light mixed together), but if we were in a room with only one color light, then we'd just see periodic light and dark bands of that color.
      I think Matt's choice of colors sort of creates an approximation/illusion of interference, since the black and white make it look like there are dark troughs and bright crests, and the additional two colors and gradients give the impression of a color spectrum. His choice to use cyan and magenta is interesting since they're secondary colors, but it doesn't look like the color values ever overlap or interact in any way to generate new colors.
      What I don't understand is why there are circular patterns inside the triangle and hyperbolic patterns outside the triangle. I think what's going on is that the hyperbolas are actually moiré patterns formed by the way Matt's program is sampling what color to display at each point. Notice how the lines get closer together as you get further away from an edge of the triangle. If the program could sample/display at infinite resolution, I bet some of the visible patterns would disappear. I've only seen these circular/hyperbolic moiré patterns on curved surfaces, so what does this triangle display have to do with spherical/hyperbolic geometry? A complex variation on the three-polarizer problem, why does a diffraction grating between two orthogonal polarizers produce the same circular/hyperbolic shapes? (It seems to only work with some diffraction gratings, like the cheap plastic ones.)
      These are the same curved shapes I saw as a kid in high school, but I never really understood how the circles/hyperbolas are made and how the conoscopic interference and moiré instances of these shapes are related, so if anyone knows, I'd be curious to hear an explanation haha
      Moiré patterns are formed by overlapping grids (or other spatially repeating patterns) that are displaced or misaligned by some angle. The two grids are superimposed on each other in such a way that an interference pattern arises as an emergent property.
      Here are some examples of moiré patterns that I find interesting:
      • Looking through two chain-link fences
      • A digital camera's CCD sensor (rectangular grid of pixels) and a grid-like target object, like a window screen, checkered shirt, or computer monitor (another rectangular grid of pixels).
      • A digital photo of a cylinder with lines on the surface (circles on the convex side, hyperbolas on the concave side). In my case, it was wound copper coils.
      • Two layers of graphene (see "magic angle graphene"), and other stacked crystal lattices. Electron images of bilayer graphene are moiré patterns because the electric fields of the overlapping atoms interfere.

    • @luxgladius
      @luxgladius 3 года назад +6

      To me they looked like the artifacts I often see right before a migraine. I actually looked away when I saw then because of some kind of triggering that I associate with those kind of patterns.

    • @I_Rasool
      @I_Rasool 3 года назад +4

      Nerds!

    • @kartoffelmozart
      @kartoffelmozart 3 года назад +2

      the universe is using the sign function! take that, haters of the sign function in pure mathematics!

  • @ASCENDANTGAMERSAGE
    @ASCENDANTGAMERSAGE 3 года назад +115

    If you're accepting piecewise functions, why not just use three lines constrained with inequalities.

    • @Simoneister
      @Simoneister 3 года назад +34

      That's a little *too* piecewise for my liking

    • @aromeran
      @aromeran 3 года назад +1

      Well, I'm on calc 3, I have to say it's easier this way

    • @mangelsimonpaniello2256
      @mangelsimonpaniello2256 3 года назад +12

      Exclusively to annoy you, probably

    • @ГеоргиГеоргиев-с3г
      @ГеоргиГеоргиев-с3г 3 года назад +2

      Isn't diagonal cut of a square, a triangle ergo
      (Isolate)Y (then) substitute with (Y+ |Y|) / 2
      giving you only the top bit (in the first square) with only one equation (to get a triangle)? It's hard to believe no one has thought of that since we do have the batman equation!

    • @blackasthesky
      @blackasthesky 3 года назад

      Yikes!

  • @linguamathematica2582
    @linguamathematica2582 3 года назад +3

    For those against the use of |x|:
    1. The center of the triangle is always inside the triangle
    2. Call a line which passes through two vertices of the triangle a line of the triangle
    3. A point p is inside the triangle if it fully agrees with the center on whether it is above or below each line of the triangle
    We can use observation 3 to construct the equation for the triangle from the equations for each of the lines
    L1(x) = m1*x + b1
    L2(x) = m2*x + b2
    L3(x) = m3*x + b3
    A point p will agree with the center with one of the lines if
    (p.y - L(p.x))(c.y - L(c.x)) > 0
    where p.y is the y-coordinate of p, p.x is the x-coordinate (same for c.y and c.x), and L(x) is the equation of the line. Using a step function u(x) would allow us to express the equation for when a point will agree with the center for all lines
    u((p.y - L1(p.x))(c.y - L1(c.x))) * u((p.y - L2(p.x))(c.y - L2(c.x))) * u((p.y - L3(p.x))(c.y - L3(c.x))) > 1/8
    But, don't we need |x| to define a step function?
    No! We can approximate a step function with arbitrary precision using
    u(x) = 1 / (1 + exp(-sx))
    by making s → infinity. To get the boundary points, and thus the equation for the triangle, simply set the inequality to an equality:
    u((p.y - L1(p.x))(c.y - L1(c.x))) * u((p.y - L2(p.x))(c.y - L2(c.x))) * u((p.y - L3(p.x))(c.y - L3(c.x))) = 1/8

  • @drewdavis2392
    @drewdavis2392 3 года назад +17

    What if you did the triangle equation in polar coordinates? Then the triangle function is defined piecewise in three parts (as you might expect), and your rays are just the angle coordinate at which the pieces change. As a bonus, you get to use the sin() function, letting you riff in that direction as well as sign().

  • @bluebukkitdev8069
    @bluebukkitdev8069 3 года назад +242

    Ok I actually really like this, and I approve of the use of the sign function because the Absolute Value function always seemed like an exception to normal algebra. But if they can accept that, they should accept sign. As a matter of fact, conditionals should be used more in math since it is used to often both in our daily lives and in nature.

    • @DrBrangar
      @DrBrangar 3 года назад +8

      Math uses plenty of conditionals, basically every theorem is one.

    • @spinnis
      @spinnis 3 года назад +31

      but absolute value isnt conditional. its just the square root of x^2

    • @feronanthus9756
      @feronanthus9756 3 года назад +17

      @@spinnis you might want to double check your notes on that.

    • @spencerhansen2927
      @spencerhansen2927 3 года назад +24

      even if people don't want to allow sign,
      |x|/x returns the same thing anyway.

    • @gamerdio2503
      @gamerdio2503 3 года назад +26

      @@feronanthus9756 He's not wrong. The principle square root is always the positive value. Thus, √x² = |x|.

  • @Niosus
    @Niosus 3 года назад +172

    This reminds me a lot of some of the trickery I had to do to model collision checking with linear programming for my masters thesis. Instead of using equalities, you use inequalities. You can use these to force your point of interest to be on the outside of an edge of a (convex) polygon. However, you had to give the solver a way to turn off these constraints because you can't be on the "outside" of all edges at the same time. You're not colliding with the polygon if you're on the outside of at least one edge. That's exactly how you use the sign function here: you're selectively disabling constraints to build up a nice convex shape.

    • @anonanon3066
      @anonanon3066 3 года назад +2

      What happens if you plug in a concave shape?

    • @828burke
      @828burke 3 года назад +1

      @@anonanon3066 if you have a concave shape it's possible to be on one side of one tangent line and the other of another.

    • @aryagerami9022
      @aryagerami9022 3 года назад +3

      @@anonanon3066 any concave shape can be broken into smaller convex shapes: you can then do collision checks on them
      There's some theorem or lemma that states any concave shape can be split into convex shapes but I don't recall what it is

    • @danielsharp2402
      @danielsharp2402 3 года назад +2

      @@aryagerami9022 The ear clipping algorithm definitely always works.

    • @RonWolfHowl
      @RonWolfHowl 3 года назад

      Ooh I'd love to read your thesis!!!

  • @nullptr5285
    @nullptr5285 3 года назад +26

    Upd: wrong answer here =)
    (|x| + |y| - 1) (y - |y|) = 0
    makes a triangle. When I saw your rectangle at 4:40, I knew there must be a simple way to map one half to 0 =)

    • @jfryk
      @jfryk 3 года назад

      Very cool!

    • @judahanstiss9088
      @judahanstiss9088 2 года назад

      but if you divide each side by (|x| + |y| - 1) (y - |y|) doesn't your equation become 1=0

    • @judahanstiss9088
      @judahanstiss9088 2 года назад +1

      How does this work in desmos
      when y>0 y - |y| = 0 this lets |x|+|y|-1 be anything therefore letting x be anything so the way Matt made his graphic calculator the whole upper half would be coloured in.
      (I'm not angry I just do not understand maths as well as you do)

    • @nullptr5285
      @nullptr5285 2 года назад

      @@judahanstiss9088 You cannot divide by something that could be zero. So no, 1 not equals 0 =)
      And if you take a different equation where the left side is never 0, you can divide by it, get 1=0, and that would mean that the original equation doesn't have solutions (we knew that from the beginning =) )
      Regarding colouring the whole upper half you're right, my mistake (but some plotting website showed it as a triangle for some reason, now I know why Matt wrote his own plotter). Thanks for catching this!

    • @Owen_loves_Butters
      @Owen_loves_Butters Год назад

      Well yeah, but that's just one specific triangle. I think he was looking for a more general equation for a triangle.

  • @Stoneman06660
    @Stoneman06660 3 года назад +1

    1980 called and wants its VHS tape of a music video background back!
    Great work. Never thought of using the sign() function in maths, only when coding.

  • @idontknowwhattowritehere8561
    @idontknowwhattowritehere8561 3 года назад +116

    I know another one: first define the equation for a segment between the points A=(a,b) and B=(c,d) as E(AB)(x,y)= sqrt((x-a)^2+(y-b)^2) + sqrt((x-c)^2+(y-d)^2) - e where e is a constant equals to the distance between A and B. For a point P=(x,y), what E(AB)(x,y) calculates is d(A,P) + d(P,B) - d(A,B). This is zero if, and only if, P is in the segment AB, such that E(AB)(x,y)=0 defines the segment AB. For a triangle A,B,C we just gotta multiply E(AB)E(BC)E(CA).

    • @chachasenri
      @chachasenri 3 года назад +4

      That's amazing

    • @1NSHAME
      @1NSHAME 3 года назад +5

      Came to post the same idea. :-)

    • @Kaepsele337
      @Kaepsele337 3 года назад +7

      That's basically an infinitely thin ellipse you use for the lines, right?

    • @vigilantcosmicpenguin8721
      @vigilantcosmicpenguin8721 3 года назад +1

      I'd love to say a model of this.

    • @1NSHAME
      @1NSHAME 3 года назад +1

      @@Kaepsele337 yeap. You can subtract one positive constant from it and it's an eclipse. If you change the squares to some other even power you can make it a different shape I think.

  • @GABRIELFILMSTUDIOS
    @GABRIELFILMSTUDIOS 3 года назад +135

    Regarding the „abs(x) and sign(x) are not real functions”: I would argue that they are, because you don’t really have to define the piecewise. You could express abs as being
    abs(x)=sqrt(x^2),
    because x^2 makes whatever x is positive and sqrt is only the positive root, and then you can say
    sign(x)=x/abs(x).
    So both can be nice functions, but especially if you accept abs you have to accept sign, as you don’t really need piecewise definition if you already have abs.
    Edit: should have watched half a minute further before I commented xD

    • @_mels_
      @_mels_ 3 года назад +14

      I mean, you don't really need much more - if you already have abs, you've done a lot of progress in your working out!

    • @samberg3864
      @samberg3864 3 года назад +3

      @@_mels_ thanks dad

    • @kaiserruhsam
      @kaiserruhsam 3 года назад +16

      x/ |x| still explodes at 0, which is something of a problem

    • @fadaaszhi
      @fadaaszhi 3 года назад +1

      @@floyo 0

    • @walterkipferl6729
      @walterkipferl6729 3 года назад +4

      @UCTiArtP2vwzyIuilnrMSLrA Depends on who you get to define it. If you want to build it‘s Fourier Series, you gotta have sign(0)=0, but sometimes you want sign(0)=1. With the x/abs(x) approach, you don‘t have a solid value at 0, so you may define that value as whatever you want. The function will never be continuous, so do what you want to do.

  • @landsgevaer
    @landsgevaer 3 года назад +99

    Oh boy, this approach is way too complicated!
    A simple equation for a triangle ABC with A(0,0), B(0,1), C(1,0) is:
    min(x,y,1-x-y) = 0
    This is easily generalized to *any* triangle; the three terms in the min-function relate to the equations of the sides.
    And, if you don't like the min- (or max-) function but don't mind the absolute value function, then min(a,b)=(a+b-|a-b|)/2, and min(a,b,c)=min(min(a,b),c), so it is easily expressible with only that.
    #QED 😜
    I'm in the camp that there ís an equation.
    [comment edited to add a bit of explanation]

    • @ruilongwackerlin7451
      @ruilongwackerlin7451 3 года назад +5

      thx now I don't have to watch the video

    • @f5673-t1h
      @f5673-t1h 3 года назад +30

      You can even do it simpler. Define a function f that's 0 on your triangle and 1 everywhere else.
      Then the equation is just f(x,y) = 0.

    • @landsgevaer
      @landsgevaer 3 года назад +6

      @@f5673-t1h Yeah, in principle. Now express that in Mattim... 😉

    • @Kaepsele337
      @Kaepsele337 3 года назад +3

      To elaborate, you can imagine a plot in 3D, with the z-value being the value of the function. a*x + b*y + c then represents a plane. If we take some planes that go through (x,y, z) = (0,0,1) and some line in the x-y plane, then the min function applied to all those functions will be a pyramid-like shape. By setting it to zero, i.e. where the pyramid crosses the x-y plane, we get the equation for any (convex) polygon.

    • @firstname4337
      @firstname4337 3 года назад +4

      you obviously don't understand the question -- we need a GENERAL equation -- like they have for circles
      coming up with an equation for a specific triangle is no where near the same

  • @eekee6034
    @eekee6034 3 года назад +4

    Speaking as a person who in my childhood, delighted in annoying people, I approve of this video.
    Separately, I see Mattim in certain circumstances makes the lines go different thicknesses as they change angle. This is also what I'm struggling with in computer graphics at the moment. Except I'm not so much struggling as going, "Okay, this is hard. I think I'll leave it alone for a while."
    The repeating ray plot looks like Moire patterns but triangular. it's gorgeous!

  • @sillymel
    @sillymel 3 года назад +2

    Corrections:
    At 12:17, you say that subtracting 1 from sign(mx - y), you get *2* above, but you actually get *-2* above. This still works, though, because each (x,y) pair selects at most one term from your equation, so you don't have to worry about terms cancelling each other out.
    At 14:33, the graphic says that |x|-x = *2x* when x < 0, but it actually equals *-2x* when x < 0. (|x|-x = (-x)-x = -2x) This, again, doesn't cause a problem in the final graph for the same reasons as before.

  • @Luk4sWorld
    @Luk4sWorld 3 года назад +223

    Matt discovered signed distance functions. Next up: SDFs in 3D space and a sneak peak to sphere tracing/ray marching. Maybe a short tangent to the computer world and its demo scene? In any case, its a great video for another fascinating topic!

    • @Roxor128
      @Roxor128 3 года назад +21

      Matt could be lost down that rabbit hole for days. I know I was after finding Inigo Quilez's site.

    • @kylebowles9820
      @kylebowles9820 3 года назад +8

      Shadertoy!

    • @JosephCatrambone
      @JosephCatrambone 3 года назад +4

      SDF was the first thing I thought of, too. Gotta' get Art of Code in here.

    • @gabor6259
      @gabor6259 3 года назад +3

      sneak *peek

    • @amyshaw893
      @amyshaw893 2 года назад +4

      SDFs in 4D space are even better! I did a uni project on them and had a lot of fun adapting things to work in 4d with my own raymarching renderer

  • @zaneoblaneo7624
    @zaneoblaneo7624 3 года назад +27

    I actually implemented a similar method to draw triangles on my ti-84+ in highschool, to win an argument with my teacher. I believe I implemented and used the sign function in place by dividing the input by a comparison between the absolute value of the input and the input. (IE: Y1 = x / ( abs( x ) = x ) where x is what you want to display if the sign is positive) It only worked because dividing by 0 was just undefined, and the calculator could test equality, but it came in handy from time to time.😅

    • @HaniSantosa
      @HaniSantosa 3 года назад +2

      I wonder what kind of an argument that you had with your teacher LOL

  • @stainlessCode
    @stainlessCode 3 года назад +18

    You can make an equation for triangle by using Barycentric coordinates, and then convert them trivially back to cartesian.
    The equation is simply u + v + w = 1, all the points int the triangle(including boundary) satisfies the equation.
    If you need only the edges, you just check that the one barycentric coordinate of a point is 0.

  • @GrapefruitGecko
    @GrapefruitGecko 3 года назад +8

    I feel like the big difference for me between absolute value and sign(x) is that absolute value when plotted is continuous everywhere (but not differentiable at 0) but sign(x) has a jump discontinuity at 0

    • @Pablo360able
      @Pablo360able 2 года назад +1

      If you’re going to get calculus involved, it’s worth noting that sign(x) is just the derivative of |x| with respect to x, and it has a discontinuity at 0 because the absolute value is not differentiable there.

    • @merren2306
      @merren2306 2 года назад

      @@Pablo360able except its not. The derivative of |x| is |x|/x, with it being undefined (not just discontinuous) at x=0.

    • @amineaboutalib
      @amineaboutalib 2 года назад

      @@merren2306 which is why it's discontinuous at 0

    • @merren2306
      @merren2306 2 года назад

      @@amineaboutalib sure, it's still a different function than sign though

  • @ChaossX77
    @ChaossX77 2 года назад

    I love how sometimes you explain the most high level thing in excruciating detail but gloss over super low level things. Keeps me on my toes and feeling stupid and/or insane

  • @MiTheMer
    @MiTheMer 3 года назад +100

    Love your fairly "programmatical" approach at this! At least that's how I perceived it. Am a developer for visualization tools (and as a hobby for games) and have used the sign function quite a couple of times to achieve things that would otherwise require complicated formulas or multiple lines of codes. It's also a trick for performance as using this is often faster in tight loops and in shaders compared to an IF clause.

    • @hyeve5319
      @hyeve5319 3 года назад +11

      The thing that matt didn't mention about sign (or abs for that matter) which I'm a bit sad about, is that they can both be computed entirely mathematically, with no conditional logic required. Hence why sign is very performant for shaders!

    • @Samsam-kl2lk
      @Samsam-kl2lk 3 года назад +4

      By 'no conditional logic' you mean it is branchless?

    • @hyeve5319
      @hyeve5319 3 года назад +2

      @@Samsam-kl2lk Yes, but it is also (at least possible, I'm unsure if it's generally implemented this way or not) possible to do entirely mathmatically, with no conditional instructions at all.

    • @vigilantcosmicpenguin8721
      @vigilantcosmicpenguin8721 3 года назад +2

      Especially the bit where he insists he's using a valid function. Anything's a valid function if it compiles.

    • @JohnDlugosz
      @JohnDlugosz 3 года назад +2

      @@hyeve5319 It would be implemented as logic gates acting on the representation of the floating point value, not as a sequence of instructions at all. And it does have "conditions" depending on the IEEE fp modes set; you can respect positive and negative zero as signed values, or have 0 produce 0. But there's no branching because there's no code: there's gates that demultiplex the circuits for the different modes of operation.

  • @johnchessant3012
    @johnchessant3012 3 года назад +6

    You can use square roots to restrict the domain:
    y (|x| + y - 1) (1 + sqrt(1 - x^2)) = 0 is a triangle with vertices (-1,0), (0,1), (1,0)

  • @shaunsaggers
    @shaunsaggers 3 года назад +45

    regarding "blue is cold, and that's negative", I once decided to implement an alternative colour bar scale for some simulations\calcs at work, where instead of (blue=low, green=medium, red=high), I did (red=low green=medium, magenta=high), on the basis that red light is lower energy photons, and blue\violet are higher energy photons... confused the hell out of everybody. didn't last long.

    • @Tumbolisu
      @Tumbolisu 3 года назад +15

      Next time try using the colors of black-body radiation.

    • @Games_and_Music
      @Games_and_Music 3 года назад +9

      I'd say magenta was not a good pick, as people still kinda associate it with red.
      Purple probably still would've looked weird though, people just aren't used to it.
      I usually argue in my head about it whenever i see people mention the red = hot & blue = cold thing, even though i happily use that system when i shower, and i'm not ready to switch taps, hate red showers.
      But that does make me think though, if you take a rainbow(and kill it), red is the lower energy side and purple/violet the high energy side, if violet is supposed to be the opposite of red, then why do you get violet when you mix blue with red?
      How does a super short wavelength have a similar color to the longest wavelength, what's red doing so close to blue, how darn "non-red yet still appears as a red mixed in to get violet" does ultraviolet have to be?
      I mean, i know it says ultra, but that doesn't cut it, more like mega ultra.
      I know that pigments and low level LED's don't compare to natural physics, or the way our eyes work, but i thought it was kinda interesting.

    • @vigilantcosmicpenguin8721
      @vigilantcosmicpenguin8721 3 года назад

      @@Tumbolisu Red is... cold?

    • @Tumbolisu
      @Tumbolisu 3 года назад +6

      @@vigilantcosmicpenguin8721 Instead of thinking "Red is hot, blue is cold" think "Blue flames are hotter than Red flames"

    • @guigazalu
      @guigazalu 3 года назад +4

      @@vigilantcosmicpenguin8721 if something emits red purely by heat, it's colder than something that emits blue purely by heat (black-body radiation).
      But red photons are "bigger" than blue photons, so they "interact better" with the macroscopic world, even though blue photons carry out more energy,

  • @jaredmulconry
    @jaredmulconry 3 года назад +6

    16:20 Thank you for making my eyes bleed, Matt.
    My first thought when I saw the title was that using piecewise was going to be part of the answer. I was not disappointed in that respect.
    What I wasn't (and really should have been) expecting was your visualisations of these plots being the best kind of visualisations; messing with the set dressing.
    Fine work as always :)

  • @lumipakkanen3510
    @lumipakkanen3510 3 года назад +1

    What is this? The standard way of doing constructive geometry like this is to use the minimum and maximum functions. If you define negative values to be "inside" a line then the maximum of three lines gives you points that are negative if and only if they are "inside" all lines i.e. inside a triangle. Therefore, the equation for a triangle is: triangle(x, y) = max(lineA(x, y), lineB(x, y), lineC(x, y)) = 0.

  • @Eivindhamre
    @Eivindhamre 3 года назад +51

    This reminds me of a function I came up with one or two years ago that returns 0 for all values of x, except those between some a and b.
    ( (x - a + |x - a|) (b - x + |b - x|) ) / ( 4(b - x) (x - a) ).
    This function explodes at a and b, but I later found this formula
    floor( (sgn(x-a) * sgn(b-x) )+1 )/2 )
    that fixes the division by 0 problem, and is 0 for a and b

  • @sapphicsylvia1590
    @sapphicsylvia1590 3 года назад +15

    I'd argue that the absolute value function isn't a piecewise function to begin with: |x|=a :x=ae^iθ. That being said, sign(x)=x/|x| seems perfectly acceptable considering not all functions are continuous nor defined everywhere: 1/x is undefined at x=0 as well.

  • @andst4
    @andst4 3 года назад +53

    There exists an equation for any triangle, using only abs function and no division, for example:
    3-3*abs(y)-abs(4x-2y+1-3*abs(y)) = 0
    (check out this formula in Wolfram Alpha)
    or simplified version thanks to Casplan Macelan in subcomment: abs(x) + abs(y + abs(x)) = 1
    I've created it using formula: min(a, b) = a+b-abs(a-b) Having that, I use min function on formulas for 3 planes creating a pyramid, and voila :) Below in a subcomment, I give detailed method of creating equation of a triangle with given vertices.

    • @Cloiss_
      @Cloiss_ 3 года назад +2

      This is very clever. The 3D visualization really helped me to understand what's going on (I hope Matt makes a follow-up with some of the great stuff from this comment section!)

    • @pickachu463
      @pickachu463 3 года назад

      wow. Is there a generalized formula for this?

    • @neopalm2050
      @neopalm2050 3 года назад +1

      slight nitpick: that's double the min
      Good catch!

    • @humanistwriting5477
      @humanistwriting5477 3 года назад

      👏👏👏👏 very nice

    • @durnsidh6483
      @durnsidh6483 3 года назад +2

      a-a|y|-|bx-cy+d-a|y||=0 always produces a triangle if a>0, but I'm not sure if it can make every triangle. As for what the parameters do, d translates the triangle along the x axis but otherwise I can't tell.

  • @blau6832
    @blau6832 3 года назад +1

    Beginning of the video: "I think I have an equation for a triangle... sort of, kind of."
    Me watching: Oh, we're gonna get a Parker equation, aren't we? :D

  • @jaberwoky_
    @jaberwoky_ 3 года назад

    I watch your clips all the time, Matt. Usually about half way through, I realize that I haven’t a clue what you’re talking about. Immensely entertaining. I wish I was smarter.

  • @danielzduniak5592
    @danielzduniak5592 3 года назад +61

    What you're doing here is very similar to visualizing so-called "signed distance fields (SDF)" - you should check the topic out, there's a lot of potential for other mathematical videos there.
    Btw: I'm afraid that those interesting features in the last plot are just moiré patterns.

    • @hyeve5319
      @hyeve5319 3 года назад +10

      SDFs are fun! No idea if you're familiar with shaders (or specifically, Shadertoy and that type of artistic shader) but they're essential for them.

    • @GabrielJones
      @GabrielJones 3 года назад +1

      ruclips.net/video/s8nFqwOho-s/видео.html

    • @programaths
      @programaths 3 года назад +1

      @@hyeve5319 I was thinking the same "But he is explaining shaders" ^^

    • @ufffd
      @ufffd 3 года назад +1

      First thing I thought of when I saw the title “no way, I’ve got SDFs for this. IQ wouldn’t lie to me”

    • @hyeve5319
      @hyeve5319 3 года назад

      @@ufffd Yup, basically my reaction too haha

  • @gorgm4136
    @gorgm4136 3 года назад +20

    It's actually okay to use sign(x) cause you can replace it with x/abs(x). And abs(x) is just sqrt(x^2)

    • @cimos5133
      @cimos5133 2 года назад +1

      without taking sqrt(x) to mean the principal square root, abs(x) has to be written as sqrt(x)^2, not sqrt(x^2). or you could just write √(x^2), as the symbol denotes the square root to be the principal square root.

    • @cmyk8964
      @cmyk8964 2 года назад

      @@cimos5133 What are you on about? The square root of a negative number is undefined within the reals, and if you used complex numbers, squaring the number will bring it back to before. sqrt(x)² = x.
      sqrt(x²) is what you want, because squaring a negative number makes it non-negative, and square-rooting it will make the graph linear again. sqrt(x²) = |x|.

  • @blahorgaslisk7763
    @blahorgaslisk7763 3 года назад +80

    I remember back when I played around with my first computer, a ZX Spectrum. While not a graphical powerhouse even back when it first came out it did allow for bitmapped graphics and the BASIC interpreter supported basic graphical functionality. This helped me a lot with visualizing mathematical equations and made experimenting with them a lot more interesting. Instead of having to manually graph them out I could just write a little program to do it and if it wasn't too involved it would provide a graphical representation within reasonable time.
    While doing this I started thinking about how the graphics primitives were programmed, and most interesting was the circle command which was slow enough it was pretty easy to see it doing it's work, but the line command turned out to be even more interesting. It's basic function was to draw a line from coordinate set one to coordinate set two. A straight line, doesn't sound that interesting. But it also accepted a third parameter that allowed you tell it to draw an arc instead. I can't for the life of me remember if it was described in radians, degrees or something else, and it's not really relevant for this. Thing is it had me starting to think about the algorithm used, and I realized that even drawing a straight line wasn't really as simple as it sounds. I spent a lot of time thinking about it and experimenting with algorithms for this. Back then finding a lot of information on things like this was hard. You didn't have anything like Google and hitting up the local library wasn't really an option as they had next to no relevant literature for something like this. And that was the fun part at the time, you had to learn how to do it. Now sure it wasn't really necessary as there was a function for it available, but what was the fun in using that? All in all it taught me that there are a lot of ways to draw a line, and very few of them are really any good. Even fewer give a good result and are reasonably quick.
    Sometimes the simple things turn out to be surprisingly complex.
    Oh and that circle primitive? Well as it turned out in addition to being slow it wasn't even particularly exact. I have to say that whoever wrote the draw primitives used in the Spectrum version of Elite must have been a genius. Not only were they able to draw filled circles fast enough they could have a "sun" filling most of the screen and redraw it at a speed that the game didn't turn into a total slideshow, but their circles were rounder than what the slow draw primitive provided in the ROM could produce. And they had to do it in Z80 machine code. Hint, no floating point instructions what so ever. Actually if I remember correctly the only mathematical functions you had was add, substract and rotate. That last was just a way to shift the bits in a register left or right one step, being equal to a multiply or divide by two. Anything more than that you had to write your own functions for. Oh and all you had were 8-bit registers, some of which could be paired up to use for 16 bit operations.

    • @cosmotect
      @cosmotect 3 года назад +4

      Can't help but feel like some graphics programming genius from the dawn of realtime graphics wrote this

    • @blahorgaslisk7763
      @blahorgaslisk7763 3 года назад +3

      @@cosmotect Well I certainly never even touched something like that, but David Braben who wrote the original Elite for rhe BBC Micro would fit the description as would the programmers who wrote the Specturm version and those who wrote the rest of the adaptations.
      Personally I dabbled in machine code but never wrote anything worth talking about. And I spent way to much time mucking about in BASIC as it totally destroyed any chance of learning more relevant languages such as C. I've spent a lot of money and time on C books and every time I get a couple of chapters in before running head first into a wall as I simply can't wrap my head around the basic concepts of the language.
      It doesn't help that three of the books, published by different companies, turned out to be written by the same person. It was pretty frustrating when I got stuck at the same things in all three and could recognize the exact way he explained it. Repeating yourself does not make it automatically make sense all of a sudden...
      I also spent a lot of time with Forth, which I still think is one of the neatest languages ever. But again it's not really something that helps when trying to make sense of C or even something as pedestrian as Java. It did teach me how to use old HP calculators though. RPN is actually pretty nifty, but it takes some to get fluent with.

    • @cosmotect
      @cosmotect 3 года назад +2

      @@blahorgaslisk7763 I can relate, tried learning programming on 4 separate occasions, but some thing are just not intuitive for my brain, so it stays as a lifelong struggle

    • @pfkproduces8505
      @pfkproduces8505 2 года назад

      Good old 'Bit Bashing'! - used to program board level firmware in PLC microcontrollers back in the early 90's this way - programming was only half of it back then as well, used to have to rely a lot more on analogue front end circuitry to make up for the comparably slow acquisition rates and ADCs that could only run a selected channel or two at once etc

    • @Artifactorfiction
      @Artifactorfiction 2 года назад

      Loved the specy and z80 - for lines move horizontally setting pixels and occasional move up or down a pixel and continue to end point - the decision to go up down can be approximated by checking overflow on a counter - filled circles could be done fast by treating them as lots of horizontal lines - only the end bytes are awkward - the bytes in between are just ld (LH), with ff or even faster LDIR with carefully chosen BC and DE, Cos and Sin generally where best pre built in an array - say 720 elements- and using Rom floating point routines to get trig value x ffff then later do your own fast multiple 2 byte by 2 byte to get 4 byte result and only look at the 2 most sig bytes - to undo the earlier ffff multiplier - doing this from 40 year old memories but that was basically the quickest rules I could come up with

  • @jakerman999
    @jakerman999 2 года назад +7

    Considering numbers as vectors on a number line, absolute value is just the magnitude of a number. In such a context it is certainly reasonable to grab just the direction of a vector while discarding it's magnitude(a.k.a. normalization).
    |X| can be expressed as √X². Building off of this, you can obtain the sign function you are looking for by X/|X|.

  • @jasonpatterson8091
    @jasonpatterson8091 2 года назад +1

    Happy RUclips moment: The thumbnail for this video, with a white bar across the top reading "Is there an equation for a triangle?" which appeared to be at the bottom of the thumbnail above, Ricky Gervais with the caption, "Are you ******** mental?"

  • @Penrose707
    @Penrose707 3 года назад +12

    The production quality of your videos has been steadily improving over the years. Great job Matt and happy mathing

  • @EDoyl
    @EDoyl 3 года назад +45

    great ending, it's fun to make pictures on the computer. 0:40 I was in the "that's ridiculous" camp and I wasn't annoyed at all by your equation. It's a perfectly cromulent equation; sign(x) is fine to use. If you don't like sign you can recreate it with abs(x), if you don't like abs you can recreate it with sqrt(x), and if you don't like sqrt you can recreate it with exp(x) and log(x) which are functions everyone has to like as a maths law.

    • @reuben4721
      @reuben4721 3 года назад +2

      who doesn't like sqrt(x) lol

    • @milanstevic8424
      @milanstevic8424 3 года назад +10

      @@reuben4721 I like pow, it reminds me of Batman

    • @tttm99
      @tttm99 3 года назад +2

      If people are comfortable with sine, then sign! Cromulent indeed. It embiggens the field of mathematics.

    • @tttm99
      @tttm99 3 года назад +3

      @@milanstevic8424 frequently i think pow(x)! appears batmanish. The answer must be in Hertz

    • @nikolaimikuszeit3204
      @nikolaimikuszeit3204 3 года назад

      I'd use fn(x) = n x / sqrt( 1+ n² x² ) with n to infinity. to avoid the rays maybe an additional x -> x-1/sqrt(n) so fn(0) tends to zero. Must love limits, too.....right?

  • @Pystro
    @Pystro 3 года назад +10

    Here's a quite crafty recipe for a triangle equation that I came up with:
    If we can define a diamond on a plane, then we can define an octahedron in 3D. (As far as I can see this doesn't really help us, though.) But if we can define a square on the plane, we can define a cube in 3D. Specifically, in a u,v,w coordinate system, the unit cube is
    u^inf + v^inf + w^inf = 1
    If you intersect a corner of that cube with your plane, you'll get a triangle. In order to do that, you just use a linear transformation
    [u,v,w] = R*[x,y,0] + [s1,s2,s3]
    (where R is some suitable 3x3 rotation matrix, and [s1,s2,s3] is needed so that you don't intersect the cube where it's cross section is a hexagon.
    Plug the second equation system into the first equation, (resist the urge to complain about the infinite powers), and voila, an equation for a triangle (or even a hexagon)! It just requires thinking outside the box (or in this case, outside the plane).

    • @peterkelley6344
      @peterkelley6344 3 года назад

      Forgive me for saying this Beatles parody: "diamonds on a plane ... with Parker ..."

    • @karolakkolo123
      @karolakkolo123 3 года назад

      That's what I was thinking, a linear transformation saves the day
      Edit: well, except the fact that having infinite exponents isn't really rigorous

  • @alex_zetsu
    @alex_zetsu 3 года назад +3

    You're right that both the sign function and the absolute value function does something different depending on what is stuffed inside it. So in that sense, if one isn't too weird, the sign function isn't weirder. But the sign function isn't continuous, which can make people think the solution for the equation was a bit fudged. On the other hand, 1/x isn't a continuous function and few people object to using it to graph a shape. So perhaps the sign function isn't that much weirder than what we've been dealing with after all.

  • @Karreth
    @Karreth 2 года назад

    Two points:
    1: ax+b is objectively the right way to write the equation for a line.
    2: In signal analysis we use the heaviside step function, u, which is 1 for positive numbers and 0 for negative numbers. So sign(x) = u(x) - u(-x). That is totally a legitimate function.

  • @dunno-a-good-username
    @dunno-a-good-username 3 года назад +18

    0:29 is he saying that his equation for a triangle is a bit of a parker-square? Can we call it a parker-triangle?

    • @MsMollieMac
      @MsMollieMac 3 года назад

      Its only half of a Parker Square, no need to panic lol

  • @btCharlie_
    @btCharlie_ 3 года назад +26

    11:50 I happily use sign function, but the thing with absolute value is that it can be "hacked" by doing sqrt(x^2), and for a lot of use cases, you can just happily use x^2, meaning you can refrain from using any piecewise functions whatsoever.

    • @chaotickreg7024
      @chaotickreg7024 2 года назад +2

      Nice hack!

    • @mironhunia300
      @mironhunia300 2 года назад +6

      And sgn(x) can be similarly hacked as x / |x| = x / sqrt(x^2), with an unfortunate exception of 0. EDIT: Nevermind, Matt mentioned it.

  • @johnwilson3918
    @johnwilson3918 5 месяцев назад

    I seem to recall learning the equation of a triangle from my school days, using the parametric line equation.
    P1 + t(P2 - P1) with t in [0,1]
    If A, B, C are the apex points of our triangle.
    Points on the triangle, satisfy :-
    [A + adj(T,0)*(B-A)]* req(T,0,1) + [B + adj(T,1)*(C-B)]* req(T,1,2) + [C + adj(T,2)*(A-C)]* req(T,2,3) T in the range [0,3]
    req(T,a,b) = 1 , T in [a,b[ otherwise 0
    adj(T,c) = T-c
    I can spot a very small mistake in the above which could be rectified with another scandalous sign/abs type function!

  • @delanomighty8113
    @delanomighty8113 2 года назад

    By this token, you can get the equation for any n-sided polynomial in any configuration. This definition also generalizes to the square and other quadrilaterals earlier in the video. Well done.

  • @MathIguess
    @MathIguess 3 года назад +27

    Considering that we're allowing absolute values, we may as well allow other piece-wise defined functions, and so we may as well just define a triangle into existence with a piece-wise defined funtion... as they do in calc 1 all the time... right?

    • @smergthedargon8974
      @smergthedargon8974 3 года назад +3

      You can do absolute values with one equation: sqrt(x^2)

    • @nicholasvinen
      @nicholasvinen 3 года назад +1

      @@smergthedargon8974 and you can define sign(x) = |x| ÷ x as long as you make sure x can never be zero

    • @smergthedargon8974
      @smergthedargon8974 3 года назад +1

      @@nicholasvinen Sure, but that undefined at 0 makes me... uncomfortable. It's not piecewise, but it's not a _perfect_ substitute in the way sqrt(x^2) is for the absolute value

    • @OrchidAlloy
      @OrchidAlloy 3 года назад +1

      √x² is not equal to |x|

    • @smergthedargon8974
      @smergthedargon8974 3 года назад +2

      @@OrchidAlloy Yes it is. Can you please give me a real number line value for which it will provide you a different answer?

  • @TheHuesSciTech
    @TheHuesSciTech 3 года назад +8

    How about abs(x + abs(y)) + abs(y) - 1 = 0. Creates a triangle with vertices (-1,-1), (-1, 1), (1, 0). And as noted elsewhere, abs() isn't really piecewise in the reals, it can just be represented as abs(x) = sqrt(x^2).

  • @thisisnotmyrealname628
    @thisisnotmyrealname628 3 года назад +17

    Triangle without rays or sgn function:
    We can plot the points of f(x;y)=0 when g(x;y)>=0 holds. Take the following equation: |f(x;y)|+|g(x;y)|-g(x;y)=0. |f(x;y)|=0 is equivalent to f(x;y)=0, and when g(x;y)>=0 the extra stuff doesn't change anything, but for g(x;y)

    • @Victor-sw4ne
      @Victor-sw4ne 3 года назад +1

      I had a similar idea, but adding and subtracting the square root of g(x,y), this way it can’t be negative, since we are working with reals

  • @legitgopnik8431
    @legitgopnik8431 3 года назад +1

    You really Parker Square'd that triangle function, where it kinda works but has sign() or kinda works but has rays

  • @matthewwhiteside4619
    @matthewwhiteside4619 2 года назад

    My favourite part was at 9:24 when Matt said "It's triangle time" and triangled all over the bad guys.

  •  3 года назад +16

    When you started the video asking about equation for a triangle I was thinking barycentric coordinates! Are you restricted to using cartesian coordinates? Would be fun to get equations in other coordinate systems.

    • @absalomdraconis
      @absalomdraconis 3 года назад +1

      Agreed, barycentrics are the way to go.

  • @sjoerdstougie
    @sjoerdstougie 3 года назад +6

    new triangle discovered? the Parker triangle

  • @SirNobleIZH
    @SirNobleIZH 2 года назад +1

    My favorite part is at 10:30 where he unintentionally point the gamma ray at his head

  • @rjtimmerman2861
    @rjtimmerman2861 3 года назад +3

    If you don't like using the sign function, you can just use |x|/x
    That's how I figured out a way to put multiple graphs together into one single y=expression :)

  • @ictogon
    @ictogon 3 года назад +15

    this reminds me of an algebra test where we had to write down the (assumed piecewise) function for a graph, but I combined it all into some abomination of absolute values so I could write it as one function. I don't remember if my teacher accepted it lol

  • @minimalistic_banhaus
    @minimalistic_banhaus 3 года назад +31

    Didn't understand what he meant by "equation for a triangle" until he put the Cartesian grid on the screen. Which begs the question, what about other coordinate systems? Can you make equations for triangles, rectangles, etc. work in Polar coordinates?

    • @diribigal
      @diribigal 3 года назад +13

      Well you could take a cartesian equation and replace x with r*cosθ and replace y with r*sinθ.

    • @dexyfexx
      @dexyfexx 3 года назад +8

      Barycentric coordinates are often used to describe triangles in this way (as well as other shapes)

    • @hoebare
      @hoebare 3 года назад +6

      it doesn't beg the question, it raises it

    • @buddhabuck
      @buddhabuck 3 года назад +2

      @@hoebare It proverbially asks @Erik Van de Water to consider other coordinate systems. That sounds like begging to me. What it doesn't sound like is the rhetorical fallacy petitio principii, a Latin mistranslation for the Greek for "assuming the conclusion" and further mistranslated into English as "begging the question".
      I hope you aren't making the mistake of assuming that a phrase in English can only have a narrow, technical, meaning (like "begging the question" = "assuming the conclusion fallacy", or "fruit" = "seed bearing structure in flowering plants formed from the ovary") instead of having many meanings.

    • @simonmultiverse6349
      @simonmultiverse6349 3 года назад

      You could also have X = Fourier series and Y = another Fourier series. Each individual series on its own would be a triangle wave, but not a zig-zag kind of series, more like a zig-zag-zug series. Isn't that what The Spice Girls were on about? Zig-Zag-Zug-aaaah!

  • @wholecreator3756
    @wholecreator3756 3 года назад +8

    There was a great tiktok response to this that uses polar coordinates to create a general function for a regular shape of n sides, including a triangle. The catch is that it uses a mod function. Don't know if that follows your rules but still, very interesting.

    • @karolakkolo123
      @karolakkolo123 3 года назад +3

      Well, mod(b,a) = b - a*floor(b/a), and floor is a step function just like sign(x), but idk

    • @karolakkolo123
      @karolakkolo123 3 года назад +1

      Do you happen to have a link to that tiktok, or at least know the equation? It's interesting

  • @darkangel2347
    @darkangel2347 2 года назад

    A very useful take on the sign function is S(x) = (1 - Sign(x))/2. Returns 1 if X0. This is of great use when solving tan (theta)=y/x when either X=0 or y=0 for theta.

  • @ariellima5929
    @ariellima5929 3 года назад

    This is such an important sponsorship that I came back to it a few times just to help (albeit just a tiny bit) in your viewer retention there :) Great video as always!!

  • @perfidiousbrit4671
    @perfidiousbrit4671 3 года назад +6

    We've had the Parker Square and now the Parker Triangle...

  • @pyglik2296
    @pyglik2296 3 года назад +5

    I guess you used some threshold for drawing the lines what caused some weird artifacts, especially in the last triangle with rays, but it also adds some more understanding to how the function works and how fast it is growing in different regions.

  • @sciphyskyguy4337
    @sciphyskyguy4337 3 года назад +27

    Also, how about using an infinite Fourier series, which can be used to describe any closed, continuous loop (which a triangle qualifies as)?

    • @FiniteJest
      @FiniteJest 3 года назад +3

      This was the first thing I thought about as well. But it would be a parametric equation with Fourier series for each coordinate. Is that considered one equation for a triangle?

    • @sb_dunk
      @sb_dunk 3 года назад

      @@FiniteJest or just in the complex domain

    • @sb_dunk
      @sb_dunk 3 года назад +1

      I guess a Fourier series always produces a continuous and differentiable function, whereas a triangle isn't differentiable everywhere... Wonder if that makes it not count.

    • @martinepstein9826
      @martinepstein9826 3 года назад

      @@sb_dunk "I guess a Fourier series always produces a continuous and differentiable function"
      Nope. Two of the most basic Fourier series are for the square wave (not continuous) and the sawtooth wave (not differentiable).

  • @reijerboodt8715
    @reijerboodt8715 3 года назад

    Let A \subset R^2 be a triangle. Let f be the indicator function of A. The equation of the triangle A is: f(x,y) = 1.
    Essentially what you did, Matt. But very good video I enjoyed it!

  • @sungod9797
    @sungod9797 2 года назад +1

    Before watching the video: you can just make a parametric piecewise-defined function r(t) for any given specified triangle that traces the perimeter of the triangle. You have to do that for line integrals and whatnot. So I guess that counts as an “equation for a triangle.”

  • @omartjo
    @omartjo 3 года назад +13

    When I was bored in class back in highschool, I would "paint a picture" by plotting the individual edges one by one on my graphic calculator. To turn them on at a specific interval them I used the fact that the calculator ignored regions with a square root of a negative number. To set the boundaries of the edges to an interval of x in [a,b] with a>b I just did:
    y=m+nx+0*sqrt(a-x)+0*sqrt(x-b)
    which is only "defined" at that interval, and when it is defined, it just adds zero. I noticed that looking at a plot of sqrt(x), nobody had a problem with the fact that we only see part of the possible values of x, so exploiting that by setting the domain of an equation to a really specific interval, you can plot the edges! Maybe it's not as mathematical as you may strive for, but as someone else already noticed this video has a "programmy" feel to it. Maybe you could use the fact that the imaginary part of y is nonzero at values of x outside the interval? Anyway, thought of it watching this video, which was great, keep up the good work!

  • @AntoniGawlikowski
    @AntoniGawlikowski 3 года назад +9

    You should give a seizure and/or nausea warning before the last part :P
    Great video as always, thanks!

    • @valvesofvalvino
      @valvesofvalvino 3 года назад +1

      Totally agree, even though I don't suffer seizures, it was giving me a headache watching it. Great video apart from that though!

  • @marcfaulk
    @marcfaulk 3 года назад +4

    Heads up: you might want to put a photosensitive epilepsy TW for the psychedelic bit at the end.

  • @danjbundrick
    @danjbundrick 3 года назад +1

    The equation for a triangle is
    x^2+y^2=sec^2(mod(arctan(x,y),(2pi/n))-(pi/n))

  • @nikodempatrycjuszswiercz4064
    @nikodempatrycjuszswiercz4064 3 года назад +1

    this equation produces a triangle with points A(0;0) B(1;1) C(2;1)
    (2y - x) (2y + abs(x - 1) - abs(x) - 1) sqrt(abs(x) / x - abs(x - 2) / (x - 2) - 1) = 0
    the first part is the side of the triangle connecting A to C
    the second part is both of the other sides combined
    the third part reduces the domain to (0, 2)
    if we want to include the left and rightmost points, we can switch the entire square root for [(abs(x) + abs(x - 2) + 2x - 2) / 2 - abs(x - 1) - (x - 1)]/[(abs(x) + abs(x - 2) + 2x - 2) / 2 - abs(x - 1) - (x - 1)]
    if we don't want to include the absolute value function in the equation, we can substitute it like abs(x)=sqrt(x^2)

  • @05degrees
    @05degrees 3 года назад +3

    Now it we use sigmoidal functions like tanh, arctan, erf (or some of the rational functions which I don’t remember) instead of sign, we can probably have a bit different nice coloring too!
    Also probably using (x cos ϕ + y sin ϕ + b) instead of (a x + y + b) might make color stripes between each pair of rays a bit more in line with each other, as (cos ϕ, sin ϕ) has a fixed length 1 however you place the two vertices that define the line, and so lines (x cos ϕ + y sin ϕ + b ± 1) are always at the same distance 1 from the original line. If I haven’t made a mistake or a typo.

  • @GerritMeinders
    @GerritMeinders 3 года назад +8

    Instead of the sign function I think you're looking for the min/max functions. That should easily combine the three half-planes into a triangle. Also works very nicely in 3D when combined with ray marching. It's typically referred to as a signed distance field in that context, I think.

  • @joiscode3832
    @joiscode3832 3 года назад +3

    Y=mx+b is how i was tought but i like c better. Also fun video as always. I love math and im taking 2 math classes next year. Your channel and numberphile are 2 of many reasons i love math thank you for being part of that and making me love math even more

  • @beardwatch1928
    @beardwatch1928 3 года назад +2

    Clean and consistent. There's nothing wrong with that but it's hard to not want more.

  • @hanneselsen5282
    @hanneselsen5282 3 года назад +1

    Oh I really like your argument for the absolute value function, I've never even really thought about that

  • @eideticex
    @eideticex 3 года назад +8

    The sign function to detect edges of features is a trick I loved to use in shader programming. I would use something like: max(sign(x - 0.5), 0) to create value of 0 below 0.5 or 1 above 0.5 in order to feed into a lerp as the interpolation term. Primarily used it tracing edges of wireframes for a better wireframe display than rendering hard lines without anti-aliasing (gets crazy computationally expensive for complex models). And to perform blending effects like Photoshop's color burn as a post process effect. Lots of fun to be had using those functions with geometry.

  • @GingerGames
    @GingerGames 3 года назад +5

    What? Why is there no equation for a triangle?
    ---
    Of course there isn't. That would be stupid.

  • @Jig_up
    @Jig_up 3 года назад +4

    I mean, I’m happy enough to accept your equation- or, I presume it to be yours, at least. I would be curious to see a version with more complicated, n-sided shapes, but the function works quite well, really- good job!

    • @kimbalcalkins6672
      @kimbalcalkins6672 2 года назад +1

      I worked on this and came up with a solution that traverses any polygon. Define the functions FXi(t),FYi(t) as the parametric pair for the ith perimeter segment. Calculate the segment distances D[i] as the perimeter distance from the start point to the polygon point Px[i],Py[i]. The last entry in D call it D[n] now contains the perimeter length. Normalize D onto 0.0->100.0, ie. for each i, set D[i]=100.0*D[i]/D[n]. The polygon is traced by varying t from 0.0 to 100.0 as follows:
      x(t)=c1(t)*FX1(t) + c2(t)* X2(t) +...
      y(t)=c1(t)*FY1(t) + c2(t)*FY2(t) + ...
      in explanation the coefficient functions are designed to be 1 within the segment that t lands on and 0 elsewhere.
      If you are interested I will continue and show how these are defined ?

    • @toomanycharacter
      @toomanycharacter 2 года назад

      I have another solution for connecting any 3 given points on a plane*, and I think that solution is extendable for all convex polygons, although I'm not sure
      *If none of them share the same x coordinate
      Here is the short version, I'll elaborate and send a working example if you want me to
      (Copying from my other comment)
      "Well if you do need an equation for any triangle* in the coordinate plane, here is a rather simple one using the fact that |a| = |b| means a = b OR a = -b
      *Given none of the sides are parallel to the y-axis, because that would necessitate we return uncountable infinity of solutions at one point of the function
      How this works, simplified:
      1. Any triangle* in the coordinate plane has no more than 2 y values for each x value
      2. For any 2 numbers (y values of the triangle), there is exactly one number (y value) that is equidistant to those numbers (y values).
      3. |a| = |b| => a = +- b
      4. (Following from 3) |a - c| = |b| => a = c +- b
      So, you can just find the function which gives you the y value equidistant to the 2 y values of the triangle at each x value, then find the functions which gives you the distance from the first function to the y-value of the triangle, plug y for a, first function for c, and second function for b."
      I think it's extendable for all convex polygons IF all convex polygons, given they have no lines parallel to the y-axis, have at most 2 y values for each x value.
      Basically you would
      1. Break the polygon into two halves (both of which have at most 1 y value for each x value)
      2. Express each of them as a function
      3. Make a function (f) which returns the middle of the two functions (the average of the y values from the two halves at each x value)
      4. Make a function (g) which returns the distance from one of the halves to f(x) (which is going to be the same as the distance from the other half to f(x))
      5. |y - f(x)| = |g(x)|
      Although this all lies on the idea that there is no convex polygon, so that there is a line which intersects it more than 2 times and is not parallel to any of the sides.

  • @bastian1833
    @bastian1833 3 года назад +1

    Don't forget the circumcircle: |y|(1-|x|-y)^2 + |1-x^2-y^2| - (1-x^2-y^2) = 0

  • @5ONE41
    @5ONE41 3 года назад +1

    I was trying to figure out exactly this problem the other day. I would've saved myself a bunch of time if I had just seen this video when you posted it. Thank you!

  • @matheusbaginskipasa7151
    @matheusbaginskipasa7151 3 года назад +6

    Is that a Parker equation?

    • @vcprado
      @vcprado 3 года назад

      Oh, c'mon, I was just going to say that

  • @bpk0666
    @bpk0666 3 года назад +5

    It's fairly straightforward in three axes. Within the first "quadrant" define any plane that doesn't go to infinity in that quadrant, then you get a triangle.
    For example, an equilateral triangle: X + Y + Z = 1
    This has its vertices at (1, 0, 0), (0, 1, 0), and (0, 0, 1)

  • @jimmorrison3432
    @jimmorrison3432 3 года назад +4

    I just absolutely love your delivery and style Matt, you're amazing

  • @gazmodius
    @gazmodius Год назад +1

    I can't wait for cosign to come out!

  • @a_mtg
    @a_mtg 3 года назад +1

    In that regard I will not even accept the absolute value function because when you are ultimately using piecewise functions you can simply define the triangle piecewise directly instead of hiding the implementation in another function be it |x| or sign(x).

  • @TheRealChronosis
    @TheRealChronosis 3 года назад +4

    Curious, if you were to extend your equation's definitions into the imaginary plane/numbers, could that potentially allow you to include in rotation of the triangle?

  • @matematicaspanish8301
    @matematicaspanish8301 2 года назад +4

    I use abs(y-abs(x))=1-abs(x) to plot a triangle, but it always takes me a lot to get it again.
    Also, I like to think of the absolute value of x as the square root of the square of x, and the sign of x as the quotient between the absolute value of x and x. It takes away the weirdness

    • @jellymath
      @jellymath 2 года назад

      wait, but abs(y-abs(x))=1-abs(x) isn't a general formula for a triangle, is it?

    • @neutronenstern.
      @neutronenstern. 2 года назад +1

      what about this:
      what about this:
      (x-y+1)*(-x-y+1)*(0.1x-y)=0
      listen: i can do anything with things like this.
      isnt it beautiful?

    • @flatfingertuning727
      @flatfingertuning727 Год назад

      @@jellymath One could replace x with ax+by+c, and y with dx+ey+f for arbitrary coefficients a-f to position a triangle anywhere, though I think a satisfying triangle equation should have a zero on one side of the equals sign, and have the properties that all points inside would yield values greater than zero, all values outside would yield values less than zero, and all values everywhere are continuous.

    • @jellymath
      @jellymath Год назад

      @@flatfingertuning727 Where did you learn this!? Wow.
      Could you explain what you mean by values inside/outside though? Do you mean the LHS of
      LHS = 0
      for (x,y) inside/outside of a triangle substituted into LHS?

    • @flatfingertuning727
      @flatfingertuning727 Год назад

      @@jellymath Linear transforms are used routinely in computer graphics systems, among other applications. You understood precisely what I meant by the latter point.