close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

Opened 16 years ago

Closed 16 years ago

#24 closed defect (fixed)

Float contagion for expt

Reported by: Raymond Toy Owned by: somebody
Priority: minor Milestone:
Component: Core Version: 2008-09
Keywords: Cc:

Description

Consider

* (expt 2 #c(-.5d0 0))
#C(0.7071067805131506d0 0.0d0)

Compare that with

* (expt 2d0 #c(-.5d0 0))
#C(0.7071067811865475d0 0.0d0)
* (sqrt .5d0)
0.7071067811865476d0

I think we should apply float contagion in the first case to produce the more accurate result.

Change History (1)

comment:1 Changed 16 years ago by Raymond Toy

Resolution: fixed
Status: newclosed

Should return the more accurate answer in snapshot 2008-11.

Both arguments are effectively coerced to the most precise argument before computing the exponential.

The above result happens because we compute the result as

(exp (* #c(-.5d0 0) (log 2)))

(log 2) only has single-precision accuracy.

We now compute it as

(exp (* #c(-.5d0 0) (log (coerce 2 'double-float))))
Note: See TracTickets for help on using tickets.