Shop OBEX P1 Docs P2 Docs Learn Events
Exponet on BS2 !! ? — Parallax Forums

Exponet on BS2 !! ?

ArchiverArchiver Posts: 46,084
edited 2001-04-06 15:25 in General Discussion
How would you do this:

X^(-0.938) (where ^ is 'raised to' and not 'or')

on the BS2 ??

I have had no luck getting the ^ part.


thanks!

Mike,

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-04-05 20:25
    I don't think you can. You're trying to use a floating point exponent.
    Basic Stamps can't do floating point.

    You could do something like X^2 or X^3

    Paul

    >
    Original Message
    > From: Mike [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=BFx5psmRVnJm0iCrIW7HlE3Z0PA-9X3K472oN0nFLt9IoxIW_JcSq5hQsVFfi1zr1aJl_-hV]silo@c...[/url
    > Sent: Thursday, April 05, 2001 1:20 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Exponet on BS2 !! ?
    >
    >
    > How would you do this:
    >
    > X^(-0.938) (where ^ is 'raised to' and not 'or')
    >
    > on the BS2 ??
    >
    > I have had no luck getting the ^ part.
    >
    >
    > thanks!
    >
    > Mike,
    >
    >
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-05 20:34
    does X**(-0.938) work?

    Original Message


    > How would you do this:
    >
    > X^(-0.938) (where ^ is 'raised to' and not 'or')
    >
    > on the BS2 ??
    >
    > I have had no luck getting the ^ part.
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-05 21:33
    You won't be able to do this directly. However, check out the PAK-II at the
    address below.

    You can do this with logarithm tables, but with integer math it doesn't make
    a lot of sense to do so.

    Al Williams
    AWC
    *Floating point math for the Stamp, PIC, SX, or any microcontroller:
    http://www.al-williams.com/awce/pak1.htm


    >
    Original Message
    > From: Mike [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=qJWOD9eQpgUSsJzocSpJKWQL3aX_RvWWCrHp16ePEOXJJqYJkRmRmVoFxyzBL6lTnH4wQ1n9aw]silo@c...[/url
    > Sent: Thursday, April 05, 2001 2:20 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Exponet on BS2 !! ?
    >
    >
    > How would you do this:
    >
    > X^(-0.938) (where ^ is 'raised to' and not 'or')
    >
    > on the BS2 ??
    >
    > I have had no luck getting the ^ part.
    >
    >
    > thanks!
    >
    > Mike,
    >
    >
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-06 00:45
    You might try Jack Crenshaw's book _Math Toolkit for Real-Time Programming_,
    (c) 2000 by CMP Books, ISBN: 1-929629-09-5. Along with other topics, he
    treats logarithms and exponentials on integer-based processors. In any
    case, his book is a fascinating read.

    Regards,
    Daniel McGlothin

    Original Message
    From: Mike [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=NxsMFsVUFuAdVnrewoDg3gnXMMIMU6u8fSrm2dwomFijXjBCapA55zTMDCh0OWxNTx00SfkUSQY]silo@c...[/url
    Sent: Thursday, April 05, 2001 3:20 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Exponet on BS2 !! ?


    How would you do this:

    X^(-0.938) (where ^ is 'raised to' and not 'or')

    on the BS2 ??

    I have had no luck getting the ^ part.


    thanks!

    Mike,




    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-06 02:23
    >You might try Jack Crenshaw's book _Math Toolkit for Real-Time Programming_,
    >(c) 2000 by CMP Books, ISBN: 1-929629-09-5. Along with other topics, he
    >treats logarithms and exponentials on integer-based processors. In any
    >case, his book is a fascinating read.
    >
    >Regards,
    >Daniel McGlothin

    Hi Daniel,

    I agree that Crenshaw's book is really good. But there is not really
    much there for integer processors on the level of the BASIC Stamp.
    The book mostly assumes that your processor can do floating point as
    a basis for the higher functions. He favors _clever_ use of
    convergent series.

    For logs and exponentials, the exception is his integer bitlog
    function. I put a BS2 implementation of that on my Web page at
    http://www.emesys.com/BS2math3.htm
    I see that there is no reference to bitlog in my index at the top of
    the page, but the material comes before the stuff on other ways to do
    the logarithm. The page also has a numerical (not power series)
    approach that comes from Donald Knuth's book.

    I was surprised that there is nothing about CORDIC algorithms in
    Crenshaw's book, surprising because that is the approach used by
    practically every good calculator in existence. (Including Al's
    PAKs) Al turned me on to the power of the CORDICs.


    -- best regards
    Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
    mailto:tracy@e...
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-06 02:58
    Thanks, Tracy, for reminding me of your math pages. As for Crenshaw's
    bitlog, I enjoyed the story of his "discovery" as much as the function
    itself. It reminds me that I'm glad for the giants who have went before,
    giving us things such as math libraries.

    Regards,
    Daniel McGlothin



    > For logs and exponentials, the exception is his integer bitlog
    > function. I put a BS2 implementation of that on my Web page at
    > http://www.emesys.com/BS2math3.htm
    > I see that there is no reference to bitlog in my index at the top of
    > the page, but the material comes before the stuff on other ways to do
    > the logarithm.
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-06 15:25
    > Date: Thu, 05 Apr 2001 19:19:59 -0000
    > From: "Mike" <silo@c...>
    >
    > How would you do this:
    > X^(-0.938) (where ^ is 'raised to' and not 'or')
    > on the BS2 ??

    I would dust off the old calculus 101
    book and try a Taylor expansion:

    f(x)=f(a) + (x-a)*f'(a)/1! + (x-a)^2*f''(a)/2! + .....
    where f'(a) is the derivative of f(x) at x=a, etc.

    I would try expanding f(x)=x^0.062 around a=1
    since x^(-0.938)=(x^0.062)/x. Two or three terms
    might be enough depending on the
    accuracy and range you require.

    You might want to scale the fractions up by 256
    and use the */ scaling multiplier. It will
    be tricky to avoid overflows!

    The boring details are
    "left as an exercise for the student" ;-)

    Ciao,

    Dave
    The Cheap Seismometer Project
    http://www.infiltec.com/seismo/
Sign In or Register to comment.