Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Math Toolkit for Real-Time Programming

timothy posted more than 11 years ago | from the doing-the-numbers dept.

Programming 153

oxgoad writes "Need a closed-form algorithm to derive square roots? Stymied by strange and scary results from your favorite compiler's math library? Math Toolkit for Real-Time Programming by Jack W. Crenshaw attempts to shed some numerical light. Read on for the goods." Oxgoad's review continues below.

Who & What

Jack W. Crenshaw, Ph.D. (Physics) wrote his first computer program in 1956 for an IBM 650. He has been working with real-time software for embedded systems ever since -- contributing several years to NASA during the Mercury, Gemini, and Apollo programs. In addition to other activities, he is currently a contributing editor for Embedded Systems Programming magazine and author of the Programmer's Toolbox column.

In Math Toolkit for Real-Time Programming, his effort is focused on describing the pitfalls of vendor-provided math libraries and providing robust replacements. In section one he gives a thorough overview of constants and the various manners in which to declare them, naming conventions, and error handling. As the work progresses, in section two, he builds a library of proven algorithms ranging from square roots to trigonometrical functions to logarithms. Did you suffer through calculus in college with a barely passing grade? Section three will teach you more about numerical calculus in a half-hour than you may have learned in three semesters.

Kudos

Math Toolkit is written in an easy to understand anecdotal manner. You might be tempted to think that the author was animatedly relating the history of computing square roots while having lunch with you. This method works very well and keeps what could be a rather heavy subject from becoming too much of a burden. Most chapters have historical tidbits liberally sprinkled throughout.

Even if college algebra left you with post-traumatic stress disorder, you will not have any trouble with section two. Indeed, you may find yourself intently following the author on the trail of the perfect arctangent algorithm -- much as a sleuth on the trail of a villain.

The depth of knowledge shown, and its presentation, is exceptional. The author's years of experience are evident in his self-confident writing style. You will rarely see a clearer overview of numerical calculus.

Quibbles

The cover of the book states: "Do big math on small machines." This, combined with the Real-Time Programming phrase in the title, might lead one to believe that the book's primary audience is intended to be the embedded microcontroller crowd. Sadly, not so. There is very little here for the die-hard assembler programmer other than some very handy integer square root and sine routines - and these examples are in C++. Based on the cover, I would have liked to see a greater emphasis on processors lacking a floating point unit. Also, some code examples in pseudo-assembler would have been welcome, as the author chose C++ as the language of choice for all examples.

Crimes

As is so often the case nowadays, there are various typographical errors scattered throughout. This seems to be an epidemic in current technical books. Fortunately, it didn't affect the readability of Math Toolkit.

Conclusions

I believe Math Toolkit for Real-Time Programming would be a great, perhaps mandatory, addition to the bookshelf of anyone that is involved in writing code that has a heavy math component. Other than the somewhat misleading cover, I cannot find anything truly negative to say about this work. Congratulations are in order to Mr. Crenshaw on a job well done.

The book also includes a CD-ROM of all example source code. In reality, to get the best benefit from the book, you should mostly ignore the CD-ROM and work through the examples. To quote the author: "Never trust a person who merely hands you an equation."

Table of Contents

  1. Getting The Constants Right
  2. A Few Easy Pieces
  3. Dealing with Errors
  4. Fundamental Functions
  5. Getting the Sines Right
  6. Arctangents: An Angle-Space Odyssey
  7. Logging in the Answers
  8. Numerical Calculus
  9. Calculus by the Numbers
  10. Putting Numerical Calculus to Work
  11. The Runge-Kutta Method
  12. Dynamic Simulation
  • Appendix A: A C++ Tools Library

Disclosure

I received a review copy of this book from the publisher. Thus, my loyalties and opinions may be completely skewed. Caveat Lector.


You can purchase Math Toolkit for Real-Time Programming from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

cancel ×

153 comments

Sorry! There are no comments related to the filter you selected.

fristy prost! (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423616)

Propz to all my niggaz! [theonion.com]

primo (-1, Offtopic)

chrisspurgeon (514765) | more than 11 years ago | (#4423621)

yo.

fp (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423629)

fp

Re:fp (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423652)

Your fp skills are lacking.

it's a turd, it's inflamed, no it's the goatse man (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423649)

http://goatse.cx

is Real Time programming still a Real Issue? (3, Interesting)

HealYourChurchWebSit (615198) | more than 11 years ago | (#4423656)

Back in the day, a book like this would have been a real life saver for those of us slugging it out with brain-damaged operating systems (e.g. MS-DOS). From things like MIDI sequencers to guidance systems, the need for real-time speed was a real issue.

However, with the the maturity of operating systems, many of them now include device drivers, APIs, objects and other goodies that insulate the average programmer from the hassle of issues like latency. So my question is, other than good academic study, would it pay for the rest of us to spend the $$ on such a book?

Though I admit, having to write my share of real-time apps back in the day has me curious enough to put the book on my wishlist.

Re:is Real Time programming still a Real Issue? (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423673)

You should heal this website [goatse.cx] .

Re:is Real Time programming still a Real Issue? (-1, Flamebait)

Anonymous Coward | more than 11 years ago | (#4423677)

Back in the day, a book like this would have been a real life saver for those of us slugging it out with brain-damaged operating systems

What I'm hearing you say is that users of open source operating systems would greatly beenfit from this book.

Re:is Real Time programming still a Real Issue? (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423684)

I believe you mean open sores. Mod parent down (-1, Ghey).

Re:is Real Time programming still a Real Issue? (4, Interesting)

beanerspace (443710) | more than 11 years ago | (#4423681)

Someone marked this question redundant? Guess that shows you jerks are everywhere.

Hey, I understand completely what you're saying. I for one am glad I don't have to deal with such as latency and pre-emption. In fact, here is a link to a nifty article entitled "Real Time Issues in Linux [helsinki.fi] " that essentially sums up what you asked with a resounding yes.

Re:is Real Time programming still a Real Issue? (1)

BigRedZX (102201) | more than 11 years ago | (#4423686)


Yes.

Real Time != Real Fast

Re:is Real Time programming still a Real Issue? (5, Informative)

jspayne (98716) | more than 11 years ago | (#4424307)

Real Time != Real Fast

This deserves some more explanation, since everyone here seems to have missed this point.

A Real Time system is one where the ouptut isn't correct unless it arrives on time. Real Time systems are deterministic - not necessarily fast. The key is to use bounded-time algorithims so that you can predict the worst case execution time at compile time. RTOS's aren't designed to be fast, they are designed to have deterministic schedulers and kernel services.

Of course, faster processors make it easier to meet real time deadlines, but as processors get faster I'm seeing engineers ignore the real time analysis and design because the code passed the last test they ran. Then they are surprised when it fails in the field...

Jeff

Re:is Real Time programming still a Real Issue? (5, Insightful)

Hayzeus (596826) | more than 11 years ago | (#4423702)

However, with the the maturity of operating systems, many of them now include device drivers, APIs, objects and other goodies that insulate the average programmer from the hassle of issues like latency. So my question is, other than good academic study, would it pay for the rest of us to spend the $$ on such a book?

The above generally doesn't apply to anyone doing serious embedded work with small and midrange microcontrollers. Often an operating system is thin to non-existent on these platforms. Some of the lower-range parts may have a 2-byte hardware stack, 28 bytes of RAM and maybe 512 bytes of program memory. Obviously, you won't be doing much sophisticated numerical work on these smallest of microcontrollers, but for more midrange parts, I've found this book to be a godsend.

The book is not aimed at PC users.

Re:is Real Time programming still a Real Issue? (3, Interesting)

GGardner (97375) | more than 11 years ago | (#4423711)

If you want to control a robot by putting a bunch of cheap 8-bit PICs on board, you are going to be hard pressed to find any nice device drivers, API, objects and other goodies.

Re:is Real Time programming still a Real Issue? (2, Informative)

Mattsson (105422) | more than 11 years ago | (#4423746)

Well... Realtime programming might now be an issue for you if you use an advanced OS coupled with a mighty cpu.
But in many situations you might find yourself programming for, say, a small 1 MHz cpu in a timecritic controllsystem at a factory or chemicalplant or something like that.
That's when you'll need your skills in realtime programming.

Re:is Real Time programming still a Real Issue? (4, Interesting)

ammie (614071) | more than 11 years ago | (#4423787)

Yes. Banks, old satallite programs, messaging systems...etc.

I work with a group of eight other people updating 40 year old Assembler on an IBM Series 1. Something tells me that if this was included in our training programs, those that are
SUF
FER
ING
through the digit-crunching wouldn't have such a hard time. Most people consider this back-in-the-day, but there's an aaaawwwful lot out there that still reeks of old german engineering, and chunk-button ATMs.

Re:is Real Time programming still a Real Issue? (3, Informative)

cheeseSource (605209) | more than 11 years ago | (#4423866)

I actually have this book. It does read fairly well with some good examples: although I should note that I haven't finished it yet. One thing it is especially usefull for is defining a math library that's accurate. Crenshaw talks about how a lot of compiler's built in function/methods don't hold up to rigorous math and he's right. But instead of just complaining about it he walks through solid alternatives. Overall it's pretty good and would provide some quality code for open projects. IMHO anyway.

Re:is Real Time programming still a Real Issue? (1)

p3d0 (42270) | more than 11 years ago | (#4423937)

Translation: I used to do real-time programming, but I don't any more. Therefore, I believe nobody else does it any more either.

Re:is Real Time programming still a Real Issue? (3, Interesting)

DocTillo (615220) | more than 11 years ago | (#4424034)

Not all computers are desktop PCs. Have you ever heard of Palm Pilots? These things are slow! I searched some time to find a decent integer square root routine to calculate object distances in my elite for palmos game [harbaum.org] . I would have loved such a book ...

Re:is Real Time programming still a Real Issue? (4, Insightful)

Phronesis (175966) | more than 11 years ago | (#4424098)

I am currently trying to get a data-acquisition computer to keep up with a five thousand frame-per-second video feed [redshirtimaging.com] while doing processing between the frames. Hard real-time is a real issue for me.

Re:is Real Time programming still a Real Issue? (1)

hyperturbopete (168434) | more than 11 years ago | (#4424645)

wow!

what are you photographing with that beastie?

Re:is Real Time programming still a Real Issue? (2, Insightful)

urbi (171156) | more than 11 years ago | (#4424136)

Of course. Real time doesn't mean low latency.
It means predictable (bounded) latency! It's a
secondary issue if that latency is low or high.
My Linux is reasonably fast, but it's still far from real time: each time I touch my xawtv window, the whole machine freezes for a second...

Re:is Real Time programming still a Real Issue? (0)

Anonymous Coward | more than 11 years ago | (#4424724)

Yes real time is still in issue.

Try using Windows to fire a timer at consistant intervals less then your OS's time slice.



dan.

Wow, I'm old, I haven't seen Runge-Kutta in years (5, Insightful)

typical geek (261980) | more than 11 years ago | (#4423670)

I remember when having a solid math background was de reguire for a programmer. Of course, I'm talking the mid 80's, engineering school and Fortran, so I'm kind of krufty.

I wonder how much better could we be if coders knew basic math, if they know how those little bitty chips actually computed the sine of something instead of assuming it works. We would probably have rock solid operating systems without all the glitzy GUI stuf..

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (2, Funny)

Anonymous Coward | more than 11 years ago | (#4423696)

I remember when having a solid math background was de reguire for a programmer.

And I remember when being able to spell the words they used was de rigueur for anyone with an education.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (2)

VAXman (96870) | more than 11 years ago | (#4423732)

I wonder how much better could we be if coders knew basic math, if they know how those little bitty chips actually computed the sine of something instead of assuming it works. We would probably have rock solid operating systems without all the glitzy GUI stuf..

Huh? What's the use of sine in an OS besides to draw glitzy GUI stuff?

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (1)

Mr_Dyqik (156524) | more than 11 years ago | (#4424578)

Software midi?

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (3, Interesting)

Havokmon (89874) | more than 11 years ago | (#4423748)

I wonder how much better could we be if coders knew basic math

Funny this topic should come up. I just did a 'Store Locator' for the company I work for (I'm the IT Manager, belive it or not). All I have is your basic HS diploma, and in creating the search, I realized I don't know a damn thing about sine and cosine. I don't know how they're used, or how they're applied. I have a feeling that they're somehow related to geometry (which makes sense, seeing I have to get a distance between two points on a curve - the earth), but I'm not sure.

Sure, it's probably taken me longer to write this post, than it took to find the php code I used as a basis for the search, but how much math is REALLY needed overall?

I slept through school, I did really bad, all because I felt it was worthless. I did feel that my business class, business law, and basic Algebra has been useful. But overall, it wasn't worth my time. Hell I had a physics teacher who'd pick on me because I was flunking (it's amazing what good test grades + 0 homework does to you), but I just found physics interesting - jeez, it was only HS. I was testing the waters, not padding my GPA. I believe that's what's HS is FOR.

And if you KNOW what you want to do (I knew I wanted to fix/program computers when I played on my Apple ][ in 6th grade), what the hell is college for?

The ease of the internet sure hasn't helped my perception.

Am I the only one?

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (3, Insightful)

wunderhorn1 (114559) | more than 11 years ago | (#4423878)

Well yeah, man, if you want to be grinding out php and html or doing admin work for the rest of your life, sure, there's no reason to get a higher education, and if you're happy with what you're doing then that's great.

But to get a job writing computer graphics software, or audio processing, or designing any sort of embedded hardware, knowledge of advanced math is required. The people who want to do this kind of work pursue higher educations, and if they enjoy what they're doing then that's great, too.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (1)

Havokmon (89874) | more than 11 years ago | (#4424004)

Well yeah, man, if you want to be grinding out php and html or doing admin work for the rest of your life, sure, there's no reason to get a higher education, and if you're happy with what you're doing then that's great.

Well, that sounds a bit belittling. I think building networks (I'm beyond admin, I just do EVERYTHING - including PBX) can be just as difficult as programming, and you get the same rewards.

I don't really grind out anything. Hell, I put up a TV antenna last summer, and hooked up the security cameras to a linux box for motion detection around xmas. I'd much rather be doing 90 different things, than concentrate on programming in 'X'..

Maybe I should have left out the 'Manager' part :) (I'm just the only one here.)

Then again, maybe I AM that good, and you're all just jealous! muhuhuhahaha! :)

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (2)

wunderhorn1 (114559) | more than 11 years ago | (#4424192)

It wasn't meant to sound belittling. I meant what I said: if you find it rewarding then that's great.

What came out as a belittling tone probably slipped through because I know that colleges around the country are churning out graduates with BSes in Information Technology or similar majors, all of whom are going to be going after YOUR JOB. Now it sounds like you've got a good mind and a good head start in the IT world so I wouldn't be too worried, but just know that your field isn't going to be getting any less competitive.

Cheers!

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (1)

Havokmon (89874) | more than 11 years ago | (#4424509)

What came out as a belittling tone probably slipped through because I know that colleges around the country are churning out graduates with BSes in Information Technology or similar majors, all of whom are going to be going after YOUR JOB.

For what I've seen, I think they're mostly programmers and MCSE's. That's not too damaging to me. For practial, in-house purposes, I can pickup whatever I need programming-wise. I completely understand I won't be programming games, or advanced simulations any time soon (Hell, you can find my pitiful posts on wine-devel about trying to get FoxPro running.. rick@v a leoinc). But those positions always seemed like a small percentage of the market as a whole. Everybody needs a network, internet access, firewalls, phones - infrastructure. It just seems like a bigger target to me.

Fortunately for me, most people I run into are sorely lacking on what I would lump together as basic infrastructure.

(but at this moment, I have to put php aside,so I can figure out an EDI issue with FoxPro) I love having so many different things. How many EDI people know PC's? Networks? The consultant who interviewed me for this job didn't know many, so here I am!

Ok.. enough of the ego-boosting stuff for now :)

Personally, I think experience can replace college. You just have to be resourceful, and create a resume that shows it. I think I did a good job doing that.

Now, Social Skills OTOH....It would have been good for me to live in a dorm for a few years. I dormed weekends with my girlfriend - which got me to where I am today, family-wise :)

So maybe it wouldn't have been such a good idea to live in a dorm :P

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (1, Insightful)

Anonymous Coward | more than 11 years ago | (#4423881)

I'd agree with the former poster that the industry would be MUCH better off if programmers actually had a clue how to:

A) Create superb programs
B) Fix them
and
C) Put some thought into the design so that others can use-, understand and change it easily.

not

Just hack something up and yell 'FINISHED!' when it seems to run "Good enough".

Score -1 ignorant (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423904)



No, computers don't need math (3, Interesting)

A nonymous Coward (7548) | more than 11 years ago | (#4423920)

I've been programming since 1968, and very little had anything to do with math. People give me the same line, wow, I'm no good with math, I couldn't program, and don't believe me when I say computers add and subtract, multiply once in a while (array subscripting usually), and hardly ever divide.

Scientific or engineering programming, they need the math because they are math programming. The rest, forget it, maybe you add some numbers for a shopping cart, multiply for sales tax, but programming has little use for math.

I learned long ago that when an 8 bitter needs trig functions, you use a look up table generated externally.

Re:No, computers don't need math (3, Insightful)

Anonymous Coward | more than 11 years ago | (#4425008)

programming has little use for math.
Somewhere in Palo Alto, California, God [stanford.edu] is cringing. Here's why [mit.edu] :
I am told that the courts are trying to make a distinction between

mathematical algorithms and nonmathematical algorithms. To a computer
scientist, this makes no sense, because every algorithm is as
mathematical as anything could be. An algorithm is an abstract
concept unrelated to physical laws of the universe.

Nor is it possible to distinguish between "numerical" and
"nonnumerical" algorithms, as if numbers were somehow different from
other kinds of precise information. All data are numbers, and all
numbers are data.
So maybe most of the math is trivial, but that's not the same as being useless... :-p

Re:No, computers don't need math (3, Insightful)

naasking (94116) | more than 11 years ago | (#4425346)

Perhaps you should rephrase these statements to "programming often has little to do numerical math". Programming has everything to do with Discrete math (which is formal reasoning and logic).

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (0)

Anonymous Coward | more than 11 years ago | (#4423946)

And if you KNOW what you want to do (I knew I wanted to fix/program computers when I played on my Apple ][ in 6th grade), what the hell is college for?

Good luck getting your next programming job without a degree, cuz I'll be right there outshining you. (which isn't hard if you don't even know what sine represents...)

But don't bother getting a degree or anything, I like having the competition be clueless.

Follow-up (1)

wunderhorn1 (114559) | more than 11 years ago | (#4424060)

How did you write the search function? Did you come up with an alorgithm on your own? Did you use a prewritten, off-the-shelf search routine?

Note that I'm not making judgements here, I'm just underscoring the point that there are some jobs that require certain knowledge, and others that don't.

And FYI (so you can impress your coworkers and/or significant other <g>): The sine of an angle refers to the y-coordinate of the point at which a line drawn from a starting point at that angle would intersect with a circle of radius=1 drawn around the starting point.

Re:Follow-up (2, Funny)

Havokmon (89874) | more than 11 years ago | (#4424184)

How did you write the search function? Did you come up with an alorgithm on your own? Did you use a prewritten, off-the-shelf search routine? Google: PHP MYSQL dealer locator

:)

A couple minutes of going through results granted me a simple:

$sql = "select zipcode.zip_code, sqrt(power(69.1*(zipcode.lat - $lat1),2)+ power(69.1*(zipcode.lng-$long1)*cos(z ipcode.lat/ 57.3),2)) as dist, $dealer.* from $dealer LEFT JOIN zipcode on " ;

$sql = $sql . " $dealer.zip = zipcode.zip_code where sqrt(power(69.1*(zipcode.lat - $lat1),2)+ power(69.1*(zipc ode.lng- $long1)*cos(zipcode.lat/57.3),2))

So, no, I didn't have to sit down and figure out how to account for the curvature of the earth, and other things I'd consider 're-inventing the wheel'.

As for the sine explanation.. That makes sense.. Now I'm going to have to go look up how it's applied.

Re:Follow-up (1)

AlgUSF (238240) | more than 11 years ago | (#4424309)

Yeah and a circle of radius=1 is called the "unit circle". Wow I miss freshman trig... :-)

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (5, Insightful)

dubious9 (580994) | more than 11 years ago | (#4424157)

I won't bash you like some of the other replies to your post, nor will I give you hope that you can advance past a limited set of jobs in the IT industry.

College (esp for computer engineering and CS) fundamentally teaches you:

1. How to solve problems

2. A toolset (ie math, algorithms) to go about solving those problems

True, you may not ever use calculus, but as a computer scientist you will use matrix theory because it is the best way to solve some problems.

This is not only for scientific/research either. If you try to write anything performance related, you'll have to use higher math. Computer science ain't easy.

Let me stress again that college teaches you about your subject matter and how to solve problems for it. You can come up with this stuff by yourself, in my experience only a tiny percent working without a college degree will ever accrue enough to offset what they missed in college.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (1)

Havokmon (89874) | more than 11 years ago | (#4424276)

I won't bash you like some of the other replies to your post, nor will I give you hope that you can advance past a limited set of jobs in the IT industry.

Thanks for not bashing, and please don't think I'm attacking when I say this but:
If anything was learned from this post, it's that there are a lot of PROGRAMMERS who read Slashdot. IMHO, Programming in itself is a limited set of jobs in the IT industry.

Let me stress again that college teaches you about your subject matter and how to solve problems for it. You can come up with this stuff by yourself, in my experience only a tiny percent working without a college degree will ever accrue enough to offset what they missed in college.

You post sounds depressing, but don't worry about me, I'm all set (maybe I'm even in that small percentage). Maybe I'll go back to college when my kids are teenagers. I'll still be less than 40.
Yes, I did EVERYTHING early - against the grain, thankyouverymuch :)

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (3, Insightful)

Daniel Dvorkin (106857) | more than 11 years ago | (#4425356)

Your code may do the job, but does it do the job efficiently? And if it didn't, how would you know?

I changed majors from CS to Mathematics halfway through because I realized that programming is easy; you can always learn a new language or a new technique by picking up the appropriate O'Reilly book on the subject. But writing good programs -- programs that are robust, that scale well, that do as much as possible as quickly as possible -- is really applied math. And math is hard.

You simply have no idea how much you don't know, and with the attitude you have, you probably never will.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (1)

coult (200316) | more than 11 years ago | (#4425362)

Funny, I'm someone with a lot of mathematical training (Ph.D. in Applied Math) but only a few courses in computer science. Somehow, I've managed to pick up a humungous amount of CS along the way, things like algorithm design and analysis, designing and coding industrial-strength C/C++ libraries and applications (yes I get paid for this), high-performance computing, OpenGL coding to roll my own volume visualization apps, doing all of my own unix system administration, setting up all of my own hardware...I've always thought that the best way to become really good at coding and software engineering is to first get a degree in mathematics. If you can do that, the rest is easy.

(Okay, I am a bit biased; I'm a college math professor, and in addition I do a lot of research and consulting related to numerical computation).

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (4, Interesting)

ohboy-sleep (601567) | more than 11 years ago | (#4423755)

When I went for my Comp Sci bachelor's I was amazed at how many math-phobics there were in my Comp Sci classes. As part of earning the degree you had to take 4 specified math classes (Calc 1 & 2, Linear Systems, Probability). You only had to take one more math class to get a minor in mathematics, Calculus 3.

Now I've always been big on math but I was kind of surprised at how few people were willing to take a single class to earn a full-fledged minor.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (2)

TheMatt (541854) | more than 11 years ago | (#4424607)

May I be the first to say, that is a sad Math minor. You should at least need to get to Number Theory or Algebra and Real Analysis to qualify for a Math minor. Those five classes are (or should be) requirements for any science course, including Comp Sci.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (0)

Anonymous Coward | more than 11 years ago | (#4424676)

Interesting at my university you can't earn a minor by choosing courses that overlap in different programs... well this is in Finland.

For example my current major is theoretical computer science and one of my minors is pure maths. Many courses in discrete math are part of both programs, but I have to choose which program I want to include these courses in. So if I take all courses in discrete math and I include them in my major, I get no credits for them to my minor, so I still have to study a minimum of 20 credits of math...

Anyway I've noticed myself that most comp sci students study only the math they have to i.e. Single/Multi Variable Calculus, Complex Analysis, Linear Algebra, Algebra, Set Theory, Logic, Graph Theory, Combinatorics and Probability. Almost no one takes further courses about the theory of generating functions, stochastic processes, mathematical logic, set theory or basic analysis like topology , measure theory, functional analysis etc.

Also few people study the theory of real-time systems or the theory of parallell and distributed systems still most of them have to code multithreaded programs when they've got their M.Sc. and start working as programmers. Most just choose a few practical courses about these subjects and ignore the theory.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (1)

Mattsson (105422) | more than 11 years ago | (#4423764)

And noone but engineers would be able to use the os. ;-)
Wait! We're back in the early 80's again! =-)

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (0)

Anonymous Coward | more than 11 years ago | (#4423863)

We would probably have rock solid operating systems without all the glitzy GUI stuf..

And we do have those today... if that's what you need. And we also have glitzy GUI-based OS's for the people that need them.

But you seem to be drawing a very bizarre conclusion in the first place. Are you saying that coders that don't know basic math tend to develop GUI-based operating systems?

And how deep do you want to go? Even if you think you know how the chip works, well... you're really just assuming that all those registers and address lines are working by magic. But if you really want to understand how those itty bitty chips work, then you have to know how transistors work, what their slew rates are, how flipflops work, and you have to be able to describe how charges move across a PN junction for all of the above to work. And to know that you'd need an understanding of how the doping compounds affect the behavior of your semiconductor crystals in the first place.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (2)

Observer (91365) | more than 11 years ago | (#4423983)

I wonder how much better could we be if coders knew basic math...
<rant>Oh, the majority of coders know basic math, all right, or at least the most important concepts that are needed to hold down a job in today's IT business. They know that time equals money, and that taking the time to get the thing done right in the first place costs too much. They know (or they think they know) that it isn't necessary to worry overmuch about program size and speed any longer, because they can always depend on the hardware engineers rescuing them with the next set of more powerful products. They know that they get a greater return on effort spent on making pretty presentation slides of all the wonderful new features that are to be put into the next release and then transcribing the slides into the product's gui than on analyzing whther the new features are being provided in a consistent and unconfusing way, or even if they are needed in the first place.</rant>

It's not that trading raw power against development costs is unreasonable where that choice exists - far from it - but rather that hand-waving away questions of efficiency on the assumption that God (or Moore's Law[1]) will provide is a sure recipe for the sort of bloated and near-unmaintainable messes that are so common today. A Mbyte here, a Mbyte there, an assumption that the compiler will find and optimize the invariant components of loops... if you're not careful these all start adding up to measurable numbers "why is this so s l o w . . .")

[1]And, of course, one can always paraphrase Parkinson's Law [google.com] for IT: programs and data expand to fill the processor power and storage available.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (1)

Hillman (137883) | more than 11 years ago | (#4424663)

it's de rigueur not de reguire. In french, i sound like e and e sounds like uh.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (2)

vidarh (309115) | more than 11 years ago | (#4424714)

Most of us wouldn't be any better at all. My math is rather rusty, though I used to be good at it at school. The reason my maths is rusty is because in the 7 years I've been doing commercial software development I have almost never needed any maths.

When I have, I've never needed anything beyond what I could find in a textbook or online in less than 5 minutes.

Heck, I've practically never even had any reason to use floating point math over that period of time.

Sure, there are lots of areas where you do need maths beyond what you can pick up from a book in 5 minutes, but there are far more where maths is irellevant.

Beyond basic algebra, maths is just another set of domain knowledge that you'll need to aquire to do particular types of software development, not something that is an inherent requirement in order to be a good coder.

Engineer versus Programmer (2)

Raiford (599622) | more than 11 years ago | (#4425100)

Embedded systems gurus are primarily ECE types. They are engineers that know programming. The math knowledge and emphasis will depend primarily on your background. There are a lot of so-called programmers out there that come from a variety of background and consequently have varying exposures to mathematics. You even tend to find programmers with MIS backgrounds who have never taken a calculus course.

It will depend really on what you call yourself. I am an engineer and I have been programming for almost 25 years however my background is definitly skewed towards scientific programming. You can even see it in the sequence of programming languages that I learned over my career:

BASIC->FORTRAN->ASSEMBLER->PASCAL->C->LISP->XLISP- >C++->JAVA

I don't call myself a programmer, but an engineer who programs. This is because you will notice there are some importand tools missing from the above list. Things such as PERL which we know that every real programmer would have in their toolbox.

Re:Wow, I'm old, I haven't seen Runge-Kutta in yea (1)

capnjack41 (560306) | more than 11 years ago | (#4425219)

I don't know how most schools are...but the school I just got by BS from lumps math and comp sci right together. Though we had to take a lot of math as it was (especially higher math, discrete math), we also had some math professors teaching CS courses (algorithms, intro to computer systems, even operating systems).

I think this prepared us pretty well for what would be a more theoretical-type CS career (i.e. not just going to work as a programmer or web developer, but also continuing on to your masters or PhD).

Some of the ideas the department was real big on was proving correctness, for example, by induction. Instead of giving you a compiler and API and saying here, do this, they made you write it out and actually write a proof about why/how your program works (now imagine people actually doing that, for their OS's CreateProcessEx function!).

flimsy review (5, Insightful)

rfischer (95276) | more than 11 years ago | (#4423676)

How does the book compare to the classics: Numerical Recipes, The Art of Computer Programming, etc?

Re:flimsy review (2, Funny)

jasonditz (597385) | more than 11 years ago | (#4423708)

If this book is done entirely in MIXAL I'm buying it!

Re:flimsy review (3, Informative)

StCredZero (169093) | more than 11 years ago | (#4423835)

The subject matter of this book is slightly different, since it has an emphasis on real-time [techtarget.com] . If you're just interested in crunching a large problem as fast as possible, then latency [netacquire.com] is not an issue.

BTW, if anyone wants to take a gander at Numerical Recipes in C/Fortran they are available here [nr.com] .

Re:flimsy review (2)

shoppa (464619) | more than 11 years ago | (#4424122)

It seems to me that the book itself is pretty flimsy, content-wise. Yeah, if you need a lot of hand-holding about the various polynomial approximations and iterative approaches to calculating special functions, you'll probably learn something. But the end of the book is Runge-Kutta; that's a technique that's covered pretty early on in Numerical Recipes or even a freshman class in numerical analysis.

Re:flimsy review (0)

Anonymous Coward | more than 11 years ago | (#4424205)

I've not taken the opportunity to really sit down and crawl through "Math Toolkit" but when I've skimmed it, it seemed to me to be almost a prequil to NR. There is some over lap (i.e. RK methods) but NR generally assumes you have a working IEEE-754 compliant math lib and goes from there. NR talks a bit about precision, but they don't dwell on it, instead focusing on packing as many different twists on numerical algorithms as possible into the book -- ending up with something that's not far from usable in a production environment at the end of each chapter -- NR in C and C++ still bears some transliteration artifacts from Fortran which bug the bejeezus out of me.

Numerical Recipes (3, Informative)

GGardner (97375) | more than 11 years ago | (#4424670)

FWIW, There's a lot of people out there who don't think too much of numerical recipes: http://math.jpl.nasa.gov/nr/

Re:Numerical Recipes (3, Insightful)

Fourier (60719) | more than 11 years ago | (#4425290)

Interesting read. Still, I would challenge all these numerical specialists to come up with a tome that is equally comprehensive and equally readable by scientists without extensive numerical analysis training. The book has been so successful because it hits the target audience perfectly.

An indispensible treasure (3, Troll)

PhysicsGenius (565228) | more than 11 years ago | (#4423704)

In my field, it is absolute essential that one squeeze every last bit of math power out of the CPU. So this books occupies a place of honor on my shelf and I refer to it almost daily when I write my Perl scripts.

I'm surprised to see it posted on /., though, because he's pretty harsh towards the gaming community. In fact, he says near the beginning that game-related technology in CPUs (MMX and so forth) is taking away much-needed brainpower from research that should be reaching towards making chips do more math per unit time (not to mention driving up production costs for toy-obsessed, joyless loners). He calls for an immediate end to the pandering that Intel et al do to get into the pocketbooks of the socially-inept, technology pseudo-elite and wants real reform in the area of empowering science.

Powerful stuff.

Dear PhysicsGenius (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423727)

I have just farted. It smells, and was quite warm during the "passing gas" stage. However, this appears to have passed now.

Yours,

Ronald B. Ghey

Re:An indispensible treasure (5, Funny)

ubermuffin (39292) | more than 11 years ago | (#4423763)

Not to nitpick here, but if you honestly wanted to "squeeze every last bit of math power out of the CPU", would you really be writing Perl scripts?

Just wondering...

-ubermuffin

Dear Ubermuffin (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423798)

Re: My previous post addressed to PhysicsGenuius

I am writing to you as PhysicsGenius has chosen to ignore my previous letters. I write in the hope that you are of a more affable disposition.

You see, in the course of readjusting myself post-flatulance it appears that I may have caused some minor soilage. If this is the case then I may require a quick trip to the bathroom. As I am the cautious sort of chap, further investigation will be required before I take action.

I will be sure to write and let you know the outcome of my investigations.

Yours,

Ronald B. Ghey

Re:An indispensible treasure (1, Insightful)

Anonymous Coward | more than 11 years ago | (#4423979)

You know, it's really easy to write complete bullshit on slashdot and get +5, so to add a little challenge, good trolls add a small self-contradition to signals to other trolls that their post is a troll. Kudos to PhysicsGenius for mastering the art of good trolling to such precision!

Re:An indispensible treasure (2)

aridhol (112307) | more than 11 years ago | (#4423793)

I have to ask. If you're trying to squeeze all the math power you can out of your computer, why are you using an interpreted language? Use something compiled so your computer can spend its time doing the math, not parsing the code.

Dear aridhol (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423808)

As I am in haste, I refer you to my previous corespondance which is addressed to Ubermuffin.

Yours,

Ronald B. Ghey

Re:An indispensible treasure (2)

WNight (23683) | more than 11 years ago | (#4424488)

This is a common question so maybe I should answer it.

If you're doing a lot of number crunching or data manipulation (in big sets, with hashes, etc) you're probably spending most of your time in the libraries which are written in C. In fact, being that they're written by programmers skilled in that specific area, you're probably getting better performance than if you wrote them yourself.

Perl isn't an interpretted language, in the traditional sense. In most BASICs, when the execution comes back to a given line it's parsed again, executed, and dumped. If anything, they usually only cache a line or two to help tight loops. Perl is interpretted/compiled all at once, when you start.

Runtime speed is a little slower than other languages, but it's mainly because you've got a lot of runtime checks and hidden memory allocation turned on. Use C++ with automatic array expanding and garbage collecting and you'll see the same kind of performance hits.

That said, the ease of perl causes a lot of features to be misused by programmers who don't know how long it'll take. If you have two pieces of data (a header name and value for instance) it's common to toss them into a hash to keep them related. This isn't really a good idea unless you need to look them up by the header name. If you're just going to dump them out in arbitrary order, you should probably use two arrays in sync. Pre-allocate them to avoid a little delay at every operation. This way you avoid the overhead of the hashing algorithm that you're never going to use, and the slightly-slower lookups compared to an array.

You can also do more complex things this way. I've seen people use hashes here and read the list out by sorting the keys to the hash and iterating through. They'll then do this a few times, sorting at every step. If you want these arrays sorted, but you still don't care about finding a specific header, use an array of two-element arrays, sort the master based on the first element, and not only do you avoid almost all the overhead of hashes, but you have a permanently sorted array, no need to sort at every use.

These programming "errors" are worse in Perl than most older languages because they're easier to implement. In C you'd have to find a library function to create hashes, or write your own. If you started to write your own you'd quickly realize how many cycles you were burning and probably find an easier way unless your application demanded it. In perl (and many little "scripting" languages) you can do so much in a single command that you may not realize.

This is why if I were hiring I'd only take programmers with a "traditional" background of C or other low-level language, before they got to the Perl, Java, Python, or whatever modern rapid-development language we were using. ASM experience is even a plus. Nobody understands the cost of a routine like someone who programmed in ASM. And it's worth thinking about. Usually you say that requiring 512MB of ram ($40 these days) is worth it to save an hour or two of programming, but hopefully at other times you realize a CGI on a busy site can't be that greedy.

So, in conclusion. Perl isn't traditionally interpretted. It's almost as fast, or faster, than C for anything that spends much time in libraries (most code). Most of what slows down Perl (or Python, or Java, or C++, etc) is programmers who don't know what routines they really need to use. The cause of this is usually not enough experience in less "helpful" languages.

Re:An indispensible treasure (1)

slimak (593319) | more than 11 years ago | (#4425414)

Agreed, much like using Matlab (which incidentally requires a rudimentary understanding of matrix algebra) - its very fast if used correctly and yet painfully slow when used incorrectly. loops = bad, vectorization = good

Re:An indispensible treasure (1)

Ella the Cat (133841) | more than 11 years ago | (#4423885)

Grrr. It's one thing to do a physics simulation with 64 bit doubles, and another thing to keep it stable with 32 bit floats. It's an art and not for the shallow thinker talk to real physicists (and gamers) at companies like Havok and MathEngine. As for intel pandering, he ought to read a book like "Platform Leadership" to learn just what Intel have done to get stuff into the hands of peasants like me, for whom Cray did diddly squat. Scientists? Hah!

Dear Ella the Cat (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#4423905)

Re: My previous post addressed to Ubermuffin

My investigations have revealed no soilage, minor or otherwise. I shall be sure to let you know should any future flatulent episodes result in a skid mark of shame.

Yours,

Ronald B. Ghey

Re:An indispensible treasure [NICE TROLL!] (0)

Anonymous Coward | more than 11 years ago | (#4424266)

Hi PhysicGenius,

I'm definetly a fan. Getting +5 on a troll like that is really a work of art.

Keep on the good work.

Re:An indispensible treasure (0, Redundant)

Hayzeus (596826) | more than 11 years ago | (#4424756)

This is a TROLL, people. And a damned good one, I might add, judging by the responses.

There is no such skewering of Intel and the gaming industry in the book AFAIK.

Hats off to PG.

Forth Algorithms (4, Interesting)

Anonymous Coward | more than 11 years ago | (#4423759)

The Forth literature contains many examples of high-performance hardware-integer-math-only routines. A core feature of most Forth algos is rescaling to a power of two space at the start of the algo and from it at the end. This allows bit shift operators to do their stuff. It can take non-trivial fiddling to rescale algorithms - hence, it's nice to just look them up.

Unfortunately, it's tricky to find Forth books these days.

That's a shame, because along with Smalltalk, Lisp and APL, I think Forth is one of the "mind expanding" languages all programmers should at least experience, instead of just deciding C/Java/C++/VB is the one true language.

Re:Forth Algorithms (0)

Anonymous Coward | more than 11 years ago | (#4423925)

"...That's a shame, because along with Smalltalk, Lisp and APL, I think Forth is one of the 'mind expanding' languages all programmers should at least experience..."


Absolutely. Forth has a few very simple ideas at its core that can be applied in many areas. Leo Brodie's "Thinking Forth" didn't just help my Forth code, but taught me a good deal about factoring problems --- a vital skill in any programming language. I also just finished a project that had some very Forthy code hidden within it: a custom rule compiler written in C# which used System.Reflection to spew out CIL code for the .NET runtime. Due to its stack-based nature, emitting CIL turns out to be very much like compiling Forth words into a dictionary.

Fun stuff!

Math in CS programs (2, Interesting)

Diver777 (614939) | more than 11 years ago | (#4423769)

I don't know of other programs, but I know at the University of Waterloo (where I am a computer science student), we must take quite a lot of math courses, ranging from linear algebra, calc, classical algebra, combinatorics & optimization and statistics. The math content for the CS program is very high, and in the end you get a BMath degree.

Maybe this is different at other schools (well, actually I know it is at most, most don't do nearly as much math), but I would hope not. I think to be a solid programmer a solid math background is a requirement.

oh, and btw, for anyone nitpicking, UW now offers a BCS program, as well as the typical BMath Honours CS. The BCS seems to offer a bit more flexibility, so BCS students may not choose to take 'as much' math.

Re:Math in CS programs (2, Interesting)

IncohereD (513627) | more than 11 years ago | (#4423915)

This is pretty much Waterloo's claim to uniqueness, is it not? Something about being the only Univeristy in Canada with a math _Faculty_?

I think this may provide some insight into whether or not it's a GoodThing for CS students to have more math in their degrees. Microsoft hires more programmers from Waterloo than anywhere else. And just look at the QUALITY of their code. :)

On a somewhat tangential note, I'm in Communications Engineering at Carleton, and we badly need a stochastics course in our program, so Digital Comm doesn't keep flying over our heads. Sometimes more math is good.

Re:Math in CS programs (0)

Anonymous Coward | more than 11 years ago | (#4424273)

To crank out HTML pages, lay cable, and write perl cgi scripts to handle shopping carts, you don't need math at all.

There are positions that need math. There are more positions, however, that don't need a lick of math.

The schools in my area all have at least one or maybe two big employers. The curriculum is generally based on the needs of these few employers.

You don't need a whole lot of math to write reports for banks and insurance comapanies. If there needs to be anything more complicated than running totals, you are told what to do.

Re:Math in CS programs (1)

Diver777 (614939) | more than 11 years ago | (#4424464)

The schools in my area all have at least one or maybe two big employers. The curriculum is generally based on the needs of these few employers

See, that is where your problem is! The school is setting curriculum based on employers. It should not happen this way. Your school is shortchanging every student who goes there, by effectively (though obviously not completely) limiting their student's employment choices after school. Post-secondary education, especially at the university level, should educate its students in a way in which they can work almost anywhere, not just the 1 or 2 big companies in the area.

And oh, as a side note for another reply, yes, MS hires more grads from U.Waterloo then anywhere else, and when even the slightest controversy comes about over MS controlling curriculum [slashdot.org] , people get angry and fights start.

Neglected subject, good review, integer!=assembly (5, Interesting)

wfmcwalter (124904) | more than 11 years ago | (#4423779)

This is a subject that's rather neglected - three years of college math didn't go very far in letting me understand how math (fp and otherwise) is actually done in discrete systems.

A year (or so) ago I attended a lecture given by Guy Steele (of Lisp/Java/ Crunchly fame) on his proposal to alter how IEEE floating point numbers are mapped to real numbers. It quickly flew over my head, but gave a great insight into the whole field. Steele then had a fair old "discussion" with the one person in the audience whose head hadn't been overflown (sic), as there was plainly still much controversy left in this area. On trying to do some "why didn't I get this stuff at college" reading, I found there wasn't a great deal of literature.

The reviewer's concern that coprocessor-less systems should be covered is valid, but I'm not sure going as far as assembly is necessary. For example, I once had the privilige of reading through Hitachi's libm implementation for their H8 series microprocessor/microcontroller (one would be generous to call H8 a 16-bit system, and ungenerous to call it an 8-bit system). With one small exception (I think the cos table lookup) the whole thing was in (quite readable) C, and (at least for basic libm stuff) performance was perfectly acceptable. For didactic purposes, a C (or sane C++) implementation would be the thing one would want to find in a book - I get very annoyed at embedded books where the examples are written in asm for the author's favourite (obscure) microcontroller.

Re:Neglected subject, good review, integer!=assemb (3, Informative)

sv0f (197289) | more than 11 years ago | (#4425506)

A year (or so) ago I attended a lecture given by Guy Steele (of Lisp/Java/ Crunchly fame) on his proposal to alter how IEEE floating point numbers are mapped to real numbers. It quickly flew over my head, but gave a great insight into the whole field.

Steele is God. He also invented Scheme, wrote the original Common Lisp manual, co-wrote with Harbison a classic reference manual for C, and wrote parallel languages for the Connection Machine.

On trying to do some "why didn't I get this stuff at college" reading, I found there wasn't a great deal of literature.

This [nec.com] is widely considered a good introduction.

Same Crenshaw? (0)

mccormick (40772) | more than 11 years ago | (#4423851)

Is this Crenshaw the same guy who wrote that compiler tutorial, the mini-epic that lasted a decade? His aim was to guide budding compiler writers in the direction of creating a native Pascal compiler. His style was lucid, informative yet friendly. I think timothy's words, "self-confident" aptly describes it. I'd recommend anyone to the works of Crenshaw and I agree, his knowledge of the subject areas is always superb.

Thats a good tutorial (0)

Anonymous Coward | more than 11 years ago | (#4423877)

Lets write a compiler! is a good tutorial. I wouldn't have wanted to try and follow it as he was writting it (Some chapters are many years apart!), but these days you can easily read the whole thing (If you don't mind the fact that its writting in Pascal and targets the 68000 CPU).

As you say, the style of writing is warm and friendly, and he takes his time to properly explain the concepts. A very good writer.

Link & More (1, Interesting)

mccormick (40772) | more than 11 years ago | (#4423910)

That's it. For those who want the quick link for the Let's Write a Compiler, right here [iecc.com] (http://compilers.iecc.com/crenshaw/.) I really hope that Crenshaw might write again about compilers. I agree with the Pascal and 68k part -- they're old, and even some of the approach taken by the tutorial is probably not up to speed with modern practices. But hey, at least it gives a good historical account.

Under covered subject; average review... (4, Interesting)

Svartalf (2997) | more than 11 years ago | (#4423869)

Embedded != Assembly coding.

To be honest, a lot of embedded coding is done with C or C++ these days. I've been following Crenshaw's articles in Embedded Developer magazine for years now. He explains a lot of what they try to teach in college Calc, etc. in simple, practical terms, and reduces it to usable algorithms.

I'd probably buy the book and add it to my shelf.

College Math (3, Interesting)

BobTheJanitor (114890) | more than 11 years ago | (#4423907)

I graduated as a Math/CS double major from Drake University, where almost all CS majors also got a Math degree because the CS prereqs covered all but 3 of the Math prereqs. It has actually helped me enormously as a programmer to know math: in the past month, I've needed transformation matrices, sine/cosine stuff, and a bunch of other things that, granted, could have been lifted verbatim from Google groups, but it's often faster (and the code is better) if I just do it myself.

Yes, it's an interesting book... (3, Interesting)

joto (134244) | more than 11 years ago | (#4423924)

Not being exactly a math whizard myself, I found this book extremely entertaining. It's pretty easy to see that the author is a heavy follower of the KISS philosophy. He tries to keep it simple not just in his code, but also in his explanations. It is possible to understand most of his explanations, even if you don't know much about differential equations, fft's or anything else.

As for the title, I agree it's a bit misleading. The book has pretty little to do about real-time (in fact nothing, as far as I could see). What it really should be called is "Computer arithmetic and a little of numerical methods for dummies". This book will help you understand how to write your own libm, and give you some ideas for more advanced tasks, but that's about it.

For me, who didn't know much of this stuff, it was very interesting. It will probably not save you that course in numerical algorithms (which I for one haven't taken), but even then, it will probably contain some interesting tidbits you didn't know.

On the other hand, if you have years of experience in writing computer math routines, it will probably quickly become dull, but that's true about anything you already know.

Don't click on Slashdots book link (3, Informative)

RedWolves2 (84305) | more than 11 years ago | (#4424239)

Bn.com has this book listed at $49.95. Amazon has it for $34.97 [amazon.com]

Save your self some money!

Decimal libraries (3, Interesting)

Tablizer (95088) | more than 11 years ago | (#4424335)

As a biz-app programmer, I am bothered by too much attention given to floating point math and not enough to decimal math. A decimal-centric approach would give better results for monetary calculations, because any truncation and rounding are at decimal (base-10) boundaries instead of base-2 boundaries. It gives results more like one expects doing it by hand on paper, which shapes most peoples' perceptions of what they expect (and the customer is always right, even if they are boneheads).

The only library I know that supports it is the BC-library sometimes used with PHP. (Well, I guess you could say that COBOL has such also.) It actually uses strings to hold the results so that there is no machine-based limitation on precision size. Plus, that improves its cross-language use since almost everything supports dynamic strings these days.

(Not the fasted approach I suppose, but most biz apps are not math intensive anyhow. Most code is devoted to comparing strings, codes, and ID's and moving things around from place to place. IBM used to include decimal-friendly operations in its CPU's. Those days seem gone for some reason, yet biz apps are still a huge domain.)

Re:Decimal libraries (2)

vidarh (309115) | more than 11 years ago | (#4424475)

The reason so little focus is given to what you call "decimal math", and most people would call "fixed point" is that there's a very simple way of doing it: You do everything with integers scaled sufficiently high up, and move the comma to the right the prerequisite number of steps to get the number of decimal points you want.

Oh, and there are lots of old fixed point code floating around. Looking for "fixed point" instead of "decimal math" might help you find what you want...

Re:Decimal libraries (1)

Tablizer (95088) | more than 11 years ago | (#4425210)

(* there's a very simple way of doing it: You do everything with integers scaled sufficiently high up, and move the comma [euro decimal?] to the right the prerequisite number of steps to get the number of decimal points you want.*)

Integers have a limited length in most built-in stuff. What if you want to store 0.666666666666666666666 in a variable?

Besides, one should still wrap such behind a library rather than manually manage the decimal position. You would then have an integer version of the BC library I mentioned.

Re:Decimal libraries (1)

wfmcwalter (124904) | more than 11 years ago | (#4424541)

If memory serves, the Mac's math libraries initially used decimal strings to represent numbers - it's been a decade since I wrote a Mac program - perhaps someone with more current knowledge can shed some light as to whether this is still the case?

Also, Java's java.lang.math.BigDecimal class contains just the kind of functionality you describe - its docs are here [sun.com] .

In general, I think you'll find lots of fixed point math libraries around - they're mostly intended for numerical computation and mathematical cryptography (e.g RSA), but they should be quite applicable (if sometimes overkill) for your biz-app uses.

Re:Decimal libraries (1)

gatkinso (15975) | more than 11 years ago | (#4425190)

What realtimre development do you do in the business setting?

I think you will find that floating point calculations have much more applications in realtime environments.

Fixed point calculation is integer based, sometimes using BCD representation in older machines.

Re:Decimal libraries (2)

Tablizer (95088) | more than 11 years ago | (#4425396)

I think you will find that floating point calculations have much more applications in realtime environments.

Why is that?

BTW, could you clarify what you mean by "real-time"? I have seen 2 different definitions before. One is that the response time has to be within a specified tolerance 100% of the time. The other is "interactive". I did not use that term IIRC.

Re:Decimal libraries (1)

Tablizer (95088) | more than 11 years ago | (#4425490)

BTW, I am *not* talking about embedded systems. I suppose that makes me *half* off-topic since I am only talking about math libraries, and not embedded ones.

Sorry about not clarifying that. I suppose that also means I will get mod slammed. Knock me only 0.5 points down since I am still partly on topic, okay guys?

Also wrote "Let's Build A Compiler" series... (2, Informative)

Anonymous Coward | more than 11 years ago | (#4424589)

Mr. Crenshaw is also the author of the popular Let's Build a Compiler [iecc.com] series of articles a while back.

These articles don't go into a lot of the complicated stuff that's involved in modern compiler design-- Crenshaw keeps it simple, keeps it straightforward, and still produces a working (if not optimizing) compiler by the end of the second or third article.

No, it won't let you code a C compiler that will beat the pants off of gcc or Borland's latest offering, but the end result is pretty useful.

Amazon link, too (2, Interesting)

tibbetts (7769) | more than 11 years ago | (#4424899)

For those who don't support Slashdot's Amazon embargo, here's their link to the book [amazon.com] . Not only are they selling the book for $35, they have 25 sample pages, including the entire index and the first half of the first chapter. (And no, I'm not in Amazon's affiliates program and don't make a dime if you buy the book using the link that I provided, as a quick glance at the URL will prove.)

Die Hard Assemblers? (1, Funny)

Anonymous Coward | more than 11 years ago | (#4425449)

Holy crap! Who would do assembly because they like it? As Brian Fellows would say, "Thats CRAZY!"
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>