Книжная полка Сохранить
Размер шрифта:
А
А
А
|  Шрифт:
Arial
Times
|  Интервал:
Стандартный
Средний
Большой
|  Цвет сайта:
Ц
Ц
Ц
Ц
Ц

Цифровая математика в R

Покупка
Артикул: 829407.01.99
Учебник состоит из 17 компьютерных практикумов, посвященных вычислительным возможностям программной среды R при решении задач математического анализа и линейной алгебры. Соответствует учебным планам дисциплин «Компьютерный практикум» и «Цифровая математика на языке R и Excel», преподаваемых в Финансовом университете при Правительстве Российской Федерации на первом курсе общеэкономических и управленческих специальностей (программы бакалавриата). В учебнике последовательно излагаются основы языка программирования R с постепенным углублением по мере продвижения по осваиваемым навыкам в применении к высшей математике. Для комфортного программирования на R практикумы ориентированы на популярную интегрированную среду разработки RStudio. Учебник будет полезен студентам, изучающим математический анализ и линейную алгебру и желающим познакомиться с самыми современными вычислительными технологиями. Также он будет полезен тем, кто хочет научиться программировать на языке R и продолжить изучать его применение в статистическом анализе и анализе данных. Учебник может быть интересен студентам магистратуры, аспирантам, научным работникам, учителям, преподавателям университетов.
Берзин, Д. В. Цифровая математика в R : учебник / Д. В. Берзин, С. А. Зададаев. — Москва : Прометей, 2023. — 192 с. - ISBN 978-5-00172-464-3. - Текст : электронный. - URL: https://znanium.ru/catalog/product/2145052 (дата обращения: 19.11.2026). – Режим доступа: по подписке.
Фрагмент текстового слоя документа размещен для индексирующих роботов
УЧЕБНИК
1919
ЦИФРОВАЯ 
МАТЕМАТИКА В R
Д.В. Берзин, С.А. Зададаев


Федеральное государственное образовательное бюджетное 
учреждение высшего образования
«ФИНАНСОВЫЙ УНИВЕРСИТЕТ 
ПРИ ПРАВИТЕЛЬСТВЕ РОССИЙСКОЙ ФЕДЕРАЦИИ»
(Финансовый университет)
Департамент математики
Д.В. Берзин, С.А. Зададаев
ЦИФРОВАЯ 
МАТЕМАТИКА В R
Учебник
Электронное издание
МОСКВА 
2023


УДК	 811.111(076.5)
ББК	
22.1+81.2Англ
	
Б48
Авторы:
Берзин Д.В., кандидат физико-математических наук, доцент Департамента математики Финансового университета при Правительстве Российской Федерации;
Зададаев С.А., кандидат физико-математических наук, профессор, 
руководитель Департамента математики Финансового университета при 
Правительстве Российской Федерации.
Рецензенты:
Шандра И.Г., канд. физ.-мат. наук, профессор департамента математики Финансового университета при Правительстве Российской Федерации;
Булычев А.В., канд.тех.наук, ведущий научный сотрудник Федерального государственного учреждения «Федеральный исследовательский 
центр «Информатика и управление» Российской академии наук».
Берзин Д.В. 
Б 48	
	
Цифровая математика в R: Учебник (электронное издание) / Д.В. Берзин, С.А. Зададаев. — М.: Прометей, 2023. — 192 с.
ISBN  978-5-00172-464-3
Учебник состоит из  17 компьютерных практикумов, посвященных 
вычислительным возможностям программной среды R при решении задач 
математического анализа и  линейной алгебры. Соответствует учебным 
планам дисциплин «Компьютерный практикум» и «Цифровая математика 
на языке R и Excel», преподаваемых в Финансовом университете при Правительстве Российской Федерации на  первом курсе общеэкономических 
и управленческих специальностей (программы бакалавриата). В учебнике последовательно излагаются основы языка программирования R с постепенным углублением по мере продвижения по осваиваемым навыкам 
в применении к высшей математике. Для комфортного программирования 
на R практикумы ориентированы на популярную интегрированную среду 
разработки RStudio. 
Учебник будет полезен студентам, изучающим математический анализ и линейную алгебру и желающим познакомиться с самыми современными вычислительными технологиями. Также он будет полезен тем, кто 
хочет научиться программировать на языке R и продолжить изучать его 
применение в статистическом анализе и анализе данных. Учебник может 
быть интересен студентам магистратуры, аспирантам, научным работникам, учителям, преподавателям университетов.
ISBN  978-5-00172-464-3	
© Берзин Д.В., Зададаев С.А., 2023
© Издательство «Прометей», 2023


FEDERAL STATE EDUCATIONAL BUDGETARY INSTITUTION 
OF HIGHER EDUCATION “FINANCIAL UNIVERSITY 
UNDER THE GOVERNMENT OF THE RUSSIAN FEDERATION”
Department of Mathematics
D. Berzin, S. Zadadaev
DIGITAL MATHEMATICS 
IN R
Textbook
Electronic edition
Moscow
2023


Authors:
Dmitry V. Berzin, PhD in Math, Associate Professor, Department of 
Mathematics of the Financial University under the Government of the Russian 
Federation;
Sergey A. Zadadaev, PhD in Math, Professor, Head of the Department of 
Mathematics of the Financial University under the Government of the Russian 
Federation.
Reviewers:
Shandra Igor Georgievich, PhD in Math, Professor, Department of 
Mathematics of Financial University under the Government of the Russian 
Federation;
Bulychev Alexander Viktorovich, PhD in Technical Science, leading 
researcher of Federal Research Center “Computer Science and Control” of the 
Russian Academy of Sciences
Berzin D.
		
Digital mathematics in R: Textbook (electronic edition) / D.  Berzin, 
S. Zadadaev. — Moscow: Prometheus publishing house, 2023. — 192 p.
ISBN  978-5-00172-464-3
Structurally, this textbook consists of  17 computer workshops 
on  computational capabilities of  the R  software environment in  solving 
problems of  Calculus and Linear Algebra. It  corresponds to  the syllabuses 
of  the disciplines “Computer Workshop” and “Digital Mathematics in  MS 
Excel and R” taught at the Financial University under the Government of the 
Russian Federation in  the first year of  general economic and management 
specialties (bachelor program of studies).
The textbook consistently presents the basics of  the R  programming 
language in a meaningful way, with a gradual deepening as we move along 
the acquired skills in applying to university mathematics. For comfortable 
programming in  R, the workshops are focused on  the popular integrated 
development environment RStudio.
The textbook will be helpful for students who study Calculus and Linear 
Algebra and want to know the most modern computing technologies. 
Also, it will be valuable for those who want to learn how to program in the 
R language and continue to study its application in statistical analysis and 
data analysis.
The textbook can be  interesting for graduate students, postgraduate 
students, researchers, teachers, and professors.
	
© Berzin D., Zadadaev S., 2023
© Prometheus рublishing house, 2023


CONTENTS
Preface . .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Competences of the discipline. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . 7
1. Introduction to R . .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2. User-defined functions. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . 22
3. Zeroes and extrema of functions. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . 37
4. Definite and improper integrals…. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . 54
5. Surfaces and level curves . .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . 61
6. Symbolic differentiation. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . 72
7. Data types. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
8. Loops. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
9. Differential equations. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . 114
10. Vectors and matrices. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . 126
11. Saving results in R and import/export of data from MS Excel (RStudio) . .  . . . . 132
12. Vector algebra. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
13. Matrix algebra. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
14. Matrix equations. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . 157
15. Extension of double-arithmetic. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . 165
16. Spectral and singular matrix decomposition . .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . 171
17. Linear optimization problem. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . 181
Recommended literature. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . 190
Conclusion. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191


PREFACE
The textbook “Digital Mathematics in R” is intended mainly for future economists 
and managers  — primarily for first-year bachelor’s students, who receive education 
in English.
The textbook covers solutions to  important mathematical problems in  the 
R software environment, such as using R for: calculating algebraic expressions; definite 
and improper integrals; setting user-defined functions and working with them; finding 
zeros and extrema of functions; constructing surfaces and level curves; differentiation. 
It also covers different types of data in R: numerical, array, character, table variables, 
etc.
The textbook is based on practical lessons on the disciplines “Digital mathematics 
in MS Excel and R” and “Computer Workshop”, taught by the authors at the Financial 
University for first-year students (bachelor programs in economics and management). 
It  contains plenty of  code examples with detailed comments illustrating theoretical 
material, as well as many screenshots and figures.
The authors are grateful to the students of the Financial University A.Polozhevich 
and P.Krochak for improving the quality of the translation of some source texts into 
English.
As  a result of  studying this textbook and following the examples given, the 
reader acquires skills in using the R software environment to do calculations in various 
application areas.
Before starting to study and master the material of this textbook, it is significant 
to imagine the specifics of modern application programming. And it lies in the fact that 
there is nothing more rapidly changing than information technologies.
In  the process of  studying, you probably want to  write more perfect functions 
or procedures than in the discussed topics. It is hard to change production technologies 
quickly, but it is easy to modify software technologies.
So, get ready for constant improvements of R packages and the RStudio integrated 
development environment. It is unlikely, but possible, that some operations will not work 
due to their cardinal update. It is the perfect norm of our time. If you want to be on the 
Olympus of numerical and visualizing capabilities, then resolutely connect the Internet 
with its resources to professionals discussing and creating in the language of R around 
the world.
By the way, the semantics of the R language is quite simple to understand and 
use, and we advise you to type program codes manually at first; and not copy them from 
the text if you use the electronic version of the textbook. Such code lines are highlighted 
in the text as follows:
# Hello, world! :)
# I’ll make you better! ))
Good luck to everyone!


COMPETENCES OF THE DISCIPLINE 
“DIGITAL MATHEMATICS IN MS EXCEL AND R”
In  the modern paradigm of  Russian university education, it  is customary 
to indicate the professional competencies developed by a particular discipline. Following 
this tradition, we will briefly outline what exactly we will fight for when studying the 
material of this textbook. The discipline provides necessary tools to form competences 
listed below.
Competence
Learning outcomes (skills and knowledge) and 
indicators that show competence development   
1. 
The ability to use 
application software 
to solve professional 
problems.
Know the basic methods of obtaining, presenting, 
storing, and processing data using R software 
environment and MS Excel;
Be able to use basic methods of obtaining, 
presenting, storing, and processing data by means 
of R and MS Excel;
Possess the skills in solving standard problems 
of Calculus and Linear Algebra using the tools of R 
and MS Excel.
2.
The ability to apply 
mathematical methods 
to solve standard 
theoretical and applied 
problems, to interpret 
the obtained 
mathematical results.
Know the computational methods of the main 
problems of mathematical analysis and linear 
algebra; 
Be able to use computer technology in the 
implementation of mathematical methods and 
models for the description and analysis of applied 
problems;
Possess the skills in computational work in R and 
communication with MS Excel.
3. 
The ability to visualize 
analytical and 
reporting materials 
based on the results 
of the work performed. 
Know the basic tools of visualizing quantitative data 
in R;
Be able to use computer technologies for data 
presentation and graphical visualization of the 
results of applying mathematical methods and 
models to describe and analyze various applied 
problems; 
Possess the skills to work in RStudio in terms 
of visualizing quantitative data.


1. INTRODUCTION TO R
R  is a  programming language and free software environment for statistical 
computing and graphics supported by the R Foundation for Statistical Computing. The 
R  language is  widely used by  statisticians and data miners for developing statistical 
software and data analysis. Polls, data mining surveys, and studies of scholarly literature 
databases show substantial increases in popularity; as of March 2022, R ranks 11th in the 
TIOBE index, which ranks programming languages in popularity among users.
A GNU package, source code for the R software environment is written primarily 
in  C,  FORTRAN, and R  itself and is  freely available under the GNU General Public 
License. Pre-compiled binary versions are provided for various operating systems. 
Although R has a command-line interface, there are several graphical user interfaces 
(GUI), such as RStudio, an integrated development environment.
RStudio is  an integrated development environment (IDE) for R,  a  programming 
language for statistical computing and graphics. Loosely speaking, RStudio is a “shell” for R.
Requirements
To work with this data (and the subsequent R training materials), you must have 
two programs installed on your computer: R programming language interpreter and the 
RStudio «shell». The procedure for the official free download and installation of these 
programs is described in the instructions (see the appendix at the end of this chapter).
We highly recommend installing these two programs on your personal computer 
(laptop, tablet, etc.), because together with tens of thousands of other specialists around 
the world, we consider this computing tool predominant now.
Starting RStudio
To work with R, we will use the user-friendly RStudio shell, which interacts with 
the R interpreter. You should start RStudio by clicking the corresponding shortcut.
Note. If text on the pictures is difficult to read, use the on-screen zoom by rotating 


the mouse wheel while pressing the «Ctrl» button. 
As a result, the program window opens up. Now, create a new document with the 
future program code (script or source code), by clicking the mouse on the upper-left menu 
item «R script» or pressing the key combination «Ctrl+Shift+N»: 
After that, the RStudio working area will split into four windows (“panes”) 
as follows
: 
1. Upper-left: the window of the worksheet with the future program code in the