Sunday, 17 May 2015

Vedic mathematics method to find a square of a number

Method to find a square of a Number
1. Find the nearest power of 10 e.g. 1,10,100,1000,10000...
2. Find Deviation. Deviation=Number-10's power
3. Square=<LHS><RHS>. We will find RHS from step 4 and LHS from step 5. Square of a given number will be concatenation of LHS with RHS.
4. RHS=Deviation * Deviation. Number of digits of RHS(say x) should be equal to number of zeros in nearest 10's power(say y). If x is more than y, then RHS will be last y digits of (Deviation * Deviation). The number formed by remaining digits should be added to the LHS.
5. LHS= Number+Deviation. Add carry(if any, from step 4) to LHS.
6. Square=<LHS><RHS>




Examples: 

Square of 12
1. Nearest 10's power: 10
2. Deviation=Number-10's power=12-10=2
3. Square=<LHS><RHS>
4. RHS=Deviation*Deviation=2*2=4
5. LHS=Number+Deviation=12+2=14
6. Square=<LHS><RHS>=144

Square of 8
1. Nearest 10's power=10
2. Deviation=Number-10's power=8-10=-2
3. Square=<LHS><RHS>
4. RHS=Deviation*Deviation=(-2)*(-2)=4
5. LHS=Number+Deviation=8+(-2)=6
6. Square=<LHS><RHS>=64

Square of 15
1. Nearest 10's power=10
2. Deviation=Number-10's power=15-10=5
3. Square=<LHS><RHS>
4. RHS=>Deviation*Deviation=5*5=25. Here RHS will be 5 as 10's power(from step 1) has only one zero. 2 will be added to the LHS
5. LHS=>Number+Deviation=15+5=20. LHS will be 20+2(from step 4)=22
6. Square=<LHS><RHS>=225

Square of 18
1. Nearest 10's power=10
2. Deviation=Number-10's power=18-10=8
3. Square=<LHS><RHS>
4. RHS=>Deviation*Deviation=8*8=64. Here RHS will be 4 as 10's power(from step 1) has only one zero. 6 will be added to the LHS.
5. LHS=>Number+Deviation=18+8=26. LHS will be 26+6(from step 4)=32.
6. Square=<LHS><RHS>=324 

Square of 25
1. Nearest 10's power=10
2. Deviation=Number-10's power=25-10=15
3. Square=<LHS><RHS>
4. RHS=>Deviation*Deviation=15*15=225. Here RHS will be 5 as 10's power(from step 1) has only one zero. 22 will be added to the LHS.
5. LHS=>Number+Deviation=25+15=40. LHS will be 40+22(from step 4)=62.
6. Square=<LHS><RHS>=625

Square of 60
1. Nearest 10's power=100
2. Deviation=Number-10's power=60-100=(-40)
3. Square=<LHS><RHS>
4. RHS=>Deviation*Deviation=(-40)*(-40)=1600. Here RHS will be 00 as 10's power(from step 1) has two zeros. 16 will be added to the LHS
5. LHS=>Number+Deviation=60+(-40)=20. LHS will be 20+16(from step 4)=36.
6. Square=<LHS><RHS>=3600

Square of 100
1. Nearest 10's power=100
2. Deviation=Number-10's power=100-100=0
3. Square=<LHS><RHS>
4. RHS=>Deviation*Deviation=0*0=0(000). Here RHS will be 00 as 10's power(from step 1) has two zeros. 0 will be added to the LHS
5. LHS=>Number+Deviation=100+0=100. LHS will be 100+0(from step 4)=100.
6. Square=<LHS><RHS>=10000
 

Square of 98
1. Nearest 10's power=100
2. Deviation=Number-10's power=98-100=(-2)
3. Square=<LHS><RHS>
4. RHS=>Deviation*Deviation=(-2)*(-2)=4. Here RHS will be 04 as 10's power(from step 1) has two zeros. 0 will be added to the LHS
5. LHS=>Number+Deviation=98+(-2)=96    LHS will be 96+0(from step 4)=96.
6. Square=<LHS><RHS>=9604
 

Square of 112
1. Nearest 10th power=100
2. Deviation=Number-10's power=112-100=12
3. Square=<LHS><RHS>
4. RHS=>Deviation*Deviation=12*12=144. Here RHS will be 44 as 10's power(from step 1) has two zeros. 1 will be added to the LHS
5. LHS=>Number+Deviation=112+12=124. LHS will be 124+1(from step 4)=125.
6. Square=<LHS><RHS>=12544

Square of 95
1. Nearest 10's power=100
2. Deviation=Number-10's power=95-100=(-5)
3. Square=<LHS><RHS>
4. RHS=>Deviation*Deviation=(-5)*(-5)=25. Here RHS will be 25 as 10's power(from step 1) has two zeros. 0 will be added to the LHS.
5. LHS=>Number+Deviation=95+(-5)=90. LHS will be 90+0(from step 4)=90.
6. Square=<LHS><RHS>=9025

Next: How to retrieve data from mysql database in jsp ( JSP-JDBC selecting records from mysql database )

Previous: Code generation using DAG / labeled tree - C++ Language Implementation




No comments:

Post a Comment