[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating

**From**: |
Olivier Amoignon |

**Subject**: |
[Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating sin^2 or cos^2 on multiple of 8 periods |

**Date**: |
Thu, 16 Jan 2020 08:19:28 -0500 (EST) |

**User-agent**: |
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko |

Follow-up Comment #5, bug #57603 (project octave):
After having a look at the code in scripts/general/quadv.m implementing an
adaptive Simpson algorithm the cause of the wrong result for certains
intervals of periodic functions being periodically equal to 0 is
straight-forward: at nfun=5 the value of q is still q=q0 and thus the
calculation stops and returns the last value q which is 0 because of the
choice of the new quadrature points (d and e) as middle points. With b-a=8pi
and a=0 when integrating sin(x), or a=pi/2 when integrating cos(x), the value
of sin or cos at the new points (d and e) is still 0. To avoid the problem,
which could occur with the current implementation for any harmonic function on
specific integration intervals, a simple cure would be to initialize quadv
starting with a division of the interval [a,b] in intervals of different
length. It rises the initial cost of quadv from 3 to 5 function "f" calls, if
initializing with a two intervals of different length, but it works fine.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?57603>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

**[Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating sin^2 or cos^2 on multiple of 8 periods**, *anonymous*, `2020/01/15`
**[Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating sin^2 or cos^2 on multiple of 8 periods**, *Kai Torben Ohlhus*, `2020/01/15`
**[Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating sin^2 or cos^2 on multiple of 8 periods**, *Kai Torben Ohlhus*, `2020/01/15`
**[Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating sin^2 or cos^2 on multiple of 8 periods**, *Rik*, `2020/01/15`
**[Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating sin^2 or cos^2 on multiple of 8 periods**, *Olivier Amoignon*, `2020/01/16`
**[Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating sin^2 or cos^2 on multiple of 8 periods**,
*Olivier Amoignon* **<=**
**[Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating sin^2 or cos^2 on multiple of 8 periods**, *Rik*, `2020/01/16`
**[Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating sin^2 or cos^2 on multiple of 8 periods**, *Rik*, `2020/01/17`
**[Octave-bug-tracker] [bug #57603] quadv gives wrong results integrating sin^2 or cos^2 on multiple of 8 periods**, *Kai Torben Ohlhus*, `2020/01/21`