Numerical Programming with Python

Course objectives

General Objectives This course provides the basic concepts of programming with Python and basic knowledge of some numerical methods that are employed for the solution of common problems in mechanical engineering (non-linear equations, differential equation, data approximation and representation, machine learning). Particular attention will be devoted to the development of algorithms and their Python implementation. Results This course will provide skills of problem solving. The student will be able to implement, compile and run some simple programs written in Python; to implement specific numerical procedures for solving some test problems; to present and analyse the results. SPECIFIC OBJECTIVES Knowledge and understanding: the student will know the basic properties of some numerical methods commonly used to solve problems that arise in engineering. The student will learn the basic concepts of programming with Python that are required for implementing and using the proposed numerical methods. Applying knowledge and understanding: the student will be able to project and to provide an algorithmic solution of a problem and to implement simple algorithms in the Python programming language. The student will learn to translate the numerical methods learned into a computational algorithm written in Python programming language, use these algorithms (or predefined libraries) to solve simple application problems, and interpret and analyze the results. Making judgments: the student will learn to analyze the correctness of a Python program; to analyze the performance of numerical method for solving some test problems, through numerical experiments, with special reference to the analysis of different sources of error, verification of results, comparison of results obtained using different methods. To this aim, several exercises will be proposed during both theoretical and lab lessons; some of them will be solved by the teacher, some others will be proposed as guided lab exercises, while the remaining ones will be given as homework and solutions will be made available. Communication skills: the student will learn to rigorously describe the rationale for selecting a particular numerical procedure for solving a specific problem, the code developed to implement the selected numerical method, and the results of numerical experimentation. Learning skills: the student will be provided with the necessary tools to plan the steps to be performed to solve a problem and formulate them in algorithmic form; to identify the main characteristics of a numerical method, to use basic numerical methods, to implement them in the Python programming language, to evaluate the results critically based on the different types and sources of error expected, to solve some application problems.

Channel 1
VITTORIA BRUNI Lecturers' profile

Program - Frequency - Exams

Course program
1. Basic notions of programming (0.5 CFU) 2. Basic notions of programming in Python (2 CFU) Generalities, development environment, variable types, operators, mathematical expressions; strings and lists, conditional instructions, loops, introduction to basic modules/packages and main functions, plots, input/output instructions, definition of multidimensional arrays (vectors and matrices), errors and tests. 3. Introduction to numerical methods, their implementation and Python packages (3.5 CFU) Simulation in Python for the numerical solution of some test problems: nonlinear equations and systems of nonlinear equations, ordinary differential equations; data approximation and representation, machine learning; Python packages for solving some problems in mechanical engineering.
Prerequisites
Knowledge of fundamentals of calculus, geometry and linear algebra provided by the following courses: Calculus and Geometry
Books
L. Gori, Calcolo Numerico, Ed. Kappa, 2006 Allen Downey, Pensare in Python - Come pensare da Informatico, seconda edizione versione pdf (in italiano) disponibile gratuitamente su github secondo la GNU Free Documentation License versione cartacea (in italiano) edita da Egea Qingkai Kong, Timmy Siauw and Alexandre M. Bayen, Python Programming and Numerical Methods: A Guide for Engineers and Scientists, Springer 2020 Course Slides (download from e-learning platform) Additional references: Cay S. Horstmann, Rance D. Necaise, Concetti di informatica e fondamenti di Python, Apogeo, 2019 S. C. Chapra, R. P. Canale, Numerical Methods for engineers, Calcolo scientifico, Springer, McGraw Hill, 2010 Alfio Quarteroni, Fausto Saleri, Paola Gervasio, Esercizi e problemi risolti con MATLAB e Octave, Springer 2017
Frequency
Attending of the course is warmly recommended
Exam mode
Assessment is based on written exercises: students should identify the numerical method suitable to solve a specific problem, implement a Python code for solving the problem, discuss numerical issues (accuracy, convergence, stability), realize some numerical tests and critically analyze the results.
Lesson mode
The course includes both lectures and lab exercises. During the lectures, the teacher will outline and discuss the main features of the numerical methods listed in the program. During lab exercises, firstly the teacher will give an introduction to programming in Python, then the teacher will show how to code algorithms. During the course the teacher will also provide guided exercises on numerical methods and programming and will assign homeworks to students.
VITTORIA BRUNI Lecturers' profile

Program - Frequency - Exams

Course program
1. Basic notions of programming (0.5 CFU) 2. Basic notions of programming in Python (2 CFU) Generalities, development environment, variable types, operators, mathematical expressions; strings and lists, conditional instructions, loops, introduction to basic modules/packages and main functions, plots, input/output instructions, definition of multidimensional arrays (vectors and matrices), errors and tests. 3. Introduction to numerical methods, their implementation and Python packages (3.5 CFU) Simulation in Python for the numerical solution of some test problems: nonlinear equations and systems of nonlinear equations, ordinary differential equations; data approximation and representation, machine learning; Python packages for solving some problems in mechanical engineering.
Prerequisites
Knowledge of fundamentals of calculus, geometry and linear algebra provided by the following courses: Calculus and Geometry
Books
L. Gori, Calcolo Numerico, Ed. Kappa, 2006 Allen Downey, Pensare in Python - Come pensare da Informatico, seconda edizione versione pdf (in italiano) disponibile gratuitamente su github secondo la GNU Free Documentation License versione cartacea (in italiano) edita da Egea Qingkai Kong, Timmy Siauw and Alexandre M. Bayen, Python Programming and Numerical Methods: A Guide for Engineers and Scientists, Springer 2020 Course Slides (download from e-learning platform) Additional references: Cay S. Horstmann, Rance D. Necaise, Concetti di informatica e fondamenti di Python, Apogeo, 2019 S. C. Chapra, R. P. Canale, Numerical Methods for engineers, Calcolo scientifico, Springer, McGraw Hill, 2010 Alfio Quarteroni, Fausto Saleri, Paola Gervasio, Esercizi e problemi risolti con MATLAB e Octave, Springer 2017
Frequency
Attending of the course is warmly recommended
Exam mode
Assessment is based on written exercises: students should identify the numerical method suitable to solve a specific problem, implement a Python code for solving the problem, discuss numerical issues (accuracy, convergence, stability), realize some numerical tests and critically analyze the results.
Lesson mode
The course includes both lectures and lab exercises. During the lectures, the teacher will outline and discuss the main features of the numerical methods listed in the program. During lab exercises, firstly the teacher will give an introduction to programming in Python, then the teacher will show how to code algorithms. During the course the teacher will also provide guided exercises on numerical methods and programming and will assign homeworks to students.
  • Lesson code10610614
  • Academic year2025/2026
  • CourseMechanical Engineering for the Green Transition
  • CurriculumSingle curriculum
  • Year3rd year
  • Semester2nd semester
  • SSDMAT/08
  • CFU6