# 2.2 Functions # Art Belmonte, Summer 1996 # These are the shaded gray examples which appear in Section 2.2. > restart; f:=x->2*x^3 - 5*x^2 + x + 2; 3 2 f := x -> 2 x - 5 x + x + 2 > f(6); 260 > f(a+h); 3 2 2 (a + h) - 5 (a + h) + a + h + 2 > vol:=(x,y)->x^2*y; vol(3,5); 2 vol := (x, y) -> x y 45 > plot(f, -2..3); plot(f(x), x=-2..3); > factor(f(x)); (x - 1) (x - 2) (2 x + 1) > g:=2*x^3 - 5*x^2 + x + 2; factor(g); 3 2 g := 2 x - 5 x + x + 2 (x - 1) (x - 2) (2 x + 1) # Incorrect syntax: Clearly not what we intended! > factor(g(x)); (x(x) - 1) (x(x) - 2) (2 x(x) + 1) > f:=2*x^3 - 5*x^2 + x + 2; 3 2 f := 2 x - 5 x + x + 2 > f:=unapply(f, x); 3 2 f := x -> 2 x - 5 x + x + 2 >