up [pdf]
from rsf.proj import *

# generate a sine wave
  #modify below
Flow('sine',None,
    '''
    math output="0" 
    d1=.01 n1=1256 o1=0
    label1=x unit1="radians"
    ''')
# plot sine 
Plot('sine','graph title="sin(x)"')
# take the derivative of the sine wave
  # modify below
Flow('dsine','sine','deriv ')
Plot('dsine','graph title="d sin(x)/dx"')
# plot the sine wave with its derivative
Result('sine_dsine','sine dsine','SideBySideAniso')
# generate a cosine curve
Flow('cosine','sine',
    '''
    math output="cos(x1)" 
    ''')
# get cosine squared by multiplying the derivative of sine with the cosine function
  # modify below
Flow('cos2','dsine cosine',
    '''
    math A=${SOURCES[0]} B=${SOURCES[1]}
    output=".0"
    ''')
# plot the cosine squared function
  # modify below
Result('cos2','graph label1="cos\^2\_(x)" wanttitle=n')

# integrate cosine squared, scale by dx
  # modify below
Flow('int-cos2','cos2','cp | scale dscale=1')
# plot the integral
Result('int-cos2','graph title="x/2+sin(2x)/4"')
End()

sfmath
sfgraph
sfderiv
sfcp
sfscale