Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering Python Scientific Computing

You're reading from   Mastering Python Scientific Computing A complete guide for Python programmers to master scientific computing using Python APIs and tools

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781783288823
Length 300 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Kumar Mehta Kumar Mehta
Author Profile Icon Kumar Mehta
Kumar Mehta
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. The Landscape of Scientific Computing – and Why Python? 2. A Deeper Dive into Scientific Workflows and the Ingredients of Scientific Computing Recipes FREE CHAPTER 3. Efficiently Fabricating and Managing Scientific Data 4. Scientific Computing APIs for Python 5. Performing Numerical Computing 6. Applying Python for Symbolic Computing 7. Data Analysis and Visualization 8. Parallel and Large-scale Scientific Computing 9. Revisiting Real-life Case Studies 10. Best Practices for Scientific Computing Index

Vectors


An n-tuple defined on real numbers can also be called a vector. In physics and mathematics, a vector is a mathematical object that has either size, magnitude or length, and a direction. In SymPy, a vector is represented as a 1 x n row matrix or an n x 1 column matrix. The following program demonstrates the concept of vector computations in SymPy. It computes the transpose and norm of a vector:

from sympy import *
u = Matrix([[1,2,3]]) # a row vector = 1x3 matrix
v = Matrix([[4],
[5],    # a col vector = 3x1 matrix
[6]])
v.T # use the transpose operation to
u[1] # 0-based indexing for entries
u.norm() # length of u
uhat = u/u.norm() # unit-length vec in same dir as u
uhat
uhat.norm()

The next program demonstrates the concepts of dot product, cross product, and projection operations on vectors:

from sympy import *
u = Matrix([ 1,2,3])
v = Matrix([-2,3,3])
u.dot(v)

acos(u.dot(v)/(u.norm()*v.norm())).evalf()
u.dot(v) == v.dot(u)
u = Matrix([2,3,4])
n = Matrix([2,2,3])
(u.dot(n) / n.norm...
lock icon The rest of the chapter is locked
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Mastering Python Scientific Computing
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime
Modal Close icon
Modal Close icon