From: Andrew Wolven
Subject: numbers question for the experts
Date: 
Message-ID: <z7idnWolmNubbpHZnZ2dnUVZ_vudnZ2d@comcast.com>
Hi all,
I'm taking a numerical methods class at school.  We had an assignment where 
we did interpolation of a point using an exact fitted curve.  We used two 
types of curves: a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4 = y, and cubic spline. 
In both cases I am getting different numbers from the solutions manual and 
the TA's version.

In one instance I used an exact transliteration to the best of my ability of 
his matlab code (the gauss-seidel algorithm).  I keep getting the same 
answer, which is different from his (but within average of 12% error).  So 
then I tried it using Maxima 5.9.2 on GCL - linsolve - (I had been using ACL 
8.0 on wintel), and got the same answer as my lisp code.  So then I used 
Macsyma 2.3 which uses CLOE, and once again, got the same answer as the ACL 
transliteration of his code.

What is going on here?  I'm loosing points on my homework.  What is lisp 
doing with the numbers?  I think I know, but I would like to hear an expert 
comment.

I'm a little tired right now, so if you want me to post code I will do that 
tomorrow.  I have to take the trash out.

Thanks in advance,
Andrew Wolven

(could be just doing it wrong) 

From: Andrew Wolven
Subject: Re: numbers question for the experts
Date: 
Message-ID: <87qdnUL-0q2LnJDZ4p2dnA@comcast.com>
never mind, in my exhaustion, I had a typo in my data set, how embarrassing
:(

but while you're here tell me about how lisp handles precision and why if I
do:

(expt 5.0d0 2.0d0) on an ACL 8.0 derivative (GDL built on ANSI mode ACL)
I get 25.0 instead of 25.0d0 ?

(damn am I embarrassed, that's why I never post here because I always find
my mistake minutes after)

(like clicking post-to-sender instead of post-to-newsgroup on this last 
message)

"Andrew Wolven" <·······@nospam.net> wrote in message 
·····································@comcast.com...
> Hi all,
> I'm taking a numerical methods class at school.  We had an assignment 
> where we did interpolation of a point using an exact fitted curve.  We 
> used two types of curves: a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4 = y, and 
> cubic spline. In both cases I am getting different numbers from the 
> solutions manual and the TA's version.
>
> In one instance I used an exact transliteration to the best of my ability 
> of his matlab code (the gauss-seidel algorithm).  I keep getting the same 
> answer, which is different from his (but within average of 12% error).  So 
> then I tried it using Maxima 5.9.2 on GCL - linsolve - (I had been using 
> ACL 8.0 on wintel), and got the same answer as my lisp code.  So then I 
> used Macsyma 2.3 which uses CLOE, and once again, got the same answer as 
> the ACL transliteration of his code.
>
> What is going on here?  I'm loosing points on my homework.  What is lisp 
> doing with the numbers?  I think I know, but I would like to hear an 
> expert comment.
>
> I'm a little tired right now, so if you want me to post code I will do 
> that tomorrow.  I have to take the trash out.
>
> Thanks in advance,
> Andrew Wolven
>
> (could be just doing it wrong)
> 
From: Duane Rettig
Subject: Re: numbers question for the experts
Date: 
Message-ID: <o08xrmew65.fsf@franz.com>
"Andrew Wolven" <·······@nospam.net> writes:

> never mind, in my exhaustion, I had a typo in my data set, how embarrassing
> :(
>
> but while you're here tell me about how lisp handles precision and why if I
> do:
>
> (expt 5.0d0 2.0d0) on an ACL 8.0 derivative (GDL built on ANSI mode ACL)
> I get 25.0 instead of 25.0d0 ?

Are you sure they're not the same?  What is the value of
read-default-float-format?  What does 5.0d0 print when
evaluated?  or 25.0d0?

Get some sleep...

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Andrew Wolven
Subject: Re: numbers question for the experts
Date: 
Message-ID: <Hc6dnY4L4pjPnJDZnZ2dnUVZ_s6dnZ2d@comcast.com>
please, work me over.

"Andrew Wolven" <·······@nospam.net> wrote in message 
···························@comcast.com...
> never mind, in my exhaustion, I had a typo in my data set, how 
> embarrassing
> :(
>
> but while you're here tell me about how lisp handles precision and why if 
> I
> do:
>
> (expt 5.0d0 2.0d0) on an ACL 8.0 derivative (GDL built on ANSI mode ACL)
> I get 25.0 instead of 25.0d0 ?
>
> (damn am I embarrassed, that's why I never post here because I always find
> my mistake minutes after)
>
> (like clicking post-to-sender instead of post-to-newsgroup on this last 
> message)
>
> "Andrew Wolven" <·······@nospam.net> wrote in message 
> ·····································@comcast.com...
>> Hi all,
>> I'm taking a numerical methods class at school.  We had an assignment 
>> where we did interpolation of a point using an exact fitted curve.  We 
>> used two types of curves: a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4 = y, and 
>> cubic spline. In both cases I am getting different numbers from the 
>> solutions manual and the TA's version.
>>
>> In one instance I used an exact transliteration to the best of my ability 
>> of his matlab code (the gauss-seidel algorithm).  I keep getting the same 
>> answer, which is different from his (but within average of 12% error). 
>> So then I tried it using Maxima 5.9.2 on GCL - linsolve - (I had been 
>> using ACL 8.0 on wintel), and got the same answer as my lisp code.  So 
>> then I used Macsyma 2.3 which uses CLOE, and once again, got the same 
>> answer as the ACL transliteration of his code.
>>
>> What is going on here?  I'm loosing points on my homework.  What is lisp 
>> doing with the numbers?  I think I know, but I would like to hear an 
>> expert comment.
>>
>> I'm a little tired right now, so if you want me to post code I will do 
>> that tomorrow.  I have to take the trash out.
>>
>> Thanks in advance,
>> Andrew Wolven
>>
>> (could be just doing it wrong)
>>
>
> 
From: David J Cooper Jr
Subject: Re: numbers question for the experts
Date: 
Message-ID: <87veuqoq95.fsf@graham.genworks.com>
Hi Andrew,

 GDL has *read-default-float-format* set to double-float, so numbers
are read _and_ printed in double-float by default, and double-floats
will not show up with the "d" indicator (although in this mode,
single-floats _will_ show up with the "f" indicator).

 -dave
David J Cooper Jr, Genworks International
From: Thomas A. Russ
Subject: Re: numbers question for the experts
Date: 
Message-ID: <ymiy7zm5dtj.fsf@sevak.isi.edu>
"Andrew Wolven" <·······@nospam.net> writes:

> never mind, in my exhaustion, I had a typo in my data set, how embarrassing
> :(
> 
> but while you're here tell me about how lisp handles precision and why if I
> do:
> 
> (expt 5.0d0 2.0d0) on an ACL 8.0 derivative (GDL built on ANSI mode ACL)
> I get 25.0 instead of 25.0d0 ?

The printed representation of floats depends on a couple of things, such
as the number of different types of floating point numbers actually
implemented in the specific Lisp implementation as well as the value of
*READ-DEFAULT-FLOAT-FORMAT*, which specifies the format for reading
floats that don't have a specific marker.

What is the result of the following:

  (type-of 25.0)
  (type-of 25.0d0)
  (type-of (expt 5.0d0 2.0d0))



-- 
Thomas A. Russ,  USC/Information Sciences Institute