Definition: A mathematical function is a function that has 1, 2, 3 or more independent variables. You must declare each of the independent variables using the command var before defining or using your function. When you substitute values (numbers) for these variables, the function yields a value.

A user-defined math function can be defined as explicit:f(x)=3x^2 or vector-parametric:r=vector((sin(t),cos(t),t)). It can also be used as implicit:x^2+y^2==0

Example 1

# You must declare the variables used in your functions
#Here we define a explicit (regular) function f(x) with one independent variable x and then evaluate it at x=4.
var('x')
f(x)=3*x*sqrt(x)
a=f(4)
print a

Result:

24

Example 2

#Look carefully at this. x is the variable in the function. w is just a "variable name". We need to declare both.
#Here we define a explicit (regular) function f(x) with one independent variable x, a constant w and then evaluate it at x=4.
var('x w')
f(x)=w*x*sqrt(x)
a=f(4)
print a

Result:

8*w

Example 3

#Notice that there is no r(t) at left. There is just r. But with explicit functions you must write f(x).
#(I think this means you cannot have "constants" in your vector-parametric function.)
#Notice the double parenthesis around the vector-parametric function.
var('t')
r=vector((cos(t),sin(t),t))
a=f(x=4)
print a

Result:

[-4, 0, 4]

Built-in Math Functions in Sage

Function

Returns the **** of the argument

abs(x)

absolute value

sqrt(x)

square root

exp(x)

e^x

log(x)

natural logarithm

log(x,10)

logarithm base 10

sin(x)

sine

cos(x)

cosine

tan(x)

tangent

asin(x)

arcsine

acos(x)

arccosine

atan(x)

arctangent

cosh(x)

hyperbolic cosine

coth(x)

hyperbolic cotangent

ceil(x)

ceiling

floor(x)

floor

int(x)

integer part

round(x)

rounds to whole number

random()

random number in the interval [0, 1)

Pages about Types of Math Functions and Using them in Sage

Definition: A mathematical function is a function that has 1, 2, 3 or more independent variables. You must declare each of the independent variables before defining or using your function. When you substitute values (numbers) for these variables, the function yields a value.

A user-defined math function can be defined as explicit:f(x)=3x^2 or vector-parametric:r=vector((sin(t),cos(t),t)). It can also be used as implicit:x^2+y^2==0

Example 1

# You must declare the variables used in your functions
#Here we define a explicit (regular) function f(x) with one independent variable x and then evaluate it at x=4.
var('x')
f(x)=3*x*sqrt(x)
a=f(4)
print a

Result:

24

Example 2

#Look carefully at this. x is the variable in the function. w is just a "variable name". We need to declare both.
#Here we define a explicit (regular) function f(x) with one independent variable x, a constant w and then evaluate it at x=4.
var('x w')
f(x)=w*x*sqrt(x)
a=f(4)
print a

Result:

8*w

Example 3

#Notice that there is no r(t) at left. There is just r. But with explicit functions you must write f(x).
#(I think this means you cannot have "constants" in your vector-parametric function.)
#Notice the double parenthesis around the vector-parametric function.
var('t')
r=vector((cos(t),sin(t),t))
a=f(x=4)
print a

Home ->Getting Started -> Functions ->

STOP HEREFunctions Math## EXAMPLES ON MY SAGE PAGE: Functions in Sage

Here we are looking atThey are two types:Math Functions.built-inoruser defined. (See also:Functions ProgrammingandCommands.)Definition:A mathematical function is a function that has 1, 2, 3 or more independent variables. You must declare each of the independent variables using the commandvarbefore defining or using your function. When you substitute values (numbers) for these variables, the function yields a value.(A

built-inmath function has no options and one parameter. For example,cos(x)is a built-in math function. See list and use at bottom of this page.)A

user-definedmath function can bedefinedasexplicit:f(x)=3x^2orvector-parametric:r=vector((sin(t),cos(t),t)). It can also be used asimplicit:x^2+y^2==0Example 1#Here we define a explicit (regular) function f(x) with one independent variable x and then evaluate it at x=4.

var('x')

f(x)=3*x*sqrt(x)

a=f(4)

print a

Result:Example 2#Here we define a explicit (regular) function f(x) with one independent variable x, a constant w and then evaluate it at x=4.

var('x w')

f(x)=w*x*sqrt(x)

a=f(4)

print a

Result:Example 3#Notice that there is no r(t) at left. There is just r. But with explicit functions you must write f(x).

#(I think this means you cannot have "constants" in your vector-parametric function.)

#Notice the double parenthesis around the vector-parametric function.

var('t')

r=vector((cos(t),sin(t),t))

a=f(x=4)

print a

Result:Built-in Math Functions in Sage

FunctionReturns the **** of the argument## EXAMPLES ON MY SAGE PAGE: Functions in Sage

Here we are looking atThey are two types:Math Functions.built-inoruser defined. (See also:Functions ProgrammingandCommands.)Definition:A mathematical function is a function that has 1, 2, 3 or more independent variables. You must declare each of the independent variables before defining or using your function. When you substitute values (numbers) for these variables, the function yields a value.(A

built-inmath function has no options and one parameter. For example,cos(x)is a built-in math function. See list and use at bottom of this page.)A

user-definedmath function can bedefinedasexplicit:f(x)=3x^2orvector-parametric:r=vector((sin(t),cos(t),t)). It can also be used asimplicit:x^2+y^2==0Example 1#Here we define a explicit (regular) function f(x) with one independent variable x and then evaluate it at x=4.

var('x')

f(x)=3*x*sqrt(x)

a=f(4)

print a

Result:Example 2#Here we define a explicit (regular) function f(x) with one independent variable x, a constant w and then evaluate it at x=4.

var('x w')

f(x)=w*x*sqrt(x)

a=f(4)

print a

Result:Example 3#Notice that there is no r(t) at left. There is just r. But with explicit functions you must write f(x).

#(I think this means you cannot have "constants" in your vector-parametric function.)

#Notice the double parenthesis around the vector-parametric function.

var('t')

r=vector((cos(t),sin(t),t))

a=f(x=4)

print a

Result:Built-in Math Functions in Sage

FunctionReturns the **** of the argumentReference: Sage_for_Newbies, pp.43 (Ted Kosan)

Keywords:functions, mathematics, variables, explicit, implicit, parametric, vector, vector-parametric