Math for Programmers
eBook - ePub

Math for Programmers

3D graphics, machine learning, and simulations with Python

Paul Orland

Condividi libro
  1. 688 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Math for Programmers

3D graphics, machine learning, and simulations with Python

Paul Orland

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

"A gentle introduction to some of the most useful mathematical concepts that should be in your developer toolbox." - Christopher Haupt, New Relic Explore important mathematical concepts through hands-on coding.
Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. Filled with graphics and more than 300 exercises and mini-projects, this book unlocks the door to interesting–and lucrative!–careers in some of today's hottest fields. As you tackle the basics of linear algebra, calculus, and machine learning, you'll master the key Python libraries used to turn them into real-world software applications. Summary
To score a job in data science, machine learning, computer graphics, and cryptography, you need to bring strong math skills to the party. Math for Programmers teaches the math you need for these hot careers, concentrating on what you need to know as a developer. Filled with lots of helpful graphics and more than 200 exercises and mini-projects, this book unlocks the door to interesting–and lucrative!–careers in some of today's hottest programming fields. About the technology
Skip the mathematical jargon: This one-of-a-kind book uses Python to teach the math you need to build games, simulations, 3D graphics, and machine learning algorithms. Discover how algebra and calculus come alive when you see them in code! What's inside Vector geometry for computer graphics
Matrices and linear transformations
Core concepts from calculus
Simulation and optimization
Image and audio processing
Machine learning algorithms for regression and classification About the reader
For programmers with basic skills in algebra. About the author
Paul Orland is a programmer, software entrepreneur, and math enthusiast. He is co-founder of Tachyus, a start-up building predictive analytics software for the energy industry. You can find him online at www.paulor.land. Table of Contents 1 Learning math with code PART I - VECTORS AND GRAPHICS 2 Drawing with 2D vectors 3 Ascending to the 3D world 4 Transforming vectors and graphics 5 Computing transformations with matrices 6 Generalizing to higher dimensions 7 Solving systems of linear equations PART 2 - CALCULUS AND PHYSICAL SIMULATION 8 Understanding rates of change 9 Simulating moving objects 10 Working with symbolic expressions 11 Simulating force fields 12 Optimizing a physical system 13 Analyzing sound waves with a Fourier series PART 3 - MACHINE LEARNING APPLICATIONS 14 Fitting functions to data 15 Classifying data with logistic regression 16 Training neural networks

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Math for Programmers è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Math for Programmers di Paul Orland in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Computer Science e Computer Science General. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Editore
Manning
Anno
2020
ISBN
9781638357070

1 Learning math with code

This chapter covers
  • Solving lucrative problems with math and software
  • Avoiding common pitfalls in learning math
  • Building on intuition from programming to understand math
  • Using Python as a powerful and extensible calculator
Math is like baseball, or poetry, or fine wine. Some people are so fascinated by math that they devote their whole lives to it, while others feel like they just don’t get it. You’ve probably already been forced into one camp or another by twelve years of compulsory math education in school.
What if we learned about fine wine in school like we learned math? I don’t think I’d like wine at all if I got lectured on grape varietals and fermentation techniques for an hour a day, five days a week. Maybe in such a world, I’d need to consume three or four glasses for homework as assigned by the teacher. Sometimes this would be a delicious educational experience, but sometimes I might not feel like getting loaded on a school night. My experience in math class went something like that, and it turned me off of the subject for a while. Like wine, mathematics is an acquired taste, and a daily grind of lectures and assignments is no way to refine one’s palate.
It’s easy to think you’re either cut out for math or you aren’t. If you already believe in yourself, and you’re excited to start learning, that’s great! Otherwise, this chapter is designed for those less optimistic. Feeling intimidated by math is so common, it has a name: math anxiety. I hope to dispel any anxiety you might have and show you that math can be a stimulating experience rather than a frightening one. All you need are the right tools and the right mindset.
The main tool for learning in this book is the Python programming language. I’m guessing that when you learned math in high school, you saw it written on the blackboard and not in computer code. That’s a shame, because a high-level programming language is far more powerful than a blackboard and far more versatile than whatever overpriced calculator you may have used. An advantage of meeting math in code is that the ideas have to be precise enough for a computer to understand, and there’s never any hand-waving about what new symbols mean.
As with learning any new subject, the best way to set yourself up for success is to want to learn. There are plenty of good reasons for this. You could be intrigued by the beauty of mathematical concepts or enjoy the “brain-teaser” feel of math problems. Maybe there’s an app or game that you dream of building, and you need to write some mathematical code to make it work. For now, I’ll focus on a more pragmatic kind of motivation−solving mathematical problems with software can make you a lot of money.

1.1 Solving lucrative problems with math and software

A classic criticism you hear in high school math class is, “When am I ever going to use this stuff in real life?” Our teachers told us that math would help us succeed professionally and make money. I think they were right about this, even though their examples were off. For instance, I don’t calculate my compounding bank interest by hand (and neither does my bank). Maybe if I became a construction site surveyor as my trigonometry teacher suggested, I’d be using sines and cosines every day to earn my paycheck.
It turns out the “real world” applications from high school textbooks aren’t that useful. Still, there are real applications of math out there, and some of them are mind-bogglingly lucrative. Many are solved by translating the right mathematical idea into usable software. I’ll share some of my favorite examples.

1.1.1 Predicting financial market movements

We’ve all heard legends of stock traders making millions of dollars by buying and selling the right stocks at the right time. Based on the movies I’ve seen, I always picture a trader as a middle-aged man in a suit yelling at his broker over a cell phone while driving around in a sports car. Maybe this stereotype was spot-on at one point, but the situation is different today.
Holed up in back offices of skyscrapers all over Manhattan are thousands of people called quants. Quants, otherwise known as quantitative analysts, design mathematical algorithms to automatically trade stocks and earn a profit. They don’t wear suits and they don’t spend time yelling on their cell phones, but I’m sure many of them own very nice sports cars.
So how does a quant write a program that automatically makes money? The best answers to that question are closely-guarded trade secrets, but you can be sure they involve a lot of math. We can look at a brief example to get a sense of how an automated trading strategy might work.
Stocks are types of financial assets that represent ownership stakes in companies. When the market perceives a company is doing well, its stock price goes up−buying the stock becomes more costly and selling it becomes more rewarding. Stock prices change erratically and in real time. Figure 1.1 shows how a graph of a stock price over a day of trading might look.
Figure 1.1 Typical graph of a stock price over time
If you bought a thousand shares of this stock for $24 around minute 100 and sold them for $38 at minute 400, you would make $14,000 for the day. Not bad! The challenge is that you’d have to know in advance that the stock was going up, and that minutes 100 and 400 were the best times to buy and sell, respectively. It may not be possible to predict the exact lowest or highest price points, but maybe you can find relatively good times to buy and sell throughout the day. Let’s look at a way to do this mathematically.
We could measure whether the stock is going up or down by finding a line of “best fit” that approximately follows the direction the price is moving. This process is called linear regression, and we cover it in part 3 of this book. Based on the variability of data, we can calculate two more lines above and below the “best fit” line that show the region in which the price is wobbling up and down. Overlaid on the price graph, figure 1.2 shows that the lines follow the trend nicely.
Figure 1.2 Using linear regression to identify a trend in changing stock prices
With a mathematical understanding of the price movement, we can then write code to automatically buy when the price is going through a low fluctuation relative to its trend and to sell when the price goes back up. Specifically, our program could connect to the stock exchange over the network and buy 100 shares when the price crosses the bottom line and sell 100 shares when the price crosses the top line. Figure 1.3 illustrates one such profitable trade: buying at around $27.80 and selling at around $32.60 makes you $480 in an hour.
Figure 1.3 Buying and selling according to our rules-based software to make a profit
I don’t claim I’ve shown you a complete or viable strategy here, but the point is that with the right mathematical model, you can make a profit automatically. At this moment, some unknown number of programs are building and updating models measuring the predicted trend of stocks and other financial instruments. If you write such a program, you can enjoy some leisure time while it makes money for you!

1.1.2 Finding a good deal

Maybe you don’t have deep enough pockets to consider risky stock trading. Math can still help you make and save money in other transactions like buying a used car, for example. New cars are easy-to-understand commodities. If two dealers are selling the same car, you obviously want to buy from the dealer that has the lowest cost. But used cars have more numbers associated with them: an asking...

Indice dei contenuti