Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import numpy as np
- import matplotlib.pyplot as plt
- def circle_square(external_radius,inner_radius):
- return math.pi*(external_radius*external_radius-inner_radius*inner_radius)
- def main():
- print(f"circle square(10,5): {circle_square(10,5)}")
- x_coords = [-3.14+i*0.02 for i in range(0, 315)]
- function1_y_coords = [2*math.sin(x_coord) for x_coord in x_coords]
- function2_y_coords = [math.cos(2*x_coord) for x_coord in x_coords]
- min_delta = 10.0
- min_coord = -1
- for index in range(0, len(x_coords)):
- current_res = abs(function1_y_coords[index]-function2_y_coords[index])
- if min_delta > current_res:
- min_delta = current_res
- min_coord = index
- print(f"intersect in (x={min_coord*0.02-3.14},y={min_delta})")
- plt.title("y1 = 2sin(x), y2 = cos(2x)")
- plt.xlabel("x")
- plt.ylabel("y1, y2")
- plt.grid()
- plt.plot(x_coords, function1_y_coords,x_coords, function2_y_coords)
- plt.show()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement