exponent math


Closed Thread
Results 1 to 5 of 5

Thread: exponent math

  1. #1
    Stump's Avatar
    Stump Guest

    Default exponent math

    Greetings all
    Is it at all possible to calculate the following...
    answer= ((a+b)^1.15) using pbp?

    (sum of a+b to the power of 1.15)

    chip used is 18F6720
    Thank you
    Ron

  2. #2
    Join Date
    Mar 2005
    Location
    Cocoa, Florida
    Posts
    42


    Did you find this post helpful? Yes | No

    Default Re: exponent math

    Me too.

    Bit late (15 years), but the same problem. I need to generate an exponential decay and PBP has no ^/exp function.

    There are several ways to do this, but none of them are particularly quick, which is also a complaint of most built-in exp functions. I think, when we get this right, the fastest answer is a lookup table/array approach.

    https://nic.schraudolph.org/bib2html...audolph99.html

    https://codingforspeed.com/using-fas...approximation/

    This doesn't seem too difficult so will try implementing this.

    double exp1(double x) {
    x = 1.0 + x / 256.0;
    x *= x; x *= x; x *= x; x *= x;
    x *= x; x *= x; x *= x; x *= x;
    return x;
    }

  3. #3
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: exponent math

    The line:
    Code:
    x = 1.0 + x / 256.0;
    casts it as floating point. If you haven't used floating point math, you have your research cut out for you.

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: exponent math

    Just create lookup table, with linear interpolation.
    I found it to be simplest and fastest way.
    I successfully created this function https://en.wikipedia.org/wiki/Mean_kinetic_temperature (second function)
    Using only 2 lookup tables, and linear approximation.
    Mel posted years ago example to create sin function with 2 decimal places, using only integer numbers.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: exponent math

    Quote Originally Posted by mpgmike View Post
    The line:

    casts it as floating point. If you haven't used floating point math, you have your research cut out for you.
    its a double precision 64 bit float too boot

Similar Threads

  1. Resolution integer math assistance?
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th January 2010, 04:01
  2. Line Graph, math problem...
    By TerdRatchett in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th May 2009, 05:20
  3. PBPL Math...new math takes more cycles...Always?
    By skimask in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2008, 11:22
  4. PIC18Fxx math 24 & 32 bit
    By ronsimpson in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd December 2006, 13:52
  5. not quite understanding the MATH function
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th January 2006, 21:20

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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