Python’s SymPy module is really cool

So I was just browsing some code, and I came across a cool module I’d never seen before: SymPy

Basically, SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS).

What is symbolic mathematics?

Symbolic computation deals with the computation of mathematical objects symbolically. This means that the mathematical objects are represented exactly, not approximately, and mathematical expressions with unevaluated variables are left in symbolic form. Symbolic computation is handling non-numerical values, this means symbols like in algebra. Variables are defined as

In simple word, “Variables are defined as Symbols in Symbolic Computation instead of defining variables as numerical values ”

This will be more clear from an example from SymPy official documentation.

Let us define a symbolic expression, representing the mathematical expression x+2xy+2y.

>>> from sympy import symbols
>>> x, y = symbols('x y')
>>> expr = x + 2*y
>>> expr
x + 2*y

Instead of evaluating to something by convention, the expression remains as just, x+2*y

>>> x*expr
x*(x + 2*y)

Here, we might have expected x(x+2y) to transform into x^2+2xy, but instead, we see that the expression was left alone. This is a common theme in SymPy.

 

The Power of Symbolic Computation

The real power of a symbolic computation system such as SymPy is the ability to do all sorts of computations symbolically.

SymPy can simplify expressions, compute derivatives, integrals, and limits, solve equations, work with matrices, and much, much more, and do it all symbolically. It includes modules for plotting, printing (like 2D pretty printed output of math formulas,), code generation, physics, statistics, combinatorics, number theory, geometry, logic, and more.

Examples from official SymPy tutorial

Solve x^2 – 2 = 0

>>> solve(x**2 - 2, x)
[-√2, √2
Compute  sin(x2)d
>>> integrate(sin(x**2), (x, -oo, oo))
√2⋅√π
─────
  2

Installation

To install SymPy run:

sudo pip install SymPy

If you already have Anaconda and want to update SymPy to the latest version, use:

conda update sympy

After installation, it is best to verify that your freshly-installed SymPy works. To do this, start up Python and import the SymPy libraries:

$ python
>>> from sympy import *

From here, execute some simple SymPy statements like the ones below:

>>> x = Symbol('x')
>>> limit(sin(x)/x, x, 0)
1
>>> integrate(1/x, x)
log(x)
 I am looking forward to using this library for mathematical computation for my IoT projects.

Currently, I am going through the tutorial and documentation to get familiar with using the software.

References:

Github: Introduction to contribution

Tutorial: http://docs.sympy.org/latest/tutorial/index.html

Documentation: http://docs.sympy.org/

Download: Releases 

 

Switched to Fedora as my Main OS & It’s going Great!

After having used Windows as the Main operating system for about the past two years of Engineering, I’m finally switched to Fedora as my main OS. So far the Fedora experience has been going excellent.

What is Fedora?

Fedora is a Unix-like operating system based on the Linux kernel and GNU programs (a Linux distribution), developed by the community-supported Fedora Project and sponsored by the Red Hat company.

Basically, Fedora is a popular open source Linux-based operating system.

How I came to know about Fedora?

I saw fedora OS for the first time in my college lab during ‘Basic concepts of operating systems like UNIX, MS DOS class’. I was not familiar with Linux at that time. Later, when I joined dgplug, They introduced us to Linux and suggested to use Fedora for all work during the session.

Switching to Fedora finally

After using fedora for more than a year, I was impressed by its simplicity, flexibility and easy to use considering myself as a newbie to Linux. It offers pure GNOME with clean Desktop.

I think Fedora is best OS if you want to move to Linux from Windows. It is easy to use and Desktop Environment provides smooth and is easy for users, especially for those who are moving from windows OS. Because It’s not easy to switch directly to the terminal based environment.

I still use Windows for gaming and some other’s work. I am trying to find alternatives to those app or software in Fedora. My machine is running on dual boot currently, Fedora 26 and Windows 10.

I’ve run Fedora for last one years with a consistently reliable experience, and I look forward to what the next one brings. My most used Linux applications are the GNOME Terminal, Mozilla Firefox, Google Chrome, Mozilla Thunderbird, Gedit, and ViM.

I will write more about Fedora in my next posts. 🙂

Looking forward to exploring more “How does a computer works”

 

Who are hackers and What is Hacking ?

I was reading “Free as in Freedom” suggested by Kushal on the #dgplug channel on IRC. We also had a session on “History of Free Software Movement” on Monday”. I bookmarked the page at that time and thought to give a read in free time.

After reading the book, I was surprised and disgraced at the same time that we have no knowledge of the history of this computer science world and even we never tried to know.

So,  I will start with short Introduction of the book. This book is “biographical snapshots of GNU project founder Richard Stallman with the political, social and economic history of the free software movement. This book examines one man’s 20-year attempt to codify and communicate the ethics of 1970s era “hacking” culture in such a way that later generations might easily share and build upon the knowledge of their computing forebears. The book documents Stallman’s personal evolution from teenage misfit to the prescient adult hacker to political leader and examines how that evolution has shaped the free software movement. ”

‘Hacker’, Whenever we read or find out this term, the image that comes to our head is “a person who secretly gets access to a computer system in order to get information, cause damage”. This is what we use to see in movies or media. This is definition by most of the dictionary we follow. But that’s not the fact.

According to Richard Stallman hack means “Playful cleverness.” Hacking meant playful brilliance.

Hackers amaze people with their intelligence and innovation. They gave life to novel ideas which people thought were impossible to do; to wrought into reality.

To understand the meaning of the word “hacker,” and to understand the hacker ethic culture, one should read this book.

This book beautifully explains how the terms cracking’,security breaking’ and prank’ mixed up and create a misunderstanding.  How the word ‘Hacking’ got the new definition as the time changed. That’s why writer of the book finished his writing with these lines

Using the term “cracking” rather than “hacking,” when you mean “security breaking,” shows respect for Stallman and all the hackers and helps preserve something which all computer users have benefited from: the hacker spirit.

After reading the book I can say “I am proud to be a hacker”

References:

  1. Kushal Das’s Article on “Hacker Ethic and Free software movement”
  2. Free as in Freedom

Free software movement & Hacker culture

I will start this post with a quote by Kushal Das in between the session yesterday.

“The history is important, Learn about it!”

We had a session on IRC channel dgplug last night and the topic was “History of hacking and free software movement”.

The session started with this simple recent tweet by Gnome and a few replies

In this session, Kushal gave an inspiring talk on this topic, He told us about

  • TX-O computer at MIT lab,
  • How ‘Hacker Ethic’ word came into existence
  • The rise of Free Software Movement.
  • PDP – I computer
  • Richard Stallman
  • Founding FSF
  • Launching GNU
  • Open Source Initiative (OSI) by Bruce Perens and Eric S. Raymond.

Whenever we use Linux, or an open source software, Everything that we see today in Open source world, It all started with Free Software movement, which is about the freedom of users.

He also suggested us some books and resources to read about “History of hacking and free software movement”

  1. Free as in Freedom
  2. Hackers: Heroes of Computer Revolution
  3. A documentary “Revolution OS”

You can check IRC logs of dgplug here.