Book Image

The Statistics and Calculus with Python Workshop

By : Peter Farrell, Alvaro Fuentes, Ajinkya Sudhir Kolhe, Quan Nguyen, Alexander Joseph Sarver, Marios Tsatsos
5 (1)
Book Image

The Statistics and Calculus with Python Workshop

5 (1)
By: Peter Farrell, Alvaro Fuentes, Ajinkya Sudhir Kolhe, Quan Nguyen, Alexander Joseph Sarver, Marios Tsatsos

Overview of this book

Are you looking to start developing artificial intelligence applications? Do you need a refresher on key mathematical concepts? Full of engaging practical exercises, The Statistics and Calculus with Python Workshop will show you how to apply your understanding of advanced mathematics in the context of Python. The book begins by giving you a high-level overview of the libraries you'll use while performing statistics with Python. As you progress, you'll perform various mathematical tasks using the Python programming language, such as solving algebraic functions with Python starting with basic functions, and then working through transformations and solving equations. Later chapters in the book will cover statistics and calculus concepts and how to use them to solve problems and gain useful insights. Finally, you'll study differential equations with an emphasis on numerical methods and learn about algorithms that directly calculate values of functions. By the end of this book, you’ll have learned how to apply essential statistics and calculus concepts to develop robust Python applications that solve business challenges.
Table of Contents (14 chapters)
Preface

12. Intermediate Calculus with Python

Activity 12.01: Finding the Velocity and Location of a Particle

Solution:

  1. For the first part, we only have to find where 2. Let's write functions for dx/dt and dy/dt:
    from math import sqrt,sin,cos,e
    def dx(t):
        return 1 + 3*sin(t**2)
    def dy(t):
        return 15*cos(t**2)*sin(e**t)
  2. Now, we can loop from 0 to 1.5 and see where dy/dt goes from positive to negative or vice versa:
    t = 0.0
    while t<=1.5:
        print(t,dy(t))
        t += 0.05

    Here's the important part of the output:

    1.0000000000000002 3.3291911769931715
    1.0500000000000003 1.8966982923409172
    1.1000000000000003 0.7254255490661741
    1.1500000000000004 -0.06119060343046955
    1.2000000000000004 -0.3474047235245454
    1.2500000000000004 -0.04252527324380706
    1.3000000000000005 0.8982461584089145
    1.3500000000000005 2.4516137491656442
    1.4000000000000006 4.5062509856573225
    1.4500000000000006 6.850332845507693...