0% found this document useful (0 votes)
3 views1 page

Python Integration and Plotting Example

This document contains Python code to calculate the area between three functions defined by lambda functions over an interval defined by user input. It imports NumPy, Matplotlib, and SciPy, defines the functions, plots the functions and shaded region, and calculates the integrals and their difference over the interval.

Uploaded by

Novyana
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Python Integration and Plotting Example

This document contains Python code to calculate the area between three functions defined by lambda functions over an interval defined by user input. It imports NumPy, Matplotlib, and SciPy, defines the functions, plots the functions and shaded region, and calculates the integrals and their difference over the interval.

Uploaded by

Novyana
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import numpy as np

import [Link] as plt


import [Link] as integrate
x = [Link](-1, 2, 200)
f = lambda x: x**2 + 1
g = lambda x: x + 9
h = lambda x: x - 1 / 2
x1 = float(input("Masukkan nilai x1: "))
x2 = float(input("Masukkan nilai x2: "))
i=x1
j=x2
fx = f(x)
gx = g(x)
hx = h(x)
[Link](x, gx, x, fx, x, hx)
plt.fill_between(x, fx, gx, hx)
[Link]((-2,3))
fdu = [Link] (f, i,j)[0]
fdu
gdu = [Link](g, i, j)[0]
gdu
hdu = [Link](h, i, j)[0]
fdu-gdu-hdu

You might also like