Omnimaga

General Discussion => Other Discussions => Math and Science => Topic started by: AngelFish on May 05, 2011, 06:08:15 pm

Title: Cool math hacks
Post by: AngelFish on May 05, 2011, 06:08:15 pm
Have you ever taken a test (or just realized in general) that some of the methods taught in school are very tedious and there's a much faster way to do precisely the same thing? For example, one of the things taught in both Statistics and Linear algebra is finding a least squares regression line for a given data set.  Statistics teaches you how to solve:

(http://upload.wikimedia.org/math/c/b/d/cbd70bd6036486ef39e0b7a027b9bd13.png)

while Linear algebra teaches you a very computationally intensive, often poorly explained method involving matrix operations.

While I was taking my Linear algebra final today, I realized that instead of solving those messes, the least squares regression line is actually a weighted "Average" of several other functions that depend on the values of the data set for the linear case, although it doesn't extend to higher order regressions. Thus, my answer took half a page to derive instead of the two pages given to solve the problem on and involved only very simple arithmetic to do the problem.

Has anyone else ever had a similar experience?
Title: Re: Cool math hacks
Post by: ruler501 on May 05, 2011, 06:42:18 pm
Kind of. I sit around in class all the time bored after I finish my books and usually I'll think about life, philosophy or math/science(same thing really in my opinion). I have found numerous ways to have easier solving of problems in class. Its just that most of what I figure out is proofs of what I already know or simplification of simple subjects(multiplication/algebra 1/etc). I'll post some of what I figured out later. most of it is published in one form or another and I come across them after I already came up with how to do it.

I'd kind of like to see your method for doing that

EDIT: some of what I did was prove parts of the Vedic Mathematics(Indian methods for efficient math solution) before I knew they existed.

I figured out their multiplication formula

(ax^2+bx+c)*(dx^2+ex+f)=x^4*a*d+x^3(a*e+d*b)+x^2*(b*e+a*f+d*c)+x(c*e+b*f)+c*f
This seems more complicated till you replace x with 10 and see how it is just place value if you flip the left side of the equation so that you go from least to greatest in powers you can do this quickly and accurately in your head.
This also proves that it will work with any base
Title: Re: Cool math hacks
Post by: Freyaday on May 06, 2011, 11:58:19 am
Yeah. This happens to me all the time.
Like, we were asked to find how far a ball drops in a given number of seconds, and we were supposed to use geometric sequences to do it, but using the little physics knowledge I have, I came up with something far simpler. t=time, a=accelleration, d=distance
dt=2t2/a
Title: Re: Cool math hacks
Post by: ruler501 on May 06, 2011, 01:23:46 pm
Yeah schools teach the accepted methods only. My teachers complain whenever I use my own methods if i don't write out my entire proof which is sometimes only in my mind and is usually long

EDIT: changed excepted to accepted
Title: Re: Cool math hacks
Post by: jnesselr on May 07, 2011, 03:50:57 pm
Yeah schools teach the accepted methods only. My teachers complain whenever I use my own methods if i don't write out my entire proof which is sometimes only in my mind and is usually long
Fixed, and yeah, I understand exactly what you mean.
Title: Re: Cool math hacks
Post by: Darl181 on May 07, 2011, 04:15:12 pm
I forgot what it was, but at one point that happened to me. I asked the teacher to prove it wrong.  She never bothered me about that again XD

I have no idea what's going on in the first post tho...I've just seen the E looking thing before and idk what it's called :P
Title: Re: Cool math hacks
Post by: ruler501 on May 07, 2011, 07:45:58 pm
Its a summation operator I believe.

I might be wrong here but I believe that is when you sum up all of the numbers in a series up to a certain point. The starting value is defined on the bottom and the ending value is on top.

I'm not sure what all that other stuff is though
Title: Re: Cool math hacks
Post by: Freyaday on May 07, 2011, 07:46:49 pm
The variable being changed is also defined on the bottom
Title: Re: Cool math hacks
Post by: Ashbad on May 07, 2011, 07:57:25 pm
you can hack math to do wonders.  Such as this:

1+(-1)

unoptimized version of 1-1 == 0.

I think this totally beats qwerty's example, but only by a little, but he did a great job with his kiddy-maths with differential regressions and conics and matrix algebraic solutions
Title: Re: Cool math hacks
Post by: ruler501 on May 07, 2011, 08:00:01 pm
My math teacher has learned over time that questioning my methods when I get the right answer is not a good idea. Many of my proofs just serve to confuse him and go far above his level of teaching and knowledge. He knows I don't cheat by the fact I can prove everything I do(well 90+% of the time)

He got confused when I tried to explain why you use e^rt in population growth.
Title: Re: Cool math hacks
Post by: PeonHero on May 07, 2011, 08:43:59 pm
Here's a cool math hack:

Usually people are taught to do math arithmetic from right to left, but it's actually more efficient (easier and faster) to do it from left to right. Scott Flansburg aka "The Human Calculator" teaches children to do math from left to right and they end up able to do the majority of arithmetic problems in their head without even writing anything down. Try it.
Title: Re: Cool math hacks
Post by: ruler501 on May 07, 2011, 08:46:24 pm
Could you explain how to do this different method of addition?
Title: Re: Cool math hacks
Post by: PeonHero on May 07, 2011, 08:48:56 pm
  55
+55
------

Normally you would carry the 5+5 on the right side first, which would be a 1, then add it to the 2 50's on the left, to make 110.

Doing it the left-to-right way, you just do 50+50 first, = 100, then 5+5 = 10, answer is 110
Title: Re: Cool math hacks
Post by: ruler501 on May 07, 2011, 08:52:16 pm
but then you have to carry backwrds

  186
+145
-------

How would you solve that easier than the regular method
Title: Re: Cool math hacks
Post by: Xeda112358 on May 07, 2011, 08:57:16 pm
Actually, the method from left to right is how I do it because I thought it was easier than what my teachers were teaching me! It feels smoother to me to do it that way.
Title: Re: Cool math hacks
Post by: Freyaday on May 07, 2011, 08:58:07 pm
Xeda and Zippy have the coolest math hack of all: Their math is in color!
Title: Re: Cool math hacks
Post by: ruler501 on May 07, 2011, 08:58:56 pm
So is the only real difference that you carry backwards(from the original method)?

EDIT:what are their math hacks Freyaday?
Title: Re: Cool math hacks
Post by: Xeda112358 on May 07, 2011, 09:00:30 pm
Yeah, but you get your numbers in the order you say them or write them, too. You just have to know the next number making it easier to store in your memory :)
Title: Re: Cool math hacks
Post by: ruler501 on May 07, 2011, 09:01:24 pm
ah. I might try using that sometime. I like things that make the maths easier.
Title: Re: Cool math hacks
Post by: PeonHero on May 07, 2011, 09:27:22 pm
but then you have to carry backwrds

  186
+145
-------

How would you solve that easier than the regular method

Dang, I did this in like 2 seconds, too fun.

  186
+145
-------

First you do the left column first: 100+100 = 200
Next column: 40+80 = 120
Add that to the last number we got (200+120) = 320
Last column 6+5 = 11
Add that to the last number we got (320+11) = 331
Title: Re: Cool math hacks
Post by: Ashbad on May 07, 2011, 09:30:53 pm
actually, I agree with that method ^-^

 5682
+ 970
-----

5 +15 carry 1 so 6, 5 +15 carry one 66, 5+ 2, 6652.

AND, I beat my time doing it this way than by pulling up a calculator.
Title: Re: Cool math hacks
Post by: Xeda112358 on May 07, 2011, 09:37:08 pm
I usually start with the second digit to obtain the carry over for the first. So I do:
8+4=12, I get the carry of 1
Add 1+1+1=3
Then I go to the last numbers 6+5=11 meaning a carry of 1 to add to the 2 from before and I get 331

It takes me three quick steps to do that as opposed to 6+5=11, carry the 1 to get 8+4+1 and now I have 13 meaning you have a carry and the first two digits are 31, then you add the carry +1+1 and you get 331. It is too cluttered for me to think that way x.x

EDIT:
AND, I beat my time doing it this way than by pulling up a calculator.
Hehe, nice! I love being able to do that because that further affirms the notion that my calculator isn't meant for basic math :D

Also, I find that the best times to learn fast techniques is through math games :D I made one that I actually find to be fun and it lets me practice my math operations ^^ I want to add timing to it, too (As in, timing a 10 question quiz on 3 digit multiplications >:D) It keeps a running score of the number of correct and incorrect questions in each category :)
EDIT2: It also will not accept any non-number characters :D
Title: Re: Cool math hacks
Post by: ruler501 on May 07, 2011, 09:51:19 pm
So no hex work on that then Zeda. I don't time myself much and I try not to do that much of the more computation extensive math. I prrefer working on more complicated things instead of the basics. even if working on the basics would mean pretty good speed
Title: Re: Cool math hacks
Post by: Xeda112358 on May 08, 2011, 12:25:47 am
Hmm, well it really is beneficial to know all the ins and outs of how numbers act and react to each other. It really does help in advanced math. Like, take for example when I found a method of finding an equation for any finite set of data-- that is because my brain was in one of those moods where it was randomly spewing off all of my knowledge of numbers until it hit a connection. This only happened because I was having fun playing with simple addition and subtraction!
Title: Re: Cool math hacks
Post by: Deep Toaster on May 08, 2011, 12:27:46 am
I've just seen the E looking thing before and idk what it's called :P

It's summation, and it's called the sideways M sigma notation :)
/me not understand first post either O.O
Title: Re: Cool math hacks
Post by: Xeda112358 on May 08, 2011, 12:32:17 am
Yeah, I cannot think of the name of the symbol (the letter)... is it sigma?
Title: Re: Cool math hacks
Post by: Freyaday on May 08, 2011, 12:40:26 am
Yeah, It's sigma
Title: Re: Cool math hacks
Post by: DrDnar on May 08, 2011, 01:28:27 am
Σ is sigma, for sum. (Sigma makes an S sound, not an E sound. So "GRΣΣK" is very, very wrong.) Similarly, Π is pi, for product. And μ (as in μm, micrometers) is mu, for micro.

I do mental addition from left to right, my justification being that it's better to start with an estimate and then refine your estimate than deal with digits that probably don't matter when you're doing mental math.
Title: Re: Cool math hacks
Post by: Munchor on May 08, 2011, 08:55:05 am
This is a Maths hack. However, it was taught in Physics (and it's related to Physics).

My teacher gave us this formula:

(http://img.removedfromgame.com/imgs/powerformula.png)

The result is always positive. However, it is sometimes negative, but due to the modulus operator we have to know when it is positive or negative by looking at the context and values.

I thought this was stupid and came up with this:

W = Qf - Qq

This gives us positive or negative values when positive or negative and works just fine.

To calculator efficiency we just have to do:

n = (|W|)/Qq

n is efficiency.

:D
Title: Re: Cool math hacks
Post by: ruler501 on May 08, 2011, 11:09:34 am
What is that formula for?

and why does your method work. They don't look like they would give the same result.
Title: Re: Cool math hacks
Post by: Munchor on May 08, 2011, 11:12:39 am
What is that formula for?

and why does your method work. They don't look like they would give the same result.

It worked in all exercises and my teacher then admitted my way is better.

That formula is for machines that heat, like heaters and stuff. W is power/potency, Qq is heat from hot source and Qf is heat from cold source.
Title: Re: Cool math hacks
Post by: phenomist on May 08, 2011, 06:28:14 pm
division by 2 semihack

128391284905932852 / 2:
lump up even blocks:
12 8 3912 8 4 90 5932 8 52 /2
divide by two without carry on each digit
01 4 1401 4 2 40 2411 4 21
add a bunch of 5's
+
05 0 0555 0 0 05 0555 0 05
06 4 1956 4 2 45 2966 4 26
= 64195642452966426.
Title: Re: Cool math hacks
Post by: piexil on May 21, 2012, 09:33:14 am
I remember last year for freshman Honors Geometry, to save time on any formula equations for polygons >4 sides in length, I created an equation that my teacher couldn't disprove.

Alas, I hated geometry and have forgotten the equation since.
Title: Re: Cool math hacks
Post by: Happybobjr on May 21, 2012, 12:21:21 pm
lol
Title: Re: Cool math hacks
Post by: piexil on May 21, 2012, 02:56:12 pm
Fuck yes!

I found it on my facebook:
Area of any regular polygon is (1/D)(P^2)√3
Where D is double the amount of sides, and P is the perimeter.

It only works for regular polygons.
Title: Re: Cool math hacks
Post by: Freyaday on May 21, 2012, 05:51:38 pm
That's useful.
Title: Re: Cool math hacks
Post by: ruler501 on June 04, 2012, 12:28:41 am
Fuck yes!

I found it on my facebook:
Area of any regular polygon is (1/D)(P^2)√3
Where D is double the amount of sides, and P is the perimeter.

It only works for regular polygons.

I'd like to see a proof for that :P
Title: Re: Cool math hacks
Post by: Builderboy on June 04, 2012, 01:50:13 am
Fuck yes!

I found it on my facebook:
Area of any regular polygon is (1/D)(P^2)√3
Where D is double the amount of sides, and P is the perimeter.

It only works for regular polygons.

That is unfortunately incorrect D: Imagine what happens if we have a regular polygon with a large number of sides.  The 1/D would approach zero as the number of sizes increased, and P^2 would approach a constant as the number of sides increased (and the radius stayed the same).  Since the 1/D is approaching zero, the P^2 is a constant, and the √3 is a constant, the equation would approach zero for large values of D.  This is obviously not the case for real polygons :P
Title: Re: Cool math hacks
Post by: Juju on June 04, 2012, 03:00:00 am
Yeah, just imagine a circle which is a regular polygon with infinite sides (D = ∞). So 1/∞ = 0 and everything*0 = 0. So it doesn't make sense.
Title: Re: Cool math hacks
Post by: leafy on June 04, 2012, 03:24:49 am
That does look suspiciously like the formula for the area of an equilateral triangle, though.
Title: Re: Cool math hacks
Post by: thepenguin77 on June 04, 2012, 12:07:43 pm
If y'all wanna find the area of a regula' polygon, y'all oughta use these.

S = sides
R = radius to a corner
L = length of one side

Area = 1/2 * R2 * S * sin(360/S)

Area = 1/4 * L2 * S * cot(180/S)

(cot(x) == 1/tan(x))


Edit:
   You'll have to use l'hopital's rule if you want to check circles.
Title: Re: Cool math hacks
Post by: blue_bear_94 on June 04, 2012, 01:31:15 pm
Does anyone remember C=2πr and A=πr2?
Title: Re: Cool math hacks
Post by: Xeda112358 on June 06, 2012, 08:20:05 pm
Hmm, I was fooling around with my math notes when I came across an old proof. I saw that all numbers of the form 4n+2 could not be expressed as the difference of two squares, but all other numbers could. However, I pretty much left it at that. Let me tell you now that there will be a really cool hack with this, but there is more to the story. Anyway, I was looking through another notebook and some of my work on the Putnam two years ago and I saw a familiar proof where I showed that all integers >2 are in at least one pythagorean triple (I had broken down the problem to requiring only this to be true). Anyways, all I did was design a formula where, given a value A, you could get a B and C. Anyways, the process to designing the formula sparked an idea. Here is the awesome math hack:

I had shown that all integers not of the form 4n+2 could be expressed as the difference of two squares, so essentially, I have A2-B2=c. If we look at only odd integers for c, however, we get magic. If c is odd, there is a trivial solution for A and B:
A=(c+1)/2
B=(c-1)/2

But guess what? A2-B2=c can be factored to (A-B)(A+B)=c. DO you know what this means? Here:


I have been using this to write really fast factoring algorithms in assembly and I have been trying to figure out if there is a polynomial time method to finding if A2-B2=c has more than 1 solution (aside from using the AKS primality test on c). If you can find a way, then you can potentially run a very fast prime testing algorithm. Other than that, since I made this connection, I have been putting tons of energy toward following every path I can with this.
Title: Re: Cool math hacks
Post by: ruler501 on June 06, 2012, 08:59:52 pm
Thats real nice Xeda any way I could see the proofs used for that?
I don't doubt your right I just find proofs interesting and would like to see them
Title: Re: Cool math hacks
Post by: Xeda112358 on June 06, 2012, 09:46:40 pm
First, let me clarify that I am working solely with positive integers (natural numbers).
These proofs are not very formal, sorry. Typing them is a bit more tedious than writing them on paper :/

Theorem: All integers except those of the form 4n+2 are the difference of two squares.
Proof:
Here, I will simply show by cases.
Let A be odd, B be even. That is, A=2n+1, B=2m. Then:


Now, let A be even, B be odd. That is, A=2n, B=2m+1. Then:


If both are even, you have:


If both are odd, you have:
[qed]

These are all the possible case, so you can have 4l,4l+1,and 4l+3 as the difference of two squares.

As a very simple proof that all odd integers can be the difference of two squares, just plug in the trivial solution (c+1)/2 and (c-1)/2 for A and B respectivels. Since c is odd, c+1 and c-1 are even, so you can divide by two. For a process to arrive to this conclusion, forst note that the difference of two consecutive squares is odd. That is:
(n+1)2-n2=n2+2n+1-n2=2n+1

So if you want to find, say, 23 as the difference of squares, 23=2n+1 means n=11. So 122-112=23. The powerful result of the math hack I presented says that because 23 is prime, this is the only solution.

Theorem: If c is composite and odd, then there is a non-trivial solution for A2-B2=c.
Proof:
Let c be composite. That is, let c=n*m where n and m are neither 1. Since A2-B2=(A-B)(A+B), let n=(A-B) and m=(A+B). Then:

n+2B=A+B
n+2B=m
2B=n-m
B=(n-m)/2      ;since c is odd, n and m are odd, so n-m is even.
A=(n+m)/2      ;This, too, is an integer.
[qed]

Theorem: If c is an odd prime, then the non-trivial solution for A2-B2=c is the only solution.
Proof:
Assume there is a non trivial solution for A and B, A=D, B=E. This implies that (D-E) and (D+E) are factors of c. Since c is prime, the only factors are 1 and c. Therefore, (D-E)=1, (D+E)=c. This means:

D+E=1+2E, D+E=c
1+2E=c
E=(c-1)/2
D=(c+1)/2

However, this is the trivial solution, so we have met a contradiction. Therefore, the trivial solution is the only solution
[qed]

EDIT: I opened up my notes and followed through some of my work and what I have found so far:
If there is a non-trivial solution for A2-B2=c, then it is of the form (A+2d)2-(B-4e)2 where d and e are integers. This will let me speed up my code as I can forget about half or 3/4 of the potential values. I am still working on cutting that down even more :)
Title: Re: Cool math hacks
Post by: thepenguin77 on June 11, 2012, 09:58:55 pm
EDIT: I opened up my notes and followed through some of my work and what I have found so far:
If there is a non-trivial solution for A2-B2=c, then it is of the form (A+2d)2-(B-4e)2 where d and e are integers. This will let me speed up my code as I can forget about half or 3/4 of the potential values. I am still working on cutting that down even more :)


I don't think this is true. And I see two problems with it.

1. (A+2d), the new A can't be greater than the original A. The reason why is that you can't get the difference between A2 and B2 any smaller than c because if you pick the best case scenario where B is 1 smaller, you'll get a new c by definition.
     So I think it's supposed to be (A-2d)

2. (B-4e), I ran some tests, and some needed 2e

Here's what I did: (A,B)
First column is number, second column is the trivial solution, third is the special solution, 4th is difference from trivial

Code: [Select]
9 5,4  3,0 2,4
15 8,7  4,1 4,6
21 11,10 7,2 4,8
25 13,12 5,0 8,12
27 14,13 6,3 8,10
33 17,16 7,4 10,12

But, (A-2d)2 - (B-2e)2 still eliminates half the numbers.

Edit:
    The table looks so much better in preview than in the actual forum, idk why.
Edit2:
    e is always greater than d, so that's another half of the numbers
Title: Re: Cool math hacks
Post by: Xeda112358 on June 23, 2012, 02:48:15 pm
Yes, I did note the mistakes I made there. I made a mistake on one of the pages testing cases of parity.

EDIT: Also, I finally found mention of this technique while searching something unrelated. It is Fermat Factorization :)