Last active
January 4, 2016 18:19
-
-
Save dmahapatro/8660084 to your computer and use it in GitHub Desktop.
Prove two adjacent numbers are equal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Prove 4 == 5 | |
def lhs = 4 | |
def rhs = 5 | |
assert -20 == -20 | |
assert 16 - 36 == 25 - 45 | |
assert lhs ** 2 - 36 == rhs ** 2 - 45 | |
assert lhs ** 2 - 2 * lhs * ( 9 / 2 ) == rhs ** 2 - 2 * rhs *( 9 / 2 ) | |
assert lhs ** 2 - 2 * lhs * ( 9 / 2 ) + ( 9 / 2 ) ** 2 == rhs ** 2 - 2 * rhs * ( 9 / 2 ) + ( 9 / 2 ) ** 2 | |
assert ( lhs - ( 9 / 2 ) ) ** 2 == ( rhs - ( 9 / 2 ) ) ** 2 //[(a-b)**2 == a**2 + b**2 - 2*a*b] | |
assert Math.sqrt( ( lhs - ( 9 / 2 ) ) ** 2 ) == Math.sqrt( ( rhs - ( 9 / 2 ) ) ** 2 ) | |
assert Math.abs( lhs - ( 9 / 2 ) ) == Math.abs( rhs - ( 9 / 2 ) ) | |
//Caveat | |
assert lhs - 9 / 2 != rhs - 9 / 2 | |
//Hence | |
assert lhs != rhs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment