Rohmad Hidayat's Blog

Icon

My Notes on Mobile Technology, Python GUI, Python Web Framework, Software Development, Database, Server, Embedded System, Mini Computer

Belajar Matematika dengan Python

Ada banyak hal yang bisa kita lakukan dengan python untuk mengolah informasi secara matematis. Salah satu modul ACS ( Algebraic Computer Module) yang cukup menaraik adalah sympy. modul ini berisi modul perhitngan yang biasanya kita lakukan di kelas. Melakukan integrasi, differensiasi, deret, perhitungan limit sampai pada plotting grafik dapat dilakukan dengan simpel.

Kalkulus

Perhitungan limit
>>>from sympy import *
>>>x=Symbol(“x”)
>>>limit(sin(x)/x, x, 0)
1
Differensiasi

from sympy import *
>>>x = Symbol(‘x’)
>>>diff(sin(x), x)
cos(x)
>>>diff(sin(2*x), x)
2*cos(2*x)

>>> diff(tan(x), x)
cos(x)**(-2)
Integrasi
from sympy import *
>>>x, y = symbols(‘xy’)
>>> integrate(6*x**5, x)
x**6
>>>integrate(sin(x), x)
-cos(x)
>>>integrate(log(x), x)
x*log(x) – x
>>>integrate(2*x + sinh(x), x)
Integral Tertentu

>>>integrate(x**3, (x, -1, 1))
0
>>>integrate(sin(x), (x, 0, pi/2))
1
>>> integrate(cos(x), (x, -pi/2, pi/2))
2

Advertisements

Filed under: Programming, Python

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: