comp.lang.ada
 help / color / mirror / Atom feed
* logarithms on ada
@ 1997-03-02  0:00 Brian R Franklin
  1997-03-04  0:00 ` John McCabe
                   ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: Brian R Franklin @ 1997-03-02  0:00 UTC (permalink / raw)



I can't find this in my ADA manual.  How can I do a logarithm in 
ADA? The compiler doesn't seem to understand  x := log(y);
The compiler complains that log is undefined. It appears in my
main program so I don't think I have to instantiate it. Is there
a mathematics package I need to declare using  "with"?






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

* Re: logarithms on ada
  1997-03-04  0:00 ` Bob Klungle
@ 1997-03-04  0:00   ` Robert Dewar
  1997-03-05  0:00     ` Bob Klungle
  1997-03-05  0:00     ` Doug Smith
  1997-03-05  0:00   ` Jon S Anthony
  1 sibling, 2 replies; 37+ messages in thread
From: Robert Dewar @ 1997-03-04  0:00 UTC (permalink / raw)



iBob Klungle said

<<On GNAT you need
with Ada.Numerics.Aux;>>

this is bad advice. Ada.Numerics.Aux is an internal, non-standard package
that should not be used by user programs. Instead look at the RM and use
the standard math packages.





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

* Re: logarithms on ada
  1997-03-02  0:00 logarithms on ada Brian R Franklin
@ 1997-03-04  0:00 ` John McCabe
  1997-03-06  0:00   ` Robert Dewar
  1997-03-07  0:00   ` Darren C Davenport
  1997-03-04  0:00 ` Bob Klungle
  1997-03-04  0:00 ` Tom Moran
  2 siblings, 2 replies; 37+ messages in thread
From: John McCabe @ 1997-03-04  0:00 UTC (permalink / raw)



gs01brf@panther.Gsu.EDU (Brian R Franklin) wrote:

>I can't find this in my ADA manual.

It's not in the Ada manual.

>How can I do a logarithm in 
>ADA? The compiler doesn't seem to understand  x := log(y);
>The compiler complains that log is undefined. It appears in my
>main program so I don't think I have to instantiate it. Is there
>a mathematics package I need to declare using  "with"?

Yes there probably is and you'll have to read your compiler
documentation to find it.

TLD Ada for example provides a "math" package you need to with which
defines log and log10 functions for various types.


Best Regards
John McCabe <john@assen.demon.co.uk>




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

* Re: logarithms on ada
  1997-03-02  0:00 logarithms on ada Brian R Franklin
  1997-03-04  0:00 ` John McCabe
  1997-03-04  0:00 ` Bob Klungle
@ 1997-03-04  0:00 ` Tom Moran
  2 siblings, 0 replies; 37+ messages in thread
From: Tom Moran @ 1997-03-04  0:00 UTC (permalink / raw)



> Is there
> a mathematics package I need to declare using  "with"?
Yes.  Are you using Ada 95 or Ada 83.  If the latter, what compiler?




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

* Re: logarithms on ada
  1997-03-02  0:00 logarithms on ada Brian R Franklin
  1997-03-04  0:00 ` John McCabe
@ 1997-03-04  0:00 ` Bob Klungle
  1997-03-04  0:00   ` Robert Dewar
  1997-03-05  0:00   ` Jon S Anthony
  1997-03-04  0:00 ` Tom Moran
  2 siblings, 2 replies; 37+ messages in thread
From: Bob Klungle @ 1997-03-04  0:00 UTC (permalink / raw)



Yes. On Verdix systems you need
with Math;

On Meridian you need
with Math_Lib;

On GNAT you need
with Ada.Numerics.Aux;

cheers..bob

> I can't find this in my ADA manual.  How can I do a logarithm in 
> ADA? The compiler doesn't seem to understand  x := log(y);
> The compiler complains that log is undefined. It appears in my
> main program so I don't think I have to instantiate it. Is there
> a mathematics package I need to declare using  "with"?





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

* Re: logarithms on ada
  1997-03-04  0:00 ` Bob Klungle
  1997-03-04  0:00   ` Robert Dewar
@ 1997-03-05  0:00   ` Jon S Anthony
  1 sibling, 0 replies; 37+ messages in thread
From: Jon S Anthony @ 1997-03-05  0:00 UTC (permalink / raw)



In article <01bc293c$68597140$d96f1fcc@p5120.bda> "Bob Klungle" <bklungle@ix.netcom.com> writes:

> implied). There is nothing on the surface or in any documentation that I
> can find that says or implies that ada.numerics.aux in an internal,
> non-standard package. I don't say it isn't, but nothing seems to say it is.
> Anyway, they both work.

It's not defined in the RM.  So, it is non-standard.

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
Belmont, MA 02178
617.484.3383
jsa@organon.com





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

* Re: logarithms on ada
  1997-03-05  0:00     ` Bob Klungle
@ 1997-03-05  0:00       ` David Shochat
  1997-03-05  0:00         ` Robert Dewar
  1997-03-06  0:00         ` Robert A Duff
  0 siblings, 2 replies; 37+ messages in thread
From: David Shochat @ 1997-03-05  0:00 UTC (permalink / raw)



Bob Klungle wrote:
> 
>... There is nothing on the surface or in any documentation that I
> can find that says or implies that ada.numerics.aux in an internal,
> non-standard package. 

Then you must not have the Ada Reference Manual. Elementary functions
are covered in A.5.1. I'd say that if the package is not provided for in
the langauge Standard, then it is non-standard.

It is true that in Ada 83, elementary functions were non-standard, so we
had no choice but to go to vendor-specific packages. But fortunately,
Ada 95 has fixed that.
-- David




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

* Re: logarithms on ada
  1997-03-05  0:00     ` Doug Smith
@ 1997-03-05  0:00       ` Robert Dewar
  1997-03-06  0:00         ` Robert A Duff
  1997-03-06  0:00       ` Robert A Duff
  1 sibling, 1 reply; 37+ messages in thread
From: Robert Dewar @ 1997-03-05  0:00 UTC (permalink / raw)



iDoug Smith said

<<This is a case where beginners have to understand generics and hunt through
the LRM to find simple operations. Of course, I found it easily using
WebAda's Surfing feature <8^O>>

I hope not! Any decent text book should teach you early on in simple
terms how to compute logs etc.





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

* Re: logarithms on ada
  1997-03-05  0:00       ` David Shochat
@ 1997-03-05  0:00         ` Robert Dewar
  1997-03-06  0:00         ` Robert A Duff
  1 sibling, 0 replies; 37+ messages in thread
From: Robert Dewar @ 1997-03-05  0:00 UTC (permalink / raw)



Bob Klungle said

<<Bob Klungle wrote:
>
>... There is nothing on the surface or in any documentation that I
> can find that says or implies that ada.numerics.aux in an internal,
> non-standard package.>>

One way to tell immediately is that this package has a GPL copyright --
we do NOT try to put specs that are in the RM under the GPL.

But in fact this package should really be private, and will be in the
next version of GNAT.





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

* Re: logarithms on ada
  1997-03-06  0:00         ` Robert A Duff
@ 1997-03-05  0:00           ` John McCabe
  1997-03-06  0:00           ` Robert Dewar
                             ` (2 subsequent siblings)
  3 siblings, 0 replies; 37+ messages in thread
From: John McCabe @ 1997-03-05  0:00 UTC (permalink / raw)



bobduff@world.std.com (Robert A Duff) wrote:

<..snip..>
>In grade-school, I was quite sure that (1/3)*3 = 1, exactly.  ;-)
>Of course, in those days, I had the foolish notion that God had not
>deemed 2**31-1 to be equal to infinity.  ;-)

Or even 2^32 to be an odd number! Try this on a casio FX-450 or
FX-450M calculator or various other Casio calculators from the mid
eighties!

>
>- Bob


Best Regards
John McCabe <john@assen.demon.co.uk>




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

* Re: logarithms on ada
  1997-03-04  0:00   ` Robert Dewar
  1997-03-05  0:00     ` Bob Klungle
@ 1997-03-05  0:00     ` Doug Smith
  1997-03-05  0:00       ` Robert Dewar
  1997-03-06  0:00       ` Robert A Duff
  1 sibling, 2 replies; 37+ messages in thread
From: Doug Smith @ 1997-03-05  0:00 UTC (permalink / raw)



In article <dewar.857536154@merv>, dewar@merv.cs.nyu.edu (Robert Dewar) wrote:

> iBob Klungle said
> 
> <<On GNAT you need
> with Ada.Numerics.Aux;>>
> 
> this is bad advice. Ada.Numerics.Aux is an internal, non-standard package
> that should not be used by user programs. Instead look at the RM and use
> the standard math packages.

This is a case where beginners have to understand generics and hunt through
the LRM to find simple operations. Of course, I found it easily using
WebAda's Surfing feature <8^O

<http://sw-eng.falls-church.va.us/cgi-bin/webada/file?template=predefined.html>

or for the reference page only:

<http://sw-eng.falls-church.va.us/AdaIC/compilers/webada/f_predefined.html>

The answer for Float is:
  Ada.Numerics.Elementary_Functions.Log
as in
  function Log     (X           : Float) return Float;
  function Log     (X, Base     : Float) return Float;

Doug
<mailto:dsmith@clark.net>




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

* Re: logarithms on ada
  1997-03-04  0:00   ` Robert Dewar
@ 1997-03-05  0:00     ` Bob Klungle
  1997-03-05  0:00       ` David Shochat
  1997-03-05  0:00     ` Doug Smith
  1 sibling, 1 reply; 37+ messages in thread
From: Bob Klungle @ 1997-03-05  0:00 UTC (permalink / raw)



If a person looks in the /usr/adainclude and reads the documentation in the
prefixes of the spec files, one notes a comment in the ada.numerics.aux to
whit "..One advantage of using this package is that it will interface
directly to hardware instructions, such as those provided on the Intel
80x87." One also notices that the ada.numerics.generic_elementary_functions
package (a-ngelfu.ads) is a generic. For someone who wants speed, the
implication of the above seems to be that the former can be faster (only
implied). There is nothing on the surface or in any documentation that I
can find that says or implies that ada.numerics.aux in an internal,
non-standard package. I don't say it isn't, but nothing seems to say it is.
Anyway, they both work.

cheers...bob

Robert Dewar <dewar@merv.cs.nyu.edu> wrote in article
<dewar.857536154@merv>...
> iBob Klungle said
> 
> <<On GNAT you need
> with Ada.Numerics.Aux;>>
> 
> this is bad advice. Ada.Numerics.Aux is an internal, non-standard package
> that should not be used by user programs. Instead look at the RM and use
> the standard math packages.
> 
> 




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

* Re: logarithms on ada
  1997-03-06  0:00         ` Robert A Duff
                             ` (2 preceding siblings ...)
  1997-03-06  0:00           ` Norman H. Cohen
@ 1997-03-06  0:00           ` Doug Smith
  3 siblings, 0 replies; 37+ messages in thread
From: Doug Smith @ 1997-03-06  0:00 UTC (permalink / raw)



In article <E6Lt30.1Fy@world.std.com>, bobduff@world.std.com (Robert A Duff) wrote:

> In article <dewar.857613145@merv>, Robert Dewar <dewar@merv.cs.nyu.edu> wrote:
> >I hope not! Any decent text book should teach you early on in simple
> >terms how to compute logs etc.
> 
> Really?  I would think students shouldn't be exposed to floating-point
> (and therefore logs and whatnot) until fairly late in the game.  I know
> *I* don't understand floating point arithmetic very well, and I feel
> like I'm above-average in the sense that I *know* I don't understand it
> (as compared to the average programmer who seems to think floating-point
> does (sort of) what we learned in grade school as rational arithmetic).
> In grade-school, I was quite sure that (1/3)*3 = 1, exactly.  ;-)
> Of course, in those days, I had the foolish notion that God had not
> deemed 2**31-1 to be equal to infinity.  ;-)
> 
> - Bob

I've heard education described as a sequence of telling half-truths.
There is no reason to get into the details of Ada model numbers in
the class-room until it comes up or the teacher feels the student is
ready. Plot a log graph. It will look OK. Learn to set loop bounds
using inequalities, when appropriate, to deal with inexact computations.

(Graduate school took all of my assumptions about numbers and tossed
 them out the window! I could just shoot some of those brilliant
 mathematicians that thought it was so clever to "draw outside of
 the lines".)

Now when it's time to program that flight control module, that
engineer had better understand model numbers or let someone else
do it!

Doug
<dsmith@clark.net>




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

* Re: logarithms on ada
  1997-03-06  0:00       ` Robert A Duff
@ 1997-03-06  0:00         ` Andrew Dunstan
  1997-03-10  0:00         ` Doug Smith
  1 sibling, 0 replies; 37+ messages in thread
From: Andrew Dunstan @ 1997-03-06  0:00 UTC (permalink / raw)



Robert A Duff (bobduff@world.std.com) wrote:
: Well, maybe I'm old-fashioned, but there's a more traditional tool that
: also works: look up "log" in the index of the RM, and it will point you
: to the right place.  ;-)

this reminds me of an old joke:

	Q. What is an on-line, real-time, random access storage device?

	A. A book.

cheers

andrew 
(whose son has just started studying computer systems engineering at
the University of Adelaide, including programming in Ada :-) 

--

-------------------------------------------------------------------------
  There's nothing either good or bad, but thinking makes it so - Hamlet
  http://www.gr-lakes.com/~andrew (including PGP key)
  PGP Key fingerprint = 5C 44 7D E4 76 A3 31 DE  3D 11 FA 15 4D 87 1F 5E
-------------------------------------------------------------------------





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

* Re: logarithms on ada
  1997-03-04  0:00 ` John McCabe
@ 1997-03-06  0:00   ` Robert Dewar
  1997-03-07  0:00     ` John McCabe
  1997-03-07  0:00   ` Darren C Davenport
  1 sibling, 1 reply; 37+ messages in thread
From: Robert Dewar @ 1997-03-06  0:00 UTC (permalink / raw)



JOhn McCabe said

<<Yes there probably is and you'll have to read your compiler
documentation to find it.

TLD Ada for example provides a "math" package you need to with which
defines log and log10 functions for various types.>>

This comment is appropriate for Ada 83, but not for Ada 95, where the log
function is standardized, and available in all Ada 95 compilers.





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

* Re: logarithms on ada
  1997-03-06  0:00         ` Robert A Duff
  1997-03-05  0:00           ` John McCabe
  1997-03-06  0:00           ` Robert Dewar
@ 1997-03-06  0:00           ` Norman H. Cohen
  1997-03-08  0:00             ` Robert Dewar
                               ` (2 more replies)
  1997-03-06  0:00           ` Doug Smith
  3 siblings, 3 replies; 37+ messages in thread
From: Norman H. Cohen @ 1997-03-06  0:00 UTC (permalink / raw)



Robert A Duff wrote:
> 
> In article <dewar.857613145@merv>, Robert Dewar <dewar@merv.cs.nyu.edu> wrote:
> >I hope not! Any decent text book should teach you early on in simple
> >terms how to compute logs etc.
> 
> Really?  I would think students shouldn't be exposed to floating-point
> (and therefore logs and whatnot) until fairly late in the game.  I know
> *I* don't understand floating point arithmetic very well

In most applications, you don't have to understand all the subtleties of
floating-point arithmetic to use floating point.  An age-old
introductory programming assignment is to read three floating-point
numbers A, B, and C, and print (approximations of) the solutions to the
quadratic equation A * x**2 + B * x + C = 0.  

Students doing this assignment have to know where to find
Ada.Numerics.Elementary_Functions.Sqrt.  They don't have to know how to
determine convergence of Newton's alogrithm for square roots.

-- 
Norman H. Cohen
mailto:ncohen@watson.ibm.com
http://www.research.ibm.com/people/n/ncohen




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

* Re: logarithms on ada
  1997-03-05  0:00       ` Robert Dewar
@ 1997-03-06  0:00         ` Robert A Duff
  1997-03-05  0:00           ` John McCabe
                             ` (3 more replies)
  0 siblings, 4 replies; 37+ messages in thread
From: Robert A Duff @ 1997-03-06  0:00 UTC (permalink / raw)



In article <dewar.857613145@merv>, Robert Dewar <dewar@merv.cs.nyu.edu> wrote:
>I hope not! Any decent text book should teach you early on in simple
>terms how to compute logs etc.

Really?  I would think students shouldn't be exposed to floating-point
(and therefore logs and whatnot) until fairly late in the game.  I know
*I* don't understand floating point arithmetic very well, and I feel
like I'm above-average in the sense that I *know* I don't understand it
(as compared to the average programmer who seems to think floating-point
does (sort of) what we learned in grade school as rational arithmetic).
In grade-school, I was quite sure that (1/3)*3 = 1, exactly.  ;-)
Of course, in those days, I had the foolish notion that God had not
deemed 2**31-1 to be equal to infinity.  ;-)

- Bob




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

* Re: logarithms on ada
  1997-03-05  0:00     ` Doug Smith
  1997-03-05  0:00       ` Robert Dewar
@ 1997-03-06  0:00       ` Robert A Duff
  1997-03-06  0:00         ` Andrew Dunstan
  1997-03-10  0:00         ` Doug Smith
  1 sibling, 2 replies; 37+ messages in thread
From: Robert A Duff @ 1997-03-06  0:00 UTC (permalink / raw)



In article <dsmith-0503971354380001@dsmith.clark.net>,
Doug Smith <dsmith@clark.net> wrote:
>This is a case where beginners have to understand generics and hunt through
>the LRM to find simple operations. Of course, I found it easily using
>WebAda's Surfing feature ...

Well, maybe I'm old-fashioned, but there's a more traditional tool that
also works: look up "log" in the index of the RM, and it will point you
to the right place.  ;-)

- Bob




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

* Re: logarithms on ada
  1997-03-05  0:00       ` David Shochat
  1997-03-05  0:00         ` Robert Dewar
@ 1997-03-06  0:00         ` Robert A Duff
  1997-03-06  0:00           ` Robert Dewar
  1 sibling, 1 reply; 37+ messages in thread
From: Robert A Duff @ 1997-03-06  0:00 UTC (permalink / raw)



In article <331E0D60.5987@itg-sepg.logicon.com>,
David Shochat  <shochat@itg-sepg.logicon.com> wrote:
>Then you must not have the Ada Reference Manual. Elementary functions
>are covered in A.5.1. I'd say that if the package is not provided for in
>the langauge Standard, then it is non-standard.

True, but one would hope that vendor-specific packages contained
comments explaining whether this is (1) a useful non-standard package
we're providing to users, vs. (2) an internal implementation-specific
thing that no user should ever "with".

This is particularly important for GNAT, since all sources are freely
available, including any implementation-specific gizmos that are not
intended for users, and that might change at the drop of a hat.  I mean,
GNAT users are free to edit the compiler itself if they don't like the
language rules (and they're willing to expend the effort)!

- Bob




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

* Re: logarithms on ada
  1997-03-06  0:00         ` Robert A Duff
  1997-03-05  0:00           ` John McCabe
@ 1997-03-06  0:00           ` Robert Dewar
  1997-03-06  0:00           ` Norman H. Cohen
  1997-03-06  0:00           ` Doug Smith
  3 siblings, 0 replies; 37+ messages in thread
From: Robert Dewar @ 1997-03-06  0:00 UTC (permalink / raw)



Bob Duff said

<<Really?  I would think students shouldn't be exposed to floating-point
(and therefore logs and whatnot) until fairly late in the game.>>

Well it is hard to say what late is, I would certainly expect floating-point
to be covered at some point in a CS1 course.





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

* Re: logarithms on ada
  1997-03-06  0:00         ` Robert A Duff
@ 1997-03-06  0:00           ` Robert Dewar
  0 siblings, 0 replies; 37+ messages in thread
From: Robert Dewar @ 1997-03-06  0:00 UTC (permalink / raw)



Bob Duff said

<<True, but one would hope that vendor-specific packages contained
comments explaining whether this is (1) a useful non-standard package
we're providing to users, vs. (2) an internal implementation-specific
thing that no user should ever "with".
>>

Indeed, and I am right now editing the sources to add comments, and also
make some packages private that were not private before!





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

* Re: logarithms on ada
  1997-03-04  0:00 ` John McCabe
  1997-03-06  0:00   ` Robert Dewar
@ 1997-03-07  0:00   ` Darren C Davenport
  1 sibling, 0 replies; 37+ messages in thread
From: Darren C Davenport @ 1997-03-07  0:00 UTC (permalink / raw)



John McCabe (john@assen.demon.co.uk) wrote:
: gs01brf@panther.Gsu.EDU (Brian R Franklin) wrote:

: >I can't find this in my ADA manual.

: It's not in the Ada manual.

It's in section A.5.1 of the Ada95 RM

Darren




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

* Re: logarithms on ada
  1997-03-06  0:00   ` Robert Dewar
@ 1997-03-07  0:00     ` John McCabe
  1997-03-07  0:00       ` Robert Dewar
  0 siblings, 1 reply; 37+ messages in thread
From: John McCabe @ 1997-03-07  0:00 UTC (permalink / raw)



dewar@merv.cs.nyu.edu (Robert Dewar) wrote:

>JOhn McCabe said
>
><<Yes there probably is and you'll have to read your compiler
>documentation to find it.
>
>TLD Ada for example provides a "math" package you need to with which
>defines log and log10 functions for various types.>>
>
>This comment is appropriate for Ada 83, but not for Ada 95, where the log
>function is standardized, and available in all Ada 95 compilers.
>

You're quite correct, but your comment appears inappropriate to the
original question.

Look at it from this point of view; logarithms are defined as part of
the Ada (1995) language and *are* listed in the Ada 95 Reference
Manual. The original question poser must therefore either be blind or
stupid (or both) to have missed it, yes?

On the other hand, we could consider that the context in which the
question was raised was that of the Ada (1983) language. This would,
in fact, be a very reasonable assumption given that:

1) The Ada Language (and RM) from 1983 does not define a Log function

and

2) Most people (despite what you would like to believe) still use the
1983 definition of the Ada language.

The other option of course is to make no assumptions (as in Tom
Moran's posting) and ask what version is being used!


Best Regards
John McCabe <john@assen.demon.co.uk>




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

* Re: logarithms on ada
  1997-03-07  0:00     ` John McCabe
@ 1997-03-07  0:00       ` Robert Dewar
  1997-03-09  0:00         ` John McCabe
  0 siblings, 1 reply; 37+ messages in thread
From: Robert Dewar @ 1997-03-07  0:00 UTC (permalink / raw)



Johnm McCabe says

<<2) Most people (despite what you would like to believe) still use the
1983 definition of the Ada language.>>

Actually I doubt that is true. It is most certainly true of large commercial
projects using Ada, since such projects adapt only slowly to new technologies.
But the availability of GNAT means that tens of thousands of students around
the world are programming in Ada 95 as we converse :-)

I would be willing to bet that the questioner in this case *was* using
Ada 95!





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

* Re: logarithms on ada
  1997-03-06  0:00           ` Norman H. Cohen
@ 1997-03-08  0:00             ` Robert Dewar
  1997-03-08  0:00             ` Robert Dewar
  1997-03-11  0:00             ` Richard A. O'Keefe
  2 siblings, 0 replies; 37+ messages in thread
From: Robert Dewar @ 1997-03-08  0:00 UTC (permalink / raw)



Robert Duff said

<<> Really?  I would think students shouldn't be exposed to floating-point
> (and therefore logs and whatnot) until fairly late in the game.  I know
> *I* don't understand floating point arithmetic very well>>

I have often introduced floating-point fairly early on. One nice
assignment is the following.

Given a function f, compute its integral using Simpson's rule
using successively smaller intervals to see how smaller intervals
give better accuracy.

be prepared for a lot of infinite loops, this does not cconverge absolutley,
but instead after a while starts to diverge as the error of adding
lots of small numbers becomes more important than the inherent error
in the approximation. The trick is to catch it at the right point, which
means looking at second deriviatives.

Of course students need to know some calculus to do this (and knowing
some calculus is, alas, not the same thing as having got a passing grade
on a calculus class) :-)





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

* Re: logarithms on ada
  1997-03-06  0:00           ` Norman H. Cohen
  1997-03-08  0:00             ` Robert Dewar
@ 1997-03-08  0:00             ` Robert Dewar
  1997-03-11  0:00             ` Richard A. O'Keefe
  2 siblings, 0 replies; 37+ messages in thread
From: Robert Dewar @ 1997-03-08  0:00 UTC (permalink / raw)



Norman Cohen said

<<Students doing this assignment have to know where to find
Ada.Numerics.Elementary_Functions.Sqrt.  They don't have to know how to
determine convergence of Newton's alogrithm for square roots.>>

or even know how many bits of accuracy the square root functoin
provides :-) :-)





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

* Re: logarithms on ada
  1997-03-07  0:00       ` Robert Dewar
@ 1997-03-09  0:00         ` John McCabe
  1997-03-09  0:00           ` Robert Dewar
  0 siblings, 1 reply; 37+ messages in thread
From: John McCabe @ 1997-03-09  0:00 UTC (permalink / raw)



dewar@merv.cs.nyu.edu (Robert Dewar) wrote:

>Johnm McCabe says
>
><<2) Most people (despite what you would like to believe) still use the
>1983 definition of the Ada language.>>
>
>Actually I doubt that is true. It is most certainly true of large commercial
>projects using Ada, since such projects adapt only slowly to new technologies.

I don't think the phrase "..adapt only slowly to new technologies.."
is really appropriate here. Most of the projects I am aware of that
are using Ada are large, long term projects that have been started
before Ada 95 compilers became available en masse (i.e. up to and
including now**).

Generally there will be some capital investment early on in the
project to obtain the relevant development tools and so on (unless
thhey are already available). Unless serious planning for the
introduction of new technology during the lifecycle of a project has
been done, the project will continue and complete using the original
tools and languages. "Adapt"ing to new technology during a project
lifecycle without planning it in detail would be commercial suicide. I
think you'll find it's the organisation rather than the project that
will adapt to new technology, and the rate that this is done depends
on the typical length of project.

**Note - not including GNAT, but how widely used is GNAT in large
safety and mission critical systems?.

>But the availability of GNAT means that tens of thousands of students around
>the world are programming in Ada 95 as we converse :-)

You may be right, but who knows how many people use GNAT? Also, having
worked in industry in the UK for almost 10 years, I find it
interesting the number of graduates in the engineering and computer
science disciplines who have *never* used Ada (83 or 95)!

>I would be willing to bet that the questioner in this case *was* using
>Ada 95!

Well, why don't we ask him! Brian Franklin, if you are still paying
attention to this thread, it would be appreciated if you could let us
know what version of the Ada manual you are referring to, and which
compiler you are using.

Let's wait and see.

Best Regards
John McCabe <john@assen.demon.co.uk>




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

* Re: logarithms on ada
  1997-03-09  0:00         ` John McCabe
@ 1997-03-09  0:00           ` Robert Dewar
  1997-03-10  0:00             ` John McCabe
  0 siblings, 1 reply; 37+ messages in thread
From: Robert Dewar @ 1997-03-09  0:00 UTC (permalink / raw)



John McCabe said

  <<I don't think the phrase "..adapt only slowly to new technologies.."
  is really appropriate here. Most of the projects I am aware of that
  are using Ada are large, long term projects that have been started
  before Ada 95 compilers became available en masse (i.e. up to and
  including now**). >>

Absolutely, that's exactly what I mean by slow to adapt, big projects
don't jump on new technology band wagons fast, and rightly so!

  <<**Note - not including GNAT, but how widely used is GNAT in large
   safety and mission critical systems?.>>

I don't know why GNAT should be excluded in your mind. Many large
mission critical systems are using GNAT. There are relatively few
deployed systems (although there are at least three we know of),
but that is as one would expect for a new technology, as per the
discussion above! A significant number of mission critical projects,
including some safety critical projects have selected GNAT as the
Ada 95 technology of choice. As time goes on we will see more and
more deployed projects using Ada 95 in general, and GNAT in
particular.

  <<You may be right, but who knows how many people use GNAT? Also, having
  worked in industry in the UK for almost 10 years, I find it
  interesting the number of graduates in the engineering and computer
  science disciplines who have *never* used Ada (83 or 95)!>>

Well not-using Ada at all is an interesting issue, but nothing to do with
the subject under discussion. As you say it is hard to know how many
people are using GNAT. But we know it is being used for instruction
in many many universities (virtually all proposals in the most recent
round of Ada curriculum development proposals mentioned GNAT), and it
is used at many universities and military academies.

In addition, we get some indication from the fact that many thousands
of people have picked up more than one version -- a pretty good indication
that they are using it! 





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

* Re: logarithms on ada
  1997-03-10  0:00             ` John McCabe
@ 1997-03-10  0:00               ` Robert Dewar
  1997-03-11  0:00                 ` John McCabe
  0 siblings, 1 reply; 37+ messages in thread
From: Robert Dewar @ 1997-03-10  0:00 UTC (permalink / raw)



John McCabe said

  You misunderstand what I'm saying here - it's not that *projects* are
  slow to adapt, it's that they don't adapt at all.

That's much too great a generalization. We are finding a lot of projects
that do want to adapt to Ada 95 over time. Perhaps one of the most
dramatic examples of this is the significant demand for a port of
GNAT to the VAX from several large projects. These are certainly
not projects that are furiously adapting to the latest hardware,
but they see the move to Ada 95 as a way of getting more milage
out of existing hardware on an existing project.

Of course there are projects that will not adapt at all, but we are
surprised how many projects are switching to at least some use of
Ada 95 in mid-stream.

  Well I have a copy of GNAT 3.05 for DOS, one for Solaris and a copy of
  the NT version 3.04, but I am not using them so your conclusion here
  is not guaranteed.

I am talking about people who pick up more than one version for the same
target, so you would not be on that particular radar screen!





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

* Re: logarithms on ada
  1997-03-09  0:00           ` Robert Dewar
@ 1997-03-10  0:00             ` John McCabe
  1997-03-10  0:00               ` Robert Dewar
  0 siblings, 1 reply; 37+ messages in thread
From: John McCabe @ 1997-03-10  0:00 UTC (permalink / raw)



dewar@merv.cs.nyu.edu (Robert Dewar) wrote:

>John McCabe said
>
>  <<I don't think the phrase "..adapt only slowly to new technologies.."
<..snip..>
>
>Absolutely, that's exactly what I mean by slow to adapt, big projects
>don't jump on new technology band wagons fast, and rightly so!

You misunderstand what I'm saying here - it's not that *projects* are
slow to adapt, it's that they don't adapt at all.

>  <<**Note - not including GNAT, but how widely used is GNAT in large
>   safety and mission critical systems?.>>
>
>I don't know why GNAT should be excluded in your mind. 

I have excluded GNAT since as far as I am aware, no other vendor
provides anywhere near as many variations (host/target) at this time.

>A significant number of mission critical projects,
>including some safety critical projects have selected GNAT as the
>Ada 95 technology of choice.

Unless you have some very mainstream requirements, I wouldn't say you
have much choice so far with Ada 95, but that's even the case with Ada
83 if you're looking at cross-compilers.

>As time goes on we will see more and
>more deployed projects using Ada 95 in general, and GNAT in
>particular.

I certainly hope so.

<..snip..>
>
>In addition, we get some indication from the fact that many thousands
>of people have picked up more than one version -- a pretty good indication
>that they are using it! 
>

Well I have a copy of GNAT 3.05 for DOS, one for Solaris and a copy of
the NT version 3.04, but I am not using them so your conclusion here
is not guaranteed.

Anyway, this has gone a bit too far off-topic. If the original poster
lets us know what version of Ada he's using then we could probably be
more helpful. It's a bit pointless giving information on how to do
things in Ada 95, if they're not supported in Ada 83 and that's the
version someone is using.


Best Regards
John McCabe <john@assen.demon.co.uk>




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

* Re: logarithms on ada
  1997-03-06  0:00       ` Robert A Duff
  1997-03-06  0:00         ` Andrew Dunstan
@ 1997-03-10  0:00         ` Doug Smith
  1997-03-11  0:00           ` Robert Dewar
  1 sibling, 1 reply; 37+ messages in thread
From: Doug Smith @ 1997-03-10  0:00 UTC (permalink / raw)



In article <E6Lq2G.Dv2@world.std.com>, bobduff@world.std.com (Robert A Duff) wrote:

> In article <dsmith-0503971354380001@dsmith.clark.net>,
> Doug Smith <dsmith@clark.net> wrote:
> >This is a case where beginners have to understand generics and hunt through
> >the LRM to find simple operations. Of course, I found it easily using
> >WebAda's Surfing feature ...
> 
> Well, maybe I'm old-fashioned, but there's a more traditional tool that
> also works: look up "log" in the index of the RM, and it will point you
> to the right place.  ;-)
> 
> - Bob

I was referring to the predefined package that works on floats, which
I think was part of the original question. The index refers to the two
generic packages which contain the log operation. If that were all I
knew, then I would instantiate the appropriate generic on float and
missed the existing predefined package.

Each to his own, I like to use both the on-line tools and the reference
manual. When one fails, the other usually produces.

Doug
<mailto:dsmith@clark.net>




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

* Re: logarithms on ada
  1997-03-11  0:00                 ` John McCabe
@ 1997-03-11  0:00                   ` Robert Dewar
  1997-03-12  0:00                     ` John McCabe
  0 siblings, 1 reply; 37+ messages in thread
From: Robert Dewar @ 1997-03-11  0:00 UTC (permalink / raw)



i
John McCabe says

<<Seems to be some subtlety here on what is and isn't a project. My
comments have tended to restrict a project to something that starts,
goes on to produce a specific piece of equipment, then ends -
basically a bespoke software / hardware item whereas you seem to be
considering more of a product based thing.>>

  Hmm! I am talking about typical large scale DoD projects that certainly
  start, certainly go on to produce a specific piece of equipment, but
  that do not seem so easily to end! They tend to get maintained and
  upgraded, and in some cases, moving the software to Ada 95 is a natural
  part of this ongoing maintenance and upgrading.

  Obviously a project of the type you are discussing will not change
  compilers in midstream, they very likely will not even change versions
  of the compiler, let alone chnage versions of the language.

Ok, so I've also got a copy of GNAT 3.03 and 3.04 for DOS, and 2.07
for Sun Sparc that I don't use :-)

  Well don't worry, you are not in our database anyway. very likely
  you got your version from other than one of the FTP sites for which
  we maintain data (and indeed there are MANY people who get GNAT from
  other than our monitored FTP sites, including large numbers of students
  who get it from their local academic environment).






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

* Re: logarithms on ada
  1997-03-06  0:00           ` Norman H. Cohen
  1997-03-08  0:00             ` Robert Dewar
  1997-03-08  0:00             ` Robert Dewar
@ 1997-03-11  0:00             ` Richard A. O'Keefe
  1997-03-12  0:00               ` Norman H. Cohen
  2 siblings, 1 reply; 37+ messages in thread
From: Richard A. O'Keefe @ 1997-03-11  0:00 UTC (permalink / raw)



"Norman H. Cohen" <ncohen@watson.ibm.com> writes:
>In most applications, you don't have to understand all the subtleties of
>floating-point arithmetic to use floating point.  An age-old
>introductory programming assignment is to read three floating-point
>numbers A, B, and C, and print (approximations of) the solutions to the
>quadratic equation A * x**2 + B * x + C = 0.  

How very subtle of Norman Cohen to cite the very example that goes
disastrously wrong if you don't understand the problems of floating
point.  (At the very least you have to know what "cancellation" means.
And you also have to know about a less direct way to get the "other"
answer.)

>Students doing this assignment have to know where to find
>Ada.Numerics.Elementary_Functions.Sqrt.  They don't have to know how to
>determine convergence of Newton's alogrithm for square roots.

But they do need to understand "cancellation".

-- 
Will maintain COBOL for money.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.




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

* Re: logarithms on ada
  1997-03-10  0:00               ` Robert Dewar
@ 1997-03-11  0:00                 ` John McCabe
  1997-03-11  0:00                   ` Robert Dewar
  0 siblings, 1 reply; 37+ messages in thread
From: John McCabe @ 1997-03-11  0:00 UTC (permalink / raw)



dewar@merv.cs.nyu.edu (Robert Dewar) wrote:

>John McCabe said
>
>  You misunderstand what I'm saying here - it's not that *projects* are
>  slow to adapt, it's that they don't adapt at all.
>
>That's much too great a generalization. We are finding a lot of projects
>that do want to adapt to Ada 95 over time. Perhaps one of the most
>dramatic examples of this is the significant demand for a port of
>GNAT to the VAX from several large projects. These are certainly
>not projects that are furiously adapting to the latest hardware,
>but they see the move to Ada 95 as a way of getting more milage
>out of existing hardware on an existing project.

Seems to be some subtlety here on what is and isn't a project. My
comments have tended to restrict a project to something that starts,
goes on to produce a specific piece of equipment, then ends -
basically a bespoke software / hardware item whereas you seem to be
considering more of a product based thing.

>Of course there are projects that will not adapt at all, but we are
>surprised how many projects are switching to at least some use of
>Ada 95 in mid-stream.
>
>  Well I have a copy of GNAT 3.05 for DOS, one for Solaris and a copy of
>  the NT version 3.04, but I am not using them so your conclusion here
>  is not guaranteed.
>
>I am talking about people who pick up more than one version for the same
>target, so you would not be on that particular radar screen!
>

Ok, so I've also got a copy of GNAT 3.03 and 3.04 for DOS, and 2.07
for Sun Sparc that I don't use :-)

Best Regards
John McCabe <john@assen.demon.co.uk>




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

* Re: logarithms on ada
  1997-03-10  0:00         ` Doug Smith
@ 1997-03-11  0:00           ` Robert Dewar
  0 siblings, 0 replies; 37+ messages in thread
From: Robert Dewar @ 1997-03-11  0:00 UTC (permalink / raw)



Doug said

<<I was referring to the predefined package that works on floats, which
I think was part of the original question. The index refers to the two
generic packages which contain the log operation. If that were all I
knew, then I would instantiate the appropriate generic on float and
missed the existing predefined package.

Each to his own, I like to use both the on-line tools and the reference
manual. When one fails, the other usually produces.>>

Well you won't find para 9 easily by any other method than reading,
which is I find a useful additional technique to fancy searching!





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

* Re: logarithms on ada
  1997-03-11  0:00             ` Richard A. O'Keefe
@ 1997-03-12  0:00               ` Norman H. Cohen
  0 siblings, 0 replies; 37+ messages in thread
From: Norman H. Cohen @ 1997-03-12  0:00 UTC (permalink / raw)



Richard A. O'Keefe wrote:
 
> "Norman H. Cohen" <ncohen@watson.ibm.com> writes:
> >In most applications, you don't have to understand all the subtleties of
> >floating-point arithmetic to use floating point.  An age-old
> >introductory programming assignment is to read three floating-point
> >numbers A, B, and C, and print (approximations of) the solutions to the
> >quadratic equation A * x**2 + B * x + C = 0.
> 
> How very subtle of Norman Cohen to cite the very example that goes
> disastrously wrong if you don't understand the problems of floating
> point.  (At the very least you have to know what "cancellation" means.
> And you also have to know about a less direct way to get the "other"
> answer.)
> 
> >Students doing this assignment have to know where to find
> >Ada.Numerics.Elementary_Functions.Sqrt.  They don't have to know how to
> >determine convergence of Newton's alogrithm for square roots.
> 
> But they do need to understand "cancellation".

Come back down to earth, Richard!  I said that we're talking about an
>>introductory<< programming assignment, for which a naive program like the one shown below is a perfectly acceptable response.  

   with Ada.Numerics.Elementary_Functions; 
   use Ada.Numerics.Elementary_Functions;
   with Ada.Text_IO, Ada.Float_Text_IO; 
   use Ada.Text_IO, Ada.Float_Text_IO;

   procedure Quadratic is
      A, B, C, D, Sqrt_D: Float;
   begin
      Put_Line ("Enter quadratic equation coefficients A, B, and C:");
      Flush;
      Get(A);
      Get(B);
      Get(C);
      if A = 0.0 then
         Put_Line ("Equation is not quadratic because A is zero.");
      else
         D := B**2 - 4.0 * A * C;
         if D < 0.0 then
            Put_Line ("There are no real solutions.");
         else
            Sqrt_D := Sqrt(D);
            Put ("Solution 1: ");
            Put ( (-B + Sqrt_D) / (2.0*A) );
            New_Line;
            Put ("Solution 2: ");
            Put ( (-B - Sqrt_D) / (2.0*A) );
            New_Line;
         end if;
      end if;
   end Quadratic;

The recipients of this assignment may have less than a month of
programming experience.  An instructor may wish to explain at this point
in the course that floating-point types are only approximations of real
numbers, and that this can lead to surprising results.  (If the user
enters 1E-50 for A, the program may report that A is zero; if the user
enters 1E-40 for A, the program may fail because of overflow on the
division.)  The instructor may then mention that there is a subfield of
computer science devoted to determining the accuracy and safety of
floating-point computations, and to writing programs in a way that
maximizes these attributes.  No more needs to be said, or understood by
the students, at this point.  (The instructor may wish to revisit this
example later in the course to make it safe, not by numerical analysis,
but simply by providing exception handlers.)

In fact, the program will work acceptably for all input values that the
typical novice programmer will supply when testing the program.  (My
experience as a graduate teaching assistant for a course that had an
introductory assignment like this was that many students only used test
data for which A=1.0, because they could factor those quadratic
equations, and check their answers, more easily.  Many of these students
also forgot to parenthesize the denominator 2.0*A and never caught their
mistake, which has no effect when A=1.0.  So much for path coverage. 
:-) )

Even outside the classroom, there are plenty of applications that stay
far enough away from extreme values and singularities that they can be
written and used in a numerically naive manner.

-- 
Norman H. Cohen
mailto:ncohen@watson.ibm.com
http://www.research.ibm.com/people/n/ncohen




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

* Re: logarithms on ada
  1997-03-11  0:00                   ` Robert Dewar
@ 1997-03-12  0:00                     ` John McCabe
  0 siblings, 0 replies; 37+ messages in thread
From: John McCabe @ 1997-03-12  0:00 UTC (permalink / raw)



dewar@merv.cs.nyu.edu (Robert Dewar) wrote:

>i
>John McCabe says
>
><<Seems to be some subtlety here on what is and isn't a project. My

<..snip..>
>
>  Hmm! I am talking about typical large scale DoD projects that certainly
>  start, certainly go on to produce a specific piece of equipment, but
>  that do not seem so easily to end! They tend to get maintained and
>  upgraded, and in some cases, moving the software to Ada 95 is a natural
>  part of this ongoing maintenance and upgrading.

That's cleared that up then.
>
>  Obviously a project of the type you are discussing will not change
>  compilers in midstream, they very likely will not even change versions
>  of the compiler, let alone chnage versions of the language.

You're quite right, especially when your customer mandates a
particular version of a particular compiler; a very stupid idea when
they specify it before anyone's had a chance to find out it's
problems!

>Ok, so I've also got a copy of GNAT 3.03 and 3.04 for DOS, and 2.07
>for Sun Sparc that I don't use :-)
>
>  Well don't worry, you are not in our database anyway. very likely
>  you got your version from other than one of the FTP sites for which
>  we maintain data (and indeed there are MANY people who get GNAT from
>  other than our monitored FTP sites, including large numbers of students
>  who get it from their local academic environment).

I generally get things like that from whichever server answers me
quickest out of the list on your ACT web page.

Best Regards
John McCabe <john@assen.demon.co.uk>




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

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

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-02  0:00 logarithms on ada Brian R Franklin
1997-03-04  0:00 ` John McCabe
1997-03-06  0:00   ` Robert Dewar
1997-03-07  0:00     ` John McCabe
1997-03-07  0:00       ` Robert Dewar
1997-03-09  0:00         ` John McCabe
1997-03-09  0:00           ` Robert Dewar
1997-03-10  0:00             ` John McCabe
1997-03-10  0:00               ` Robert Dewar
1997-03-11  0:00                 ` John McCabe
1997-03-11  0:00                   ` Robert Dewar
1997-03-12  0:00                     ` John McCabe
1997-03-07  0:00   ` Darren C Davenport
1997-03-04  0:00 ` Bob Klungle
1997-03-04  0:00   ` Robert Dewar
1997-03-05  0:00     ` Bob Klungle
1997-03-05  0:00       ` David Shochat
1997-03-05  0:00         ` Robert Dewar
1997-03-06  0:00         ` Robert A Duff
1997-03-06  0:00           ` Robert Dewar
1997-03-05  0:00     ` Doug Smith
1997-03-05  0:00       ` Robert Dewar
1997-03-06  0:00         ` Robert A Duff
1997-03-05  0:00           ` John McCabe
1997-03-06  0:00           ` Robert Dewar
1997-03-06  0:00           ` Norman H. Cohen
1997-03-08  0:00             ` Robert Dewar
1997-03-08  0:00             ` Robert Dewar
1997-03-11  0:00             ` Richard A. O'Keefe
1997-03-12  0:00               ` Norman H. Cohen
1997-03-06  0:00           ` Doug Smith
1997-03-06  0:00       ` Robert A Duff
1997-03-06  0:00         ` Andrew Dunstan
1997-03-10  0:00         ` Doug Smith
1997-03-11  0:00           ` Robert Dewar
1997-03-05  0:00   ` Jon S Anthony
1997-03-04  0:00 ` Tom Moran

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