comp.lang.ada
 help / color / mirror / Atom feed
* Re: Ada83 Exponentiation HELP !!!
  1999-12-13  0:00 Ada83 Exponentiation HELP !!! jxredi
  1999-12-13  0:00 ` Gautier
  1999-12-13  0:00 ` David C. Hoos, Sr.
@ 1999-12-13  0:00 ` DuckE
  1999-12-14  0:00   ` Preben Randhol
  1999-12-19  0:00   ` Robert Dewar
  2 siblings, 2 replies; 8+ messages in thread
From: DuckE @ 1999-12-13  0:00 UTC (permalink / raw)


It's been years since I've dealt with evaluating things like this, but as I
recall 6^(1.3) is equivalent to:

   Exp( 1.3 * Log( 6 ) )

Don't quote me on this, but it's somehting like that.

SteveD

jxredi <jxredi@gecms.com.au> wrote in message
news:831tka$rue$1@tobruk.sydney.gecm.com...
> Can anyone help me with the following  :
>
> I understand that in Ada83,     6^3  is represented as 6**3, where 6 can
be
> int or real,
> and 3 can only be an INTEGER.
>
> So how do I represent in ada83 this .....  -->    6^(1.3) where 1.3 is
type
> REAL.
>
>
> Regards,
> Jxredi.
>
>






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Ada83 Exponentiation HELP !!!
  1999-12-13  0:00 Ada83 Exponentiation HELP !!! jxredi
  1999-12-13  0:00 ` Gautier
@ 1999-12-13  0:00 ` David C. Hoos, Sr.
  1999-12-13  0:00 ` DuckE
  2 siblings, 0 replies; 8+ messages in thread
From: David C. Hoos, Sr. @ 1999-12-13  0:00 UTC (permalink / raw)



jxredi <jxredi@gecms.com.au> wrote in message
news:831tka$rue$1@tobruk.sydney.gecm.com...
> Can anyone help me with the following  :
>
> I understand that in Ada83,     6^3  is represented as 6**3, where 6 can
be
> int or real,
> and 3 can only be an INTEGER.
>
> So how do I represent in ada83 this .....  -->    6^(1.3) where 1.3 is
type
> REAL.
You either need a third-party math library, or possibly your compiler
includes
a math library, or possibly you could interface to the C library.

Since you gave no clue as to the compiler you're using, nor the platform
(Hardware and OS), it's difficult to be more specific with recommendations.

In any case, a function with the signature
function "**"(Left, Right : Real) return Real;
can be implemented, or is implemented in a math library to do this.

With such a function implemented and visible in the current scope, then
you can say 6.0 ** 1.3, or whatever.

Incidentally the Ada language does _not_ define a type Real, so I assume
that Real has been declared somewhere in your code, or in a library you
have mentioned in a context clause.







^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Ada83 Exponentiation HELP !!!
  1999-12-13  0:00 Ada83 Exponentiation HELP !!! jxredi
@ 1999-12-13  0:00 ` Gautier
  1999-12-13  0:00 ` David C. Hoos, Sr.
  1999-12-13  0:00 ` DuckE
  2 siblings, 0 replies; 8+ messages in thread
From: Gautier @ 1999-12-13  0:00 UTC (permalink / raw)


> So how do I represent in ada83 this .....  -->    6^(1.3) where 1.3 is type
> REAL.

Try importing Elementary_functions, instanciating Generic_elementary_functions
(Alsys) or Float_math_lib, Long_float_math_lib (DEC): they have a "**"
for it.

-- 
Gautier

_____\\________________\_______\
http://members.xoom.com/gdemont/




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Ada83 Exponentiation HELP !!!
@ 1999-12-13  0:00 jxredi
  1999-12-13  0:00 ` Gautier
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: jxredi @ 1999-12-13  0:00 UTC (permalink / raw)


Can anyone help me with the following  :

I understand that in Ada83,     6^3  is represented as 6**3, where 6 can be
int or real,
and 3 can only be an INTEGER.

So how do I represent in ada83 this .....  -->    6^(1.3) where 1.3 is type
REAL.


Regards,
Jxredi.






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Ada83 Exponentiation HELP !!!
  1999-12-13  0:00 ` DuckE
@ 1999-12-14  0:00   ` Preben Randhol
  1999-12-19  0:00     ` Robert Dewar
  1999-12-19  0:00   ` Robert Dewar
  1 sibling, 1 reply; 8+ messages in thread
From: Preben Randhol @ 1999-12-14  0:00 UTC (permalink / raw)


"DuckE" <nospam_steved@pacifier.com> writes:

| It's been years since I've dealt with evaluating things like this, but as I
| recall 6^(1.3) is equivalent to:
| 
|    Exp( 1.3 * Log( 6 ) )
                ^^^
Just to make it clear, Log here must be the natural logarithm Ln

Ln(a^b) = b*Ln(a)

a^b = exp(b*Ln(a))       ; a > 0

Isn't this correct?
-- 
Preben Randhol -- [randhol@pvv.org] -- [http://www.pvv.org/~randhol/]     
         "Det eneste trygge stedet i verden er inne i en fortelling." 
                                                      -- Athol Fugard




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Ada83 Exponentiation HELP !!!
  1999-12-13  0:00 ` DuckE
  1999-12-14  0:00   ` Preben Randhol
@ 1999-12-19  0:00   ` Robert Dewar
  1 sibling, 0 replies; 8+ messages in thread
From: Robert Dewar @ 1999-12-19  0:00 UTC (permalink / raw)


In article <3855ab32.0@news.pacifier.com>,
  "DuckE" <nospam_steved@pacifier.com> wrote:
> It's been years since I've dealt with evaluating things like
this, but as I
> recall 6^(1.3) is equivalent to:
>
>    Exp( 1.3 * Log( 6 ) )
>
> Don't quote me on this, but it's somehting like that.


AAARGH! A classical horrible algorithm, designed to maximize
round off error. Don't invent for yourself in floating-point
you will likely blunder if you are not an expert :-)


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Ada83 Exponentiation HELP !!!
  1999-12-14  0:00   ` Preben Randhol
@ 1999-12-19  0:00     ` Robert Dewar
  1999-12-19  0:00       ` Preben Randhol
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Dewar @ 1999-12-19  0:00 UTC (permalink / raw)


In article <m3puw9uacy.fsf@kiuk0156.chembio.ntnu.no>,
  Preben Randhol <randhol@pvv.org> wrote:
> "DuckE" <nospam_steved@pacifier.com> writes:
>
> | It's been years since I've dealt with evaluating things like
this, but as I
> | recall 6^(1.3) is equivalent to:
> |
> |    Exp( 1.3 * Log( 6 ) )
>                 ^^^
> Just to make it clear, Log here must be the natural logarithm
Ln
>
> Ln(a^b) = b*Ln(a)
>
> a^b = exp(b*Ln(a))       ; a > 0
>
> Isn't this correct?


No it is completely wrong. See chapter 5 on IEEE arithmetic
in my microprocessors book if you can find a copy around :-)
In that chapter I use this example to motivate the need for
IEEE extended format, but of course only the ia32 and ia64
architectures provide this in hardware among commonly used
processors, so the above algorithm should almost never be
used. Even if the log and exp routines are last bit accurate
the result of the exponentiation can be very far off being
last bit accurate, and there are perfectly good accurate
algorithms available.h


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Ada83 Exponentiation HELP !!!
  1999-12-19  0:00     ` Robert Dewar
@ 1999-12-19  0:00       ` Preben Randhol
  0 siblings, 0 replies; 8+ messages in thread
From: Preben Randhol @ 1999-12-19  0:00 UTC (permalink / raw)


Robert Dewar <robert_dewar@my-deja.com> writes:

| used. Even if the log and exp routines are last bit accurate
| the result of the exponentiation can be very far off being
| last bit accurate, and there are perfectly good accurate
| algorithms available.h

Do you have a reference to one? It would be interesting to read up.
-- 
Preben Randhol -- [randhol@pvv.org] -- [http://www.pvv.org/~randhol/]     
         "Det eneste trygge stedet i verden er inne i en fortelling." 
                                                      -- Athol Fugard




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1999-12-19  0:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-13  0:00 Ada83 Exponentiation HELP !!! jxredi
1999-12-13  0:00 ` Gautier
1999-12-13  0:00 ` David C. Hoos, Sr.
1999-12-13  0:00 ` DuckE
1999-12-14  0:00   ` Preben Randhol
1999-12-19  0:00     ` Robert Dewar
1999-12-19  0:00       ` Preben Randhol
1999-12-19  0:00   ` Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox