Author Topic: Cool math hacks  (Read 25662 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Cool math hacks
« Reply #30 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.

Offline phenomist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 132
  • Rating: +46/-3
    • View Profile
Re: Cool math hacks
« Reply #31 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.
Level Designer for Graviter

[Disclaimer: I can't program for my life.]

Offline piexil

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +2/-0
  • Guys, we have a weenie hut jr. over here
    • View Profile
Re: Cool math hacks
« Reply #32 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.
<a href="http://www.nerdtests.com/ft_nt2.php">
<img src="http://www.nerdtests.com/images/badge/nt2/d9b48a7b7395142b.png" alt="NerdTests.com says I'm a Highly Dorky Nerd King.  Click here to take the Nerd Test, get geeky images and jokes, and talk to others on the nerd forum!">
</a>

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Cool math hacks
« Reply #33 on: May 21, 2012, 12:21:21 pm »
lol
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline piexil

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +2/-0
  • Guys, we have a weenie hut jr. over here
    • View Profile
Re: Cool math hacks
« Reply #34 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.
<a href="http://www.nerdtests.com/ft_nt2.php">
<img src="http://www.nerdtests.com/images/badge/nt2/d9b48a7b7395142b.png" alt="NerdTests.com says I'm a Highly Dorky Nerd King.  Click here to take the Nerd Test, get geeky images and jokes, and talk to others on the nerd forum!">
</a>

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Cool math hacks
« Reply #35 on: May 21, 2012, 05:51:38 pm »
That's useful.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Cool math hacks
« Reply #36 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
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Cool math hacks
« Reply #37 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

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Cool math hacks
« Reply #38 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.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Cool math hacks
« Reply #39 on: June 04, 2012, 03:24:49 am »
That does look suspiciously like the formula for the area of an equilateral triangle, though.
In-progress: Graviter (...)

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Cool math hacks
« Reply #40 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.
« Last Edit: June 04, 2012, 12:08:47 pm by thepenguin77 »
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline blue_bear_94

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 801
  • Rating: +25/-35
  • Touhou Enthusiast / Former Troll / 68k Programmer
    • View Profile
Re: Cool math hacks
« Reply #41 on: June 04, 2012, 01:31:15 pm »
Does anyone remember C=2πr and A=πr2?
Due to dissatisfaction, I will be inactive on Omnimaga until further notice. (?? THP hasn't been much success and there's also the CE. I might possibly be here for a while.)
If you want to implore me to come back, or otherwise contact me, I can be found on GitHub (bluebear94), Twitter (@melranosF_), Reddit (/u/Fluffy8x), or e-mail (if you know my address). As a last resort, send me a PM on Cemetech (bluebear94) or join Touhou Prono (don't be fooled by the name). I've also enabled notifications for PMs on Omnimaga, but I don't advise using that since I might be banned.
Elvyna (Sunrise) 4 5%
TI-84+SE User (2.30 2.55 MP 2.43)
TI-89 Titanium User (3.10)
Casio Prizm User? (1.02)
Bag  東方ぷろの

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Cool math hacks
« Reply #42 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:
  • If c is prime, the trivial solution is the only solution
  • If c is composite, there is more than one solution


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.

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Cool math hacks
« Reply #43 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
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Cool math hacks
« Reply #44 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:
  • A2-B2=
  • (2n+1)2-(2m)2=
  • 4n2+4n+1-4m2=
  • 4(n2+n-m2)+1=
  • 4l+1


Now, let A be even, B be odd. That is, A=2n, B=2m+1. Then:
  • A2-B2=
  • (2n)2-(2m+1)2=
  • 4n2-4m2-4m-1=
  • 4(n2-m2-m)-1=
  • 4k-1=
  • 4(k-1)+3=
  • 4l+3=


If both are even, you have:
  • A2-B2=
  • (2n)2-(2m)2=
  • 4n2-4m2=
  • 4(n2-m2)=
  • 4l


If both are odd, you have:
  • A2-B2=
  • (2n+1)2-(2m+1)2=
  • 4n2+4n+1-4m2-4m-1=
  • 4(n2+n-m2-n)+1-1=
  • 4l
[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 :)