Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168733
Image: ubuntu2004
# 2010 Aug 1 by Keith Smeltz # Inspired by and written for Perry Rose Morrow
# What is a function? # A function is a map which takes an input and produces an output # A function can be described by a t-chart: a list of inputs and the outputs that they produce var('x') print 'The cube numbers:' y(x)=x*x*x print y for x in range(10): print x,'|-->',y(x) print '**************' print 'The triangle numbers:' y(x)=x*(x+1)/2 print y for x in range(10): print x,'|-->',y(x) print '**************' print 'The square roots:' y(x)=sqrt(x) print y for x in range(10): print x,'|-->',y(x)
The cube numbers: x |--> x^3 0 |--> 0 1 |--> 1 2 |--> 8 3 |--> 27 4 |--> 64 5 |--> 125 6 |--> 216 7 |--> 343 8 |--> 512 9 |--> 729 ************** The triangle numbers: x |--> 1/2*(x + 1)*x 0 |--> 0 1 |--> 1 2 |--> 3 3 |--> 6 4 |--> 10 5 |--> 15 6 |--> 21 7 |--> 28 8 |--> 36 9 |--> 45 ************** The square roots: x |--> sqrt(x) 0 |--> 0 1 |--> 1 2 |--> sqrt(2) 3 |--> sqrt(3) 4 |--> 2 5 |--> sqrt(5) 6 |--> sqrt(6) 7 |--> sqrt(7) 8 |--> 2*sqrt(2) 9 |--> 3
# given a function's t-chart, we can draw a picture of those inputs and the outputs they produce # the input can be read from the horizontal axis, while the output can be read from the vertical axis show(plot(points([[0,0],[1,1],[2,4],[3,9],[4,16],[5,25]]))) show(plot(points([[0,0],[1,-1],[2,-8],[3,-27],[4,-64],[5,-125]])))
# There's no need to limit ourselves to so few points. # We can draw so many points they appear a line. var('x') show(plot(x*x)) show(plot(-x*x*x))