CSC 107 - Programming for Science Lecture 7: Math Functions.

Slides:



Advertisements
Similar presentations
Building Java Programs
Advertisements

Return values.
Arithmetic in Pascal (2) Arithmetic Functions Perform arithmetic calculations Gives an argument to the function and it returns the result.
1 ICS103 Programming in C Lecture 5: Introduction to Functions.
CSC Programming for Science Lecture 5: Actual Programming.
Numbers. Number data types store numeric values They are immutable data types, which means that changing the value of a number data type results in a.
Lecture 6 MATLAB functions Basics of Built-in Functions, Help Feature, Elementary Functions (e.g., Polynomials, Trigonometric Functions), Data Analysis,
CS 201 Functions Debzani Deb.
Topic 2A – Library Functions and Casting. CISC 105 – Topic 2A Functions A function is a piece of code which performs a specific task. When a function.
Introduction to Matlab. Entering Commands Constants and Functions >> pi ans = >> eps ans = e-016 >> sin(pi/2) ans = 1 >> log(1000) ans =
1 Data types, operations, and expressions Continued l Overview l Assignment statement l Increment and Decrement operators l Short hand operators l The.
6.8 Notes In this lesson you will learn how to… write trigonometric equations as inverse trigonometric relation equations. find the values that satisfy.
Microsoft® Small Basic The Math Object Estimated time to complete this lesson: 1 hour.
1 CS101 Introduction to Computing Lecture 38 String Manipulations (Web Development Lecture 13)
1 CS101 Introduction to Computing Lecture 35 Mathematical Methods (Web Development Lecture 12)
Trigonometric Functions Of Real Numbers
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
Honors Geometry Sections 10.1 & 10.2 part 2 Solving Right Triangles.
EG280 - CS for Engineers Chapter 2, Introduction to C Part I Topics: Program structure Constants and variables Assignment Statements Standard input and.
JavaScript Part 2 – Page 1 of 35CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: JavaScript Part 2.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
1 TAC2000/ Protocol Engineering and Application Research Laboratory (PEARL) MATH Functions in C Language.
IMS 3253: Math 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Five Fundamental Math Operations Precedence of Math.
CSC1015F – Chapter 3, Computing with Numbers Michelle Kuttel
CSE202: Lecture 4The Ohio State University1 Mathematical Functions.
JavaScript For...In Statement The for...in statement loops through the elements of an array or through the properties of an object. Syntax for (variable.
Inverse Trigonometric Functions Section 4.7. Objectives Evaluate inverse trigonometric functions at given values. State the domain and range of each of.
© 2012 EMC Publishing, LLC Slide 1 Chapter 7 The Math Class  Includes shared methods that perform common math functions.  Math Class methods include:
Week 2 - Friday.  What did we talk about last time?  Using Scanner to get input  Basic math operations.
Slide Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
1 © 2010 Pearson Education, Inc. All rights reserved © 2010 Pearson Education, Inc. All rights reserved Chapter 4 Trigonometric Functions.
Copyright © 2011 Pearson, Inc. 4.7 Inverse Trigonometric Functions.
STANDARD FUNCTIONS Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
1 Week 2: Variables and Assignment Statements READING: 1.4 – 1.6 EECS Introduction to Computing for the Physical Sciences.
1 ICS103 Programming in C Lecture 7: Introduction to Functions.
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
Topic:  Reading Input  identifier,  if statement,  Arithmetic Operation CSE 102 – Programming Fundamentals.
Visual Basic I Programming
Introduction As programmers, we don’t want to have to implement functions for every possible task we encounter. The Standard C library contains functions.
C++ Programming Lecture 9 Functions – Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
1 © 2011 Pearson Education, Inc. All rights reserved 1 © 2010 Pearson Education, Inc. All rights reserved © 2011 Pearson Education, Inc. All rights reserved.
BY: MARIAH & JON 13.4 INVERSE OF SINE AND TANGENT.
PHY 107 – Programming For Science. Announcements  Lectures may not cover all material from readings  Material that is most difficult or challenging.
1 What you will learn  How to evaluate inverse trigonometric functions  How to find missing angle measures  How to solve right triangles.
Computer Graphics Basic Maths for Graphics in C++ CO2409 Computer Graphics Week 4.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
CSC Programming for Science Lecture 8: Character Functions.
Hazırlayan:Emin BORANDAĞ 2/17/ Numerik Değerler Kullanımı Integers are considered accurate up to 15 digits. Try it function myFunction() { var x.
Header File cmath(math.h) C++. cmath Header File cmath / math functions Function name and parameters Parameters typeFunction return value acos(x)x is.
Definition if and only if y =log base a of x Important Idea Logarithmic Form Exponential Form.
10.4: Inverses of Trigonometric Functions Algebra 2.
CSC Programming for Science Lecture 5: Actual Programming.
Variables, Operators, and Expressions
Simple C Programs.
Some Useful MATLAB Functions
Arithmetic Operations
Library Functions Goals of software engineering reliable code
ECE 1304 Introduction to Electrical and Computer Engineering
Inverses of Trigonometric Functions 13-4
BIL 104E Introduction to Scientific and Engineering Computing
TMF1414 Introduction to Programming
FUNCTIONS EXAMPLES.
Math Library and IO formatting
11–8A – Define Radian Measure
Using Free Functions Chapter 3 Computing Fundamentals with C++
Functions October 23, 2017.
Trigonometric Equations with Multiple Angles
Inverse Trigonometric Functions
Graphing Trigonometric Functions
Trigonometric Inverses
Presentation transcript:

CSC Programming for Science Lecture 7: Math Functions

Today’s Goal At the end of today’s lecture, you should have a better understanding of functions  These are important in real programs  Includes way to convert decimals to integers

Functions C includes many pre-defined functions  Function just means a routine that does some useful work  #include statement allow us to use functions Differs from what function means in math  printf & scanf do not return values  Functions discussed today do, however

Mathematical Functions To use, at start of program must add #include All of these functions will return a value  Will not change value of any argument  Can assign result to a variable  Can use result in an equation  Can ignore result, but why call function?

Using These Functions double fabs(double x)  Returns absolute value of a number double d1 = fabs(-1); double d2 = fabs(-56.54); double d3 = fabs(d1); double d4 = fabs(d1 + d2 * d3); double d5 = d4 * fabs(d2); d2 = 46 * fabs(d1); d5 = fabs(fabs(d3));

Other Functions Some other good, useful functions that return data of type double  sqrt(x)returns square root of x  pow(x,y)returns x y  exp(x)returns e x  log(x)returns ln x; natural logarithm of x  log10(x)returns log 10 x double includes value “NaN” that returns when result is undefined, as in sqrt(-1)

Trigonometric Functions Angle measurements are in radians -- program must do any conversions  sin(x)returns sine of x  cos(x)returns cosine of x  tan(x)returns tangent of x  asin(x)return arcsine of x; x must be in the range [-1, 1] & result is in the range [-  /2,  /2]  acos(x)return arccosine of x; x must be in the range [-1, 1] & result is in the range [-  /2,  /2]  atan(x)return arctangent of x; result is in the range [-  /2,  /2]

Rounding Functions Additional functions allow us to convert decimal numbers into integers floor(x) returns x rounded to nearest integer toward -  (negative infinity)  floor(2.01) returns 2  floor( ) returns 78  floor( ) returns -1  floor( ) returns -66

Rounding Functions Additional functions allow us to convert decimal numbers into integers ceil(x) returns x rounded to nearest integer toward  (positive infinity)  ceil(2.01) returns 3  ceil( ) returns 79  ceil( ) returns 0  ceil( ) returns -65

Normal Rounding C does not define function to perform typical rounding operation  floor(x + 0.5) works with numbers >  ceil(x + 0.5) works with numbers < -0.5 We will revisit this problem later…

Your Turn Get into groups and complete daily activity

For Next Lecture Read through Section 2.6 of book  Do not need to understand all the details  But important knowing what is not understood Start homework assignment for week 3  Covers material from this week’s lectures