Diagonalizing Matrices in C++: A Beginner's Guide

Click For Summary
SUMMARY

This discussion focuses on diagonalizing matrices using C++ and the Eigen library. The user seeks assistance with solving a second-order equation related to eigenvalues, which is essential for diagonalization. It is clarified that while the characteristic equation is often used to find eigenvalues, numerical routines can bypass this step. Additionally, alternatives like Octave are suggested for those looking for simpler matrix manipulation tools.

PREREQUISITES
  • Understanding of eigenvalues and eigenvectors
  • Familiarity with the Eigen library for C++
  • Knowledge of characteristic equations
  • Basic algebra skills, particularly solving quadratic equations
NEXT STEPS
  • Explore the Eigen library documentation for matrix diagonalization
  • Learn how to compute eigenvalues and eigenvectors using C++
  • Study the concept of characteristic equations in linear algebra
  • Investigate Octave as an alternative for matrix operations
USEFUL FOR

Students learning linear algebra, C++ developers working with mathematical computations, and anyone interested in matrix diagonalization techniques.

drake
Messages
30
Reaction score
2

Homework Statement


Hi :) I want to write a program in c++ to diagonalize given matrix. However, I'm stuck and I don't have any ideas to do it. I found a linear algebra library for c++ but I could not solve my problem because I don't know how to solve a 2nd order equation. Can you help me please?


Homework Equations


How to diagonalize a matrix?


The Attempt at a Solution


This is the library:
http://eigen.tuxfamily.org/index.php?title=Main_Page
this is what diagonalization is:
http://www.math.uconn.edu/~troby/Math2210S14/LT/sec5_3.pdf
 
Physics news on Phys.org
drake said:

Homework Statement


Hi :) I want to write a program in c++ to diagonalize given matrix. However, I'm stuck and I don't have any ideas to do it. I found a linear algebra library for c++ but I could not solve my problem because I don't know how to solve a 2nd order equation. Can you help me please?


Homework Equations


How to diagonalize a matrix?


The Attempt at a Solution


This is the library:
http://eigen.tuxfamily.org/index.php?title=Main_Page
this is what diagonalization is:
http://www.math.uconn.edu/~troby/Math2210S14/LT/sec5_3.pdf

If by "I don't know how to solve a 2nd order equation" you mean an equation of the second order in the unknown eigenvalue λ, there's formulas for that, too.

It's not clear if you are referring to the characteristic equation of a given matrix, which results from trying to find the eigenvalues by expanding a determinant. While this technique is used often to illustrate some properties of the eigenvalues, most numerical routines don't actually require that the user explicitly form and solve the characteristic equation of a matrix.

And if you are too young to know about how to solve quadratic equations, you're also much too young to be diagonalizing innocent matrices.
 
Using the function that calculates the eigenvalues and eigenvectors, you will get a vector of eigenvalues, which correspond to the diagonal entries in D, and a matrix of eigenvectors, which corresponds to P.


SteamKing said:
I
And if you are too young to know about how to solve quadratic equations, you're also much too young to be diagonalizing innocent matrices.
I will humbly disagree with you on that point. I think that a lot of learning and fun can be had working with matrices, even when one hasn't mastered algebra.

To drake: if you just want to play around with matrices, there are easier ways than the approach you are taking. You should get Octave instead, which will be much simpler than using a library in C++.
 

Similar threads

  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 7 ·
Replies
7
Views
8K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K