-
中值定理符号怎么读_微分、微分中值定理、泰勒公式
2021-01-15 14:59:37问对问题,找对方法,...-上海交大032-047行列式的定义、性质与计算10/03048-078矩阵的定义、运算10/03079-117可逆矩阵、初等变换与秩10/04118-143最大线性无关向量组与秩10/05144-159线性方程组解的判断与求解方法...问对问题,找对方法,做对的事~
黑莓 2020/10/09
温习
001-031 逻辑、集合、空间 + 线性代数 00线性代数研究什么内容?-上海交大 032-047 行列式的定义、性质与计算10/03 048-078 矩阵的定义、运算10/03 079-117 可逆矩阵、初等变换与秩10/04 118-143 最大线性无关向量组与秩10/05 144-159 线性方程组解的判断与求解方法10/05 数学分析01 极限与连续2020/10/07 数学分析02 导数、求导与导数的应用 10/08 微分
详见 微分
定义
Q A 函数y=f(x)在x点处的微分是指什么? ①指因变量增量△y关于自变量增量△x的线性主部
②记作 dy或df(x) dy=df(x)=f'(x)dx=y'dx
③微分dy是因变量增量△y的近似值
④也可以说函数的微分等于函数的导数乘以自变量的微分。
微分的几何意义是? 详见?微分 可微与可导的关系是什么? dy=f'(x)dx 等价于 y'=f '(x) 怎么求微分呢? 你以为需要先求y'或f'(x),再求得dy=f'(x)dx 吗?
不用那样的。我们可以直接求微分。
详见?
和差积商法则与常用公式
微分中值定理
罗尔定理?
拉格朗日中值定理
泰勒公式
直线部分为函数在点x0处的切线方程,将f(x0)移到等号右边后……
①从几何的角度,
现在是以直线来代替曲线,
那我们是否可以用曲线来代替曲线呢?
它的近似度是否会更好一些呢?
②从分析的角度,
我们想知道:O(x-x0)有多大?到底是什么结构?
这就是泰勒公式要讨论的问题。
?
Q A 带有皮亚诺余项的泰勒公式是指? 若f(x)在x0处有n阶导数,那么存在x0的一个邻域,对于该邻域内的任一x,有f(x)=……
此式叫做函数f(x)在点x0处的带有皮亚诺余项的n阶泰勒公式。
带有皮亚诺余项的麦克劳林公式又是指什么呀? 【特殊】当x0=0时,所得的式子叫做带有皮亚诺余项的麦克劳林公式。 求f(x)=e^x在x=0处的Taylor展开式 【提示】y=e^x的n阶导数都为e^x 求f(x)=sin x在x=0处的Taylor展开式 【提示】正弦函数是奇函数,其展开式仍然能显示该特征。 求f(x)=cos x在x=0处的Taylor展开式 【提示】余弦函数是偶函数,其展开式仍然能显示该特征。 带有拉格朗日余项的泰勒公式是? 带有拉格朗日余项的麦克劳林公式又是什么呢? 不妨拿O(x-x0)与(x-x0)^2作比较。
为什么拿它来比较呢??
因为比一次方已经没有意义了,
我们已经知道它→0:
当x→ x0,O(x-x0)/(x-x0)→0
j=0时,我们约定:
f(x0)的0阶就是不求导的意思
0的阶乘为1。
函数在x0点可以写成:
多项式+皮亚诺余项
很多时候,我们是在x=0点展开。
因为什么呢?
一个函数在x=0点展开,
与在x=x0点展开,
仅仅就是展开式的一个平移。
特殊泰勒?
泰勒公式-应用
Q A 泰勒公式的应用有哪些呢? 近似计算、估计误差、求函数极限……例子↓ 比起用洛必达法则求极限,用泰勒公式计算极限有何优势? 直接、一次性 近似计算、误差?
用于求极限?
-
MyMathLib系列(矩阵算法--2)
2015-01-05 21:11:47矩阵相关的算法比较多,也是比较重要的,而且算法之间的性能差异确实比较大,初等变换法求逆比古典法求逆快不是一点点。矩阵的计算量和数值其实都是比较大的,特别是20阶以上,我在机器上最多只搞到40阶,随机产生的...矩阵相关的算法比较多,也是比较重要的,而且算法之间的性能差异确实比较大,初等变换法求逆比古典法求逆快不是一点点。矩阵的计算量和数值其实都是比较大的,特别是20阶以上,我在机器上最多只搞到40阶,随机产生的矩阵,很容易就爆掉decimal和double类型。
另外,这里使用了操作符重载,后面的一元符号运算也用到了操作符重载,后面如果有时间,我会将这些算法利用这些特性统一起来,本来它们的计算就应该是统一的。特别是符号运算。如果符号运算搞完,还可以试试自动命题证明玩玩。
好了,上矩阵的菜(有点长,但基本都调试过,至少书上的题都能正确计算出来!):
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyMathLib { /// <summary> /// 矩阵及相关算法. /// </summary> public class TMatrix { private int _Rank = -1; public bool IsZero { get; private set; } public bool IsUnit { get; private set; } private double[][] _Elements; public double[,] Elements { get { var theElements = new double[RowCount, ColCount]; for (int i = 0; i < RowCount; i++) { for (int j = 0; j < ColCount; j++) { theElements[i, j] = _Elements[i][j]; } } return theElements; } } public int ColCount { get; private set; } public int RowCount { get; private set; } /// <summary> /// 构造Row行,Col列矩阵,并用InitValue初始化。 /// </summary> /// <param name="Row">矩阵行数</param> /// <param name="Col">矩阵列数</param> /// <param name="InitValue">初始值</param> public TMatrix(int Row, int Col, double InitValue = 0) { IsZero = InitValue == 0; IsUnit = true; this.RowCount = Row; this.ColCount = Col; _Elements = new double[this.RowCount][]; for (int i = 0; i < Row; i++) { _Elements[i] = new double[this.ColCount]; for (int j = 0; j < this.ColCount; j++) { _Elements[i][j] = InitValue; if (Row == Col) { if (i == j) { if (InitValue != 1) { IsUnit = false; } } else { if (InitValue != 0) { IsUnit = false; } } } else { IsUnit = false; } } } } /// <summary> /// 构造Row行,Row列方阵.并用InitValue初始化 /// </summary> /// <param name="Row">方阵行列数</param> /// <param name="OnlyInitDiagonal">仅初始化对角线</param> public TMatrix(int Row, double InitValue = 0, bool OnlyInitDiagonal = false) { IsZero = InitValue == 0; IsUnit = (InitValue == 1 && OnlyInitDiagonal); this.RowCount = Row; this.ColCount = Row; _Elements = new double[this.RowCount][]; for (int i = 0; i < Row; i++) { _Elements[i] = new double[this.ColCount]; if (OnlyInitDiagonal) { _Elements[i][i] = InitValue; } else { for (int j = 0; j < this.ColCount; j++) { _Elements[i][j] = InitValue; } } } } public TMatrix(double[][] InitElements) { if (InitElements == null) { throw new Exception("矩阵不能为空!"); } IsZero = true; IsUnit = true; _Elements = InitElements; RowCount = _Elements.Length; ColCount = _Elements[0].Length; for (int i = 0; i < RowCount; i++) { for (int j = 0; j < this.ColCount; j++) { if (_Elements[i][j] != 0) { IsZero = false; } if (RowCount == ColCount) { if (i == j) { if (_Elements[i][j] != 1) { IsUnit = false; } } else { if (_Elements[i][j] != 0) { IsUnit = false; } } } else { IsUnit = false; } } } } public TMatrix(double[,] InitElements) { if (InitElements == null) { throw new Exception("矩阵不能为空!"); } IsZero = true; IsUnit = true; RowCount = InitElements.GetLength(0); ColCount = InitElements.GetLength(1); _Elements = new double[RowCount][]; for (int i = 0; i < RowCount; i++) { _Elements[i] = new double[ColCount]; for (int j = 0; j < ColCount; j++) { this[i, j] = InitElements[i, j]; } } } public double this[int i, int j] { get { return _Elements[i][j]; } set { if (value != 0) { this.IsZero = false; } if (Math.Round(value,8) != 1) { this.IsUnit = false; } else { if (i != j) { this.IsUnit = false; } } _Elements[i][j] = value; } } public double[] this[int i] { get { return _Elements[i]; } } public double[] this[int i, bool GetCol] { get { double[] theResult = new double[RowCount]; for (int k = 0; k < RowCount; k++) { theResult[k] = _Elements[k][i]; } return theResult; } } public void SwapRow(int i, int j) { if (i != j) { double[] theTemp = _Elements[i]; _Elements[i] = _Elements[j]; _Elements[j] = theTemp; } } public void SwapCol(int i, int j) { if (i != j) { for (int k = 0; k < RowCount; k++) { double theTemp = _Elements[k][j]; _Elements[k][j] = _Elements[k][i]; _Elements[k][i] = theTemp; } } } public bool IsSquareMatrix { get { return this.ColCount == this.RowCount; } } public void CopyFrom(TMatrix A) { if (A.RowCount != this.RowCount || A.ColCount != this.ColCount) { throw new Exception("不是同型矩阵不能拷贝!"); } for (int i = 0; i < A.RowCount; i++) { for (int j = 0; j < A.ColCount; j++) { this[i, j] = A[i, j]; } } } #region 初等变换 /// <summary> /// 行初等变换1:交换两行. /// </summary> /// <param name="i"></param> /// <param name="j"></param> private void EleTransRow1(int i, int j) { SwapRow(i, j); } /// <summary> /// 行初等变换2:用一个非零数乘以一行. /// </summary> /// <param name="RowIndex">行号</param> /// <param name="Multiplier">乘数,不能为零</param> private void EleTransRow2(int RowIndex, double Multiplier) { if (Multiplier == 1) { return; } if (Multiplier != 0) { for (int j = 0; j < ColCount; j++) { this[RowIndex, j] = this[RowIndex, j] * Multiplier; } } } /// <summary> /// 行初等变换3:行1减行2 /// </summary> /// <param name="Row1">行号1</param> /// <param name="Row2">行号2</param> private void EleTransRow3(int Row1, int Row2, double Multiplier) { for (int j = 0; j < ColCount; j++) { this[Row1, j] = this[Row1, j] - this[Row2, j] * Multiplier; } } /// <summary> /// 行初等变换4:行1 * 系数1 - 行2 * 系数2 /// </summary> /// <param name="Row1">行号</param> /// <param name="M1">乘数1,不能为零</param> /// <param name="M2">乘数2,不能为零</param> private void EleTransRow4(int Row1, int Row2,double M1,double M2) { for (int j = 0; j < ColCount; j++) { this[Row1, j] = this[Row1, j] * M1 - this[Row2, j] * M2; } } /// <summary> /// 列初等变换1:交换两列. /// </summary> /// <param name="i"></param> /// <param name="j"></param> public void EleTransCol1(int i, int j) { SwapCol(i, j); } /// <summary> /// 列初等变换2:用一个非零数乘以一列. /// </summary> /// <param name="ColIndex">列号</param> /// <param name="Multiplier">乘数,不能为零</param> public void EleTransCol2(int ColIndex, double Multiplier) { if (Multiplier != 0) { for (int j = 0; j < RowCount; j++) { this[j, ColIndex] = this[j, ColIndex] * Multiplier; } } } /// <summary> /// 列初等变换3:列1减列2 /// </summary> /// <param name="Row1">列号1</param> /// <param name="Row2">列号2</param> public void EleTransCol3(int Col1, int Col2, double Multiplier) { for (int j = 0; j < RowCount; j++) { this[j, Col1] = this[j, Col1] - this[j, Col2] * Multiplier; } } /// <summary> /// 列初等变换4:列1 * 系数1 - 列2 * 系数2 /// </summary> /// <param name="Col1">列号</param> /// <param name="Col2">列号2</param> /// <param name="M1">乘数1,不能为零</param> /// <param name="M2">乘数2,不能为零</param> public void EleTransCol4(int Col1, int Col2, double M1, double M2) { for (int j = 0; j < RowCount; j++) { this[j, Col1] = this[j, Col1] * M1 - this[j, Col2] * M2; } } #endregion /// <summary> /// 矩阵消元,转换成阶梯矩阵 /// 本算法也可以用来求矩阵的秩. /// 仅用行初等变换. /// </summary> public void TransToEchelonMatrix(List<TransformItem> TransformRecords) { //从第1列到第theE列进行变换. //最大非0行,用以标记进行变换到现在,可以继续进行处理的最小行号. var theNoZeroIndex = 0; for (int i = 0; i < this.ColCount; i++) { var theR = -1; for (int j = theNoZeroIndex; j < this.RowCount; j++) { if (this[j, i] != 0) { theR = j; break; } } if (theR >= 0) { //将找到非零元素行交换到当前行. TransformRecords.Add(TransformItem.CreateEleTransRow1(theR, theNoZeroIndex)); EleTransRow1(theR, theNoZeroIndex); //将大于当前行的列初等变换为0 var theM1 = this[theNoZeroIndex, i]; for (int k = theNoZeroIndex + 1; k < this.RowCount; k++) { var theRate = Math.Round(this[k, i] / theM1,ConstDef.Decimals); TransformRecords.Add(TransformItem.CreateEleTransRow4(k, theNoZeroIndex, 1, theRate)); EleTransRow4(k, theNoZeroIndex, 1, theRate); } theNoZeroIndex++; } } } /// <summary> /// 变换成标准形.方法很简单:先用行初等变换,尽量消元,然后用列初等变换,尽量消元. /// 但在这里会同时用到行列的初等变换.这里采用变换函数,如果为了效率,其实可以将初等 /// 变换代码直接写到函数里。 /// </summary> public List<TransformItem> TransToStandardForm() { var theTransList = new List<TransformItem>(); //从第i=1行开始,使得[i,i]不等于0,然后将剩余的i行,i列的元素通过初等变换变成0. //如果[i,i]无法获得非零元素则变换终止. for (int i = 0; i < this.RowCount; i++) { //如果[i,i]等于0,则进行行交换直到到交换到[i,i]变为非零元素, //如果没找到,就找列,如果都没找到,则终止 var theRow = -1; var theCol = -1; //在行>i,列>i的所有元素中找到一个非零值,如果找到,就进行初等变换 //如果没找到,则说明完成标准型转换. var theFind = false; for (int r = i; r < this.RowCount; r++) { for (int c = i; c < this.ColCount; c++) { if (this[r, c] != 0) { theRow = r; theCol = c; theFind = true; break; } } if (theFind) { break; } } if (theFind) { //先做行变换,再做列变换,目的是将找到的非零元素交换到当前位置. //行初等变换1, theTransList.Add(TransformItem.CreateEleTransRow1(i, theRow)); EleTransRow1(i, theRow); //列初等变换 theTransList.Add(TransformItem.CreateEleTransCol1(i, theCol)); EleTransCol1(i, theCol); //将[i,i] 变为1 double theMultipler = Math.Round((double)1 / this[i, i], ConstDef.Decimals); //行初等变换2(这里采用列也是一样,是等价的) theTransList.Add(TransformItem.CreateEleTransRow2(i, theMultipler)); EleTransRow2(i, theMultipler); //将i行上>i的列上的其它元素变换成0 for (int c = i + 1; c < this.ColCount; c++) { var theM2 = this[i,c]; //c=c*1-i*theM2,这个函数其实是综合了几个初等变换. theTransList.Add(TransformItem.CreateEleTransCol4(c, i,1, theM2)); EleTransCol4(c, i, 1, theM2); } //将i列上>i的行上的其它元素变换成0 for (int r = i + 1; r < this.RowCount; r++) { var theM2 = this[r, i]; //c=c*1-i*theM2,这个函数其实是综合了几个初等变换. theTransList.Add(TransformItem.CreateEleTransRow4(r, i,1,theM2)); EleTransRow4(r, i, 1, theM2); } } else { break; } } return theTransList; } /// <summary> /// 变换成标准形:这里仅采用行变换.但需要注意的是这里如果不是满秩矩阵, /// 得到的就不一定是标准型.这个转换主要用于求矩阵的逆. /// </summary> /// <returns>变换过程记录.</returns> public List<TransformItem> TransToStandardForm2() { var theTransfromRecords = new List<TransformItem>(); //先把矩阵转换成上三角矩阵。 TransToEchelonMatrix(theTransfromRecords); //然后从最后一列开始,第1行开始变换为0. for (int j = this.ColCount - 1; j >= 0; j--) { //从下到上找到第1个非0行,作为基准行(减少行) //因为矩阵的下半部分全为0,则开始找的位置在对角线上开始. int theR = -1; int theStartIndex = Math.Min(j,this.RowCount-1); for (int i = theStartIndex; i >= 0; i--) { if (this[i, j] != 0) { theR = i; break; } } //如果找到基准行,则开始变换,利用减去基准行*一个系数来消除第0到thR-1行的元素 if (theR >= 0) { for (int i = 0; i < theR; i++) { var theRate = Math.Round(this[i, j] / this[theR, j], ConstDef.Decimals); theTransfromRecords.Add(TransformItem.CreateEleTransRow4(i, theR, 1, theRate)); EleTransRow4(i, theR, 1, theRate); } } } //将对角线上的元素化为1 var theMinRC = Math.Min(this.ColCount, this.RowCount); for (int i = 0; i < theMinRC; i++) { if (this[i, i] != 0) { var theRate = Math.Round((double)1.0 / this[i, i], ConstDef.Decimals); EleTransRow2(i, theRate); theTransfromRecords.Add(TransformItem.CreateEleTransRow2(i, theRate)); } } return theTransfromRecords; } /// <summary> /// 对矩阵按照TransformItems里的变换做变换 /// </summary> /// <param name="TransformItems">变换集合</param> public void DoTransform(List<TransformItem> TransformItems) { if (TransformItems == null) { return; } for (int i = 0; i < TransformItems.Count; i++) { var theTransItem = TransformItems[i]; switch (theTransItem.RowOrCol) { case TransRowOrCol.Row: switch (theTransItem.TransMethod) { case BasicTransMethod.Swap: EleTransRow1(theTransItem.i, theTransItem.j); break; case BasicTransMethod.Multipler: EleTransRow2(theTransItem.i, theTransItem.M1); break; case BasicTransMethod.CoPlus1: EleTransRow3(theTransItem.i, theTransItem.j, theTransItem.M1); break; case BasicTransMethod.CoPlus2: EleTransRow4(theTransItem.i, theTransItem.j,theTransItem.M1,theTransItem.M2); break; } break; case TransRowOrCol.Col: switch (theTransItem.TransMethod) { case BasicTransMethod.Swap: EleTransCol1(theTransItem.i, theTransItem.j); break; case BasicTransMethod.Multipler: EleTransCol2(theTransItem.i, theTransItem.M1); break; case BasicTransMethod.CoPlus1: EleTransCol3(theTransItem.i, theTransItem.j, theTransItem.M1); break; case BasicTransMethod.CoPlus2: EleTransCol4(theTransItem.i, theTransItem.j, theTransItem.M1, theTransItem.M2); break; } break; } } } public TMatrix Clone() { var theA = new TMatrix(this.RowCount, this.ColCount); for (int i = 0; i < theA.RowCount; i++) { for (int j = 0; j < theA.ColCount; j++) { theA[i, j] = this[i, j]; } } return theA; } public static TMatrix NewZeroMatrix(int Row, int Col) { return new TMatrix(Row, Col, 0); } public static TMatrix NewSquareMatrix(int n) { return new TMatrix(n, 1, true); } /// <summary> /// 转置矩阵 /// </summary> /// <param name="A">矩阵</param> /// <returns>转置矩阵</returns> public static TMatrix Transposition(TMatrix A) { var theRetM = new TMatrix(A.ColCount, A.RowCount); for (int i = 0; i < A.RowCount; i++) { for (int j = 0; j < A.ColCount; j++) { theRetM[j, i] = A[i, j]; } } return theRetM; } public static TMatrix SwapRow(TMatrix A, int i, int j) { var theA = A.Clone(); theA.SwapRow(i, j); return theA; } public static TMatrix SwapCol(TMatrix A, int i, int j) { var theA = A.Clone(); theA.SwapCol(i, j); return theA; } public static TMatrix operator +(TMatrix A, TMatrix B) { if (A.RowCount != B.RowCount || A.ColCount != B.ColCount) { throw new Exception("不是同型矩阵不能相加!"); } double[][] theResult = new double[A.RowCount][]; for (int i = 0; i < A.RowCount; i++) { theResult[i] = new double[A.ColCount]; for (int j = 0; j < A.ColCount; j++) { theResult[i][j] = A[i, j] + B[i, j]; } } return new TMatrix(theResult); } public static TMatrix operator -(TMatrix A) { var theA = new TMatrix(A.RowCount, A.ColCount); for (int i = 0; i < A.RowCount; i++) { for (int j = 0; j < A.ColCount; j++) { theA[i, j] = 0 - A[i, j]; } } return theA; } public static TMatrix operator -(TMatrix A, TMatrix B) { if (A.RowCount != B.RowCount || A.ColCount != B.ColCount) { throw new Exception("不是同型矩阵,不能相减"); } var theA = new TMatrix(A.RowCount, A.ColCount); for (int i = 0; i < A.RowCount; i++) { for (int j = 0; j < A.ColCount; j++) { theA[i, j] = A[i, j] - B[i, j]; } } return theA; } public static TMatrix operator *(double K, TMatrix A) { if (A.IsZero) { return TMatrix.NewZeroMatrix(A.RowCount, A.ColCount); } var theA = new TMatrix(A.RowCount, A.ColCount); for (int i = 0; i < A.RowCount; i++) { for (int j = 0; j < A.ColCount; j++) { theA[i, j] = K * A[i, j]; } } return theA; } public static TMatrix operator *(decimal K, TMatrix A) { return K * A; } public static TMatrix operator *(TMatrix A, double K) { return K * A; } public static TMatrix operator *(TMatrix A, TMatrix B) { if (A.ColCount != B.RowCount) { throw new Exception("A的列数不等于B的行数,不能相乘!"); } if (A.IsZero) { return TMatrix.NewZeroMatrix(A.RowCount, B.ColCount); } if (A.IsUnit) { return B.Clone(); } if (B.IsUnit) { return A.Clone(); } double[][] theResult = new double[A.RowCount][]; for (int i = 0; i < A.RowCount; i++) { theResult[i] = new double[B.ColCount]; for (int j = 0; j < B.ColCount; j++) { theResult[i][j] = 0; for (int k = 0; k < A.ColCount; k++) { theResult[i][j] += A[i, k] * B[k, j]; } } } return new TMatrix(theResult); } public static TMatrix operator ^(TMatrix A, int K) { if (A.IsSquareMatrix) { if (A.IsUnit) { return A.Clone(); } if (A.IsZero) { return TMatrix.NewZeroMatrix(A.RowCount, A.ColCount); } if (K == 0) { return TMatrix.NewSquareMatrix(A.RowCount); } if (K == 1) { return A.Clone(); } var theA = A; if (K < 0) { theA = GetInverseMatrix(A); } var theRet = theA; for (int i = 1; i < K; K++) { theRet = theRet * theA; } return theRet; } throw new Exception("只有方阵才能做幂运算!"); } public static bool operator ==(TMatrix A, TMatrix B) { if (A.RowCount != B.RowCount || A.ColCount != B.ColCount) { throw new Exception("不是同型矩阵,不能比较"); } if (A.IsUnit && B.IsUnit || A.IsZero && B.IsZero) { return true; } for (int i = 0; i < A.RowCount; i++) { for (int j = 0; j < A.ColCount; j++) { if (A[i, j] != B[i, j]) { return false; } } } return true; } public static bool operator !=(TMatrix A, TMatrix B) { if (A.RowCount != B.RowCount || A.ColCount != B.ColCount) { throw new Exception("不是同型矩阵,不能比较"); } if (A.IsUnit && B.IsUnit || A.IsZero && B.IsZero) { return false; } for (int i = 0; i < A.RowCount; i++) { for (int j = 0; j < A.ColCount; j++) { if (A[i, j] != B[i, j]) { return true; } } } return true; } /// <summary> /// 初等变换法求矩阵A的逆. /// </summary> /// <param name="A"></param> /// <returns></returns> public static TMatrix GetInverseMatrix(TMatrix A) { var theA = A.Clone(); var theTransItems = theA.TransToStandardForm2(); var theE = new TMatrix(theA.RowCount, 1, true); theE.DoTransform(theTransItems); return theE; } /// <summary> /// 古典法求逆矩阵 /// </summary> /// <param name="A">方阵</param> /// <returns></returns> public static TMatrix GetInverseMatrix2(TMatrix A) { if (A.RowCount != A.ColCount) { throw new Exception("次函数仅支持方阵!"); } //计算其行列式的值 var theValOfA = LinearAlgebra.CalcDeterminant(A.Elements); if (theValOfA == 0) { throw new Exception("不可逆!"); } if (A.RowCount == 1) { return new TMatrix(1, 1, Math.Round((double)1.0 / theValOfA,ConstDef.Decimals)); } //求伴随矩阵 //var theAdjoint = new TMatrix(A.RowCount); var theAElements = A.Elements; var theMElements = new double[A.RowCount, A.ColCount]; for (int i = 0; i < A.RowCount; i++) { for (int j = 0; j < A.ColCount; j++) { var theMij = LinearAlgebra.GetDeterminantMij(theAElements, i + 1, j + 1); var theSign = LinearAlgebra.CalcDeterMijSign(i+1, j+1); var theValOfAij = theSign * LinearAlgebra.CalcDeterminant(theMij); //注意这里.弄反了,结果就是逆矩阵的转置矩阵. theMElements[j, i] = theValOfAij; } } //计算伴随矩阵结果. return (Math.Round((double)1.0 / theValOfA,ConstDef.Decimals)) * (new TMatrix(theMElements)); } /// <summary> /// 获取矩阵的秩. /// </summary> /// <returns></returns> public int GetRank() { if (_Rank < 0) { var theA = this.Clone(); theA.TransToStandardForm(); _Rank = GetRank(theA); } return _Rank; } public static int GetRank(TMatrix StdForm) { int theRank = 0; for (int i = 0; i < StdForm.ColCount && i < StdForm.RowCount; i++) { if (StdForm[i, i] == 1) { theRank++; continue; } } return theRank; } /// <summary> /// 是否是标量矩阵 /// </summary> public bool IsScalarMatrix { get { if (this.RowCount != this.ColCount) { return false; } var theScalar = _Elements[0][0]; for (int i = 0; i < this.RowCount; i++) { for (int j = 0; j < this.ColCount; j++) { if (i != j) { if (_Elements[i][j] != 0) { return false; } } else { if (_Elements[i][i] != theScalar) { return false; } } } } return true; } } /// <summary> /// 对角矩阵 非对角线上的元素全部为0方阵 /// </summary> public bool IsDiagonalMatrix { get { if (this.RowCount != this.ColCount) { return false; } for (int i = 0; i < this.RowCount; i++) { for (int j = 0; j < this.ColCount; j++) { if (i != j) { if (_Elements[i][j] != 0) { return false; } } } } return true; } } /// <summary> /// 上三角矩阵 /// </summary> public bool IsUpperTriangularMatrix { get { if (this.RowCount != this.ColCount) { return false; } for (int i = 0; i < this.ColCount; i++) { for (int j = i + 1; j < this.RowCount; j++) { if (_Elements[j][i] != 0) { return false; } } } return true; } } /// <summary> /// 下三角矩阵 /// </summary> public bool IsLowerTriangularMatrix { get { if (this.RowCount != this.ColCount) { return false; } for (int i = 0; i < this.ColCount; i++) { for (int j = 0; j < i; j++) { if (_Elements[j][i] != 0) { return false; } } } return true; } } /// <summary> /// 对称矩阵Aij=Aij. /// </summary> public bool IsSymmetricMatrix { get { if (this.RowCount != this.ColCount) { return false; } for (int i = 0; i < this.RowCount; i++) { for (int j = 0; j < this.ColCount; j++) { if (_Elements[j][i] != _Elements[i][j]) { return false; } } } return true; } } /// <summary> /// 反对称矩阵Aij=-Aji.注意其对角线元素为0. /// </summary> public bool IsAntisymmetricMatrix { get { if (this.RowCount != this.ColCount) { return false; } for (int i = 0; i < this.RowCount; i++) { for (int j = 0; j < this.ColCount; j++) { if (i == j) { if (_Elements[j][i] != 0) { return false; } } else { if (_Elements[j][i] != -_Elements[i][j]) { return false; } } } } return true; } } /// <summary> /// 正交矩阵A*t(A)=E. /// </summary> public bool IsOrthogonalMatrix { get { if (this.RowCount != this.ColCount) { return false; } var theA = this.Clone(); var theAt = Transposition(theA); var theRet = theA * theAt; return theRet.IsUnit; } } /// <summary> /// 零幂矩阵(A^k=O)。 /// |A|==0 /// </summary> public bool IsZeroPowerMatrix { get { if (this.RowCount != this.ColCount) { return false; } var theVal = LinearAlgebra.CalcDeterminant(this.Elements); return theVal == 0; } } } }
-
MATLAB第5章 线性代数运算_线性代数矩阵运算公式
2020-03-17 08:47:335.1常用矩阵的生成 5.2矩阵的基本运算 5.3符号矩阵的基本运算 5.4矩阵分析 5.4.1矩阵的共轭与逆 5.4.2向量和矩阵的范数 5.4.3矩阵的条件数 5.5矩阵的秩与初等变换 5.6矩阵的分解 5.6.1对称正定矩阵的Cholesky分解 ... -
bzoj 4031: [HEOI2015]小Z的房间 矩阵树定理
2017-04-20 20:43:22题意给出一个n*m的方阵,一些格子是空地一些是柱子。格子间的邻边看做边,问空地的生成树数量。...一开始忘了行初等变换要让行列式换符号了。代码#include #include #include #include #include using namespace s题意
给出一个n*m的方阵,一些格子是空地一些是柱子。格子间的邻边看做边,问空地的生成树数量。
n<=9分析
权当省选前复习一波矩阵树定理了。
一开始忘了行初等变换要让行列式换符号了。
代码
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; typedef long long LL; const int N=10; const int MOD=1000000000; int n,m,sz,num[N][N],a[N*N][N*N],f; char ch[N]; void gauss(int n) { f=1; for (int i=1;i<=n;i++) { if (!a[i][i]) return; for (int j=i+1;j<=n;j++) if (a[j][i]) { while (a[j][i]) { f=-f; int w=a[i][i]/a[j][i]; for (int k=i;k<=n;k++) swap(a[i][k],a[j][k]); for (int k=i;k<=n;k++) a[j][k]=(a[j][k]-(LL)a[i][k]*w%MOD)%MOD; } } } } int main() { scanf("%d%d",&n,&m); for (int i=1;i<=n;i++) { scanf("%s",ch+1); for (int j=1;j<=m;j++) if (ch[j]=='.') num[i][j]=++sz; } for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) if (num[i][j]) { if (j<m&&num[i][j+1]) a[num[i][j]][num[i][j]]++,a[num[i][j+1]][num[i][j+1]]++,a[num[i][j]][num[i][j+1]]--,a[num[i][j+1]][num[i][j]]--; if (i<n&&num[i+1][j]) a[num[i][j]][num[i][j]]++,a[num[i+1][j]][num[i+1][j]]++,a[num[i][j]][num[i+1][j]]--,a[num[i+1][j]][num[i][j]]--; } gauss(sz-1); int ans=1; for (int i=1;i<sz;i++) ans=(LL)ans*a[i][i]%MOD; printf("%d",(ans*f+MOD)%MOD); return 0; }
-
怎么根据矩阵判断极大无关组_矩阵的秩和向量组的线性相关无关
2020-12-31 08:42:27线代的最核心方法就是用秩去刻画问题,秩在方程组的解的判定,向量组的线性相关无关,向量组的线性表示问题,向量组...矩阵进行初等变换(包含行列变换)我们都是在两个矩阵之间写箭头“---》”或者写“~”的符号,不...线代的最核心方法就是用秩去刻画问题,秩在方程组的解的判定,向量组的线性相关无关,向量组的线性表示问题,向量组的极大线性无关组的判定,向量组的等价和矩阵等价的判断,齐次线性方程组的基础解系问题,一个特征值对应几个线性无关的特征向量,方阵能否对角化等等问题都要用到,秩没学好,线代寸步难行!
矩阵进行初等变换(包含行列变换)我们都是在两个矩阵之间写箭头“---》”或者写“~”的符号,不能写等号,那这两个矩阵之间相差什么能写等号呢?那就是初等矩阵的引入,有些秩的问题也要可以用初等阵去解释的。所以我也上传了类型10 初等矩阵。
向量组的线性相关无关(类型12)同学们相当害怕,有很多性质记不住,我都一一进行了推导,而且是一招鲜,秩走到底,很多选择题用秩引刃而解,看过再说!
这是初等阵和矩阵的秩的问题:
这是线性表示的问题,昨天有人说增加分量搞不清楚,看过你会极度舒适的:
另外我们文都考研最近准备搞一次大模拟考试(新大纲,新分值),并由我来讲评数学部分,数学二单独讲评,数学一和数学三放在一起讲评!
看看这个扫码参与预约哦!
除了数学模考,还有其他科目,看看吧?我希望你能来!我会教你做题顺序,当然主要是知识点和方法的讲解!
-
求具体矩阵的逆矩阵
2014-02-16 15:51:00求具体矩阵的逆矩阵 求元素为具体数字的矩阵的逆矩阵时,常采用如下一些方法. 方法1 伴随矩阵法:. 注1 对于阶数较低(一般不超过3阶)或元素的代数余子式易于计算的矩阵可用此...方法2 初等变换法: 注对... -
欧拉公式cos_“数学英雄”欧拉的天才之作—欧拉公式,为啥被称为宇宙第一公式?...
2020-11-23 03:52:25作为数学界四大天王之一的欧拉,一直以来都被誉为天才之中的天才。他发明了一系列对人类影响深远的符号...而大学生生也难逃欧拉的折磨,从初等几何的欧拉线,多面体的欧拉定理,立体解析几何的欧拉变换公式,四次方... -
《工程数学手册(第四版)》
2019-05-16 15:31:3116.拉普拉斯变换 17.数值方法 18.概率与统计 19.不定积分表 20.定积分表 21.平面曲线和区域 22.空间曲线和曲面 附录A 数值表 附录B 数学符号和术语 附录C 美国惯用单位和国际单位转换表 附录D 曲型问题,数学程序和... -
算法心得:高效算法的奥秘(原书第2版).[美]Henry S.Warren,Jr(带详细书签).pdf
2019-01-24 22:10:227.8 重排与下标变换 149 7.9 LRU算法 150 7.10 习题 153 第8章 乘法 154 8.1 多字乘法 154 8.2 64位积的高权重部分 156 8.3 无符号与带符号的高权重积互化 157 8.4 与常数相乘 157 8.5 习题 160 第9章 整数... -
AxMath数学公式编辑器.7z
2019-06-03 15:23:05AxMath是一款专业的...3、支持函数分析:包括概率论、积分变换、平面几何、微积分、无穷级数、线性代数、向量代数基础; 4、提供函数图像查看,支持微分方程、初等函数、代数、复变函数、复数以及复平面、复变函数。 -
《 概率论基础:第二版》作者: 严士健 著 ; 王隽骧 著 ; 刘秀芳 著 出版时间: 2009年
2019-05-25 16:03:193.4 随机变量函数的数学期望的L-S积分表示与积分变换定理 3.5 离散型和连续型随机变量 3.6 γ次平均收敛与空间Lγ 3.7 不定积分与σ-可加集函数的分解 第4章 乘积测度空间 4.1 有限维乘积测度 4.2 Fubini定理... -
计算机图形学(OpenGL)第三版(带完整目录).pdf
2017-02-15 10:03:09并具备初等代数、几何、三角函数和初等微积分的基本知识。向量和矩阵的有关知识将有助于本书的阅读,但不是必须的。本书在相关章节中介绍了向量和矩阵的基本知识,同时,附录中总结了向量和矩阵的关键概念。 ... -
【理论学习班】锁相环设计、仿真与应用(第5版)中文版 PART2
2010-05-17 15:23:47附录B是在这本书中经常使用的初等拉普拉斯变换。附录 C是对数字滤波器的综述,在高复杂度的PLL系统中它变得越来越重要。 目录回到顶部↑ 第1章 锁相环简介 1.1 锁相环工作原理 1.2 PLL的分类 第2章 混合信号... -
《数学要项定理公式证明辞典》作者: [日]笹部贞市郎 译者: 高隆昌 / 王世璠 / 田景黄 / 罗朝杰 出版年: ...
2019-05-25 16:34:42本书译自笹部贞市郎先生编著的《数学要项定理公式证明辞典》(圣文社1980年第六次印刷本),囊括了初等数学及高等数学中基本概念,定理、公式的详细证明和解法。对现代数学好些分支(线性规划、对策论、拓补、群论、... -
《数学要项定理公式证明辞典》 作者: [日]笹部贞市郎 译者: 高隆昌 / 王世璠 / 田景黄 / 罗朝杰 出版年: ...
2019-05-25 16:46:49本书译自笹部贞市郎先生编著的《数学要项定理公式证明辞典》(圣文社1980年第六次印刷本),囊括了初等数学及高等数学中基本概念,定理、公式的详细证明和解法。对现代数学好些分支(线性规划、对策论、拓补、群论、... -
MATLAB R2016a完全自学一本通
2018-03-29 17:00:14函数所能解决的问题其大致包括矩阵运算和线性方程组的求解、微分方程及偏微分方程的组的求解、符号运算、傅立叶变换和数据的统计分析、工程中的优化问题、稀疏矩阵运算、复数的各种运算、三角函数和其他初等数学运算... -
《算术探索》 作者: [德] 卡尔·弗里德里希·高斯 译者: 潘承彪 / 张明尧 出版年: 2011年
2019-05-24 23:22:59与胞兄潘承洞合著有《哥德巴赫猜想》、《解析数论基础》、《素数定理的初等证明》、《代数数论》、《初等数论》及《模形式导引》等。 张明尧,1945年12月生于山东省菏泽市,1967年毕业于安徽大学数学系,1981年获得... -
C开发金典随书源码:含数据结构 数值计算分析 图形图像处理 目录和文件操作 系统调用方面的范例
2013-10-25 13:12:12配书光盘Readme文件 C 语言通用范例开发金典 第1章 数据结构. 1 1.1 数组和字符串 2 1.1.1 一维数组的倒置 2 范例1-1 一维数组的倒置 2 ∷相关函数:fun函数 1.1.2 一维数组应用 3 ...∷相关函数:asin... -
C语言通用范例开发金典.part2.rar
2012-08-31 14:18:18资源简介 第1章 数据结构. 1 1.1 数组和字符串 2 1.1.1 一维数组的倒置 2 范例1-1 一维数组的倒置 2 ∷相关函数:fun函数 1.1.2 一维数组应用 3 范例1-2 一维数组应用 3 ...2.1.6 求反正切 ... -
C 开发金典
2013-06-20 16:20:03配书光盘Readme文件 C 语言通用范例开发金典 第1章 数据结构. 1 1.1 数组和字符串 2 1.1.1 一维数组的倒置 2 范例1-1 一维数组的倒置 2 ∷相关函数:fun函数 1.1.2 一维数组应用 3 ...2.1.2 求浮点数的...