Page 1 of 1

Maths help please!

Posted: Thu Jan 13, 2011 4:25 pm
by Jon Corby
Okay, I'm having a blank moment. It feels like there should be a very easy answer to this, but possibly not.

If I've got this set of data where a = 2^b, how do I determine the value of a if I'm given b? Is there an easy formula or do I have to use calculus or something like that? I can obviously do it in a loop with code (which is what I'm about to do, as it won't really ever have to do more than about a dozen iterations to get near enough to the answer to be usable, so it's not a huge overhead), but I wondered if there was a neater way and it bugs me that I should probably know how to do it...

Re: Maths help please!

Posted: Thu Jan 13, 2011 4:43 pm
by Kai Laddiman
That's odd, I've never really considered doing that without programming. There's probably an Egyptian technique somewhere, I'll have a look.

Re: Maths help please!

Posted: Thu Jan 13, 2011 4:50 pm
by Jon Corby
Kai Laddiman wrote:That's odd, I've never really considered doing that without programming. There's probably an Egyptian technique somewhere, I'll have a look.
Oh okay, I assumed I was being dim. I was just a bit annoyed looking at such a simple set of data (actually my real data wasn't quite so simple, but the same principle applied) that I couldn't work out a simple formula. Maybe there isn't one then.

Re: Maths help please!

Posted: Thu Jan 13, 2011 4:51 pm
by Ian Fitzpatrick
Jon Corby wrote:Okay, I'm having a blank moment. It feels like there should be a very easy answer to this, but possibly not.

If I've got this set of data where a = 2^b, how do I determine the value of a if I'm given b? Is there an easy formula or do I have to use calculus or something like that? if there was a neater way and it bugs me that I should probably know how to do it...
Just trying to wind up these old cogs of mine and I think it's done like this:
Take logs of both sides:
log a = b*log 2
therefore
b=(log a)/log 2

Hope that helps, it's been a long long time!!!!!!!!!

Re: Maths help please!

Posted: Thu Jan 13, 2011 4:59 pm
by Jon Corby
Ian Fitzpatrick wrote:
Jon Corby wrote:Okay, I'm having a blank moment. It feels like there should be a very easy answer to this, but possibly not.

If I've got this set of data where a = 2^b, how do I determine the value of a if I'm given b? Is there an easy formula or do I have to use calculus or something like that? if there was a neater way and it bugs me that I should probably know how to do it...
Just trying to wind up these old cogs of mine and I think it's done like this:
Take logs of both sides:
log a = b*log 2
therefore
b=(log a)/log 2

Hope that helps, it's been a long long time!!!!!!!!!
Wow, you're a genius! That does help in that it shows me how it's done, makes me feel a bit better for not being able to work it out myself (despite being a little bit mathsy, I can't think I actually know how to use logarithms anywhere), but I'll actually leave my code as it is (with the loop) as it's much easier to follow and tinker with. Thanks though!

Re: Maths help please!

Posted: Thu Jan 13, 2011 5:02 pm
by Michael Wallace
Jon Corby wrote:
Ian Fitzpatrick wrote:
Jon Corby wrote:Okay, I'm having a blank moment. It feels like there should be a very easy answer to this, but possibly not.

If I've got this set of data where a = 2^b, how do I determine the value of a if I'm given b? Is there an easy formula or do I have to use calculus or something like that? if there was a neater way and it bugs me that I should probably know how to do it...
Just trying to wind up these old cogs of mine and I think it's done like this:
Take logs of both sides:
log a = b*log 2
therefore
b=(log a)/log 2

Hope that helps, it's been a long long time!!!!!!!!!
Wow, you're a genius! That does help in that it shows me how it's done, makes me feel a bit better for not being able to work it out myself (despite being a little bit mathsy, I can't think I actually know how to use logarithms anywhere), but I'll actually leave my code as it is (with the loop) as it's much easier to follow and tinker with. Thanks though!
You said you wanted to calculate a given b, not b given a...

Re: Maths help please!

Posted: Thu Jan 13, 2011 8:16 pm
by Kai Laddiman
Michael Wallace wrote:You said you wanted to calculate a given b, not b given a...
I can't remember much about logarithms, but I think that means ln a = 2 * ln b => a = e^(2 * ln b). You might want to check that.

Re: Maths help please!

Posted: Thu Jan 13, 2011 8:27 pm
by Gavin Chipper
a = 2 ^ b

Re: Maths help please!

Posted: Fri Jan 14, 2011 8:26 am
by Jon Corby
Michael Wallace wrote:You said you wanted to calculate a given b, not b given a...
Haha, oh yeah. I obviously meant the other way around.

Re: Maths help please!

Posted: Fri Jan 14, 2011 10:30 am
by JackHurst
Kai Laddiman wrote:
Michael Wallace wrote:You said you wanted to calculate a given b, not b given a...
I can't remember much about logarithms, but I think that means ln a = 2 * ln b => a = e^(2 * ln b). You might want to check that.
You could simplify that further;
a=e^(2*lnb)
=e^(lnb*2)
=(e^lnb)^2
=b^2

Not that that's any help to the OP.

Re: Maths help please!

Posted: Fri Jan 14, 2011 11:30 am
by Charlie Reams
Kai Laddiman wrote:
Michael Wallace wrote:You said you wanted to calculate a given b, not b given a...
I can't remember much about logarithms, but I think that means ln a = 2 * ln b => a = e^(2 * ln b). You might want to check that.
Definitely something wrong here, I'm not sure how you got the first expression. a=b^2 is obviously not consistent with a=2^b which you started with.

Re: Maths help please!

Posted: Fri Jan 14, 2011 1:11 pm
by Ian Volante
Ian Fitzpatrick wrote:
Jon Corby wrote:Okay, I'm having a blank moment. It feels like there should be a very easy answer to this, but possibly not.

If I've got this set of data where a = 2^b, how do I determine the value of a if I'm given b? Is there an easy formula or do I have to use calculus or something like that? if there was a neater way and it bugs me that I should probably know how to do it...
Just trying to wind up these old cogs of mine and I think it's done like this:
Take logs of both sides:
log a = b*log 2
therefore
b=(log a)/log 2

Hope that helps, it's been a long long time!!!!!!!!!
I'm also dredging up old maths memories, but can you do:

b=(log a)/log 2
b=log a (log to the base 2)

Very helpful of course.

Re: Maths help please!

Posted: Fri Jan 14, 2011 4:50 pm
by Kai Laddiman
Charlie Reams wrote:
Kai Laddiman wrote:
Michael Wallace wrote:You said you wanted to calculate a given b, not b given a...
I can't remember much about logarithms, but I think that means ln a = 2 * ln b => a = e^(2 * ln b). You might want to check that.
Definitely something wrong here, I'm not sure how you got the first expression. a=b^2 is obviously not consistent with a=2^b which you started with.
Oops, went wrong there, sorry. It's sort of irrelevant now that Corby's changed his initial question anyway.