Post Reply 
(CAS) Symbolic vs Numeric Solver (Non CAS)
06-10-2022, 05:57 AM
Post: #6
RE: (CAS) Symbolic vs Numeric Solver (Non CAS)
(06-09-2022 06:11 PM)rawi Wrote:  But be aware that CAS is rather limited. If I type in solve(a*x^3+b*x^2+c*x+d=0,x) no solution is given despite a formula for the solution exists.
This is not a limitation, but intended, because the Cardan formula for a general 3rd order equation would raise expressions that could not be simplified afterwards. I mean that there are 3 complex solutions, that can be expressed with 1/3 powers of arguments themselves containing square roots. Now it's a well known result that the sum of the roots is -b/a, but trying to simplify the sum of the 3 expressions to -b/a would just be too hard.
Therefore real-life CAS handle these kind of polynomials with algebraic extensions.

Of course you are entirely free to write a small program yourself, you can inspire yourself from this Xcas code:
Code:

cardan(P,x):={
  local b,p,q,d,V,u,v,x1,x2,x3,n,j;
  j:=exp(2*i*pi/3);
  V:=symb2poly(P,x);
  n:=size(V);
  if (n!=4){
    throw(print(P)+" n'est pas de degre 3");
  }
  // Reduction 
  V:=V/V[0];
  b:=V[1];
  V:=ptayl(V,-b/3);
  p:=V[2];
  q:=V[3];
  // now x^3+p*x+q=0
  // x=u+v -> u^3+v^3+(3uv+p)(u+v)+q=0
  // Let uv=-p/3 then u^3+v^3=-q and u^3 and v^3 are solutions
  // of u^3 v^3 = -p^3/27 et u^3+v^3=-q
  // hence of x^2+q*x-p^3/27=0
  d:=q^2/4+p^3/27;
  if (d==0){
    // root of multiplicity 2
    return solve(P,x); 
  }
  d:=sqrt(d);
  u:=(-q/2+d)^(1/3);
  v:=-p/3/u;
  x1:=u+v-b/3;
  x2:=u*j+v*conj(j)-b/3;
  x3:=u*conj(j)+v*j-b/3;
  return [x1,x2,x3];
}:;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (CAS) Symbolic vs Numeric Solver (Non CAS) - parisse - 06-10-2022 05:57 AM



User(s) browsing this thread: 2 Guest(s)