def sign(display): angle = float(v.get()) flag = v1.get() print(flag) rad = 3.14 * (angle / 180) # 化角度为弧度 if (flag == 1): result = eng.New_sin(rad) # return result else: result = func.sin(rad) result = round(result, 3) # print(result) # v.set(result) if (display == 1): v.set(result) return result
def test_sin(): #调用九组func.py进行测试 error_max = 0 deg = 0 for i in range(0, 1000): #测试1000组数据 deg = i * 0.36 # 0.36步长测试1000组角度 rad = func.angle2radian(deg) #角度转弧度 error = math.fabs(func.sin(rad) - math.sin(rad)) #调用九组sin 与系统math.sin做误差分析 error_max = error if (error > error_max) else error_max #得出最大误差 error_max = '{:.5g}'.format(error_max) error_max = float(error_max) if (error_max > 1e-3): # print("error_max:", error_max, "deg:", deg) # v.set('sin功能测试完成,误差大于0.001!') content.set("sin功能测试完成,误差:" + str(error_max)) tkinter.messagebox.showwarning(title='出错了!', message='sin功能测试完成,误差大于0.001!') else: # v.set('sin功能测试完成,误差大于0.001!') content.set("sin功能测试完成,误差:" + str(error_max)) tkinter.messagebox.showinfo(title='信息提示!', message='sin功能测试完成,误差不大于0.001!')
def create_signal(): _, sinexp = func.exp(N=N) _, sin = func.sin(N=N) _, sinc = func.sinc(N=N) return np.arange(len(sinc)), sinexp + sin + sinc
_v_found[v0 + fn.Function.delta_x] = v1 _v_found[v0 - fn.Function.delta_x] = v2 @staticmethod def _add_found2(d2vdz2: float, _v_found: dict, v0: float): delta_x = fn.Function.delta_x _v_found[v0 + 2 * delta_x] = _v_found[v0 - 2 * delta_x] \ = 2 * delta_x ** 2 * d2vdz2 + _v_found[v0] if __name__ == "__main__": x_func = fn.from_var_factory(fn.Var('x')) y_func = fn.from_var_factory(fn.Var('y')) z_func = fn.from_var_factory(fn.Var('z')) test_F = x_func + fn.sinh(x_func) - fn.sin(y_func) - y_func + z_func * 0 test_G = z_func + fn.exp(z_func) - x_func - fn.log(1 + x_func) - 1 + y_func * 0 p = (0, 0, 0) test = ImplicitCurve3D(test_F, test_G) res = test.implicit_theorem(p) curve = ParamCurve3D(res) print(res(1)) print("r':", res.derivative()(1)) print("r'':", res.derivative(order=2)(1)) print("r''':", res.derivative(order=3)(1))
def plot(self, dots=1000, start=-100, end=100): self.reset_axes() start = max(start, self.vector.left) end = min(end, self.vector.right) t = np.linspace(start, end, dots) x, y, z = self(t) self.ax.plot(x, y, z, c='r') def frenet(self, t0): tau = self.tangent_unit()(t=t0) beta = self.binormal_unit()(t=t0) nu = self.normal_unit()(t=t0) point = self(t=t0) x0, y0, z0 = point X = [x0, x0, x0] Y = [y0, y0, y0] Z = [z0, z0, z0] return self.ax.quiver(X, Y, Z, tau, beta, nu) if __name__ == '__main__': t = fn.Var('t') r = VectorFunc(1 + fn.cos(t), fn.sin(t), 2 * fn.sin(fn.from_var_factory(t) / 2), 0, 4 * np.pi) curve = ParamCurve3D(r) curve.plot() curve.frenet(2) plt.show()