CS99 Lecture6 - Functions - Chapter 5 (forthcoming) - week of 9/2 Mathematical Functions - definition correspondance between domain and range - y = f(x) = something with x in it + y is dependent variable + x is independent variable + f(x) takes x as input and spits out a value - what about domain and range? + essentially ignore this concept for now + will focus on input/output concept Maple Functions - perform task (think, "commands") - syntax: + expr(exprseq) usually, expr is name exprseq is expr,expr,... ex) sqrt(4) ex) plot(x,x=0..10) - INPUT arguments (parameters): exprseq Maple evaluates each expr before PASSING into code - OUTPUT expression Maple + evaluates entire function using inputs + produces output ex) Ans := sqrt(4); Ans := 2 Maple replaces function with OUTPUT! ex) x := 3; Ans := sqrt(x^2); Ans := 3 - Nesting ex) A:=Pi/6: B:=sin(A): sqrt(B); Active Exercise: How to make nested? sqrt(sin(Pi/6)) (1/2) sqrt(2) - Powers 2 sin (x) means sin(x)^2 - Incorrect notation > f(x) := m*x + b will NOT work! correct: > restart; > f := x -> m*x + b; > f(2); Active Exercise: answer? m + b Variety of Functions - see ?polynom, ?trig note: must use radians for angles! convert(angle,radians) or use rads/2*Pi = degs/360 Powers and Roots - exponentiation: ** and ^ - roots: expr^(expr) root(expr,n) surd(expr,n) -> finds more real roots! ex) > simplify((-1)^(1/3)); > root(-1,3) 1/2 + 1/2 I sqrt(3) > surd(-1,3) Logarithms x b = y means log x means Maple: log[b](y) b log[b](y) -> ln(y)/ln(b) ln? Natual log -> log base e e? exp(1) = 2.71828... Maple: ln(x), exp(x)