{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "collapsed_sections": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "source": [ "**题目1:**天文学家要确定一颗小行星围绕太阳运行的轨道,在轨道平面内建立以太阳为原点的直角坐标系,在两坐标轴上去天文测量单位(一天文单位为地球到太阳的平均距离:9300公里)。在五个不同的时间点对小行星作了观察,测得轨道上五个点的坐标数据如下:\n", "\n", "|x|$4.5596$|$5.0816$|$5.5546$|$5.9636$|$6.2756$|\n", "|-|-|-|-|-|-|\n", "|y|$0.8145$|$1.3685$|$1.9895$|$2.6925$|$3.5265$|\n", "\n", "由开普勒第一定律知,小行星轨道为一椭圆。设方程为$$a_1x^2+2a_2xy+a_3y^2+2a_4x+2a_5y+1=0$$\n", "使确定椭圆的方程并在轨道的平面内以太阳为原点绘出椭圆曲线。并应用坐标平移变换和正交变换将上例题中的二次曲线方程化为标准方程,绘图样轨道图,完成小行星运行的动态模拟。\n" ], "metadata": { "id": "7vLMTNqJH23i" } }, { "cell_type": "code", "execution_count": 90, "metadata": { "id": "3N9jie5LF-X_", "colab": { "base_uri": "https://localhost:8080/", "height": 508 }, "outputId": "5e614821-c859-47b9-f09a-cca8e0c5ad09" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "解得方程\n", "-0.34x^2+2*0.19*xy+-0.38y^2+2*0.46x+2*0.41y+1=0\n", "坐标平移\n", "x=x_2+2.72\n", "y=y_2+2.42\n", "-0.10x^2+2*0.06*xy+-0.12y^2+1=0\n", "正交变换\n", "0.05x^2+0.17y^2=1\n", "坐标映射\n", "(4.56,0.81) -> (-0.30,2.42)\n", "(5.08,1.37) -> (-1.06,2.36)\n", "(5.55,1.99) -> (-1.83,2.21)\n", "(5.96,2.69) -> (-2.60,1.96)\n", "(6.28,3.53) -> (-3.39,1.54)\n" ] }, { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw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+wBPAo9pxBxacAQKue+6fvc2hKaVcsIT4XK31AqPrKSIeAroppboAJYAySqkftdbPG1WQQw4IUkpFAiFaa4efzU0p1Rn4GGijtY41uh6jKKVMWG72PoolwHcBz2qtDxtamIGU5arn/4CLWus3ja6nKMq+Ih+utX7CyDocpo1c3NQXQGngL6XUPqXUDKMLMkL2Dd8hwEosN/V+c+QQz/YQ8ALQPvvfxr7sq1BRxDjkFbkQQhQnckUuhBB2ToJcCCHsnAS5EELYOQlyIYSwcxLkQghh5yTIhRDCzkmQCyGEnft/eRsTe77JL+cAAAAASUVORK5CYII=\n" }, "metadata": { "needs_background": "light" } } ], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import matplotlib.animation as animation\n", "\n", "x=np.array([4.5596,5.0816,5.5546,5.9636,6.2756])\n", "y=np.array([0.8145,1.3685,1.9895,2.6925,3.5265])\n", "\n", "#解方程\n", "a=np.mat([x**2,2*x*y,y**2,2*x,2*y]).T\n", "b=np.mat([-1]*5).T\n", "solve=np.linalg.lstsq(a,b,rcond=None)[0].reshape(1,-1).getA()[0]\n", "print(\"解得方程\")\n", "print(\"%.2fx^2+2*%.2f*xy+%.2fy^2+2*%.2fx+2*%.2fy+1=0\"%tuple(solve))\n", "\n", "#坐标平移\n", "#x=x_2+k_1\n", "#y=y_2+k_2\n", "#\n", "#a_1*k_1+a_2*k_2+a_4=0\n", "#a_2*k_1+a_3*k_2+a_5=0\n", "print(\"坐标平移\")\n", "a=np.mat([[solve[0],solve[1]],\n", " [solve[1],solve[2]]])\n", "b=np.mat([-solve[3],-solve[4]]).T\n", "k=np.linalg.lstsq(a,b,rcond=None)[0]\n", "k_1=k[0,0]\n", "k_2=k[1,0]\n", "print(\"x=x_2+%.2f\"%k_1)\n", "print(\"y=y_2+%.2f\"%k_2)\n", "k=solve[0]*(k_1**2)+solve[2]*(k_2**2)+2*solve[1]*k_1*k_2+2*solve[3]*k_1+2*solve[4]*k_2+1\n", "a_1=solve[0]/k\n", "a_2=solve[1]/k\n", "a_3=solve[2]/k\n", "print(\"%.2fx^2+2*%.2f*xy+%.2fy^2+1=0\"%(a_1,a_2,a_3))\n", "\n", "#正交变换\n", "#a_1*x_2**2+2*a_2*x_2*y_2+a_3*y_3**2+1=0\n", "#求特征值和特征向量\n", "#x_2=[x_3,y_3]*featurevector[0]\n", "#y_2=[x_3,y_3]*featurevector[1]\n", "\n", "print(\"正交变换\")\n", "a=np.mat([[-a_1,-a_2],[-a_2,-a_3]])\n", "eigenvalue,featurevector=np.linalg.eig(a)\n", "mat=(featurevector.T*a*featurevector)\n", "a_1=mat[0,0]+mat[1,0]\n", "a_3=mat[0,1]+mat[1,1]\n", "print(\"%.2fx^2+%.2fy^2=1\"%(a_1,a_3))\n", "\n", "print(\"坐标映射\")\n", "mov_x=x-k_1\n", "mov_y=y-k_2\n", "featurevector_I=featurevector.I\n", "map_x=featurevector_I[0,0]*mov_x+featurevector_I[0,1]*mov_y\n", "map_y=featurevector_I[1,0]*mov_x+featurevector_I[1,1]*mov_y\n", "for i in range(len(x)):\n", " print(\"(%.2f,%.2f) -> (%.2f,%.2f)\"%(x[i],y[i],map_x[i],map_y[i]))\n", "\n", "plt.figure()\n", "t=np.arange(-2*np.pi,2*np.pi,0.01)\n", "plt_x=np.sin(t)/np.sqrt(a_1)\n", "plt_y=np.cos(t)/np.sqrt(a_3)\n", "plt.plot(plt_x,plt_y)\n", "plt.plot(map_x,map_y,'o')\n", "for i in range(len(x)):\n", " plt.text(map_x[i],map_y[i],'(%.2f,%.2f)'%(x[i],y[i]))\n", "plt.show()" ] }, { "cell_type": "markdown", "source": [ "**题目2:**价格指数是反应价格水平的总体变化的一种统计指数,经常被用以检测宏观经济中物价的波动形势。2006年1-6月我国企业商品价格指数的统计数据如下表。试建立多元线性回归模型:$y=\\beta_0+\\beta_1x_1+\\beta_2x_2$,并估计回归系数$\\beta_0$、$\\beta_1$和$\\beta_2$。若又知2006年7月农产品价格指数为$101$,矿产品价格指数为$111$,试上述关系预测2006年7月的价格总指数。\n", "\n", "|日期|总指数$y$|农产品$x_1$|矿产品$x_2$|\n", "|----|---------|-----------|-----------|\n", "|2006年1月|$101.1$|$101.3$|$105.6$|\n", "|2006年2月|$100.7$|$100.0$|$109.0$|\n", "|2006年3月|$100.8$|$101.0$|$107.9$|\n", "|2006年4月|$101.0$|$101.2$|$107.6$|\n", "|2006年5月|$101.5$|$100.8$|$108.9$|\n", "|2006年6月|$102.3$|$102.7$|$110.6$|" ], "metadata": { "id": "osOyydQPMGUM" } }, { "cell_type": "code", "source": [ "import numpy as np\n", "\n", "x_1=[101.3,100.0,101.0,101.2,100.8,102.7]\n", "x_2=[105.6,109.0,107.9,107.6,108.9,110.6]\n", "y=[101.1,100.7,100.8,101.0,101.5,102.3]\n", "a=np.mat([[1]*6,x_1,x_2]).T\n", "b=np.mat(y).T\n", "solve=np.linalg.lstsq(a,b,rcond=None)[0].reshape(1,-1).getA()[0]\n", "print(\"计算得:y=%.2f+%.2fx_1+%.2fx_2\"%tuple(solve))\n", "y_2=sum(np.array(solve)*np.array([1,101,111]))\n", "print(\"当x_1=101,x_2=111时,y=%.2f\"%y_2)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "w_AeblKlH1Oc", "outputId": "7679a9cd-8b4a-4452-c92d-052e4793804d" }, "execution_count": 112, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "计算得:y=37.03+0.49x_1+0.13x_2\n", "当x_1=101,x_2=111时,y=101.51\n" ] } ] } ] }