You need to play a total of 20 battles to post in this section.

## Recommended Posts

2,211  Members
7,307 posts
3,304 battles

Maybe someone in the community can help. I have tried googling the answer but the answers found were not satisfactory.

This question is about logarithms. I need an equation that will be used to find the base and exponent of a given power. This equation must be usable with any power within reason (standard stuff both exponent and base are greater than 1). I have decided to go with log2 because it seems the most flexible to me. The problem I run into is when the base is not two.

Example: 5^2= 25 but when applied to log2(25). It doesn't work for obvious reasons.

if its not obvious to you then you probably couldn't help me anyways Question is: Is there any one-in-all equation or would I need to use multiple equations to get my answer?

##### Share on other sites
29  Members
378 posts
1,791 battles

Dear lord went over this last week but it kinda flew over my head in class

##### Share on other sites
520
[-FBS-]  Members
2,646 posts
4,290 battles

Maybe someone in the community can help. I have tried googling the answer but the answers found were not satisfactory.

This question is about logarithms. I need an equation that will be used to find the base and exponent of a given power. This equation must be usable with any power within reason (standard stuff both exponent and base are greater than 1). I have decided to go with log2 because it seems the most flexible to me. The problem I run into is when the base is not two.

Example: 5^2= 25 but when applied to log2(25). It doesn't work for obvious reasons.

if its not obvious to you then you probably couldn't help me anyways Question is: Is there any one-in-all equation or would I need to use multiple equations to get my answer?

https://www.wolframalpha.com/input/?i=25

Try wolframalpha. Input the number. Scroll down and see if it has a prime factorization.

That's if you just want an answer however. Edit: Maybe try http://www.mathsisfun.com/prime-factorization.html to do the math yourself?

Edited by saagri
• 1

##### Share on other sites
473  Members
1,776 posts
6,776 battles

I see mathematics... I click on down vote... You win this time.

##### Share on other sites
1,324
[NERO]  Members
3,630 posts

log2(25) = Y is asking 2^y = 25. It doesn't apply to 5^2 at all because the base is different.

The base is going to change depending on the problem you're looking at. log2 can only be used when dealing with 2 being raised to various powers.

• 1

##### Share on other sites
221  Members
1,116 posts
10,974 battles

There's this rule which says that
Log_a(b) = [Log_c(b)]/ [Log_c(a)]
So suppose you want to change the expression Log_2(8) to base 10.
Then, using the given rule,
Log_2(8)=[ Log_10(8) ] / [ Log _10(2) ]
Or, ( Log 8) / ( Log 2)
'Cause you didn't always have to mention the base when you work in base ten.
Hope that helped.

• 1

##### Share on other sites
2,211  Members
7,307 posts
3,304 battles

log2(25) = Y is asking 2^y = 25. It doesn't apply to 5^2 at all because the base is different.

The base is going to change depending on the problem you're looking at. log2 can only be used when dealing with 2 being raised to various powers.

And now you see my problem, I need to make an equation where I can plug in any number (power) amd will return the base and exponent.

But I'm sort of stuck on how to start, that's why I chose log2 as a constant

##### Share on other sites
520
[-FBS-]  Members
2,646 posts
4,290 battles

And now you see my problem, I need to make an equation where I can plug in any number (power) amd will return the base and exponent.

But I'm sort of stuck on how to start, that's why I chose log2 as a constant

Hm. From what I can recall of math this is how I see the problem.

You have one known, the number you want to find the base and exponent of.

You have two unknowns, the base and exponent.

You would need two equation to solve it simultaneously if using algebra.

• 1

##### Share on other sites
468  Members
2,379 posts
4,080 battles

wait, you want to take a number and magically get a base and an exponent? And I'm assuming you want whole numbers here?

but if you take Log225/Log25 you will get 2

that being said, log without a base is 10 and ln is base e and both are very useful. bl are usually only used in computer science because they are kindof a pain.

Edited by TheSupremeOne34
• 1

##### Share on other sites
100  Beta Testers
365 posts
12,391 battles

I don't think you can, not without restricting base and exponent to integers.  And even then, a composite (not prime) base will foul things up.

Take, for example, 216^2 = 46656.  This can also be written as 6^6 = 46656 or 36^3 = 46656.  Which answer should your function (not equation) return?

saagri's comment on factorization is probably more promising than trying to puzzle over logarithms.

• 1

##### Share on other sites
2,211  Members
7,307 posts
3,304 battles

Hm. From what I can recall of math this is how I see the problem.

You have one known, the number you want to find the base and exponent of.

You have two unknowns, the base and exponent.

You would need two equation to solve it simultaneously if using algebra.

Yes, while it doesn't need to be simultaneously, I am only given the power and leaves me with two variables. Solving an equation with multiple varies is pretty difficult so I am using the base of 2 (log2) to replace one of the variables.

Example:

my inputs I'm working with are 4, 25, 49, 81 (just perfect powers I'm using but the number will be randomly generated)

Lets say 81 is put it: 81 = 3^4 but thats only because I know thats the answer. What happens if they give me say 441, I would need to find the exponent and power using a similar process that I used to find the exponent and power of 81.

##### Share on other sites
1,324
[NERO]  Members
3,630 posts

Hm. From what I can recall of math this is how I see the problem.

You have one known, the number you want to find the base and exponent of.

You have two unknowns, the base and exponent.

You would need two equation to solve it simultaneously if using algebra.

Agreed. You aren't going to find Y and Z with one equation if you only know X, unless it's acceptable to express the answer as itself containing unknowns.

logx(16) = y

This could be either x=2 and y=4 or x=4 and y=2, but there's no way to tell which is right without more information. Both 2^4 and 4^2 result in 16. There may be a formula that returns an array of possible whole number answers, but there are going to be cases where you won't know which is the right one.

• 1

##### Share on other sites
520
[-FBS-]  Members
2,646 posts
4,290 battles

Ok, I came up with a different solution, however it involves using a graphing calculator.

Just plot y=25^(1/x) and look at the table. X=your exponent and Y=your base. Just look for when Y is a whole number.

However, I am at a loss because I do not understand the exact situation of our problem.

Edited by saagri
• 1

##### Share on other sites
2,211  Members
7,307 posts
3,304 battles

Maybe this will help:

Your task is to check wheter a given integer is a perfect power. If it is a perfect power, return a pair `m` and `k` with mk = n as a proof. Otherwise return `Nothing`, `Nil`, `null`, `None` or your language's equivalent.

Note: For a perfect power, there might be several pairs. For example `81 = 3^4 = 9^2`, so `(3,4)` and `(9,2)` are valid solutions. However, the tests take care of this, so if a number is a perfect power, return any pair that proves it.

I am writing a python program to find the base and exponent of a power and return it as ain parenthesis. Where I am stuck is the actual formulation of the equation Now that I think about it, using log2 might be why I am having difficulty. I will trying using log as another poster suggested

Edited by 10T0nHammer

##### Share on other sites
468  Members
2,379 posts
4,080 battles

Maybe this will help:

I am writing a python program to find the base and exponent of a power and return it as ain parenthesis. Where I am stuck is the actual formulation of the equation oh, you're doing this in python?

take the log in multiple bases (like the first 10 prime numbers) and then come up with a way of getting the base of the exponent by seeing how the values of the fractional part of different logs converge to 0

Edited by TheSupremeOne34
• 1

##### Share on other sites
520
[-FBS-]  Members
2,646 posts
4,290 battles

Maybe this will help:

I am writing a python program to find the base and exponent of a power and return it as ain parenthesis. Where I am stuck is the actual formulation of the equation Plot Y=(desired number)^(1/x) for x= 0 to 100

Return all values of y that are a whole number.

• 1

##### Share on other sites
185
[-DPF-] Members
774 posts
11,104 battles

Yes, while it doesn't need to be simultaneously, I am only given the power and leaves me with two variables. Solving an equation with multiple varies is pretty difficult so I am using the base of 2 (log2) to replace one of the variables.

Example:

my inputs I'm working with are 4, 25, 49, 81 (just perfect powers I'm using but the number will be randomly generated)

Lets say 81 is put it: 81 = 3^4 but thats only because I know thats the answer. What happens if they give me say 441, I would need to find the exponent and power using a similar process that I used to find the exponent and power of 81.

Not all integer values are natural powers of other integer values, so your general problem statement has no solution.  A prior poster pointed out that you can do a prime factorization to determine if your value is a power of any number other than itself (all primes are only powers of themselves, and in order to be a power of an integer, that integer must be a factor as well).  That still leaves you with a hard problem to determine which factors might be an appropriate base.  Offhand, I do not know a technique for this other than searching the space, but there might be one.

##### Share on other sites
1,324
[NERO]  Members
3,630 posts

Maybe this will help:

I am writing a python program to find the base and exponent of a power and return it as ain parenthesis. Where I am stuck is the actual formulation of the equation Now that I think about it, using log2 might be why I am having difficulty. I will trying using log as another poster suggested

http://cstheory.stackexchange.com/questions/2077/how-to-check-if-a-number-is-a-perfect-power-in-polynomial-time

• 1

##### Share on other sites
468  Members
2,379 posts
4,080 battles

##### Share on other sites
2,211  Members
7,307 posts
3,304 battles

Not all integer values are natural powers of other integer values, so your general problem statement has no solution.

True, part of the program needs to return "None" if the random number that was generated does not have a perfect base and exponent (IE 25 is a perfect power because it has 5 as its base and 2 as its exponent compared to 13 which has 10 as its base and 1.1139 as its exponent)

##### Share on other sites
100  Beta Testers
365 posts
12,391 battles

Maybe this will help:

I am writing a python program to find the base and exponent of a power and return it as ain parenthesis. Where I am stuck is the actual formulation of the equation ...python program.  Why are you assuming you can do it in one "equation"?  Build a factorization algorithm!  Make it recursive - "divide by 2, if an integer, factorize it, otherwise multiply by 2 and divide by 3..." - that returns a list of factors, then add a check to the list of factors that compares the number of each factor involved - if they're equal, you have a perfect power.

##### Share on other sites
6,113
[FOXEH]  Banned
14,364 posts
23,318 battles

I am going to sit down on a log, and drink a beer. (calculate =1)

and then possibly another (calculate = 2)

and then pass out (calculate = thump)

##### Share on other sites
2,211  Members
7,307 posts
3,304 battles

...python program.  Why are you assuming you can do it in one "equation"?  Build a factorization algorithm!  Make it recursive - "divide by 2, if an integer, factorize it, otherwise multiply by 2 and divide by 3..." - that returns a list of factors, then add a check to the list of factors that compares the number of each factor involved - if they're equal, you have a perfect power.

Ill be 100% honest, I was trying to go with the simplest to read/write. Best practices and all

and maybe a little too lazy to write that much Edited by 10T0nHammer

##### Share on other sites
468  Members
2,379 posts
4,080 battles

Ill be 100% honest, I was trying to go with the simplest to read/write. Best practices and all

and maybe a little too lazy to write that much from a computational standpoint, his is simpler. he is only using div and mul operations inside a for loop. If done properly, this program could be like 10 lines in x-86 assembly
Edited by TheSupremeOne34

##### Share on other sites
468  Members
2,379 posts
4,080 battles

so, here's what I'd do

start with the fermat primality test so that you're not wasting too much time.

okay, now, take your number and run divisions on it by number n until this happen

a=0 (mod n)

now, we have to prove n is the base of a.

if logna is a whole number you're good.

n is the base and the output of the log is the power

if not, increment n and run your modular check again

looks like.... two/three for loops to me

Edited by TheSupremeOne34
• 1