# 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) = 10*e^(-k1*t)
g(t) = 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


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

edit retag close merge delete

You may enjoy http://www.gregorybard.com/Sage.html for a good free introductory Sage text relevant to your audience in terms of level.

If you are writing a text that has significant online Sage (or R, or whatever) interactive content and needs good technical formatting, I recommend a look at http://mathbook.pugetsound.edu

Sort by » oldest newest most voted

This is really subtle, and is no doubt related to a copy-paste issue.

You have color=’blue’. Notice how the quotes lean forward a bit. That is not a standard Python string delimiter; you need normal (ASCII) single or double quotes. Here you can see what you get if you use color='blue' as correct.

Looks good otherwise! Welcome to Sage! I'll put some other comments in the, well, comments.

more