Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

trivial problem with trying to graph 2 functions

I'm very new to SageMath. I want to plot two functions on 1 graph. Here is the code @interact def draw1st_2nd_Order( k1=slider(0.01, 10, 0.1, 5, label = "k1 (s^-1)"), k2=slider(0.01, 10, 0.1, 5, label = "k2 (M^-1s^-1)" ) ): f(t) = 10e^(-k1t) g(t) = 10/(1+(10k2t)) P1 = plot( f(t), 0, 10, ymin=0, ymax=10, color=’blue’, gridlines='minor') P2 = plot( g(t), 0, 10, ymin=0, ymax=10, color='red') P=P1+P2 P.show() print print "The x-axis is time in sec." print "The y-axis is [A] in mM."
return

This is the error I get:

File "<ipython-input-1-8e804a2c9a22>", line 5 P1 = plot( f(t), Integer(0), Integer(10), ymin=Integer(0), ymax=Integer(10), color=’blue’, gridlines='minor') ^ SyntaxError: invalid syntax

I'm trying to convert lots of Mathematica files to SageMath for an online biochem text. Once I get this example worked out, I can easily convert the rest. Any help would be greatly appreciated Henry J

click to hide/show revision 2
No.2 Revision

trivial problem with trying to graph 2 functions

I'm very new to SageMath. I want to plot two functions on 1 graph. Here is the code code

@interact
def draw1st_2nd_Order( k1=slider(0.01, 10, 0.1, 5, label = "k1 (s^-1)"), k2=slider(0.01, 10, 0.1, 5, label = "k2 (M^-1s^-1)" ) ):
    f(t) = 10e^(-k1t)
10*e^(-k1*t)
    g(t) = 10/(1+(10k2t))
10/(1+(10*k2*t))
    P1 = plot( f(t), 0, 10, ymin=0, ymax=10, color=’blue’, gridlines='minor') 
    P2 = plot( g(t), 0, 10, ymin=0, ymax=10, color='red')
    P=P1+P2
    P.show()
    print
    print "The x-axis is time in sec."
    print "The y-axis is [A] in mM." 
return

return

This is the error I get:

File "<ipython-input-1-8e804a2c9a22>", line 5
    P1 = plot( f(t), Integer(0), Integer(10), ymin=Integer(0), ymax=Integer(10), color=’blue’, gridlines='minor')
                                                                                       ^
SyntaxError: invalid syntax

syntax

I'm trying to convert lots of Mathematica files to SageMath for an online biochem text. Once I get this example worked out, I can easily convert the rest. Any help would be greatly appreciated Henry J