public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Pavan, Amancherla (IE10)" <Pavan.Amancherla@honeywell.com>
To: gcc-help@gcc.gnu.org
Subject: Deviations in _Sinh(double, double); and the related functions.
Date: Tue, 18 Nov 2003 14:58:00 -0000	[thread overview]
Message-ID: <77ED2BF75D59D1439F90412CC5B1097404454606@ie10-sahara.hiso.honeywell.com> (raw)

The following functions are giving wrong results for some of the inputs on
gcc_ppc compiler with Dinkumware library.
double _Sinh(double, double);
float _FSinh(float, float);
long double _LSinh(long double, long double);
These are declared in <ymath.h> in Dinkumware library.

These functions are supposed to behave as follows
_Sinh(a, b) = sinh(a) * b

But when the value of the the first argument('a') is in between [-0.55, 0)
or (0, 0.55]
I am getting wrong results.
_Sinh(a, b) is returning a value equal to sinh(a), what ever may be the
second argument, for the above range of values.
For zero and values very near to it(like 0.00000013) and other values, I am
getting right results.


Here is the sample code.

#include <ymath.h>
#include <iostream>
#include <cmath>

using namespace std;
void verify(char * comment_string, double actual_value, double
expected_value)
{
	
cout<<comment_string<<"\t\t"<<actual_value<<"\t\t"<<expected_value<<endl;
}

void main()
{
	for(double value = -0.6; (value <= 0.6); value += 0.01)
	{
		cout<<"Angle  : "<<value<<endl;
		verify("_Sinh with second arg as -1.2", 
			_Sinh(value, -1.2), std::sinh(value) * -1.2);
		verify("_Sinh with second arg as -1.0", 
			_Sinh(value, -1.0), std::sinh(value) * -1.0);
		verify("_Sinh with second arg as -0.9", 
			_Sinh(value, -0.9), std::sinh(value) * -0.9);
		verify("_Sinh with second arg as -0.2", 
			_Sinh(value, -0.2), std::sinh(value) * -0.2);
		verify("_Sinh with second arg as 0.0", 
			_Sinh(value, 0.0), std::sinh(value) * 0.0);
		verify("_Sinh with second arg as 0.2", 
			_Sinh(value, 0.2), std::sinh(value) * 0.2);
		verify("_Sinh with second arg as 0.9", 
			_Sinh(value, 0.9), std::sinh(value) * 0.9);
		verify("_Sinh with second arg as 1.0", 
			_Sinh(value, 1.0), std::sinh(value) * 1.0);
		verify("_Sinh with second arg as 1.2", 
			_Sinh(value, 1.2), std::sinh(value) * 1.2);
	}
	verify("_Sinh for a value very near to zero", 
		_Sinh(value, 0.00000013), std::sinh(value) * 0.00000013);
}

Observe that when the values for 'a' for _Sinh(a, b) are in the range [-0.6,
-0.55] the results are correct,
for [-0.55, 0.55] results are wrong(except for zero),
for [0.55, 0.6] the results are correct.
Can you please tell me if my observation is correct and why this is
happening like this.

Thanks,
pavan.

             reply	other threads:[~2003-11-18 14:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-18 14:58 Pavan, Amancherla (IE10) [this message]
2003-11-22 23:37 Dara Hazeghi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77ED2BF75D59D1439F90412CC5B1097404454606@ie10-sahara.hiso.honeywell.com \
    --to=pavan.amancherla@honeywell.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).