help-octave
[Top][All Lists]
Advanced

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

Re: Fwd: [Maxima-discuss] dblquad fail


From: Tatsuro MATSUOKA
Subject: Re: Fwd: [Maxima-discuss] dblquad fail
Date: Thu, 28 Jul 2016 13:37:16 +0900 (JST)

>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 [1]

**********************************
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 [2]
As written by Doug, you should write function as

@(r,q)r.*sqrt(r.^2+1-2*cos(2*pi()*q)) 

[1] 
https://www.gnu.org/software/octave/doc/interpreter/Functions-of-Multiple-Variables.html#index-dblquad
[2] 
https://www.gnu.org/software/octave/doc/interpreter/Arithmetic-Ops.html#Arithmetic-Ops


BTW, 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



reply via email to

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