Here is the finished product for CS.
--------------------------------------------------
def CSquare(co1,co2,co3):
    eq1=co1*x^2+co2*x+co3
    eq3=eq1==0
    eq2=factor(eq1)
    eq4=(1/co1)*eq2
    eq10=expand(eq4)
    M1=maxima.args(eq10);L1=len(M1)
    Cof1=maxima.args(eq10);Cof1a=Cof1[2];
    val2=((1/2)*(maxima.coeff(eq10,x,1)))
    Addon=maxima.ev(val2^2)
    eq5=maxima.ev(val2^2)+M1[0]+M1[1]#this gets value from Maxima
    eq6=factor(eq5);
    eq7=-M1[2]+Addon;
    Str1="This is added to both sides of the quad-- "
    Soln=maxima.solve(eq1)
    return eq3,eq2,eq10,eq6,Str1,eq7,Soln
-----------------------------------------------
The line that solve the problem was
Addon=maxima.ev(val2^2)
I now get a real number, that finishes the CS.
Willian, I need Maxima to write this function.
Here is some output.
---------------------------------------------
the call ---val1=CSquare(2,-1,-2);val1[0];val1[1];val1[2];val1[3];val1
[4],val1[5];val1[6]
  2*x^2 - x - 2 == 0
2*(x^2 - x/2 - 1)
x^2 - x/2 - 1
(4*x-1)^2/16
('This is added to both sides of the quad-- ', 17/16)
[x=-(sqrt(17)-1)/4,x=(sqrt(17)+1)/4]
---------------------------------------------------------------------------------------------
the call--val1=CSquare(2,-1,-3);val1[0];val1[1];val1[2];val1[3];val1
[4],val1[5];val1[6]
2*x^2 - x - 3 == 0
2*(x - 3/2)*(x + 1)
x^2 - x/2 - 3/2
(4*x-1)^2/16
('This is added to both sides of the quad-- ', 25/16)
[x=3/2,x=-1]
-------------------------------------------------------------------------------------------
Now to get it work on my server.  When I finish I will give the link.
Current version at http://pirsqrt.com:1843/
Wolfram Alpha eat your hart out.
Still looking for help with pretty print output. (JSmath)


On Sep 2, 6:51 pm, Robert Bradshaw <[email protected]>
wrote:
> On Wed, 2 Sep 2009, [email protected] wrote:
> > That's a good question!  I've written functions in MATLAB (well Octave
> > actually) no problem.  But I get confused where Python leaves off and Sage
> > kicks in when witting functions here.
>
> The way to think about this is that Sage is just a huge Python library,
> and writing a function in Sage (in the programming sense, not the
> mathematical sense) is exactly the same as writing a function in Python.
>
> From the command line/notebook, there is some preparsing that goes on, but
> it's stuff like 5 -> Integer(5) so that 1/5 doesn't become 0.
>
>
>
> > Could someone please  give me a barebones example, soup to nuts, of a
> > Python vs. Sage vs. Other (Maxima and such) function that does, say, 
> > Newton's
> > Method for finding Roots?
>
> > 1) what does the function look like
> > 2) how do you invoke it
> > 3) what's the input
> > 3) where's the output
> > 4) etc
>
> > TIA,
> > A.  Jorge Garcia
> > _http://calcpage.tripod.com_(http://calcpage.tripod.com/)
>
> > Teacher  & Professor
> > Applied Mathematics, Physics & Computer  Science
> > Baldwin Senior High School & Nassau Community College
>
> > In a message dated 9/2/2009 5:57:37 P.M. Eastern Daylight Time,
> > [email protected] writes:
>
> > No.  The call is CSquare(2,3,4).  Just trying to setup a  random quad.
> > Could this function be done with just Sage?  I need  coeficients, each
> > term, sides of the equation,  etc.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to