Created
December 30, 2019 20:07
-
-
Save accessnash/28f8a6b9ba0c36879f350763c353cc8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Mon Dec 30 21:00:52 2019 | |
| @author: DASA0 | |
| """ | |
| """ find the value of the integral xsinx from 0 to pi/2""" | |
| from math import sin, pi | |
| f = lambda x: x*sin(x) | |
| a = 0 | |
| b = pi/2 | |
| n = 16 | |
| h = (b - a) /n | |
| S = 0.5*(f(a) + f(b)) | |
| for i in range(1, n): | |
| S += f(a + i*h) | |
| integral = h * S | |
| print('Integral = %f' % integral) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment