 Classic List Threaded 9 messages Open this post in threaded view
|

 Hello.I am trying to numerically integrate a function using dblquad, but getting errors shown below.  Thank you.octave-3.6.4.exe:3> I = dblquad(@(r,q)r*sqrt(r^2+1-2*cos(2*pi()*q)),0,1,0,1)error: for A^b, A must be a square matrixerror: evaluating argument list element number 1error: called from:error:    at line -1, column -1error:    at line -1, column -1error: quadcc: integrand F must return a single, real-valued vectorerror:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 72, column 10error:    at line -1, column -1error: quadcc: integrand F must return a single, real-valued vectorerror:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 65, column 5 _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

 On Wed, Jul 27, 2016 at 9:57 PM, Ether Jones wrote:Hello.I am trying to numerically integrate a function using dblquad, but getting errors shown below.  Thank you.octave-3.6.4.exe:3> I = dblquad(@(r,q)r*sqrt(r^2+1-2*cos(2*pi()*q)),0,1,0,1)error: for A^b, A must be a square matrixerror: evaluating argument list element number 1error: called from:error:    at line -1, column -1error:    at line -1, column -1error: quadcc: integrand F must return a single, real-valued vectorerror:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 72, column 10error:    at line -1, column -1error: quadcc: integrand F must return a single, real-valued vectorerror:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 65, column 5 _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave I don't know what you want, but maybe this will help.>> I = dblquad(@(r,q)abs( r.*sqrt(r.^2+1-2*cos(2*pi*q))),0,1,0,1)I =  0.58663-- DAS _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

 On Wed, Jul 27, 2016 at 10:32 PM, Doug Stewart wrote:On Wed, Jul 27, 2016 at 9:57 PM, Ether Jones wrote:Hello.I am trying to numerically integrate a function using dblquad, but getting errors shown below.  Thank you.octave-3.6.4.exe:3> I = dblquad(@(r,q)r*sqrt(r^2+1-2*cos(2*pi()*q)),0,1,0,1)error: for A^b, A must be a square matrixerror: evaluating argument list element number 1error: called from:error:    at line -1, column -1error:    at line -1, column -1error: quadcc: integrand F must return a single, real-valued vectorerror:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 72, column 10error:    at line -1, column -1error: quadcc: integrand F must return a single, real-valued vectorerror:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 65, column 5 _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave I don't know what you want, but maybe this will help.>> I = dblquad(@(r,q)abs( r.*sqrt(r.^2+1-2*cos(2*pi*q))),0,1,0,1)I =  0.58663-- DAS This might also help: r=0:.01:1; q=0:.01:1; [xx yy]=meshgrid(r,q);   ff= @(r,q)abs( r.*sqrt(r.^2+1-2*cos(2*pi*q))) zz=ff(xx,yy); mesh(xx,yy,zz) # this shows the surface that we are using.  I = dblquad(@(r,q)abs( r.*sqrt(r.^2+1-2*cos(2*pi*q))),0,1,0,1)-- DAS _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

## Re: Fwd: [Maxima-discuss] dblquad fail

 In reply to this post by Ether Jones-2 >From: Ether Jones  >To: help-octave   >Date: 2016/7/28, Thu 10:57 >Subject: Fwd: [Maxima-discuss] dblquad fail > > >Hello. > >I am trying to numerically integrate a function using dblquad, but getting errors shown below.  Thank you. > >octave-3.6.4.exe:3> I = dblquad(@(r,q)r*sqrt(r^2+1-2*cos(2*pi()*q)),0,1,0,1) >error: for A^b, A must be a square matrix >error: evaluating argument list element number 1 >error: called from: >error:    at line -1, column -1 >error:    at line -1, column -1 >error: quadcc: integrand F must return a single, real-valued vector >error:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 72, column 10 >error:    at line -1, column -1 >error: quadcc: integrand F must return a single, real-valued vector >error:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 65, column 5 In the octave manual of dblquad  ********************************** f is a function handle, inline function, or string containing the name of the function to evaluate.  The function f must have the form z = f(x,y) where x is a vector and y is a scalar.  It should return a vector of the same length and orientation as x. ********************************** It should return a vector of the same length and orientation as x. So that function should be written using element-by-element  calculation  As written by Doug, you should write function as @(r,q)r.*sqrt(r.^2+1-2*cos(2*pi()*q))   https://www.gnu.org/software/octave/doc/interpreter/Functions-of-Multiple-Variables.html#index-dblquad https://www.gnu.org/software/octave/doc/interpreter/Arithmetic-Ops.html#Arithmetic-OpsBTW, you seem to use old octave 3.6.4 on windows. The latest and modern octave 4.0.3 is available on the  https://ftp.gnu.org/gnu/octave/windows/Tatsuro _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

 In reply to this post by Doug Stewart-4 Thank you. This works: octave-3.6.4.exe:3>  I = dblquad(@(r,q)abs( r.*sqrt(r.^2+1-2*cos(2*pi*q))),0,1,0,1) I =  0.586626703381746 ... but this doesn't: octave-3.6.4.exe:4>  I = dblquad(@(r,q)r.*sqrt(r.^2+1-2*cos(2*pi*q)),0,1,0,1) error: quadcc: integrand F must return a single, real-valued vector error: called from: error:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 72, column 10 error:    at line -1, column -1 error: quadcc: integrand F must return a single, real-valued vector error:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 65, column 5 Why is the abs() necessary?
Open this post in threaded view
|

 On Thu, Jul 28, 2016 at 7:54 AM, Ether Jones wrote: Thank you. This works: octave-3.6.4.exe:3>  I = dblquad(@(r,q)abs( r.*sqrt(r.^2+1-2*cos(2*pi*q))),0,1,0,1) I =  0.586626703381746 ... but this doesn't: octave-3.6.4.exe:4>  I = dblquad(@(r,q)r.*sqrt(r.^2+1-2*cos(2*pi*q)),0,1,0,1) error: quadcc: integrand F must return a single, real-valued vector error: called from: error:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 72, column 10 error:    at line -1, column -1 error: quadcc: integrand F must return a single, real-valued vector error:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 65, column 5 Why is the abs() necessary? Your range of values for r and p start at zero.if you put 0 and 0 in your eq. you getsqrt(0^2+1-2*1)sqrt(-1) this is imaginaryinstead of abs you could try I = dblquad(@(r,q)real(r.*sqrt(r.^2+1-2*cos(2*pi*q))),0,1,0,1) I = dblquad(@(r,q)imag(r.*sqrt(r.^2+1-2*cos(2*pi*q))),0,1,0,1)  Look at the plot of the surfase when you ask for the real part. -- View this message in context: http://octave.1599824.n4.nabble.com/Fwd-Maxima-discuss-dblquad-fail-tp4678866p4678889.html Sent from the Octave - General mailing list archive at Nabble.com. _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave -- DAS _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

 In reply to this post by Ether Jones Il 28 lug 2016 5:50 PM, "Ether Jones" <[hidden email]> ha scritto: > > > Thank you. > > This works: > octave-3.6.4.exe:3>  I = dblquad(@(r,q)abs( > r.*sqrt(r.^2+1-2*cos(2*pi*q))),0,1,0,1) > I =  0.586626703381746 > > ... but this doesn't: > octave-3.6.4.exe:4>  I = > dblquad(@(r,q)r.*sqrt(r.^2+1-2*cos(2*pi*q)),0,1,0,1) > error: quadcc: integrand F must return a single, real-valued vector > error: called from: > error:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 72, > column 10 > error:    at line -1, column -1 > error: quadcc: integrand F must return a single, real-valued vector > error:   K:\OctaveVS\share\octave\3.6.4\m\general\dblquad.m at line 65, > column 5 > > Why is the abs() necessary? The error message you reported says: error: quadcc: integrand F must return a single, real-valued vector Is your integrand function real for any value of (r,q) in (0,1)? c. _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave