View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000509 | ascend | compiler | public | 2011-04-15 00:27 | 2013-02-26 13:39 |
Reporter | ujjavalverma10 | ||||
Assigned To | |||||
Priority | normal | Severity | trivial | Reproducibility | have not tried |
Status | feedback | Resolution | reopened | ||
Platform | Linux | OS | Ubuntu | OS Version | 9.04 |
Product Version | 0.9.7 | ||||
Target Version | 0.9.9 | Fixed in Version | 0.9.8 | ||
Summary | 0000509: Second derivative of tan() function, ie : datan2() returns wrong expression | ||||
Description | I 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. | ||||
Tags | No tags attached. | ||||
related to | 0000508 | resolved | Incorrect function call in safe.c |
|
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) |
|
I have uploaded a patch that will rectify both issue 509 and issue 508 |
|
whoa! hang on... there was still a missing power of two in the (1+x^2)^2 that should be in the denominator... no? |
|
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] |
|
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] |
|
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) |
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 |