python罗小黑
import matplotlib.pyplot as plt
ab = 2.21
cd = 1.37
n = 1024
def type_selection(clazz):
assert clazz=="numpy" or clazz == "sympy"
import numpy as np
import sympy as sp
if clazz == "numpy":
return np
else:
return sp
def f(x, clazz):
return 0.5 * ab * type_selection(clazz).sqrt(25 - x ** 2)
def g(x, clazz):
return -0.5 * cd * type_selection(clazz).sqrt(25 - x ** 2)
def h_left(x, clazz):
return type_selection(clazz).sqrt(5.77 ** 2 - (x + 9.08) ** 2) + 1.35
def h_right(x, clazz):
return h_left(-x, clazz)
def q_right(x, y, clazz):
return x - type_selection(clazz).sqrt(8.11 ** 2 - (y - 3.4) ** 2) + 2.56
def q_left(x, y, clazz):
return x + type_selection(clazz).sqrt(8.11 ** 2 - (y - 3.4) ** 2) - 2.56
def r_left(x, clazz):
return type_selection(clazz).sqrt(7.19 ** 2 - (x + 3.21) **2) - 1.32
def r_right(x, clazz):
return r_left(-x, clazz)
def s_left(x, clazz):
return type_selection(clazz).sqrt(0.64 ** 2 - (x+4.72) ** 2) + 5.04