On Thu, Oct 30, 2008 at 8:39 AM, Alejandro Jakubi wrote: > I wonder how it is done in Axiom the selection of roots of a polynomial > with some property. As in this example, select the positive roots out > of the list of three roots generated by: > > radicalSolve(p^3-p+1/10=0,p) >
Since the discriminant is positive we know all roots are real, so in principle we should be able to solve the problem like this: (1) -> discriminant(p^3-p+1/10) 373 (1) --- 100 Type: Fraction(Integer) (2) -> select(p+->rhs(p)::AlgebraicNumber>0,radicalSolve(p^3-p+1/10=0,p)) +------------------+2 | +-+ +-----+ +---+ |- 3\|3 + \|- 373 (- 3\|- 3 - 3) |------------------ + 2 3| +-+ \| 60\|3 (2) [p= -----------------------------------------] +------------------+ | +-+ +-----+ +---+ |- 3\|3 + \|- 373 (3\|- 3 - 3) |------------------ 3| +-+ \| 60\|3 Type: List(Equation(Expression(Integer))) --------- As I understand it AlgebraicNumber is supposed to be able to properly order the roots. Unfortunately there seems to be a bug and AlgebraicNumber gets it exactly wrong! (3) -> complexNumeric rhs %.1 (3) - 1.0466805318 0460226115 8656311996 0435287484 7096514654 44382606 + - 0.6 E -60 %i Type: Complex(Float) The actual positive roots are: (4) -> select(p+->rhs(p)::AN<0,radicalSolve(p^3-p+1/10=0,p)) (4) +------------------+2 +------------------+2 | +-+ +-----+ | +-+ +-----+ +---+ |- 3\|3 + \|- 373 |- 3\|3 + \|- 373 (- 3\|- 3 + 3) |------------------ - 2 3 |------------------ + 1 3| +-+ 3| +-+ \| 60\|3 \| 60\|3 [p= -----------------------------------------,p= ---------------------------] +------------------+ +------------------+ | +-+ +-----+ | +-+ +-----+ +---+ |- 3\|3 + \|- 373 |- 3\|3 + \|- 373 (3\|- 3 + 3) |------------------ 3 |------------------ 3| +-+ 3| +-+ \| 60\|3 \| 60\|3 Type: List(Equation(Expression(Integer))) ------ Regards, Bill Page. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ open-axiom-devel mailing list open-axiom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open-axiom-devel