Jump to content

Maths Errors


czardas
 Share

Recommended Posts

I have been thinking about what constitutes an error in basic mathematical operations. I'm beginning to form the opinion that very few exist. Division by zero is not really an error - or is it? Just because we can't represent certain numbers in binary doesn't imply an error. What about imaginary roots? - they have properties but we call them NaN. I'm curious about your opinions in relation to programming. Do you consider -1^0.5 to be an error?

Edit
To clarify: normally we catch these events before a they happen and return an error from the function we are writing. This has to be done this way because no error is thrown by the mathematical operation itself. Context is of consequence here.

Edited by czardas
Link to comment
Share on other sites

i can't help but recall that _FileListToArray() returns an error when no files found - which is a perfectly valid result. i'd presume error definition varies quite widely, in any discipline you look at. in general, i would say that an error should be defined as a situation which prevented you (or your script, or your mathematical operator) from performing its task. as far as math is concerned, being the most abstract of all exact sciences, i'd recon one would have to work pretty hard to formulate such circumstances, if possible at all.

 

for your example, -1^0.5, although hardly useful, may well be a perfectly valid result, in some unforeseen scenario. let's look at the other approach: say i currently cannot imagine such a scenario, therefore i define it as an error - that would be quite arrogant on my part; and when such scenario does come to existence, would i say "oh, the error was resolved."? ridiculous.

 

and as for programming - one should sanitize input before processing, so if an error does occur, it is most likely a "real" error, not just feeding gibberish to functions.

Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Taking the sqare root of -1 ( i ) is only an error when the operation takes place outside of the suitable set within a given math "theory" (a set of axioms), for instance the set of so-called complex numbers, namely .

As you say, everything is context-dependant. Yet there are rules that needs to be observed in every math context, like predicate logic, because they are the funding of the mathematical thinking. If you create new fundamental rules (i.e. a new axiomatic), then you're building another distinct math construct (theory) with which you're left alone.

When doing mathematical operations with a computer, things are a little more fuzzy, because you're always limited by implementation possibilities. That may be by limited integer or real (FP) representation, by the difficulty to implement abstract entities or by the time operations require. As a basic example of such difficulty, there is no good way to perform actual computations with the real counterpart of the rational ⅓ which is normaly noted 0.3 with a black dot above the 3. Even an unlimited precision arithmetic library can't represent it (it can represent unbounded precision but not infinite precision).

So an error in computer context is nothing more than hitting one limitation of the hardware or software you use even if you stay within a sound mathematical theory (don't violate the set of rules of the underlying axiomatic).

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Both responses are very helpful to me, although I'm still unsure if these types of result should be considered errors in coding generally. The examples I gave do not crash AutoIt, and return a numeric value - albeit one which is generally meaningless in most programming contexts. I was thinking of having error codes consistent with all functions in a particular UDF - which could involve gaps eg. @error = 1, 2, ... 5. Then I was thinking of doing the same with @extended information, and infinity (or i) would set the extended flag instead. Then if someone wanted to use these values, they could do so without errors being returned by the UDF functions. This seems to be the way things are done already - with the onus still being on the user to catch problems themselves before they occur (when a mathematical operation occurs).

Edited by czardas
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...