• Aqarius@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    15 hours ago

    Essentially.

    A straightforward example would be an equation system: 2x+4y=10, 3x+5y=13. You could solve it manually, or you could call Cramer’s rule and plug the numbers into the formula:

    Ax+By=C
    Dx+Ey=F

    x=[CB/FE]/[AB/DE] = (CE-BF)/(AE-BD)=(10*5-4*13) / (2*5 - 3*4) = (50-52)/(10-12)=1,
    y=[AC/DF]/[AB/DE]=AF-CD / AE-BD = -4/-2=2

    Pure algo, no thinking required. Also note that you don’t strictly need x to get y and vice versa.

    In a more complex example: You’re making a program to draw something in 2D. You could implement mirroring, rotation, scaling etc…, or, you could declare each point (xy) a vector V=[X Y], implement matrices, and then V times [1 0/0 1] gives you V, [-1 0/0 1] gives you V mirrored on the Y axis, [1 0/0 -1] mirrors on the X axis, [j 0/0 j] scales it by j, [cosw -sinw/sinw cosw] rotates it by w… Makes life much easier.