ExpX? How is the math done?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: ExpX? How is the math done?

  1. #1
    Join Date
    Dec 2004
    Posts
    3

    ExpX? How is the math done?

    The following is what my output has to be. Well, minus the numbers obviously. I have to enter an integer for x, than n and than get an answer. Now, I'm really confused. How exactly is the math done? If I enter 5 for x and 6 for n, how do I get 26.041666?


    [phps-Computer:~] php% javac ExpX.java
    [phps-Computer:~] php% java ExpX

    enter an integer for x: 5

    enter an integer for n: 6
    E(5) using n =6 terms is: 26.041666666666668

    [phps-Computer:~] php% java ExpX

    enter an integer for x: 34

    enter an integer for n: 3
    E(34) using n =3 terms is: 578.0

    [phps-Computer:~] php% java ExpX

    enter an integer for x: 12

    enter an integer for n: 9
    E(12) using n =9 terms is: 10664.228571428572

    [phps-Computer:~] php% java ExpX

    enter an integer for x: 5

    enter an integer for n: -4
    service not available
    [phps-Computer:~] php% java ExpX

    enter an integer for x: 3

    enter an integer for n: 6
    E(3) using n =6 terms is: 2.025

  2. #2
    Join Date
    Sep 2004
    Posts
    150
    Definition of e

    Exponential function

    Here is what Java's exp method does:

    static double exp(double a)
    Returns Euler's number e raised to the power of a double value.


    Without the code it's impossible to say what yours is doing. My guess is your program is calculating 'E' using varying degrees of accuracy (with variable n). Normally you would expect them to raise 'x' to the E power. Where E is calculated to the 'n'th accuracy.

    When I tested it though with your examples, the results didn't match up. So, in short, without the code it's just guessing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center