Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve accuracy of eraStarpv() #41

Merged
merged 1 commit into from
Dec 8, 2016

Conversation

olebole
Copy link
Collaborator

@olebole olebole commented Nov 21, 2016

In the relativistic correction, the term

del = sqrt(1+x) - 1

is used with a rather small value of x (often 1e-8 or such). This gives inaccurate results because of the subtraction of 1 from a number very close to 1.

To improve this, the right term is extended by sqrt(1+x)+1, which gives

 del = x / (sqrt(1+x) + 1)

without a subtraction of two equally large numbers and therefore a better accuracy. This helps on i386 FPU. to get on all platform results that are as excellent as with the x87 FPU ;-)

The test is adjusted as well.

This will fix #33.

In the relativistic correction, the term

 del = sqrt(1+x) - 1

is used with a rather small value of x (often 1e-8 or such). This gives
inaccurate results because of the subtraction of 1 from a number very close
to 1.

To improve this, the right term is extended by sqrt(1+x)+1, which gives

 del = x / (sqrt(1+x) + 1)

without a subtraction of two equally large numbers and therefore a better
accuracy. This helps on i386 FPU.

The test is adjusted as well.
@timj
Copy link
Contributor

timj commented Nov 21, 2016

@scottransom can you take a look at this with regard to whether this patch is suitable for upstream SOFA? See also #33.

@eteq
Copy link
Member

eteq commented Dec 8, 2016

@scottransom - just to check, did you also pass this along to the sofa board when discussing #40 ?

@scottransom
Copy link

@eteq and @timj Whoops.... I completely missed this one. I'll pass it along today. I suspect this will be quickly approved.

@eteq
Copy link
Member

eteq commented Dec 8, 2016

@scottransom just mentioned in #40 that this is a good fix, so I'll just go ahead and merge this. Probably we can just remove it again at the next SOFA release, but just in case...

Thanks @olebole!

@eteq eteq merged commit 16f22ec into liberfa:master Dec 8, 2016
@scottransom
Copy link

@eteq So SOFA is planning a new release for Wed, Dec 21. That will include this improvement and #40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with gcc 6 and i386
4 participants