Results 1 to 4 of 4

Thread: Exponentiation with real numbers.

  1. #1

    Exponentiation with real numbers.

    Hi, everyone. I'm currently working on a little fun program. Basically it just does some computing with input values, that's not the point anyway. My problem is that I can't write the function that I need.

    I need a function like this:

    Function exp(x,y:real):real;

    And it would return the value of x^y. Note that y is real, not an integer so a simple for loop will not do it, if I want to calculate 5.678^4.350. Basically it would be 5.678^(4350/1000)=5.678^(87/20) So that means (5.678^87) under the root with an exponent of 20. But I have no idea how would I calculate that. I've searched some forums but haven't been able to find a working solution yet.

    Oh... FYI I have Free Pascal. Thanks, in advance!

  2. #2
    What you are asking for is not "exponentiation", but "power of". Exponentiation is to calculate the exponent of a number, that is, e^x or "the number e to the power x", being e a mathematical constant (wiki).

    Math unit has function Power that does what you are looking for. If you need to build the function by your self, download RTL sources and look in them.
    Last edited by Ñuño Martínez; 16-12-2012 at 05:22 PM.
    No signature provided yet.

  3. #3
    Yeah, sorry my english is not that great when it comes to the name of exact math functions. I just used the google translator. Thanks a lot, it should be working fine now

  4. #4
    there's a way to calculate power of a number using logarithms, natural ones, if you want to do x^y you wrote exp(ln(x)*y), works with integers, floating point, negatives.

Bookmarks

Posting Permissions

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