Computing with formulas - GitHub Pages
Computing with formulas
FC CK0030 2019.1
A formula
Programs and programming Variables Comments, text and numbers formatting
Another formula
Integer division Objects in Python Integer division Arithmetic operators
Mathematical functions
Examples Rounding errors
Interactive computing
The shell Type conversion IPython
019 Computing with formulas 2 Foundation of programming (CK0030) R 20F,C ? Francesco Corona A? M
Computing with formulas
FC CK0030 2019.1
A formula
Programs and programming Variables Comments, text and numbers formatting
Another formula
Integer division Objects in Python Integer division Arithmetic operators
Mathematical functions
Examples Rounding errors
Interactive computing
The shell Type conversion IPython
FdP
19 Intro to variables, objects, modules, and text formatting 0 Programming with WHILE- and FOR-loops, and lists 2 Functions and IF-ELSE tests 0, ? Data reading and writing
Error handling
R 2FC Making modules A ? Arrays and array computing
Plotting curves and surfaces
M
Computing with formulas
FC CK0030 2019.1
A formula
Programs and programming Variables Comments, text and numbers formatting
Another formula
Integer division Objects in Python Integer division Arithmetic operators
Mathematical functions
Examples Rounding errors
Interactive computing
The shell Type conversion IPython
, 2019 A formula R 20FC ? Computing with formulas A? M
Computing with formulas
A formula
FC
CK0030 2019.1
A formula
Programs and programming Variables Comments, text and numbers formatting
Another formula
Integer division Objects in Python Integer division Arithmetic operators
Mathematical functions
Examples Rounding errors
Interactive computing
The shell Type conversion
9 Example 1 The vertical motion of a ball thrown up in the air 0 We can set up a mathematical model for the motion of the ball 2 ? From Newton's second law of motion
, The vertical position of the ball, called y, varies with time t
20 ? y(t)
=
v0t
-
1 gt2 2
R FC v0 is the initial velocity of the ball
A ? g is the acceleration of gravity
t is time
(1)
IPython
M The y axis is chosen such that the ball starts from y = 0 at t = 0
Computing with formulas
FC CK0030 2019.1
A formula
Programs and programming Variables Comments, text and numbers formatting
Another formula
Integer division Objects in Python Integer division Arithmetic operators
Mathematical functions
Examples Rounding errors
Interactive computing
The shell Type conversion IPython
A formula (cont.)
19 The time for the ball to move upwards and return to the ground again
0 We are interested in the solutions to equation y(t) = 0
, 2 v0t
-
1 gt
2
2
=
t (v0
-
1 gt )
2
=
0
0 ? t = 0
(2)
2 t = 2v0 Cg
R F The ball returns to ground level in 2v0/g (seconds) A ? ? We can focus in the interval t [0, 2v0/g]
M
Computing with formulas
FC CK0030 2019.1
A formula
Programs and programming Variables Comments, text and numbers formatting
Another formula
Integer division Objects in Python Integer division Arithmetic operators
Mathematical functions
Examples Rounding errors
Interactive computing
The shell Type conversion IPython
A formula (cont.)
y (t )
=
v0t
-
1 gt2 2
We evaluate the formula for some values of v0 and g
9 ? v0 = 5 ms-1 1 ? g = 9.81 ms-2
0 We want to compute the ball's height for t = 0.6 s
2 1.4 0, ? 1.2 2 1 R FC 0.8
A ? 0.6
M0.4 0.2
0
0
0.5
1
1.5
Computing with formulas
A formula (cont.)
FC
CK0030 2019.1
A formula
Programs and programming Variables Comments, text and numbers formatting
Another formula
Integer division Objects in Python Integer division Arithmetic operators
Mathematical functions
Examples Rounding errors
Interactive computing
The shell Type conversion
9 y = 5 ? 0.6 - 1 ? 9.81 ? 0.62 2
1 v0
t
g
t2
0 1 print 5*0.6 - 0.5*9.81*0.6**2
, 2 Remark 0 ? The four standard arithmetic operators
2 +, -, * and / R FC Exponentiation employs a double asterisk ** notation
A ? The arithmetic expression is easily evaluated and printed
(3)
IPython
M ? A one-line Python program
The ball comes back after some time t = 2v0/g 1 [s]
Computing with formulas
FC CK0030 2019.1
A formula
Programs and programming Variables Comments, text and numbers formatting
Another formula
Integer division Objects in Python Integer division Arithmetic operators
Mathematical functions
Examples Rounding errors
Interactive computing
The shell Type conversion IPython
, 2019 Programs and programming R 20FC ? A formula
A? M
Computing with formulas
FC CK0030 2019.1
A formula
Programs and programming Variables Comments, text and numbers formatting
Another formula
Integer division Objects in Python Integer division Arithmetic operators
Mathematical functions
Examples Rounding errors
Interactive computing
The shell Type conversion IPython
Programs and programming
9 Our task is to create programs/code and run it 1 There are three main types of tools for writing Python code 0 ? A plain text editor 2 ? An IPython notebook
? An integrated development environment (IDE) with a text editor
20, ? Remark C What you choose depends on how you access Python R F There are various possibilities
? Access a plain installation on your own computer
A ? ? Access a pre-installed environment (distribution) M ? Access Python in a cloud service
Computing with formulas
Programs and programming (cont.)
FC CK0030 2019.1
A formula
Programs and programming Variables Comments, text and numbers formatting
Another formula
Integer division Objects in Python Integer division Arithmetic operators
Mathematical functions
Examples Rounding errors
Interactive computing
The shell Type conversion IPython
2019 t = 0.6s , v0 = 5 ms-1 0 ? g = 9.81 ms-2
y (t )
=
v0t
-
1 gt2 2
2 1 print 5*0.6 - 0.5*9.81*0.6**2 R FC This line is a complete Python program for evaluating the formula A ? ? Copy the line in a text file
M ? Save the text file with name ball1.py
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- scientific and mathematical computing using python
- pandas format numbers with commas
- s e c t i o n 2 4 p o w e r f u l o u t p u t f o r m
- numbers lists and tuples
- str s format method for introduction to programming using
- python course rutgers university
- introduction to python university of pennsylvania
- programming in python 3 smu
- using python in labeling and field calculations esri
- formatting numbers with c output streams
Related searches
- ms excel formulas with examples
- download excel formulas with examples
- excel formulas list with example
- excel all formulas with examples
- advanced excel formulas with examples
- spreadsheet help with formulas and functions
- dictionary with pages online
- free conservative home pages with search engines
- basic excel formulas with example
- basic statistics formulas with examples
- complex excel formulas with examples
- free coloring pages with colors