help-gsl
[Top][All Lists]

Re: [Help-gsl] problems w/ gsl_poly_solve_quadratic

 From: Giulio Bottazzi Subject: Re: [Help-gsl] problems w/ gsl_poly_solve_quadratic Date: Tue, 13 Jul 2004 08:03:29 +0200

```Use this instead:

#include "stdio.h"
#include <gsl/gsl_poly.h>

int main()
{

double a, b, c, x0,x1;

printf("Enter the coefficients a, b, c of ax^2 + b*x + c = 0\n");
scanf("%lf %lf %lf", &a, &b, &c);

gsl_poly_solve_quadratic(a, b, c, &x0, &x1);

printf("The roots are: %lf, %lf\n", x0, x1);

return 0;
}

it should work. See the difference?

G.

On Tue, 13 Jul 2004 00:27:03 -0500
Jon Drews <address@hidden> wrote:

> FreeBSD 5.2-CURRENT #0: Sat Jul 10 17:19:21 CDT 2004
>
> Configured with: FreeBSD/i386 system compiler
> Thread model: posix
> gcc version 3.3.3 [FreeBSD] 20031106
>
> GSL ver. 1.5
>
>
> Hi:
>
>  When I run the following program:
> /* Finds the roots to Quadratic Eqn. (a*x^2 + b*x + c = 0) */
>
> #include <stdio.h>
> #include <gsl/gsl_poly.h>
>
>
> int main()
> {
>
>   double a, b, c, *x0,*x1;
>
>   printf("Enter the coefficients a, b, c of ax^2 + b*x + c = 0\n");
>   scanf("%lf %lf %lf", &a, &b, &c);
>
>   gsl_poly_solve_quadratic(a, b, c, x0, x1);
>
>
>   printf("The roots are: %lf, %lf\n", *x0, *x1);
>
>   return 0;
> }
>
> I get a core dump. I have compiled it and run it like so:
>
> bash-2.05b\$ gcc -g -c  -Wall -I/usr/local/include quadratic.c
> bash-2.05b\$ gcc -o QUAD -L/usr/local/lib quadratic.o -lgsl -lgslcblas
> Enter the coefficients a, b, c of ax^2 + b*x + c = 0
> 1 2 1
> Bus error (core dumped)
> bash-2.05b\$
>
> I get this output from ddd:
>
> Copyright © 1995-1999 Technische Universität Braunschweig, Germany.
> Copyright © 1999-2001 Universität Passau, Germany.
> Copyright © 2001 Universität des Saarlandes, Germany.
> Copyright © 2003 Free Software Fundation, Inc.
> (gdb) file /usr/home/xfce/programs/gsl/QUAD
> (gdb) run
> Enter the coefficients a, b, c of ax^2 + b*x + c = 0
> 1 2 1
>
> Program received signal SIGBUS, Bus error.
> 0x281235a9 in gsl_poly_solve_quadratic () from
> /usr/local/lib/libgsl.so.6(gdb) bt
> #0  0x281235a9 in gsl_poly_solve_quadratic () from
> #/usr/local/lib/libgsl.so.6 1  0x080485da in main () at quadratic.c:15
> (gdb)
>
> I also get the same error with gsl_poly_solve_cubic. What might I have
> done wrong here?
>
>
>                             TIA
>                             Jonathan
>
>
> _______________________________________________
> Help-gsl mailing list
> http://lists.gnu.org/mailman/listinfo/help-gsl

--