help-gsl
[Top][All Lists]
Advanced

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

[Help-gsl] gsl_poly_solve_cubic problem


From: nick kama
Subject: [Help-gsl] gsl_poly_solve_cubic problem
Date: Thu, 20 Dec 2007 01:34:37 +0100

Hello,

I have this problem with the solver of the cubic equations in gsl:

if i take  an equation of the form

(x-1)^3=0

solver finds 3 roots
1 1 1

if i took the equation
(x-1.1)^3

it finds only one root equal to 1.1,this is a little of code  that can show
this behaviour.
Documentation says :"the case of coincident roots is not considered special.
For example, the equation (x-1)^3=0 will have three roots with exactly equal
values " so this should'nt happen, pleas let me know where i'm wronging.

Many Thanks

Niccolo'


#include <iostream>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_eigen.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_poly.h>



main()
{

  double landa1=0;
  double landa2=0;
  double landa3=0;
 //(x-1.1)^3
  int numero = gsl_poly_solve_cubic ( -3.3,3.63, -1.331, &landa1, &landa2,
&landa3);
  std::cout << numero<< std::endl;
  std::cout << landa1<< std::endl;
  std::cout << landa2<< std::endl;
  std::cout << landa3<< std::endl;

  // (x-1)^3
  numero = gsl_poly_solve_cubic ( -3,3, -1, &landa1, &landa2, &landa3);
  std::cout << numero<< std::endl;
  std::cout << landa1<< std::endl;
  std::cout << landa2<< std::endl;
  std::cout << landa3<< std::endl;

}


reply via email to

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