Object Oriented Programming for Python

Size: px
Start display at page:

Download "Object Oriented Programming for Python"

Transcription

1 Object Oriented Programming for Python Bas Roelenga Rijksuniversiteit Groningen Kapteyn Institute February 20, 2017 Bas Roelenga (RUG) February 20, / 21

2 Why use Object Oriented Programming? Code will be more readable and organized There is less duplicate code, i.e. a more efficient program Makes it easier to write larger programs Bas Roelenga (RUG) February 20, / 21

3 What is Object Oriented Programming? A type of programming which uses object These objects can be everything What is an object? A structure that contains data Data from this structure can be manipulated We can request the data from this structure Bas Roelenga (RUG) February 20, / 21

4 Syntax structure of Object Oriented Programming Constructing a class 1 c l a s s Y o u r C l a s s : 2 d e f i n i t ( s e l f ) : Listing 1: Creating a python class Two key things to note class def init (self) (constructor) Bas Roelenga (RUG) February 20, / 21

5 The Constructor What is a constructor? 1 c l a s s Y o u r C l a s s : 2 d e f i n i t ( s e l f, x, y, z ) : 3 s e l f. x = x 4 s e l f. y = y 5 s e l f. z = z Listing 2: The constructor The 4 parameters: self, this is the object itself x, y and z represent the position of the object Bas Roelenga (RUG) February 20, / 21

6 Instantiating our object 1 x = 2 2 y = 3 3 z = 1 4 How do we create our object? 5 o u r C l a s s = Y o u r C l a s s ( x, y, z ) Listing 3: Creating our object Bas Roelenga (RUG) February 20, / 21

7 Adding a method(function) to our object Why add a method to our object? 1 c l a s s Y o u r C l a s s : 2 d e f i n i t ( s e l f, x ) : 3 s e l f. x = x 4 5 d e f getx ( s e l f ) : 6 r e t u r n s e l f. x Listing 4: Implementing a method When calling the function getx() it will return the x value Also called a getter function Bas Roelenga (RUG) February 20, / 21

8 Using our object 1 c l a s s Y o u r C l a s s : 2 d e f i n i t ( s e l f, x ) : 3 s e l f. x = x 4 5 d e f getx ( s e l f ) : 6 r e t u r n s e l f. x Listing 5: Our object 1 o u r C l a s s = Y o u r C l a s s ( 2 ) 2 x = o u r C l a s s. getx ( ) 3 4 p r i n t x Listing 6: Obtaining data from our object Bas Roelenga (RUG) February 20, / 21

9 Adding more methods(functions) to our object Instead of getting a value from our object we can also change the value of an object 1 c l a s s Y o u r C l a s s : 2 d e f i n i t ( s e l f, x ) : 3 s e l f. x = x 4 5 d e f setx ( s e l f, x ) : 6 s e l f. x = x Listing 7: Implementing a method 1 o u r C l a s s = Y o u r C l a s s ( 2 ) 2 o u r C l a s s. setx ( 3 ) 3 4 p r i n t o u r C l a s s. getx ( ) Listing 8: Obtaining data from our object Bas Roelenga (RUG) February 20, / 21

10 Adding more methods(functions) to our object Add a function which returns an operation on data members of the class 1 c l a s s Y o u r C l a s s : 2 d e f i n i t ( s e l f, x, y ) : 3 s e l f. x = x 4 s e l f. y = y 5 6 d e f g e t R a d i u s ( s e l f ) : 7 r e t u r n np. s q r t ( s e l f. x 2 + s e l f. y 2) Listing 9: Implementing a method When calling the function getradius() of the object, the object will return the radius Bas Roelenga (RUG) February 20, / 21

11 Adding a class variable Class variables are variables that are a part of the class (not of the object) These are static elements 1 c l a s s Y o u r C l a s s : 2 3 c = 3E8 4 5 d e f i n i t ( s e l f, x, y ) : 6 s e l f. x = x 7 s e l f. y = y Listing 10: Adding static variable When creating 2 objects from this class c will remain the same for both, thus if we change c it will change for both objects Bas Roelenga (RUG) February 20, / 21

12 Exercise 1: Question Code 10 particles which have the following parameters and store them in a list: A 3 dimensional position A mass It doesn t matter what the actual values of the positions or mass end up being. Bas Roelenga (RUG) February 20, / 21

13 Exercise 1: Answer 1 c l a s s P a r t i c l e : 2 d e f i n i t ( s e l f, x, y, z, mass ) : 3 4 s e l f. x = x 5 s e l f. y = y 6 s e l f. z = z 7 s e l f. mass = mass 8 9 p a r t i c l e l i s t = [ ] 0 1 f o r i i n range ( 0, 10) : 2 3 p = P a r t i c l e ( i, i, i, i 10) 4 p a r t i c l e l i s t. append ( p ) Listing 11: Answer Bas Roelenga (RUG) February 20, / 21

14 Inheritance What is inheritance? When is inheritance useful, i.e why do we want to use it? There are 2 kinds of classes now: Superclass (can also be called an abstract class) Subclass Bas Roelenga (RUG) February 20, / 21

15 Using inheritance: superclass The superclass looks like any other class This class will serve as a abstract for our subclasses 1 c l a s s S u p e r c l a s s : 2 3 d e f i n i t ( s e l f, x, y ) : 4 5 s e l f. x = x 6 s e l f. y = y 7 8 d e f getx ( s e l f ) : 9 r e t u r n s e l f. x 0 1 d e f gety ( s e l f ) : 2 r e t u r n s e l f. y Listing 12: Our superclass Bas Roelenga (RUG) February 20, / 21

16 Using inheritance: subclass The subclass looks a little bit different 1 2 c l a s s S u b c l a s s ( S u p e r c l a s s ) : 3 4 d e f g e t S u b c l a s s S p e c i f i c P r o p e r t i e ( s e l f ) : 5 r e t u r n s e l f. x s e l f. y Listing 13: Our subclass Notice that this subclass does not contain a constructor Bas Roelenga (RUG) February 20, / 21

17 Using inheritance: putting it all together We create the a class in the following way: 1 2 x = 1 3 y = o u r C l a s s = S u b c l a s s ( x, y ) 6 7 p r i n t o u r C l a s s. getx ( ) 8 p r i n t o u r C l a s s. g e t S u b c l a s s S p e c i f i c P r o p e r t i e ( ) Listing 14: Putting it together We can use all the function and variables from the superclass Only our subclass can use its specific property method!! Bas Roelenga (RUG) February 20, / 21

18 Overloading What is overloading? 1 2 c l a s s S u b c l a s s ( S u p e r c l a s s ) : 3 4 d e f i n i t ( s e l f, x, y, mass ) : 5 s e l f. x = x 6 s e l f. y = y 7 8 s e l f. mass = mass 9 0 d e f g e t S u b c l a s s S p e c i f i c P r o p e r t i e ( s e l f ) : 1 r e t u r n s e l f. x s e l f. y Listing 15: Overloading The constructor function now overloads the constructor function of the superclass Bas Roelenga (RUG) February 20, / 21

19 Exercise 2: Question Create 3 classes of particles (call them electrons, protons and neutrons) Every class has the following properties: A position An energy Every class also has a specific method which can only be used by the class itself: Electron: A function that returns the spin (hint: Overload the electron class constructor) Proton: A function that returns the kinetic energy Neutron: A function that returns the mass Bas Roelenga (RUG) February 20, / 21

20 Exercise 2: Answer First of we create the superclass Particle We create a subclass for each particle For electrons we overload the constructor For protons and neutrons we give there mass as a static variable We create the function that does each of the operations Bas Roelenga (RUG) February 20, / 21

21 If there is time left Create a simple N-body simulation using object oriented programming The following steps can be followed: Create a 100 particles with x, y, z and mass parameters (just assume everything starts with no velocities at all) Create a loop which does a 100 iterations of our N-Body simulation In each iterations each particles needs to update its position, use the gravitational force between the particles to calculate the acceleration, then use this acceleration to calculate to update the velocity of each particle and thus update the position. Hints: It doesn t really matter what values are used for the simulation, we only want to train our object oriented part. Give every particle an update function, so you only have to call the update function and put in the acceleration to update the position of the particle. Bas Roelenga (RUG) February 20, / 21

COMP 204. Object Oriented Programming (OOP) Mathieu Blanchette

COMP 204. Object Oriented Programming (OOP) Mathieu Blanchette COMP 204 Object Oriented Programming (OOP) Mathieu Blanchette 1 / 14 Object-Oriented Programming OOP is a way to write and structure programs to make them easier to design, understand, debug, and maintain.

More information

Read all questions and answers carefully! Do not make any assumptions about the code other than those that are clearly stated.

Read all questions and answers carefully! Do not make any assumptions about the code other than those that are clearly stated. Read all questions and answers carefully! Do not make any assumptions about the code other than those that are clearly stated. CS177 Fall 2014 Final - Page 2 of 38 December 17th, 10:30am 1. Consider we

More information

Your Second Physics Simulation: A Mass on a Spring

Your Second Physics Simulation: A Mass on a Spring Your Second Physics Simulation: A Mass on a Spring I. INTRODUCTION At this point I think everybody has a working bouncing ball program. In these programs the ball moves under the influence of a very simple

More information

Section 4.6 Negative Exponents

Section 4.6 Negative Exponents Section 4.6 Negative Exponents INTRODUCTION In order to understand negative exponents the main topic of this section we need to make sure we understand the meaning of the reciprocal of a number. Reciprocals

More information

Tutorial Three: Loops and Conditionals

Tutorial Three: Loops and Conditionals Tutorial Three: Loops and Conditionals Imad Pasha Chris Agostino February 18, 2015 1 Introduction In lecture Monday we learned that combinations of conditionals and loops could make our code much more

More information

CS177 Spring Final exam. Fri 05/08 7:00p - 9:00p. There are 40 multiple choice questions. Each one is worth 2.5 points.

CS177 Spring Final exam. Fri 05/08 7:00p - 9:00p. There are 40 multiple choice questions. Each one is worth 2.5 points. CS177 Spring 2015 Final exam Fri 05/08 7:00p - 9:00p There are 40 multiple choice questions. Each one is worth 2.5 points. Answer the questions on the bubble sheet given to you. Only the answers on the

More information

Python. chrysn

Python. chrysn Python chrysn 2008-09-25 Introduction Structure, Language & Syntax Strengths & Weaknesses Introduction Structure, Language & Syntax Strengths & Weaknesses Python Python is an interpreted,

More information

8.2 Examples of Classes

8.2 Examples of Classes 206 8.2 Examples of Classes Don t be put off by the terminology of classes we presented in the preceding section. Designing classes that appropriately break down complex data is a skill that takes practice

More information

Lesson 39: Kinetic Energy & Potential Energy

Lesson 39: Kinetic Energy & Potential Energy Lesson 39: Kinetic Energy & Potential Energy Kinetic Energy Work-Energy Theorem Potential Energy Total Mechanical Energy We sometimes call the total energy of an object (potential and kinetic) the total

More information

Tou has been released!

Tou has been released! Tou has been released! Shoot- em-up, heavy use of collision detection Much more open-ended than previous projects Easier than previous projects if you work smart Should help those of you combating the

More information

Electrostatics Notes 1 Charges and Coulomb s Law

Electrostatics Notes 1 Charges and Coulomb s Law Electrostatics Notes 1 Charges and Coulomb s Law Matter is made of particles which are or charged. The unit of charge is the ( ) Charges are, meaning that they cannot be It is thought that the total charge

More information

Chapter 17 Lecture Notes

Chapter 17 Lecture Notes Chapter 17 Lecture Notes Physics 2424 - Strauss Formulas: qv = U E W = Fd(cosθ) W = - U E V = Ed V = kq/r. Q = CV C = κε 0 A/d κ = E 0 /E E = (1/2)CV 2 Definition of electric potential Definition of Work

More information

Description of the motion using vectorial quantities

Description of the motion using vectorial quantities Description of the motion using vectorial quantities RECTILINEAR MOTION ARBITRARY MOTION (3D) INERTIAL SYSTEM OF REFERENCE Circular motion Free fall Description of the motion using scalar quantities Let's

More information

Python & Numpy A tutorial

Python & Numpy A tutorial Python & Numpy A tutorial Devert Alexandre School of Software Engineering of USTC 13 February 2012 Slide 1/38 Table of Contents 1 Why Python & Numpy 2 First steps with Python 3 Fun with lists 4 Quick tour

More information

Why Doesn t the Moon Hit us? In analysis of this question, we ll look at the following things: i. How do we get the acceleration due to gravity out

Why Doesn t the Moon Hit us? In analysis of this question, we ll look at the following things: i. How do we get the acceleration due to gravity out Why Doesn t the oon Hit us? In analysis of this question, we ll look at the following things: i. How do we get the acceleration due to gravity out of the equation for the force of gravity? ii. How does

More information

ESCI 386 Scientific Programming, Analysis and Visualization with Python. Lesson 18 - Linear Algebra

ESCI 386 Scientific Programming, Analysis and Visualization with Python. Lesson 18 - Linear Algebra ESCI 386 Scientific Programming, Analysis and Visualization with Python Lesson 18 - Linear Algebra 1 Matrix Operations In many instances, numpy arrays can be thought of as matrices. In the next slides

More information

Calculus I 2nd Partial Project Applications of Motion: Position, Velocity, and Acceleration

Calculus I 2nd Partial Project Applications of Motion: Position, Velocity, and Acceleration Calculus I 2nd Partial Project Applications of Motion: Position, Velocity, and Acceleration Fernando Jair Balcázar A01570174 René Alejandro Ponce A01570252 Alberto Frese A01570191 María Renée Gamboa A01570128

More information

Lecture Notes Chapter 5 Friction

Lecture Notes Chapter 5 Friction Lecture Notes Chapter 5 Friction NORMAL FORCES When an object rests on a surface, the surface exerts a normal force on the object, keeping it from accelerating downward. A normal force is perpendicular

More information

Introduction to Electricity and Magnetism

Introduction to Electricity and Magnetism Introduction to Electricity and Magnetism Where should we begin our study of electricity and magnetism (E&M)? Here are three possibilities: 1. The Historical Approach: in the first three sections of chapter

More information

In this section we want to learn how to solve equations containing radicals, like 5 x 4 = 9. In order to do this we need the following property.

In this section we want to learn how to solve equations containing radicals, like 5 x 4 = 9. In order to do this we need the following property. .7 Solving Radical Equations In this section we want to learn how to solve equations containing radicals, like. In order to do this we need the following property. n-th Power Property n n If a b, then

More information

Lecture 10: Linear Multistep Methods (LMMs)

Lecture 10: Linear Multistep Methods (LMMs) Lecture 10: Linear Multistep Methods (LMMs) 2nd-order Adams-Bashforth Method The approximation for the 2nd-order Adams-Bashforth method is given by equation (10.10) in the lecture note for week 10, as

More information

Write a simple 1D DFT code in Python

Write a simple 1D DFT code in Python Write a simple 1D DFT code in Python Ask Hjorth Larsen, asklarsen@gmail.com Keenan Lyon, lyon.keenan@gmail.com September 15, 2018 Overview Our goal is to write our own KohnSham (KS) density functional

More information

CMSC 451: Lecture 7 Greedy Algorithms for Scheduling Tuesday, Sep 19, 2017

CMSC 451: Lecture 7 Greedy Algorithms for Scheduling Tuesday, Sep 19, 2017 CMSC CMSC : Lecture Greedy Algorithms for Scheduling Tuesday, Sep 9, 0 Reading: Sects.. and. of KT. (Not covered in DPV.) Interval Scheduling: We continue our discussion of greedy algorithms with a number

More information

What if the characteristic equation has a double root?

What if the characteristic equation has a double root? MA 360 Lecture 17 - Summary of Recurrence Relations Friday, November 30, 018. Objectives: Prove basic facts about basic recurrence relations. Last time, we looked at the relational formula for a sequence

More information

3 Types of Nuclear Decay Processes

3 Types of Nuclear Decay Processes 3 Types of Nuclear Decay Processes Radioactivity is the spontaneous decay of an unstable nucleus The radioactive decay of a nucleus may result from the emission of some particle from the nucleus. The emitted

More information

CHAPTER 1. Review of Algebra

CHAPTER 1. Review of Algebra CHAPTER 1 Review of Algebra Much of the material in this chapter is revision from GCSE maths (although some of the exercises are harder). Some of it particularly the work on logarithms may be new if you

More information

Problem Set 6: Magnetism

Problem Set 6: Magnetism University of Alabama Department of Physics and Astronomy PH 10- / LeClair Spring 008 Problem Set 6: Magnetism 1. 10 points. A wire with a weight per unit length of 0.10 N/m is suspended directly above

More information

NP, polynomial-time mapping reductions, and NP-completeness

NP, polynomial-time mapping reductions, and NP-completeness NP, polynomial-time mapping reductions, and NP-completeness In the previous lecture we discussed deterministic time complexity, along with the time-hierarchy theorem, and introduced two complexity classes:

More information

Faculty of Engineering and Department of Physics Engineering Physics 131 Midterm Examination Monday February 24, 2014; 7:00 pm 8:30 pm

Faculty of Engineering and Department of Physics Engineering Physics 131 Midterm Examination Monday February 24, 2014; 7:00 pm 8:30 pm Faculty of Engineering and Department of Physics Engineering Physics 131 Midterm Examination Monday February 4, 014; 7:00 pm 8:30 pm 1. No notes or textbooks allowed.. Formula sheets are included (may

More information

- Why aren t there more quantum algorithms? - Quantum Programming Languages. By : Amanda Cieslak and Ahmana Tarin

- Why aren t there more quantum algorithms? - Quantum Programming Languages. By : Amanda Cieslak and Ahmana Tarin - Why aren t there more quantum algorithms? - Quantum Programming Languages By : Amanda Cieslak and Ahmana Tarin Why aren t there more quantum algorithms? there are only a few problems for which quantum

More information

CS Deep Reinforcement Learning HW2: Policy Gradients due September 19th 2018, 11:59 pm

CS Deep Reinforcement Learning HW2: Policy Gradients due September 19th 2018, 11:59 pm CS294-112 Deep Reinforcement Learning HW2: Policy Gradients due September 19th 2018, 11:59 pm 1 Introduction The goal of this assignment is to experiment with policy gradient and its variants, including

More information

CS177 Spring Midterm 2. April 02, 8pm-9pm. There are 25 multiple choice questions. Each one is worth 4 points.

CS177 Spring Midterm 2. April 02, 8pm-9pm. There are 25 multiple choice questions. Each one is worth 4 points. CS177 Spring 2015 Midterm 2 April 02, 8pm-9pm There are 25 multiple choice questions. Each one is worth 4 points. Answer the questions on the bubble sheet given to you. Only the answers on the bubble sheet

More information

Mathematics 96 (3581) CA (Class Addendum) 1: Commutativity Mt. San Jacinto College Menifee Valley Campus Spring 2013

Mathematics 96 (3581) CA (Class Addendum) 1: Commutativity Mt. San Jacinto College Menifee Valley Campus Spring 2013 Mathematics 96 (3581) CA (Class Addendum) 1: Commutativity Mt. San Jacinto College Menifee Valley Campus Spring 2013 Name This class handout is worth a maximum of five (5) points. It is due no later than

More information

Lesson 39: Kinetic Energy & Potential Energy

Lesson 39: Kinetic Energy & Potential Energy Lesson 39: Kinetic Energy & Potential Energy Kinetic Energy You ve probably heard of kinetic energy in previous courses using the following definition and formula Any object that is moving has kinetic

More information

CLASSICAL ITERATIVE METHODS

CLASSICAL ITERATIVE METHODS CLASSICAL ITERATIVE METHODS LONG CHEN In this notes we discuss classic iterative methods on solving the linear operator equation (1) Au = f, posed on a finite dimensional Hilbert space V = R N equipped

More information

SYDE 112, LECTURE 7: Integration by Parts

SYDE 112, LECTURE 7: Integration by Parts SYDE 112, LECTURE 7: Integration by Parts 1 Integration By Parts Consider trying to take the integral of xe x dx. We could try to find a substitution but would quickly grow frustrated there is no substitution

More information

Los Altos Physics Honors. Electrostatics: Electric Fields, Electric Forces, Electric Potentials and. Electric Potential Energy.

Los Altos Physics Honors. Electrostatics: Electric Fields, Electric Forces, Electric Potentials and. Electric Potential Energy. Los Altos Physics Honors Electrostatics: Electric Fields, Electric Forces, Electric Potentials and Electric Potential Energy Workbook adam.randall@mvla.net www.laphysics.com dls.mvla.net/los_altos Spring

More information

Managing Uncertainty

Managing Uncertainty Managing Uncertainty Bayesian Linear Regression and Kalman Filter December 4, 2017 Objectives The goal of this lab is multiple: 1. First it is a reminder of some central elementary notions of Bayesian

More information

Project 5: Molecular Dynamics

Project 5: Molecular Dynamics Physics 2300 Spring 2018 Name Lab partner Project 5: Molecular Dynamics If a computer can model three mutually interacting objects, why not model more than three? As you ll soon see, there is little additional

More information

Forces. gravity, weight, free fall, friction

Forces. gravity, weight, free fall, friction Forces gravity, weight, free fall, friction Forces can affect motion in several ways: They can make objects start moving They can make objects move faster They can make objects move slower They can make

More information

= lim. (1 + h) 1 = lim. = lim. = lim = 1 2. lim

= lim. (1 + h) 1 = lim. = lim. = lim = 1 2. lim Math 50 Exam # Solutions. Evaluate the following its or explain why they don t exist. (a) + h. h 0 h Answer: Notice that both the numerator and the denominator are going to zero, so we need to think a

More information

Study Guide #2. L. Colonna-Romano/T. Keil. Electricity and Magnetism

Study Guide #2. L. Colonna-Romano/T. Keil. Electricity and Magnetism PH1120 Electricity and Magnetism L. Colonna-Romano/T. Keil Term B98 Study Guide #2 With this Study Guide, we will discuss work and energy in situations involving an electric field and related concepts.

More information

Electric Potential and Potential Energy. A reformulation from a vector approach to a scalar approach

Electric Potential and Potential Energy. A reformulation from a vector approach to a scalar approach Electric Potential and Potential Energy A reformulation from a vector approach to a scalar approach Once again, compare to gravity, be very careful though Potential is not the same thing as potential energy

More information

Appendix A Objectives Mapping

Appendix A Objectives Mapping Appendix A Objectives Mapping (for CGS 2060) Ken Christensen christen@cse.usf.edu CGS2060 - Mapping of New Objectives to Old Objectives Obj. 1 Obj. 2 Obj. 3 Obj. 4 Obj. 5 Obj. 6 Obj. 12 a b c d e f g h

More information

Time-Independent Perturbation Theory

Time-Independent Perturbation Theory 4 Phys46.nb Time-Independent Perturbation Theory.. Overview... General question Assuming that we have a Hamiltonian, H = H + λ H (.) where λ is a very small real number. The eigenstates of the Hamiltonian

More information

Best Practices. Nicola Chiapolini. Physik-Institut University of Zurich. June 8, 2015

Best Practices. Nicola Chiapolini. Physik-Institut University of Zurich. June 8, 2015 Nicola Chiapolini, June 8, 2015 1 / 26 Best Practices Nicola Chiapolini Physik-Institut University of Zurich June 8, 2015 Based on talk by Valentin Haenel https://github.com/esc/best-practices-talk This

More information

Rotational Motion. PHY131H1F Summer Class 10. Moment of inertia is. Pre-class reading quiz

Rotational Motion. PHY131H1F Summer Class 10. Moment of inertia is. Pre-class reading quiz PHY131H1F Summer Class 10 Today: Rotational Motion Rotational energy Centre of Mass Moment of Inertia Oscillations; Repeating Motion Simple Harmonic Motion Connection between Oscillations and Uniform Circular

More information

CRASH COURSE PHYSICS EPISODE #1: Universal gravitation

CRASH COURSE PHYSICS EPISODE #1: Universal gravitation CRASH COURSE PHYSICS EPISODE #1: Universal gravitation No one (including me) really seems to understand physics when Bordak teaches so I decided to translate all the Universal Gravitation stuff to plain

More information

9.4 Radical Expressions

9.4 Radical Expressions Section 9.4 Radical Expressions 95 9.4 Radical Expressions In the previous two sections, we learned how to multiply and divide square roots. Specifically, we are now armed with the following two properties.

More information

Atom Model and Relativity

Atom Model and Relativity Atom Model and Relativity Kimmo Rouvari September 8, 203 Abstract What is the theoretical explanation for fine structure? What is the mechanism behind relativity? These questions have bothered numerous

More information

Computer Science Introductory Course MSc - Introduction to Java

Computer Science Introductory Course MSc - Introduction to Java Computer Science Introductory Course MSc - Introduction to Java Lecture 3:,, Pablo Oliveira ENST Outline 1 2 3 Definition An exception is an event that indicates an abnormal condition

More information

CONSERVATIVE FORCES, POTENTIAL ENERGY AND CONSERVATION OF ENERGY

CONSERVATIVE FORCES, POTENTIAL ENERGY AND CONSERVATION OF ENERGY CONSERVATIVE FORCES, POTENTIAL ENERGY AND CONSERVATION OF ENERGY Today s Objectives: Students will be able to: 1. Use the concept of conservative forces and determine the potential energy of such forces.

More information

Vectorization. Yu Wu, Ishan Patil. October 13, 2017

Vectorization. Yu Wu, Ishan Patil. October 13, 2017 Vectorization Yu Wu, Ishan Patil October 13, 2017 Exercises to be covered We will implement some examples of image classification algorithms using a subset of the MNIST dataset logistic regression for

More information

Lab/Demo 4 Circular Motion and Energy PHYS 1800

Lab/Demo 4 Circular Motion and Energy PHYS 1800 Lab/Demo 4 Circular Motion and Energy PHYS 1800 Objectives: Demonstrate the dependence of centripetal force on mass, velocity and radius. Learn to use these dependencies to predict circular motion Demonstrate

More information

Vector, Matrix, and Tensor Derivatives

Vector, Matrix, and Tensor Derivatives Vector, Matrix, and Tensor Derivatives Erik Learned-Miller The purpose of this document is to help you learn to take derivatives of vectors, matrices, and higher order tensors (arrays with three dimensions

More information

Lesson 3-2: Solving Linear Systems Algebraically

Lesson 3-2: Solving Linear Systems Algebraically Yesterday we took our first look at solving a linear system. We learned that a linear system is two or more linear equations taken at the same time. Their solution is the point that all the lines have

More information

Atoms, Molecules and Solids. From Last Time Superposition of quantum states Philosophy of quantum mechanics Interpretation of the wave function:

Atoms, Molecules and Solids. From Last Time Superposition of quantum states Philosophy of quantum mechanics Interpretation of the wave function: Essay outline and Ref to main article due next Wed. HW 9: M Chap 5: Exercise 4 M Chap 7: Question A M Chap 8: Question A From Last Time Superposition of quantum states Philosophy of quantum mechanics Interpretation

More information

l Every object in a state of uniform motion tends to remain in that state of motion unless an

l Every object in a state of uniform motion tends to remain in that state of motion unless an Motion and Machine Unit Notes DO NOT LOSE! Name: Energy Ability to do work To cause something to change move or directions Energy cannot be created or destroyed, but transferred from one form to another.

More information

Gravitational Wave. Kehan Chen Math 190S. Duke Summer College

Gravitational Wave. Kehan Chen Math 190S. Duke Summer College Gravitational Wave Kehan Chen 2017.7.29 Math 190S Duke Summer College 1.Introduction Since Albert Einstein released his masterpiece theory of general relativity, there has been prediction of the existence

More information

7.1 Interacting Systems p Action/reaction pairs p Newton s Third Law p Ropes and Pulleys p.

7.1 Interacting Systems p Action/reaction pairs p Newton s Third Law p Ropes and Pulleys p. 7.1 Interacting Systems p. 183-185 7.2 Action/reaction pairs p. 185-189 7.3 Newton s Third Law p. 189-194 7.4 Ropes and Pulleys p. 194-198 7.5 Interacting-system Problems p. 198-202 1 7.1 Interacting Systems

More information

6.1 Simple circuits. Electric charge

6.1 Simple circuits. Electric charge 6.1 Simple circuits Electricity is one of many forms of energy. Electrical energy powers your MP4 player, laptop computer, hairdryer, iphone and electric toothbrush. It starts the car and it lights up

More information

Part A-type questions

Part A-type questions PHYS306: lecture 8 th February 008 Part A-type questions. You toss an apple horizontally at 8.7 m/s from a height of.6 m. Simultaneously, you drop a peach from the same height. How long does each take

More information

AST1100 Lecture Notes

AST1100 Lecture Notes AST11 Lecture Notes Part 1G Quantum gases Questions to ponder before the lecture 1. If hydrostatic equilibrium in a star is lost and gravitational forces are stronger than pressure, what will happen with

More information

Weekly Update. Shaghayegh Atashi July 10, 2017

Weekly Update. Shaghayegh Atashi July 10, 2017 Weekly Update Shaghayegh Atashi 1 Outline Some info on the partonic production channel How BdNMC calculates # of signal events Reproducing some plots from paper 2 Update on parton_production channel Reminder:

More information

Motion. Definition a change of position

Motion. Definition a change of position Potential energy Definition stored energy an object has because of its position Characteristics the higher up an object is, the greater its potential energy Example book sitting on the desk Kinetic energy

More information

SPH4U UNIVERSITY PHYSICS

SPH4U UNIVERSITY PHYSICS SPH4U UNIVERSITY PHYSICS ELECTRIC, GRAVITATIONAL, &... FIELDS L (P.346-349) Electric Fields From the definition of an electric field as a force acting on a charge, it follows that, for a given uniform

More information

Least Mean Squares Regression. Machine Learning Fall 2018

Least Mean Squares Regression. Machine Learning Fall 2018 Least Mean Squares Regression Machine Learning Fall 2018 1 Where are we? Least Squares Method for regression Examples The LMS objective Gradient descent Incremental/stochastic gradient descent Exercises

More information

Worksheet 1: Integrators

Worksheet 1: Integrators Simulation Methods in Physics I WS 2014/2015 Worksheet 1: Integrators Olaf Lenz Alexander Schlaich Stefan Kesselheim Florian Fahrenberger Peter Košovan October 22, 2014 Institute for Computational Physics,

More information

Problem Solving. Undergraduate Physics

Problem Solving. Undergraduate Physics in Undergraduate Physics In this brief chapter, we will learn (or possibly review) several techniques for successful problem solving in undergraduate physics courses Slide 1 Procedure for The following

More information

Java Programming. Final Examination on December 13, 2015 Fall 2015

Java Programming. Final Examination on December 13, 2015 Fall 2015 Java Programming Final Examination on December 13, 2015 Fall 2015 Department of Computer Science and Information Engineering National Taiwan University Problem 1 (10 points) Multiple choice questions.

More information

8.3. SPECIAL METHODS 217

8.3. SPECIAL METHODS 217 8.3. SPECIAL METHODS 217 8.3 Special Methods There are a number of method names that have special significance in Python. One of these we have already seen: the constructor method is always named init

More information

Derivation of Electro Weak Unification and Final Form of Standard Model with QCD and Gluons 1 W W W 3

Derivation of Electro Weak Unification and Final Form of Standard Model with QCD and Gluons 1 W W W 3 Derivation of Electro Weak Unification and Final Form of Standard Model with QCD and Gluons 1 W 1 + 2 W 2 + 3 W 3 Substitute B = cos W A + sin W Z 0 Sum over first generation particles. up down Left handed

More information

PHYS 1007

PHYS 1007 Core Concepts: Finding and Manipulating Equations Centripetal Force Angular Velocity Energy Work Opener: Equation Review Kahoot! Time 10 minutes Go to www.kahoot.it and enter the code on the screen to

More information

Classical mechanics: conservation laws and gravity

Classical mechanics: conservation laws and gravity Classical mechanics: conservation laws and gravity The homework that would ordinarily have been due today is now due Thursday at midnight. There will be a normal assignment due next Tuesday You should

More information

Section 2.7 Solving Linear Inequalities

Section 2.7 Solving Linear Inequalities Section.7 Solving Linear Inequalities Objectives In this section, you will learn to: To successfully complete this section, you need to understand: Add and multiply an inequality. Solving equations (.1,.,

More information

14-Feb-18 INSIDE STARS. Matter and Energy. Matter and Energy. Matter and Energy. What is matter?

14-Feb-18 INSIDE STARS. Matter and Energy. Matter and Energy. Matter and Energy. What is matter? What is matter? What is matter? It's what everything that occupies space and has mass is made of And everything like that is made out of chemical elements There are 92 naturally occurring chemical elements,

More information

Least Mean Squares Regression

Least Mean Squares Regression Least Mean Squares Regression Machine Learning Spring 2018 The slides are mainly from Vivek Srikumar 1 Lecture Overview Linear classifiers What functions do linear classifiers express? Least Squares Method

More information

Transformations and A Universal First Order Taylor Expansion

Transformations and A Universal First Order Taylor Expansion Transformations and A Universal First Order Taylor Expansion MATH 1502 Calculus II Notes September 29, 2008 The first order Taylor approximation for f : R R at x = x 0 is given by P 1 (x) = f (x 0 )(x

More information

Multivariate Distributions

Multivariate Distributions Copyright Cosma Rohilla Shalizi; do not distribute without permission updates at http://www.stat.cmu.edu/~cshalizi/adafaepov/ Appendix E Multivariate Distributions E.1 Review of Definitions Let s review

More information

Chapter 5 Circular Motion; Gravitation

Chapter 5 Circular Motion; Gravitation Chapter 5 Circular Motion; Gravitation Units of Chapter 5 Kinematics of Uniform Circular Motion Dynamics of Uniform Circular Motion Highway Curves, Banked and Unbanked Nonuniform Circular Motion Centrifugation

More information

AP PHYSICS 1 Content Outline arranged TOPICALLY

AP PHYSICS 1 Content Outline arranged TOPICALLY AP PHYSICS 1 Content Outline arranged TOPICALLY with o Big Ideas o Enduring Understandings o Essential Knowledges o Learning Objectives o Science Practices o Correlation to Common Textbook Chapters Much

More information

Math 231E, Lecture 25. Integral Test and Estimating Sums

Math 231E, Lecture 25. Integral Test and Estimating Sums Math 23E, Lecture 25. Integral Test and Estimating Sums Integral Test The definition of determining whether the sum n= a n converges is:. Compute the partial sums s n = a k, k= 2. Check that s n is a convergent

More information

Temporal Difference Learning & Policy Iteration

Temporal Difference Learning & Policy Iteration Temporal Difference Learning & Policy Iteration Advanced Topics in Reinforcement Learning Seminar WS 15/16 ±0 ±0 +1 by Tobias Joppen 03.11.2015 Fachbereich Informatik Knowledge Engineering Group Prof.

More information

Conceptual Physical Science 6 th Edition

Conceptual Physical Science 6 th Edition Conceptual Physical Science 6 th Edition Chapter 8: STATIC AND CURRENT ELECTRICITY 1 Chapter 8: STATIC AND CURRENT ELECTRICITY Chapter 8: Read: All Homework: Four problems from the following set: 4, 6,

More information

Programming Languages Fall 2013

Programming Languages Fall 2013 Programming Languages Fall 2013 Lecture 11: Subtyping Prof Liang Huang huang@qccscunyedu Big Picture Part I: Fundamentals Functional Programming and Basic Haskell Proof by Induction and Structural Induction

More information

Section 1.5. Solution Sets of Linear Systems

Section 1.5. Solution Sets of Linear Systems Section 1.5 Solution Sets of Linear Systems Plan For Today Today we will learn to describe and draw the solution set of an arbitrary system of linear equations Ax = b, using spans. Ax = b Recall: the solution

More information

Chapter 8 Rotational Equilibrium and Rotational Dynamics Force vs. Torque Forces cause accelerations Torques cause angular accelerations Force and

Chapter 8 Rotational Equilibrium and Rotational Dynamics Force vs. Torque Forces cause accelerations Torques cause angular accelerations Force and Chapter 8 Rotational Equilibrium and Rotational Dynamics Force vs. Torque Forces cause accelerations Torques cause angular accelerations Force and torque are related Torque The door is free to rotate about

More information

Chapter 22 : Electric potential

Chapter 22 : Electric potential Chapter 22 : Electric potential What is electric potential? How does it relate to potential energy? How does it relate to electric field? Some simple applications What does it mean when it says 1.5 Volts

More information

Dr. Ines Espinoza, USA

Dr. Ines Espinoza, USA Dr. Ines Espinoza, USA email: dr.ines@vasantcorporation.com Editor: it is worth mentioning that the first gravitational-wave physical mechanism and the mechanism of spineffect "grazer" (gravitational lasers)

More information

3) Uniform circular motion: to further understand acceleration in polar coordinates

3) Uniform circular motion: to further understand acceleration in polar coordinates Physics 201 Lecture 7 Reading Chapter 5 1) Uniform circular motion: velocity in polar coordinates No radial velocity v = dr = dr Angular position: θ Angular velocity: ω Period: T = = " dθ dθ r + r θ =

More information

r CM = ir im i i m i m i v i (2) P = i

r CM = ir im i i m i m i v i (2) P = i Physics 121 Test 3 study guide Thisisintendedtobeastudyguideforyourthirdtest, whichcoverschapters 9, 10, 12, and 13. Note that chapter 10 was also covered in test 2 without section 10.7 (elastic collisions),

More information

Machine Learning & Data Mining Caltech CS/CNS/EE 155 Hidden Markov Models Last Updated: Feb 7th, 2017

Machine Learning & Data Mining Caltech CS/CNS/EE 155 Hidden Markov Models Last Updated: Feb 7th, 2017 1 Introduction Let x = (x 1,..., x M ) denote a sequence (e.g. a sequence of words), and let y = (y 1,..., y M ) denote a corresponding hidden sequence that we believe explains or influences x somehow

More information

COMP 204. Object Oriented Programming (OOP) - Inheritance. Mathieu Blanchette

COMP 204. Object Oriented Programming (OOP) - Inheritance. Mathieu Blanchette COMP 204 Object Oriented Programming (OOP) - Inheritance Mathieu Blanchette 1 / 14 Inheritance Motivation: We often need to create classes that are closely related but not identical to an existing class.

More information

Electric Potential Energy

Electric Potential Energy Electric Potential Energy the electric potential energy of two charges depends on the distance between the charges when two like charges are an infinite distance apart, the potential energy is zero An

More information

Week 5 - Dielectrica, Resistance and Resistivity

Week 5 - Dielectrica, Resistance and Resistivity Week 5 - Dielectrica, Resistance and Resistivity Further, the dignity of the science itself seems to require that every possible means be explored for the solution of a problem so elegant and so celebrated.

More information

MA 510 ASSIGNMENT SHEET Spring 2009 Text: Vector Calculus, J. Marsden and A. Tromba, fifth edition

MA 510 ASSIGNMENT SHEET Spring 2009 Text: Vector Calculus, J. Marsden and A. Tromba, fifth edition MA 510 ASSIGNMENT SHEET Spring 2009 Text: Vector Calculus, J. Marsden and A. Tromba, fifth edition This sheet will be updated as the semester proceeds, and I expect to give several quizzes/exams. the calculus

More information

1 Problem 1 Solution. 1.1 Common Mistakes. In order to show that the matrix L k is the inverse of the matrix M k, we need to show that

1 Problem 1 Solution. 1.1 Common Mistakes. In order to show that the matrix L k is the inverse of the matrix M k, we need to show that 1 Problem 1 Solution In order to show that the matrix L k is the inverse of the matrix M k, we need to show that Since we need to show that Since L k M k = I (or M k L k = I). L k = I + m k e T k, M k

More information

HW9 Concepts. Alex Alemi November 1, 2009

HW9 Concepts. Alex Alemi November 1, 2009 HW9 Concepts Alex Alemi November 1, 2009 1 24.28 Capacitor Energy You are told to consider connecting a charged capacitor together with an uncharged one and told to compute (a) the original charge, (b)

More information

Universal gravitation

Universal gravitation Universal gravitation Physics 211 Syracuse University, Physics 211 Spring 2015 Walter Freeman February 22, 2017 W. Freeman Universal gravitation February 22, 2017 1 / 14 Announcements Extra homework help

More information

Proof Rules for Correctness Triples

Proof Rules for Correctness Triples Proof Rules for Correctness Triples CS 536: Science of Programming, Fall 2018 A. Why? We can t generally prove that correctness triples are valid using truth tables. We need proof axioms for atomic statements

More information