Maths help please!
Moderator: Jon O'Neill
Maths help please!
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...
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...
- Kai Laddiman
- Fanatic
- Posts: 2314
- Joined: Wed Oct 15, 2008 3:37 pm
- Location: My bedroom
Re: Maths help please!
That's odd, I've never really considered doing that without programming. There's probably an Egyptian technique somewhere, I'll have a look.
16/10/2007 - Episode 4460
Dinos Sfyris 76 - 78 Dorian Lidell
Proof that even idiots can get well and truly mainwheeled.
Dinos Sfyris 76 - 78 Dorian Lidell
Proof that even idiots can get well and truly mainwheeled.
Re: Maths help please!
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.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.
- Ian Fitzpatrick
- Devotee
- Posts: 620
- Joined: Sat Jan 31, 2009 12:23 pm
- Location: Wimborne, Dorset
Re: Maths help please!
Just trying to wind up these old cogs of mine and I think it's done like this: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...
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 thought I was good at Countdown until I joined this forum
Re: Maths help please!
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!Ian Fitzpatrick wrote:Just trying to wind up these old cogs of mine and I think it's done like this: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...
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!!!!!!!!!
- Michael Wallace
- Racoonteur
- Posts: 5458
- Joined: Mon Jan 21, 2008 5:01 am
- Location: London
Re: Maths help please!
You said you wanted to calculate a given b, not b given a...Jon Corby wrote: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!Ian Fitzpatrick wrote:Just trying to wind up these old cogs of mine and I think it's done like this: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...
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!!!!!!!!!
- Kai Laddiman
- Fanatic
- Posts: 2314
- Joined: Wed Oct 15, 2008 3:37 pm
- Location: My bedroom
Re: Maths help please!
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.Michael Wallace wrote:You said you wanted to calculate a given b, not b given a...
16/10/2007 - Episode 4460
Dinos Sfyris 76 - 78 Dorian Lidell
Proof that even idiots can get well and truly mainwheeled.
Dinos Sfyris 76 - 78 Dorian Lidell
Proof that even idiots can get well and truly mainwheeled.
-
- Post-apocalypse
- Posts: 13315
- Joined: Mon Jan 21, 2008 10:37 pm
Re: Maths help please!
a = 2 ^ b
Re: Maths help please!
Haha, oh yeah. I obviously meant the other way around.Michael Wallace wrote:You said you wanted to calculate a given b, not b given a...
Re: Maths help please!
You could simplify that further;Kai Laddiman wrote: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.Michael Wallace wrote:You said you wanted to calculate a given b, not b given a...
a=e^(2*lnb)
=e^(lnb*2)
=(e^lnb)^2
=b^2
Not that that's any help to the OP.
- Charlie Reams
- Site Admin
- Posts: 9494
- Joined: Fri Jan 11, 2008 2:33 pm
- Location: Cambridge
- Contact:
Re: Maths help please!
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.Kai Laddiman wrote: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.Michael Wallace wrote:You said you wanted to calculate a given b, not b given a...
- Ian Volante
- Postmaster General
- Posts: 3967
- Joined: Wed Sep 03, 2008 8:15 pm
- Location: Edinburgh
- Contact:
Re: Maths help please!
I'm also dredging up old maths memories, but can you do:Ian Fitzpatrick wrote:Just trying to wind up these old cogs of mine and I think it's done like this: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...
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!!!!!!!!!
b=(log a)/log 2
b=log a (log to the base 2)
Very helpful of course.
Last edited by Ian Volante on Fri Jan 14, 2011 6:27 pm, edited 1 time in total.
meles meles meles meles meles meles meles meles meles meles meles meles meles meles meles meles
- Kai Laddiman
- Fanatic
- Posts: 2314
- Joined: Wed Oct 15, 2008 3:37 pm
- Location: My bedroom
Re: Maths help please!
Oops, went wrong there, sorry. It's sort of irrelevant now that Corby's changed his initial question anyway.Charlie Reams wrote: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.Kai Laddiman wrote: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.Michael Wallace wrote:You said you wanted to calculate a given b, not b given a...
16/10/2007 - Episode 4460
Dinos Sfyris 76 - 78 Dorian Lidell
Proof that even idiots can get well and truly mainwheeled.
Dinos Sfyris 76 - 78 Dorian Lidell
Proof that even idiots can get well and truly mainwheeled.