Waldek Hebisch <[EMAIL PROTECTED]> writes:

> Martin, first I _really_ prefer to get exceptions in normal code.
> Ignoring exceptions is a great way to do not see bugs.  Also, things
> like infinities and (particularly nasty) "not a number" break normal
> mathematical reasoning.

Don't worry, I see your point.  One thing though:

> (basically IEEE defined a new formal system quite unlike mathematical real
> numbers).

Is it really different?  I thought that computation with +infinity and
-infinity was OK - except for imagpart...

I don't care about nan.

(but read on, first...)

> Note: trapping exceptions in plotted (user provided) function is
> reasonable because we have no control on user code.

Yes, this is what I want in the end.  It would have been easier to commit the
current code, but I guess that you are right.

> I think that correct way is to rewrite plotting routine in a way
> which avoids overflow.  If we up front limit user values to some
> reasonable range (like -10^150..10^150) this should be not that
> hard.  Of course, we will have to think a while about each formula,
> but if we do not care much what happens with big numbers than
> it will be easy to clip them.  If some case turns out to be more
> tricky, then it is quite likely that ignoring errors would
> produce wrong value.  I understand that clipping code may
> be bulky and look ugly, but proper clipping/rounding is essential
> part of the plotting algorithm.

Unfortunately, it is not that easy, since trapNumericErrors does *not* trap all
errors - most importantly, (float reallybiginteger 0.0d0) throws a type-error
instead:

------------------------------------------------------------------------
)lisp (defmacro |mytrap| (form)    `(handler-case (cons 0 ,form)
(arithmetic-error () |$numericFailure|)  (simple-type-error (var) (print
(simple-condition-format-control var)) |$numericFailure|)))
Value = |mytrap|
(1) -> )lisp (|mytrap| (float (expt 10 400) 0.0d0))

"Too large to be represented as a ~S:~%  ~S" 
Value = (1 . "failed")

(1) )lisp (|mytrap| (float (- (expt 10 400)) 0.0d0))

"Too large to be represented as a ~S:~%  ~S" 
Value = (1 . "failed")
------------------------------------------------------------------------

One problem I have is that myTrap distinguishes between positive and negative
infinity.

However, if I trap arithmetic-errors myself, I loose this possibility: I can
only see in which operation the error occurred and cannot continue computation.

So, maybe I should just return max()$FLOAT always and ignore infinities?  I'll
try that first.

Martin


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to fricas-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to