function ret=csquare( a=1, b=1, c=0, d=0)
  ret=0;
  
  printf( "\t\t\t\t\tOriginal problem: %i x² + %i x + %i = %i\n", a, b, c, d );
  
  %% Step 1
  printf( "1) Subtract %i from both sides.\n", c );
  printf( "\t\t\t\t\t%i x² + %i x = %i\n", a, b, d-c );

  %% Step 2
  printf( "2) Divide everything by %i.\n", a );
  printf( "\t\t\t\t\t x² + (%i/%i) x = (%i/%i)\n", b,a, (d-c),a );

  %% Step 2.5
  printf( "2.5) Reduce any fractions that can be reduced.\n");

  B=gcd(b,a);
  C=gcd(d-c,a);

  b2=b/B;
  ab=a/B;

  b=b2;

  c2=(d-c)/C;
  ac=a/C;

  c=c2;
  printf( "\t\t\t\t\t x² + (%i/%i) x = (%i/%i)\n", b,ab, c,ac );

  %% Step 3
  printf( "3) Add half of middle-term squared to both sides. (%i/%i)²\n",b,2*ab);

  printf( "\t\t\t\t\t x² + (%i/%i) x + (%i/%i)²= (%i/%i) + (%i/%i)²\n", b,ab,b,2*ab,c,ac,b,2*ab );
  printf( "\t\t\t\t\t x² + (%i/%i) x + (%i/%i)²= (%i/%i) + (%i/%i)\n", b,ab,b,2*ab,c,ac,b*b,4*ab*ab );

  %% Step 4
  printf( "4) Combine Like Terms\n");

  c3n=c*4*ab*ab;
  c3d=ac*4*ab*ab;

  c4n=b*b*ac;
  c4d=c3d;

  c=c3n+c4n;

  printf( "\t\t\t\t\t x² + (%i/%i) x + (%i/%i)²= (%i/%i)\n", b,ab,b,2*ab,c,c3d );

  %% Step 5
  printf( "5) Rewrite left side as a perfect square binomial.\n");
  printf( "\t\t\t\t\t (x + %i/%i)² = (%i/%i)\n", b,2*ab,c,c3d );

  %% Step 6
  printf( "6) Take the square root of both sides.\n");
  printf( "\t\t\t\t\t x + %i/%i = ±√(%i/%i)\n", b,2*ab,c,c3d );
  s = " ";
  if( c < 0 )
    s="i";
    c=abs(c);
  endif
  printf( "\t\t\t\t\t x + %i/%i = ±%c√(%i/%i)\n", b,2*ab,s,c,c3d );
  
  %% Step 7
  printf( "7) Solve for 'x'.\n");
  printf( "\t\t\t\t\t x = %i/%i ± %c√(%i/%i)\n", -b,2*ab,s,c,c3d );
  ret=c;
endfunction
