View Issue Details

IDProjectCategoryView StatusLast Update
0000509ascendcompilerpublic2013-02-26 13:39
Reporterujjavalverma10 
Assigned To 
PrioritynormalSeveritytrivialReproducibilityhave not tried
Status feedbackResolutionreopened 
PlatformLinuxOSUbuntuOS Version9.04
Product Version0.9.7 
Target Version0.9.9Fixed in Version0.9.8 
Summary0000509: Second derivative of tan() function, ie : datan2() returns wrong expression
DescriptionI came across the following code in ascend/compiler/func.c : ( line 343 )

double datan2(register double d)
{
  return -ldexp(d/(1.0+d*d),1);
}

But datan2(d) should return -2*d/sqr(1+d*d) instead of the above expression.
TagsNo tags attached.

Relationships

related to 0000508 resolved Incorrect function call in safe.c 

Activities

ujjavalverma10

2011-04-15 00:34

reporter  

ujjaval-bug509and508.patch (698 bytes)
Index: ascend/compiler/func.c
===================================================================
--- ascend/compiler/func.c	(revision 3372)
+++ ascend/compiler/func.c	(working copy)
@@ -288,7 +288,7 @@
 
 double datan2(register double d)
 {
-  return -ldexp(d/(1.0+d*d),1);
+  return -2*d/sqr(1+d*d);
 }
 
 #ifdef HAVE_ERF
Index: ascend/compiler/safe.c
===================================================================
--- ascend/compiler/safe.c	(revision 3372)
+++ ascend/compiler/safe.c	(working copy)
@@ -510,7 +510,7 @@
 double safe_cube_D0(double x,enum safe_err *safe)
 {
   (void)safe;
-   return( cbrt(x) );
+   return( cube(x) );
 }
 
 double safe_cbrt_D0(double x,enum safe_err *safe)

ujjavalverma10

2011-04-15 00:35

reporter   ~0000735

I have uploaded a patch that will rectify both issue 509 and issue 508

john

2011-08-19 00:12

administrator   ~0000769

whoa! hang on... there was still a missing power of two in the (1+x^2)^2 that should be in the denominator... no?

john

2011-11-14 12:35

administrator   ~0000793

Email from: John Pye <john.pye@anu.edu.au>

Hi Ben

We might need to review this bug, because some code was committed in
changeset 3772.

Cheers
JP

On 18/08/11 23:33, Ben Allan wrote:
> the code is already correct with ldexp.
> man ldexp for details of why this is so.
> ben
>
> On Wed, Aug 17, 2011 at 2:34 AM, Mantis Bug Tracker<mantis@ascend4.org> wrote:
>> The following issue has been UPDATED.
>> [EmailReporting -> Removed part identified as reply]

ben

2011-11-17 08:50

manager   ~0000795

Email from: Ben Allan <ba22.cmu@gmail.com>

re bug 508, the patch should have been:

- return cbrt(x);
+ if (fabs(x) < cbrt(DBL_MAX)) {
+ return cube(x);
+ } else {
+ *safe_err = safe_overflow;
+ return DBL_MAX;
+ }

if ambitious, define F_MAX_CBRT in func.h to avoid repeated calls to
cbrt(DBL_MAX).

re bug 509, there should have been not patch, as there is no bug. The
original ldexp code is correct.

Ben


incorrect patch issue 508 below

Index: ascend/compiler/safe.c
===================================================================
--- ascend/compiler/safe.c (revision 3372)
+++ ascend/compiler/safe.c (working copy)
@@ -510,7 +510,7 @@
 double safe_cube_D0(double x,enum safe_err *safe)
 {
   (void)safe;
- return( cbrt(x) );
+ return( cube(x) );
 }

 double safe_cbrt_D0(double x,enum safe_err *safe)


On Sun, Nov 13, 2011 at 5:31 PM, John Pye <john.pye@anu.edu.au> wrote:
> Hi Ben
>
> We might need to review this bug, because some code was committed in
> changeset 3772.
>
> Cheers
> JP
>
> On 18/08/11 23:33, Ben Allan wrote:
>>
>> the code is already correct with ldexp.
>> man ldexp for details of why this is so.
>> ben
>>
>> On Wed, Aug 17, 2011 at 2:34 AM, Mantis Bug Tracker<mantis@ascend4.org>
>>  wrote:
>>>
>>> The following issue has been UPDATED.
>>> [EmailReporting -> Removed part identified as reply]

saheb

2012-03-28 07:32

developer   ~0000828

I wanted to know why hasn't the bug's status changed to resolved, as it is correctly present in the trunk.

If you want to change and calculate it using ldexp,

then use return -ldexp(d/sqr(1+d*d),1)

Issue History

Date Modified Username Field Change
2011-04-15 00:27 ujjavalverma10 New Issue
2011-04-15 00:34 ujjavalverma10 File Added: ujjaval-bug509and508.patch
2011-04-15 00:35 ujjavalverma10 Note Added: 0000735
2011-08-17 19:34 svn
2011-08-17 19:34 svn Status new => resolved
2011-08-17 19:34 svn Resolution open => fixed
2011-08-17 19:34 john Product Version => 0.9.7
2011-08-17 19:34 john Fixed in Version => 0.9.8
2011-08-17 19:34 john Target Version => 0.9.8
2011-08-19 00:12 john Note Added: 0000769
2011-11-14 12:35 john Note Added: 0000793
2011-11-14 12:35 john Status resolved => feedback
2011-11-14 12:35 john Resolution fixed => reopened
2011-11-17 08:50 ben Note Added: 0000795
2012-03-28 07:32 saheb Note Added: 0000828
2012-04-11 06:18 john Relationship added related to 0000508
2012-04-28 10:25 john Target Version 0.9.8 => 1.0
2013-02-26 13:39 john Target Version 1.0 => 0.9.9