Quick math question for a script of mine

2^x = 100

how do I calculate X?

x2=100
Two solutions were found :
x = 10
x = -10
Rearrange:
Rearrange the equation by subtracting what is to the right of the equal sign from both sides of the equation :

                 x^2-(100)=0 

Step by step solution :
Step 1 :
Trying to factor as a Difference of Squares :
1.1 Factoring: x2-100

Theory : A difference of two perfect squares, A2 - B2 can be factored into (A+B) • (A-B)

Proof : (A+B) • (A-B) =
A2 - AB + BA - B2 =
A2 - AB + AB - B2 =
A2 - B2

Note : AB = BA is the commutative property of multiplication.

Note : - AB + AB equals zero and is therefore eliminated from the expression.

Check : 100 is the square of 10
Check : x2 is the square of x1

Factorization is : (x + 10) • (x - 10)

Equation at the end of step 1 :
(x + 10) • (x - 10) = 0
Step 2 :
Theory - Roots of a product :
2.1 A product of several terms equals zero.

When a product of two or more terms equals zero, then at least one of the terms must be zero.

We shall now solve each term = 0 separately

In other words, we are going to solve as many equations as there are terms in the product

Any solution of term = 0 solves product = 0 as well.

Solving a Single Variable Equation :
2.2 Solve : x+10 = 0

Subtract 10 from both sides of the equation :
x = -10

Solving a Single Variable Equation :
2.3 Solve : x-10 = 0

Add 10 to both sides of the equation :
x = 10

I ended up using Logarithm…

uh maybe its correct too, i just searched by google xd

1 Like

Or you could do

local function SquareRoot(Number,ToRoot)
	return Number ^ (1/ToRoot)
end   

print(SquareRoot(8,3))

Method 2 (only works for powers of 2):

local function SquareRoot(Number)
	return Number ^ 0.5
end 

print(SquareRoot(4))
1 Like

x = log10(100) / log10(2)

2 Likes

For anyone else wondering:

print(math.log(100, 2)) -- output: 6.6438561897747
print(2^6.6438561897747) -- output: 99.999999999998
1 Like