Here is my start using Sage and Maxima. ------------------------------------------------ def CSquare(co1,co2,co3): eq1=co1*x^2+co2*x+co3 eq3=eq1==0 eq2=factor(eq1) eq4=(1/co1)*eq2 Cof1=maxima.args(eq4);Cof1a=Cof1[2]; val2=real(((1/2)*(maxima.coeff(eq4,x,1)))) val1=val2^2 eq5=eq4+val1 return eq3,eq2,eq4,eq5,val1 --------------------------------------------------
The val1 does produce 9/16. This is good, but when I add it to the lhs I get (here is my output) ------------------------------------- 2*x^2 + 3*x + 4 == 0 2*(x^2 + 3*x/2 + 2) x^2 + 3*x/2 + 2 x^2 + 3*x/2 + sage261 + 2 9/16 -------------------------------- Why the "sage261"? On Sep 2, 11:09 am, Robert Bradshaw <rober...@math.washington.edu> wrote: > On Wed, 2 Sep 2009, Mikie wrote: > > > Here is a proc(Mupad) I wrote for showing the steps in completing the > > square for a quad > > ---------------------------------------------------- > > //Completing the Square Method of solving quadratic equation > > quad:= proc(co1,co2,co3) > > local a,b,c,eq1,q1,Lcoef,half2,eq2,eq3,op1,op2,op3, > > eq1a,eq1b,eq1c,eq4,eq5,eq6,r1,sol1,sol2; > > begin; > > eq1:=co1*x^2+co2*x+co3=0; > > eq2:=(eq1/co1); > > q1:=[coeff(lhs(eq2))]; > > Lcoef:=q1[2]; > > op1:= op(lhs(eq2)); op2:=op(op1,3); > > eq1a := subs(R1 + R2 = R3, R1=op(op1,1), > > R2 =op(op1,2),R3 = -op2, Unsimplified); > > half2:=(Lcoef/2)^2; > > a := lhs(eq1a); b:=rhs(eq1a); > > eq1b:= subs(R4 + R5 + R6 = R7 + R8, R4 =op(a,1), > > R5 = op(a,2), R6 = half2, R7=b,R8 = half2,Unsimplified); > > eq3:=eq2-q1[3]; > > eq4:=eq3+half2; > > eq5:= (x+Lcoef/2)^2=rhs(eq4); > > eq6:= x+Lcoef/2=sqrt(rhs(eq5)); > > eq6a:= x+Lcoef/2=-sqrt(rhs(eq5)); > > sol1:=eq6-Lcoef/2;sol2:=x=rhs(-eq6-Lcoef/2); > > ---------------------------------- > > I need rhs, lhs, op, coef, subs, etc. Are any of these functions in > > Sage or Maxima? > > Thanx > > I bet they all are, but to know you'd have to find out what they mean. > > - Robert- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---