Laddning av Hjälppaket: with plots ; with LinearAlgebra ; animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fieldplot, fieldplot3d, gradplot, gradplot3d, graphplot3d, implicitplot, implicitplot3d, inequal, interactive, interactiveparams, intersectplot, listcontplot, listcontplot3d, listdensityplot, listplot, listplot3d, loglogplot, logplot, matrixplot, multiple, odeplot, pareto, plotcompare, pointplot, pointplot3d, polarplot, polygonplot, polygonplot3d, polyhedra_supported, polyhedraplot, rootlocus, semilogplot, setcolors, setoptions, setoptions3d, spacecurve, sparsematrixplot, surfdata, textplot, textplot3d, tubeplot &x, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, CompanionMatrix, ConditionNumber, ConstantMatrix, ConstantVector, Copy, CreatePermutation, CrossProduct, DeleteColumn, DeleteRow, Determinant, Diagonal, DiagonalMatrix, Dimension, Dimensions, DotProduct, EigenConditionNumbers, Eigenvalues, Eigenvectors, Equal, ForwardSubstitute, FrobeniusForm, GaussianElimination, GenerateEquations, GenerateMatrix, Generic, GetResultDataType, GetResultShape, GivensRotationMatrix, GramSchmidt, HankelMatrix, HermiteForm, HermitianTranspose, HessenbergForm, HilbertMatrix, HouseholderMatrix, IdentityMatrix, IntersectionBasis, IsDefinite, IsOrthogonal, IsSimilar, IsUnitary, JordanBlockMatrix, JordanForm, KroneckerProduct, LA_Main, LUDecomposition, LeastSquares, LinearSolve, LyapunovSolve, Map, Map, MatrixAdd, MatrixExponential, MatrixFunction, MatrixInverse, MatrixMatrixMultiply, MatrixNorm, MatrixPower, MatrixScalarMultiply, MatrixVectorMultiply, MinimalPolynomial, Minor, Modular, Multiply, NoUserValue, Norm, Normalize, NullSpace, OuterProductMatrix, Permanent, Pivot, PopovForm, QRDecomposition, RandomMatrix, RandomVector, Rank, RationalCanonicalForm, ReducedRowEchelonForm, Row, RowDimension, RowOperation, RowSpace, ScalarMatrix, ScalarMultiply, ScalarVector, SchurForm, SingularValues, SmithForm, StronglyConnectedBlocks, SubMatrix, SubVector, SumBasis, SylvesterMatrix, SylvesterSolve, ToeplitzMatrix, Trace, Transpose, TridiagonalForm, UnitVector, VandermondeMatrix, VectorAdd, VectorAngle, VectorMatrixMultiply, VectorNorm, VectorScalarMultiply, ZeroMatrix, ZeroVector, Zip Loading plottools (.)
Formulering av uppgiften: Hitta den andragradsyta, centrerad i origo som bäst anpassar sig till mätpunkterna och klassificera ytan: är den en ellipsoid, hyperboloid eller paraboloid eller något annat? x y z 7 3 K 4 K3 5 5 K K K3 K3 K K K K7 En andragradsyta centrerad i origo ges som en andragradsekvation i tre variabler av typen: a x C a y C z C xy C xz C yz = ; a x C a y C z C xy C xz C yz = (.) Utvikning: kvadratisk form Ett sådant uttryck kallas för en kvadratisk form och vänster led kan tolkas mha matriser: X T MX där X T = matrisen x, y, z är en radvektor och X är motsvarande kolonnvektor och M är den symmetriska a M = a ; M = a a (..)
Lösning: Våra mätdata insatt i (.) ger oss sju stycken ekvationer för att bestämma koeffecienterna i, i =...6. Dessa ekvationer ger oss följande matrissystem Aa=b, där 4 49 9 4 6 a 6 K K4 4 a A d 9 4 K3 K6 5 5 5 K5 K5 ; a = ; b d ; 4 9 6 K K3 9 K3 3 K 49 7 7 4 49 9 4 6 6 K K4 4 9 4 K3 K6 5 5 5 K5 K5 4 9 6 K K3 9 K3 3 K 49 7 7 a a a =
(3.) Vi ställer upp normalekvationens A T A a = A T b matriser ATA d MatrixMatrixMultiply Transpose A, A ; ATb d MatrixVectorMultiply Transpose A, b ; 74 877 43 675 K77 K57 877 39 577 335 75 833 43 577 757 75 337 563 675 335 75 877 K57 75 K77 75 337 K57 43 75 K57 833 563 75 75 577 Nu löser vi normalekvationen: a d LinearSolve ATA, ATb ; 45 95 8 39 7 7 (3.)
396049456 57344855 74836503 44644897 4884780 44644897 K 836430976 9077404885 K 66964556 9077404885 K 9068409784 57344855 Andragradspolynomet i tre variabler i vänster led av Ekvation (.) blir nu (3.3) Q x, y, z d a $x C a $y C $z C $x$y C $x$z C $y$z; x, y, z /a x C a y C z C x y C x z C y z (3.4) Notera att a,..., anger de respektive elementen i kolonnvektorn a så att t.ex. = 4884780 44644897. Vi ska sedan plotta de värden på variablerna x, y och z som gör att detta polynom blir, vilket blir den ellipsoid vi söker. Plottning: Vi börjar med att plotta våra "mätpunkter": 7 3 K 4 K3 5 5 K K K3 K3 K K K K7
B d 7 3 K 4 K3 5 5 K K K3 K3 K K K K7 ; 7 3 K 4 K3 5 5 K K K3 K3 K K K K7 with plots ; animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fieldplot, fieldplot3d, gradplot, gradplot3d, graphplot3d, implicitplot, implicitplot3d, inequal, interactive, interactiveparams, intersectplot, listcontplot, listcontplot3d, listdensityplot, listplot, listplot3d, loglogplot, logplot, matrixplot, multiple, odeplot, pareto, plotcompare, pointplot, pointplot3d, polarplot, polygonplot, polygonplot3d, polyhedra_supported, polyhedraplot, rootlocus, semilogplot, setcolors, setoptions, setoptions3d, spacecurve, sparsematrixplot, surfdata, textplot, textplot3d, tubeplot plot d pointplot3d B, symbol = diagonalcross, color = red ; PLOT3D... plot d implicitplot3d Q x, y, z =, x =K7..7, y =K7..7, z =K7..7, numpoints = 50000 ; [Length of output exceeds limit of 000000] display plot, plot ; (4.) (4.) (4.3) (4.4)
Observera att man kan rotera bilden genom att klicka och dra med musen. Jag har högerklickat på bilden och valt axes>boxed. Man kan också högerklicka och välja olika sätt att rendera bilden tex style, color, glossiness etc...experimentera själva! Vi ser ju från denna bild att ytan inte är en ellipsoid utan en enmantlad hyperboloid. Vi ska titta på matrisen som dess kvadratiska form ger a M d a ;
MM d evalf % ; 396049456 57344855 K 0985488 9077404885 K 80846378 9077404885 396049456 57344855 K0.0573359 K 0985488 9077404885 74836503 44644897 K 95340489 57344855 K 80846378 9077404885 K 95340489 57344855 4884780 44644897 K0.0573359 K0.0437805063 74836503 44644897 K0.0437805063 K0.066588089 evalf ger numeriska approximativa värden. Eigenvalues MM ; 0.063095863 0.900 K0.0090093 K0.066588089 4884780 44644897 Från detta ser vi alltså att vi har två positiva egenvärden och ett negativt vilket ger att den kvadratiska formen Q inte är positivt definit utan indefinit (Theorem 5 kapitel 7. i Lay). Endast i fallet då alla egenvärden är positiva har vi en ellipsoid. (4.5) (4.6) (4.7) Referenser http://sv.wikipedia.org/wiki/andragradsyta