
Python学习
殇情雨
Stay hungry Stay foolish
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
排序算法python实现
快速排序选择数组中的任意一个元素pivot,该元素作为基准,将小于基准的元素移到左边,大于基准的元素移到右边(分区操作),数组被pivot分为两部分,继续对剩下的两部分做同样的处理,直到所有子集元素不再需要进行上述步骤。class Solution(object): def sortArray(self, nums): n = len(nums) def quick(low, high): if low >= high: # 说明已原创 2021-06-03 22:58:09 · 132 阅读 · 1 评论 -
Anaconda中配置tensorflow虚拟环境问题总结
最近在Anaconda中配置tensorflow虚拟环境,配置过程中遇到了许多问题,总结如下:1 创建的虚拟环境用的pyhon版本和电脑里安装的版本不一样,比如conda create -n tensorflow python = 3.5,而你的电脑里是python.3.7,这时候在运行jupyter notebook时就会出现dead kernal的问题,把3.5改为3.7问题马上解决。2 ...原创 2019-10-14 09:00:53 · 505 阅读 · 0 评论 -
Python学习笔记
python 学习笔记np.random.random(N) #在[0,1)生成N个随机数,不给参数就生成1个随机数要是想在(-1,1)上生成随机数np.random.random()*2-1就好了,想到这种方法好难哎.T也是一种转置方法,不过没有指定转置规则...原创 2019-04-10 16:33:30 · 130 阅读 · 0 评论 -
龙贝格求积公式
利用龙贝格法求f(x)=x^3-2x*x+7x-5的积分值2019.4.17# -*- coding: utf-8 -*-"""Created on Wed Apr 17 19:29:54 2019@author: xh216"""import numpy as npa=1b=3N=800R=[0.038271604938272, 0.180599647266314...原创 2019-04-17 21:52:13 · 3575 阅读 · 0 评论 -
计算方法中的牛顿—科特斯求积分
牛顿—科特斯求积分2019.4.17f(x)=x^3-2x*x+7x-5a=1b=3def f(x): return x**3-2*x*x+7*x-5error1=(b-a)/2*(f(1)+f(3))-20-2/3 error2=(b-a)/6*(f(1)+4*f(2)+f(3))-20-2/3error4=(b-a)/90*(7*f(1)+32*f(1.5)+12*f...原创 2019-04-17 21:57:23 · 3542 阅读 · 0 评论 -
牛顿迭代法python求x^3-x-1=0的根
def f(xi): return xi*xi*xi-xi-1def f1(xi): return 3*xi*xi-1x=[]x.append(0.5)eps=1e-14 #误差限制error=abs(f(x[-1])) #最新加的x在最后number_iteration=0while error>eps: x.append(x[-1]-f...原创 2019-04-27 14:43:22 · 8899 阅读 · 0 评论 -
求勒让德导数的零点
import matplotlib.pyplot as pltdef Legendr(n,m,x): #Legendr=Legendre(n,m,x) Legendre=[([0]*24) for i in range(24)] for j in range(m): if j==0: Legendre[1+0][1+j]=1 ...原创 2019-04-27 17:22:05 · 2109 阅读 · 0 评论 -
牛顿下山法和弦截法求x^3-x-1=0的根
牛顿下山法# -*- coding: utf-8 -*-"""Created on Wed May 8 20:16:34 2019@author: xh216"""def f(m): return m*m*m-m-1def f1(m): return 3*m*m-1x=[]x.append(0.5)#初始值eps=1e-14 #精度fx=abs(f(...原创 2019-05-08 21:46:17 · 3369 阅读 · 1 评论 -
用牛顿法求勒让德倒数的零点
import matplotlib.pyplot as plt def Legendr(n,m,x): #Legendr=Legendre(n,m,x) Legendre=[([0]*24) for i in range(24)] for j in range(m): if j==0: Legendre[1+0][1+j]=1 Legendre[1+1][1+j]=x for k in range...原创 2019-05-15 15:03:36 · 462 阅读 · 0 评论