X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=blobdiff_plain;f=scilab%2Fmodules%2Fdifferential_equations%2Fhelp%2Fen_US%2Fnumdiff.xml;h=ee957a92c028f6c8a46414b3e329ef77cacce79f;hp=fad719a353cd408943b466ae9314e77d34de93fc;hb=5bb57c7827e9db96a5c6bf0e01660554a213306e;hpb=db041a2d1a19eea2b7e30a773a6b2559e92e1558 diff --git a/scilab/modules/differential_equations/help/en_US/numdiff.xml b/scilab/modules/differential_equations/help/en_US/numdiff.xml index fad719a..ee957a9 100644 --- a/scilab/modules/differential_equations/help/en_US/numdiff.xml +++ b/scilab/modules/differential_equations/help/en_US/numdiff.xml @@ -13,7 +13,7 @@ numdiff - numerical gradient estimation + numerical gradient estimation at one point Calling Sequence @@ -28,14 +28,15 @@ an external, Scilab function or list. See below for calling sequence, see also external for details about external functions. + f: Rn --> Rp x - a vector, the argument of the function - fun. + + a vector of the `n` coordinates of the single point at which the gradient is sought. @@ -43,14 +44,16 @@ dx a vector, the finite difference step. Default value is - `dx=sqrt(%eps)*(1+1d-3*abs(x))`. + `dx = sqrt(%eps)*(1+1d-3*abs(x))`. g - a vector, the estimated gradient. + + a matrix, the estimated gradient at the locus x. + @@ -59,23 +62,23 @@ Description Given a function `fun(x)` from - `R^n` to `R^p` computes the matrix - g such as + Rn to Rp computes the `p x n` matrix + g such that using finite difference methods. Uses an order 1 formula. Without parameters, the function fun calling sequence is - `y=fun(x)`, and numdiff can be called as - `g=numdiff(fun,x)`. Else the function fun calling + `y = fun(x)`, with x ∈ Rn and y ∈ Rp, and numdiff can be called as + `g = numdiff(fun, x)`. Else the function fun calling sequence must be y = fun(x, param_1, pararm_2, ..., param_q). If parameters param_1, param_2, ..., param_q exist then numdiff can be called as follow - g=numdiff(list(fun, param_1, param_2, ..., param_q), x). + g = numdiff(list(fun, param_1, param_2, ..., param_q), x). See the @@ -85,42 +88,77 @@ g(i,j) = (df_i)/(dx_j) Examples - myfun(x) -function f=myfun(x) - f=x(1)*x(1)+x(1)*x(2) + myfun(x) +function f = myfun(x) + f = x(1)*x(1) + x(1)*x(2) endfunction -x=[5 8] -g=numdiff(myfun,x) +x = [5 8]; +g = numdiff(myfun, x) + +// The exact gradient (i.e first component = derivate with respect to x(1) +// and second component = derivate with respect to x(2)) is: +exact = [2*x(1)+x(2) x(1)] -// The exact gradient (i.e derivate belong x(1): first component -// and derivate belong x(2): second component) is -exact=[2*x(1)+x(2) x(1)] -//example 2 (with parameters) -// myfun is a function from R to R: x(1) |--> myfun(x) -// myfun contains 3 parameters: a, b, c -function f=myfun(x,a,b,c) - f=(x+a)^c+b +// Example 2 (with parameters) +// myfun is a function from R to R: x |--> myfun(x) +// myfun contains 3 parameters: a, b and c +function f = myfun(x, a, b, c) + f = (x+a)^c + b endfunction -a=3; b=4; c=2; -x=1 -g2=numdiff(list(myfun,a,b,c),x) +a = 3; b = 4; c = 2; +x = 1; +g2 = numdiff(list(myfun, a, b, c), x) + +// The exact gradient, i.e derivate with respiect to x, is: +exact2 = c*(x+a)^(c-1) + + +// Example 3 (f: R^3 --> R^3) +// myfun is a function from R^2 to R^2: (x(1), x(2), x(3)) |--> (myfun(x)(1), myfun(x)(2), mfun(x)(3)) +function f = myfun(x) + f(1) = x(1) * x(1); + f(2) = x(1) * x(2) * x(3); + f(3) = 2*x(1) + 2*x(2) + 2*x(3); +endfunction + +x = [5 8 10]; +g = numdiff(myfun, x) + +// The exact gradient is: +// [ df_1/dx_1 df_1/dx_2 df_1/dx_3 ; +// df_2/dx_1 df_2/dx_2 df_2/dx_3 ; +// df_3/dx_1 df_3/dx_2 df_3/dx_3 ; ] +exact3 = [2*x(1) 0 0 ; x(2)*x(3) x(1)*x(3) x(1)*x(2) ; 2 2 2] -// The exact gradient, i.e derivate belong x(1), is : -exact2=c*(x+a)^(c-1) ]]> See Also + interp + + + interp2d + + + splin + + + eval_cshep2d + + optim + diff + + derivative