[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Root finding for systems of the type R^n -> R
From: |
Juan Pablo Amorocho |
Subject: |
Re: [Help-gsl] Root finding for systems of the type R^n -> R |
Date: |
Sat, 13 Jul 2013 10:42:49 +0200 |
Hi Vale –
This is not a GSL problem, but a math problem. Your Jacobian isn't square and
therefore it doesn't have an inverse, so Newton won't work. Depending on what
you know about your problem, you can apply one or another method, like fix
point iteration. I hope this helps.
– Juan Pablo
On Jul 12, 2013, at 9:08 PM, Vale Cofer-Shabica <address@hidden> wrote:
> I've read through the root-finding documentation, but didn't find a
> reference to this case. Any assistance would be appreciated.
>
> Summary:
> I get "gsl: lu.c:147: ERROR: matrix is singular" when tying to find
> the zeros of a function from R^n -> R using the functionality in
> gsl_multiroots.h.
>
> How should I proceed?
>
> Details:
> I'm trying to find the zeros of mufti dimensional (anywhere from 2 to
> 1500 degrees of freedom) potential-energy-type functions, which map
> vectors to scalars. To that end, I started trying to set up the
> gsl_multiroot_function_fdf struct for use with the Newton-Raphson
> solver.
>
> However, when implementing
>
> int (* df) (const gsl_vector * x, void * params, gsl_matrix * J)
>
> to produce the Jacobian, I was concerned. Because my function is
> scalar valued only the the first row of partial derivatives has any
> meaning. I used code like this:
>
> //only row 0 has non-zero elements
> gsl_matrix_set_all (J, 0.0);
> //grad is a gsl_vector * containing the gradient
> gsl_matrix_set_row (J, (size_t) 0, grad);
>
> to input the part of the Jacobian that exists.
> I used similar code for the function itself:
>
> //all elements but the first are 0
> gsl_vector_set_all (f, 0.0);
> // energy is a double holding the value of the function
> gsl_vector_set (f, (size_t) 0, energy);
>
> I filled the vector with 0 and wrote the first element with the
> function's value.
>
> My code compiles without warnings or errors using the recommend (gsl
> manual A.4 [1]) flags with gcc. However, when executing, I get the
> following error:
>
> $ ./a.out
> gsl: lu.c:147: ERROR: matrix is singular
> Default GSL error handler invoked.
> Aborted
>
> How should I express my function so I can avoid this?
>
> Thanks very much,
> vale
>
>
> [1]
> http://www.gnu.org/software/gsl/manual/html_node/GCC-warning-options-for-numerical-programs.html
>
> --
> Vale Cofer-Shabica
> Department of Chemistry, Brown University
> address@hidden
> 401.267.8253
>