Articles

5.1: Introduction to functions - Mathematics


5.1: Introduction to functions - Mathematics

Numpy | Mathematical Function

NumPy contains a large number of various mathematical operations. NumPy provides standard trigonometric functions, functions for arithmetic operations, handling complex numbers, etc.

Trigonometric Functions –
NumPy has standard trigonometric functions which return trigonometric ratios for a given angle in radians.

numpy.sin(x[, out]) = ufunc ‘sin’) : This mathematical function helps user to calculate trignmetric sine for all x(being the array elements).

numpy.cos(x[, out]) = ufunc ‘cos’) : This mathematical function helps user to calculate trignmetric cosine for all x(being the array elements).

Hyperbolic Functions –
numpy.sinh(x[, out]) = ufunc ‘sin’) : This mathematical function helps user to calculate hyperbolic sine for all x(being the array elements).

Equivalent to 1/2 * (np.exp(x) - np.exp(-x)) or -1j * np.sin(1j*x) .

numpy.cosh(x[, out]) = ufunc ‘cos’) : This mathematical function helps user to calculate hyperbolic cosine for all x(being the array elements).

Equivalent to 1/2 * (np.exp(x) - np.exp(-x)) and np.cos(1j*x)

Functions for Rounding –
numpy.around(arr, decimals = 0, out = None) : This mathematical function helps user to evenly round array elements to the given number of decimals.

numpy.round_(arr, decimals = 0, out = None) : This mathematical function round an array to the given number of decimals.

Exponents and logarithms Functions –
numpy.exp(array, out = None, where = True, casting = ‘same_kind’, order = ‘K’, dtype = None) : This mathematical function helps user to calculate exponential of all the elements in the input array.

numpy.log(x[, out] = ufunc ‘log1p’) : This mathematical function helps user to calculate Natural logarithm of x where x belongs to all the input array elements.
Natural logarithm log is the inverse of the exp(), so that log(exp(x)) = x . The natural logarithm is log in base e.

Arithmetic Functions –
numpy.reciprocal(x, /, out=None, *, where=True) : This mathematical function is used to calculate reciprocal of all the elements in the input array.

Note: For integer arguments with absolute value larger than 1, the result is always zero because of the way Python handles integer division. For integer zero the result is an overflow.


Engaging video tutorials

Select a Lesson to Get Started

Introduction

Familiarize yourself with symbolic mathematics and the course.

Introduction

Familiarize yourself with the course.

Creating Symbolic Variables

Represent numbers symbolically instead of numerically and create symbolic variables.

Creating Symbolic Variables

Represent numbers symbolically instead of numerically and create symbolic variables.

Mathematical Expressions with Symbolic Variables

Create and visualize mathematical expression and substitute values for symbolic variables.

Mathematical Expressions with Symbolic Variables

Create and visualize mathematical expression, and substitute values for symbolic variables.

Creating and Solving Symbolic Equations

Define and solve algebraic equations containing symbolic variables.

Creating and Solving Symbolic Equations

Define and solve algebraic equations containing symbolic variables.

Algebraic Manipulation and Simplification

Manipulate, evaluate, and simplify symbolic equations and expressions.

Algebraic Manipulation and Simplification

Manipulate, evaluate, and simplify symbolic equations and expressions.

Working with Assumptions

Set assumptions on symbolic variables to get real-world results.

Working with Assumptions

Set assumptions on symbolic variables to get real-world results.

Working with Units of Measurement

Assign real-world units to symbolic variables and convert from one unit of measurement to another.

Working with Units of Measurement

Assign real-world units to symbolic variables and convert from one unit of measurement to another.

Creating Symbolic Functions

Define mathematical functions containing symbolic variables.

Creating Symbolic Functions

Define mathematical functions containing symbolic variables.

Visualizing Symbolic Functions and Equations

Visualize functions and equations in two and three dimensions.

Visualizing Symbolic Functions and Equations

Visualize functions and equations in two and three dimensions.

Review Project I

Bring together concepts you have learned with a project.

Review Project I

Bring together concepts you have learned with a project.

Calculus with Symbolic Math

Perform common calculus tasks symbolically.

  • Finding Derivatives
  • Finding Integrals
  • Differentiating and Integrating Multivariable Functions
  • Approximating Functions Using Taylor Polynomials
  • Solving Ordinary Differential Equations

Calculus with Symbolic Math

Perform common calculus tasks symbolically.

  • Finding Derivatives
  • Finding Integrals
  • Differentiating and Integrating Multivariable Functions
  • Approximating Functions Using Taylor Polynomials
  • Solving Ordinary Differential Equations

Review Project II

Bring together concepts you have learned with a project.

Review Project II

Bring together concepts you have learned with a project.

Related Courses

MATLAB Onramp

Get started quickly with the basics of MATLAB.

Solving Nonlinear Equations with MATLAB

Use root-finding methods to solve nonlinear equations.

Solving Ordinary Differential Equations with MATLAB

Use MATLAB ODE solvers to numerically solve ordinary differential equations.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:


Setting up the R Notebook

Let’s remove the template RStudio gives us, and add a title of our own.

This header block is called the YAML header. This is where we specify whether we want to convert this file to a HTML or PDF file. This will be discussed in more detail in another class. For now, we just care about including the lecture title here. For now, let’s type out a note:

This lecture covers fundamental R usage, such as assigning values to a variable, using functions, and commenting code, and more.

Under this sentence, we will insert our first code chunk. Remember that you insert a code chunk by either clicking the “Insert” button or pressing Ctrl/Cmd + Alt + i simultaneously. To run a code chunk, you press the green arrow, or Ctrl/Cmd + Shift + Enter .


Stat 216 will be using blended classroom format. Rather than the typical 150 class hours each week, students will meet with their instructor and cohort of classmates during one 50-minute class period each week. The remaining 100 minutes typically spent in class are instead spent outside of class watching instructor video lectures, reading the textbook, working through case studies, and participating in online discussion with your classmates. This structure serves two purposes: (1) enhance the safety of our community during the COVID-19 pandemic, and (2) provide additional flexibility for students to create their own schedule and make their own decisions on how they learn best.

  • meet with your fellow student cohort in your assigned classroom one class period per week for in-class group activities and discussion,
  • read assigned sections of the online textbook and watch videos on that week's content,
  • read that week's case study and answer discussion questions on the case study via D2L,
  • complete one assignment in Gradescope.

Online sections are available for those students who would prefer not to meet face-to-face in the classroom. If you are unable to attend the face-to-face portions of the blended class, please make sure to register for an online section.


Math Functions

If you're an aviator and needs to calculate windcorrection angles and groundspeed (e.g. during flightplanning) this can be very useful.

$windcorrection = rad2deg(asin((($windspeed * (sin(deg2rad($tt - ($winddirection-180))))/$tas))))
$groundspeed = $tas*cos(deg2rad($windcorrection)) + $windspeed*cos(deg2rad($tt-($winddirection-180)))

You can probably write these lines more beautiful, but they work!

And the reason I needed a Factorial function is because I there were no nPr or nCr functions native to PHP, either.

Wouldn't the following function do the same but a lot easier than the one in the comment before?

function trimInteger($targetNumber,$newLength) <
return $targetNumber%pow(10,$newLength)
>

If you need to deal with polar co-ordinates for somereason you will need to convert to and from x,y for input and output in most situations: here are some functions to convert cartesian to polar and polar to cartesian
<?
//returns array of r, theta in the range of 0-2*pi (in radians)
function rect2polar($x,$y)
<
if(is_numeric($x)&&is_numeric($y))
<
$r=sqrt(pow($x,2)+pow($y,2))
if($x==0)
<
if($y>0) $theta=pi()/2
else $theta=3*pi()/2
>
else if($x<0) $theta=atan($y/$x)+pi()
else if($y<0) $theta=atan($y/$x)+2*pi()
else $theta=atan($y/$x)
$polar=array("r"=>$r,"theta"=>$theta)
return $polar
>
else return false
>

//r must be in radians, returns array of x,y
function polar2rect($r,$theta)
<
if(is_numeric($r)&&is_numeric($theta))
<
$x=$r*cos($theta)
$y=$r*sin($theta)
$rect=array("x"=>$x,"y"=>$y)
>
else
<
return false
>
>
?>

here is an algorithm to calculate gcd of a number. This is Euclid algorithm i was studying in Maths. I've converted it in php for the fun.

A function that simulates the sum operator. (http://en.wikipedia.org/wiki/Sum). Be careful with the expression because it may cause a security hole note the single quotes to don't parse the "$".
<?php
# @param string $expr expression to evaluate (for example (2*$x)^2+1)
# @param string $var dummy variable (for example "x")
# @param integer $start
# @param integer $end
# @param integer $step

function sum ( $expr , $var , $start , $end , $step = 1 ) <
$expr = str_replace ( '' , '' , $expr )
$var = str_replace ( '

Unit 1: Representing Functions

In this lesson, the concept of a function is introduced. We look at the definition of a function and different ways to represent functions.

In this lesson, function notation is introduced. We also explore concepts previously learned about linear and quadratic functions, now using function notation.

In this lesson, we will define domain and range. Set notation will be introduced and used to describe the domain and range of various functions, including quadratic functions.

In this lesson, we will continue our study of domain and range. The domain and range of square root functions and rational functions will be investigated.

All of the pencil and paper practice exercises, answers, and solutions for this unit are reproduced here.

This is a collection of additional, and sometimes challenging, problems that extend the material covered in this unit, connect material from different lessons, and further explore real-world applications.

Unit 2: Transforming and Graphing Functions

In this lesson, the graphs of the quadratic function (f(x)=x^2), the square root function (f(x)=sqrt x), and the reciprocal function (f(x)= dfrac<1>) will be sketched. The domain and range of each of these functions will also be discussed in relation to the graphs.

In this lesson, we will discuss horizontal and vertical translations and their effect on functions. We will express translations using function notation and sketch graphs by applying transformations to base functions.

In this lesson, we will discuss reflections in the ‌(y)-axis as well as horizontal stretches and compressions, and their effect on functions. We will express all of these types transformations using function notation and use them to sketch graphs.

In this lesson, we will discuss reflections in the ‌(x)-axis as well as vertical stretches and compressions, and their effect on functions. We will express all of these types of transformations using function notation and use them to sketch graphs. Comparisons will be made between reflections in the ‌(x)-axis and ‌(y)-axis, and between vertical and horizontal stretches or compressions.

In this lesson, we will be discussing all of the types of transformations together. Transformations on a function (f(x)) will be identified from the notation (y=af(b(x-h))+k) and applied in an appropriate order to sketch graphs.


Types of function

There are two types of function in C programming:

Standard library functions

The standard library functions are built-in functions in C programming.

These functions are defined in header files. For example,

  • The printf() is a standard library function to send formatted output to the screen (display output on the screen). This function is defined in the stdio.h header file.
    Hence, to use the printf() function, we need to include the stdio.h header file using #include <stdio.h> .
  • The sqrt() function calculates the square root of a number. The function is defined in the math.h header file.

User-defined function

You can also create functions as per your need. Such functions created by the user are known as user-defined functions.


Some remarks on the lack of pathological examples

Of course, there are some obvious examples -- e.g., if we permit the function to be unbounded or if we permit its domain to be unbounded. But what about a bounded function on a bounded interval? Within this class of functions, it is hard to give an example of a function that is not integrable. It was already hard enough with the Riemann integral -- for that integral we had to use rather bizarre functions, such as the characteristic function of the rationals. Now, when we turn to the gauge integral or the Lebesgue integral, more functions are integrable, and so it is even harder to produce examples of non-integrable functions.

Every introductory textbook on Lebesgue integrals includes a short proof (due to Vitali) of the existence of a nonmeasurable set the characteristic function of that set is then a nonmeasurable function. But that proof, like every known proof of that theorem, is nonconstructive -- it uses the Axiom of Choice to prove the existence of the nonmeasurable function without actually "finding" the function or describing it explicitly. Vitali's proof is one of the most elementary uses of the Axiom of Choice, and perhaps it makes a good introduction to the Axiom of Choice it could be included in an appendix in a book intended for some advanced undergraduate students. But I think this is conceptually way beyond the grasp of freshman calculus students. All we can do is tell these students: "Yes, there does exist a non-integrable, bounded function on a bounded interval, but describing it to you would require a great deal of higher math, far beyond the scope of this freshman calculus course."


Wolfram Web Resources

The #1 tool for creating Demonstrations and anything technical.

Explore anything with the first computational knowledge engine.

Explore thousands of free applications across science, mathematics, engineering, technology, business, art, finance, social sciences, and more.

Join the initiative for modernizing math education.

Solve integrals with Wolfram|Alpha.

Walk through homework problems step-by-step from beginning to end. Hints help you try the next step on your own.

Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.

Collection of teaching and learning tools built by Wolfram education experts: dynamic textbook, lesson plans, widgets, interactive Demonstrations, and more.


Trigonometry

Note: To convert a radians value to degrees, multiply it by 180/pi (approximately 57.29578). To convert a degrees value to radians, multiply it by pi/180 (approximately 0.01745329252). The value of pi (approximately 3.141592653589793) is 4 times the arctangent of 1.

Returns the trigonometric sine of Number.

Number must be expressed in radians.

Returns the trigonometric cosine of Number.

Number must be expressed in radians.

Returns the trigonometric tangent of Number.

Number must be expressed in radians.

Returns the arcsine (the number whose sine is Number) in radians.

If Number is less than -1 or greater than 1, the function yields a blank result (empty string).

Returns the arccosine (the number whose cosine is Number) in radians.

If Number is less than -1 or greater than 1, the function yields a blank result (empty string).

Returns the arctangent (the number whose tangent is Number) in radians.