Results 1 to 9 of 9

Thread: Solve x^x=k..where k is a constant

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    20

    Question Solve x^x=k..where k is a constant

    if x is a variable... then how do we solve x^x=k.... where k is a real number???
    is there any viable and structural method for it....other than trial and error
    Last edited by The Godfather; Jun 9th, 2005 at 02:04 PM.

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Solve x^x=k..where k is a constant

    To my mind there are only 2 solutions. x=0 and x=1 both yielding k=1 as the answer. I don't know how to prove this though.
    I don't live here any more.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    20

    Re: Solve x^x=k..where k is a constant

    i mean k is a real number for exambple... 2^2=4....3^3=27.......2.s^2.5=something i dunno... so on..

  4. #4
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Smile Re: Solve x^x=k..where k is a constant

    Sure - you should be able to use Newton's method to iteratively find a solution. I'm doing this from memory, so I apologize if I get something wrong.

    you basically want to find the solution to the problem:

    x^x - C = 0

    Where C is the constant. With Newton's method, you make a guess at the solution, evaluate the equation and derivative (slope) at the guess, then update the guess based on the derivative, and so on. I'd go further, but my math is rusty enough that I don't remember how to differentiate y = x^x with respect to x.

    See attachment for graphical representation for C = 300. Newton's method is of a 'shooting' type, so the closer you are the faster it arrives at the solution. Also, from the nature of x^x, an initial guess that's too high is much better than guessing too low.

    Edit - this link should help figure out the derivative of x^x:

    http://mathcentral.uregina.ca/QQ/dat...04/kunle1.html

    VBAhack
    Attached Images Attached Images
    Last edited by VBAhack; Jun 9th, 2005 at 03:34 PM.

  5. #5
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Solve x^x=k..where k is a constant

    Hi,

    I don't think differentiation is the way forward, d/dx (x^2 - C) gives 2x =0.

    Try the bisection method: pick an initial start point A (do it based on the number of digits in C so that you aren't starting at 1 and trying to find 1000000) and square it, checking to see if it is bigger than C. If so, halve it (B), square and check again. If B is smaller than C, go halfway in between A and B, square and check again. Repeat until you find the number to as many dp as you want.

    Basically, you guess each time halfway between a number definitely smaller than x and a number definitely larger than x. If a guess does not give you x, then it gives you a number either smaller (in which case this is your new lower bound) or larger (in which case this is your new upper bound). You can narrow it down in as many iterations as you want.


    zaza

  6. #6
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: Solve x^x=k..where k is a constant

    The equation was x^x - C = 0, not x^2 - C = 0. Even if it were, Newton's method still works. In your case, 2x just represents the slope of the function at x. The methodology is identical in either case. Bi-section also works, is more stable for 'ill-behaved' functions (lots of min and max points), but it is much slower to converge. Newton's method converges very rapidly, and is ideal for well behaved (i.e. smooth) functions like this. I've used Newton's Method (Newton-Raphson, actually) to solve a set of 7 non-linear equations and it was almost magical in how quickly it converged.

    VBAhack

    Edit: the following link has a good explanation of Newton's method:

    http://numbers.computation.free.fr/C...ms/newton.html

    The basic equation is:

    xnew = xold - f(xold)/f'(xold)

    where xold is the current/old/initial guess of the solution, and xnew is the updated guess.
    Last edited by VBAhack; Jun 11th, 2005 at 11:56 PM.

  7. #7
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: Solve x^x=k..where k is a constant

    Got it. The derivative of x^x is (x^x)(1+ln(x)). The solution to x^x = 256 (solution is 4) is attached using Newton's Method and bi-section. Initially, bi-section converges faster then Newton, but after the 17th iteration, Newton converges extremely rapidly whereas bi-section still keeps plodding away. (see page 2). Newton's Method is a very good technique.

    VBAhack
    Attached Images Attached Images
    Last edited by VBAhack; Jun 11th, 2005 at 11:53 PM.

  8. #8
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Solve x^x=k..where k is a constant

    Oh yes. Whoops, my mistake. Didn't realise you meant Newton-Raphson (duh).

    zaza

  9. #9
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: Solve x^x=k..where k is a constant

    Zaza, no worries.

    So, Godfather,

    Now you've got at least 2 methods to choose from to solve x^x = C, each with pros/cons. Bi-section is computationally simple (function evaluation only), is very stable (won't diverge), but converges slowly (linearly?). Newton's method is more computationally expensive (function evaluation and derivative), can diverge if the intitial guess isn't 'close enough', but converges rapidly (quadratically) when close to the solution.

    Pick your poison.

    VBAhack

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width