Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!news.cs.indiana.edu!ariel.unm.edu!ghostwheel.unm.edu!john From: john@ghostwheel.unm.edu (John Prentice) Newsgroups: comp.lang.misc Subject: Re: Fortran vs. C for numerical work Message-ID: <1990Dec11.065616.2802@ariel.unm.edu> Date: 11 Dec 90 06:56:16 GMT References: <1980@mts.ucs.UAlberta.CA> <18016@hydra.gatech.EDU> <16671@csli.Stanford.EDU> <1990Dec5.022302.25764@alchemy.chem.utoronto.ca> <1990Dec8.024943.15468@ariel.unm.edu> Sender: John K. Prentice Organization: Amparo Corporation, Albuquerque, NM Lines: 175 In article pcg@cs.aber.ac.uk (Piercarlo Grandi) writes: << long discussion of the pitfalls of the dangers of naive numerical methods deleted >> Your points are extremely valid and well taken. I have absolutely no quarrel about the fact that scientists very often fail to comprehend the difficulties and dangers inherent in sometimes even simple numerical math. I don't think one can lay the blame on any particular computer language however. I have to agree that saying c=a+b probably misleads some people into thinking you get the same answer on the computer as you would "analytically", but what is the alternative? Beyond that, certainly Fortran can't be held singularly responsible for that. The syntax is the same in almost all languages. >john> As far as Fortran's relationship to mathematical notation, I don't >john> think this has anything to do with why people fail to comprehend >john> numerical methods. > >Well, again based on anectodal evidence, it misleads the unwary (that is >those that are not coached hard in numerical analysis) into believing >that Fortran == maths. As you say, this is a small problem, some people >even fail to understand the properties of their algorithms, not just of >computer algebra: Okay, I can accept this up to a point. It is certainly true finite precision arithmetic is quite different from infinite precision arithmetic. This can lead to problems that even the best numerical analysists do not yet comprehend (a good deal of non-linear dynamics research is tied up with this precise point!). However, why lay the blame on Fortran? Just because the originators designated the language Fortran, meaning "Formula Translation" ? That seems a bit strong to me I guess. How is something like C or Pascal any better? While not in any way denying any of your quite valid points about numerical methods, I don't think language designers can be held responsible for this situation. << after referring to an example I originally gave of poor application of numerical methods >> > >And they probably will fail to appreciate the fact that in all >likelyhood they are mixing in the same calculations quantities with five >or six orders of magnitude between them, and this may well cause >problems with their floating point as well. As well. > >john> Are you telling me it is because Fortran misled them? > >No, even if examples of [censored] [censored] like this are all too >common. But surely these [censored] also believe that Fortran == maths. >The least of their problems, but probably (OK, I admit handwaving here!) >it contributed. > >Certainly the major problem is poor mathematics, but the second major >one is a failure to appreciate that maths and numerical analysis are >quite different disciplines, just like theoretical and experimental >physics, even if they have a common ground. But Fortran yes it does help >to maintain the illusion that the common ground is much larger than it >really is. > Okay, maybe so. It is a sad statement about the quality of scientists using computers (not necessarily a wrong one, but a sad one). Still, why just Fortran? This is a problem with people not understanding numerical methods, not a problem with Fortran (or so it seems to me). Do you REALLY think Fortran promotes this sort of thing or is it just that it is the most popular language for scientists? If scientists start programming in language [..pick one..], I bet you would have the same problem. >Hey, however, would you believe that as a practical matter major >computer manufacturers have had to provide floating point compatibility >modes with the IBM/370 to sell their machines? What do you do when your >customer says "My programs print 5.3E-15 on a 370 and 8.4E-15 on your >machine, why does your machine get the result wrong by more than 50%"? > >Do you explain to them that the mantissa (if not the order of >magnitude!) of the result printed by their program with which they have >published loads of paper is solely function of the rounding algorithms >of the machine it runs on? Hey, no, you wanna keep the customer, so out >goes base 2 mantissa with rounding, and in comes base 16 mantissa with >truncation like the IBM 370, which gives the right results: IBM of >course does it right. > >I have seen worried comments by people heavvy in computational physics >that since everybody in that field is running the same codes, >independent verification is no longer common, as wide circulation of >codes also means wide criculation of the bugs and poor numerical aspects >of some of those codes. > No quarrel at all here, in fact we violently agree! >pcg> What are the good languages for numerical research then? Sadly, >pcg> Fortran is so preminent, precisely because it deceives the unwary >pcg> about the immense chasm between maths and numerical computing, that >pcg> I cannot think of any other similar low level language. [ ... but >pcg> maybe scheme or C++ .. ] Well, we have hashed this out above. However, I would again suggest that Fortran is getting the rap just because it is the most common language used for doing science, not because it is inherently bad. As I said earlier, I have no doubt that if all the C enthusiasts out there managed to convert the scientific world to C tomorrow (or if not C, you name it), then you would see the same problems. > >john> And I suppose if some hydrologist codes the same finite difference >john> scheme I just referred to in C (or Scheme or whatever) instead of >john> Fortran, divine elightenment will happen and he will see that he >john> is making serious mathematical mistakes? > >john> Come on, this argument is ridiculous. > >But it is not my argument! You are reducing it to absurdity yourself. >The argument is that a misleadingly familiar notation can trap the >unwary, not that an unfamiliar notation will automagically make them >wary. > My apologies if I misrepresented your position. My choice of wording was inappropiate, I am sorry. And yes, I can accept that familiar notation can trap the unwary, but what about all those people out there who know what they are doing? I would hate to give up the convience of saying c=a+b just to avoid some idiot failing to understand the limitations of computer arithmetic. > >Given that a language should not be preferred (or avoided) because of >its familiar notation, things like Scheme can become attractive. > >Scheme has excellent performance (a little more work on compilers can >yield MAClisp style ones I think), and it has inbuilt support for things >like infinite precision numbers, rationals, ... that ought to be used >far more in numerical analysis, but are not because Fortran does not >have them. Scheme has also fairly powerful abstraction facilities, so >that for example adding interval arithmetic (another thing that is not >in Fortran, and thus ignored by many) is not that difficult, and it has >also excellent exception handling and library facilities, and so on. It >does not a familiar looking syntax, but nobody should care. > I am not familiar with Scheme. Could you point me at a reference so I can learn about it? Thanks. > >Even I ... can be outraged by the [censored] idea that computers >ought to give the illusion that they can do maths, and that any >mathematician can become an instant numerical analyst (Fortran) or >symbolic algebrist (Mathematica). > I only wish you were in charge of my funding! I couldn't agree with you more and wish the powers that be understood this more. Piercarlo, I think we are probably violently agreeing throughout this argument. I don't think Fortran is specifically to blame and you apparently do, but so be it. However, your points about people underestimating the difficulty of numerical methods are ones that most numerical analysists would agree on I think. In fact, one of the bigger problems computational physicists (or computational scientists in general, no matter what their principal discipline) face is the fact that the field is highly interdisciplinary and requires understanding computers, mathematics, and physics (or whatever). That is a tall order and most people end up compromising on one or more of these fields. More importantly however is that computational physics is really a separate discipline, not just physics which happens to be done on a computer. Makes you feel a bit like neither fish nor fowl. Regards, John Prentice john@unmfys.unm.edu