octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #62468] quadgk.m should be able to do array-va


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #62468] quadgk.m should be able to do array-valued integration
Date: Thu, 19 May 2022 11:25:09 -0400 (EDT)

Follow-up Comment #7, bug #62468 (project octave):

re waypoints:

according to the matlab 2022a help:  


When A, B,and the waypoints are all real, only the waypoints between A and B
are used, and they are used in sorted order.
...
If A, B, or any entry of the waypoints vector is complex, the integration is
performed over a sequence of straight line paths in the complex plane, from A
to the first waypoint, from the first waypoint to the second, and so forth,
and finally from the last waypoint to B.


real:

>> quadgk(@(x) 1./x, 1,2)
ans =
    0.6931
>> quadgk(@(x) 1./x, 2,1)
ans =
   -0.6931
>> quadgk(@(x) 1./x, 1,2,'waypoints',[1.25,1.5,1.75])
ans =
    0.6931
>> quadgk(@(x) 1./x, 2,1,'waypoints',[1.25,1.5,1.75])
ans =
   -0.6931
>> quadgk(@(x) 1./x, 2,1,'waypoints',[1.75,1.5,1.25])
ans =
   -0.6931

complex:

>> quadgk(@(x) 1./x, 1+i,2+i)
ans =
   0.4581 - 0.3218i
>> quadgk(@(x) 1./x,2+i,1+i)
ans =
  -0.4581 + 0.3218i
>> quadgk(@(x) 1./x, 1+i,2+i, 'waypoints', [1.25+1,1.5+i, 1.75+i])
ans =
   0.4581 - 0.3218i
>> quadgk(@(x) 1./x, 2+i,1+i, 'waypoints', [1.25+1,1.5+i, 1.75+i])
ans =
  -0.4581 + 0.3218i
>> quadgk(@(x) 1./x, 1+i,2+i, 'waypoints', [1.75+1,1.5+i, 1.25+i])
ans =
   0.4581 - 0.3218i
>> quadgk(@(x) 1./x, 2+i,1+i, 'waypoints', [1.75+1,1.5+i, 1.25+i])
ans =
  -0.4581 + 0.3218i


closed contour, using matlab help example:

>> f = @(z) 1./(2.*z-1);
contour_segments = [1+1i 0+1i 0-1i 1-1i];
q = quadgk(f,1,1,'Waypoints',contour_segments)
q =
  -0.0000 + 3.1416i
>> q = quadgk(f,1,1,'Waypoints',fliplr(contour_segments))
q =
  -0.0000 - 3.1416i


it seems waypoints ordering only matters for closed intervals. I would have
thought the complex piecewise integration would have mattered, but it must
still sort first, which seems odd, as it should cause a counting of doubly
traversed paths. (but maybe those go negative and cancel? )


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62468>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]