[Solved] X as the exponent

What's the process for solving for X when it's the exponent?

3 ^ X = 9 I know X = 2.

But 5 ^ X = 18 ?

Take logs of both sides, take the exponent to the front (I forget which law number that is), solve for exponent

Edit....

log (5^x) = log 18

x log5 = log 18

x = log 18 / log 5

You could work it out in code: 5^1 = 5 5^2 = 25 take 1/2 the difference, add to lower number, test again. 5^1.5 = 11.18 5^1.75 = 16.71 5^1.875 = 20.44 5^1.8125 = 18.48 5^1.78125 = 17.58 5^1.796875 = 18.03 - close enough?

x = log 18 / log 5 = 1.255272 / 0.69897 = 1.7958889 ==> so crossroads algorithm works ...

You could work it out in code

Newton's Method?

Is that what it's called? I may have known that at some point at some programming class in college 25+ years ago ...

5 ^ x = 18 It's the 5th root of 18, I guess. My calculator comes up with 1.782602458, but punching that back in gives me 17.61917819

2 ^ X = 8 The cube root 8 is 2.

2 ^ X = 32 The fifth root of 32 is 2.

How would I write that equation as a programme line [ X = ... ]

[quote author=Runaway Pancake link=topic=166748.msg1242487#msg1242487 date=1368729569] How would I write that equation as a programme line [ X = ... ] [/quote]

..... X = log 18 / log 5

Its called bisection method - http://en.wikipedia.org/wiki/Bisection_method -

Newton(-Raphson) method is much faster - http://en.wikipedia.org/wiki/Newton%27s_method - it uses the first derivative which may be difficult to find

robtillaart: Its called bisection method - http://en.wikipedia.org/wiki/Bisection_method -

Newton(-Raphson) method is much faster - http://en.wikipedia.org/wiki/Newton%27s_method - it uses the first derivative which may be difficult to find

But why use a numerical method when there's a pure maths solution in the first place, using logs?

Edit.... unless "log" isn't implemented in Arduino's C?

My calculator comes up with 1.782602458

Mine says 1.7958888947 and reversing the operation gives exactly 18.

To solve a^x=b for x,

x = log(b)/log(a);

There are some special cases. When a=10 you are solving for the base-10 log of b because x=log(b)/log(a) -> log(b)/log(10) -> log(b)/1 -> log(b) If a = e then you are solving for the natural log in which case you can use x=ln(b)/ln(e) -> ln(b)

Pete

Thanks for the Replies, everyone.

el_supremo: Mine says 1.7958888947 and reversing the operation gives exactly 18.

I got the "1.782602458" on two different TI-brand calculators. It's a little bit off, so I pumped it up to 1.79 on my own and got a lot closer, which prompted me to put it up to the forum.

X = log 18 / log 5 : x = log(b)/log(a); gave lots better results on the calculator.

5 ^ x = 18 It's the 5th root of 18, I guess.

No, the 5th root of 18 would be the solution to x^5 = 18

That makes better sense, westfw.

I have two versions of this calculator, TI-30.
The keys on the newer one that I have at work are labelled differently. The older one has a key labelled with “y to the x” and its shift is “x-th root of y” while the newer one has a circumflex for the former and the latter is a shift on a different key.
No matter here, wrong “solution”.

in re. 5 ^ x = 18
On one site I looked at they had
x = log 18 / log 5
x = 1.255273 / 0.69897
x = 1.7958897
5 ^ 1.7958897 = 18.000022,

but another had
x = ln 18 / ln 5
x = 2.890372 / 1.609438
x = 1.795889
x = 18.00000153

And:

x = log2 18 / log2 5
x = 4.169925001442312 / 2.321928094887362
x = 1.79588894704536
etc., etc.

JimboZA had it right way back in the first reply.

Take logs of both sides, take the exponent to the front, solve for exponent

See “rule 4” here: Mathwords: Logarithm Rules

5 ^ X = 18
log(5^x) = log(18)
x * log(5) = log(18)
x = log(18)/log(5)

Or you can think:
5^x = 18
logbase5(5^x) = logbase518
x = logbase518
and then use the “change of base” forumla (rule 5 at the above page.)