---
title: "Discussion on \"Singular Value Decomposition: From the Math to C++ with Eigen\" | Hashnode"
description: "Discussion on \"Singular Value Decomposition: From the Math to C++ with Eigen\". Understand SVD through a movie ticket example, derive its matrices step by step, and verify the result with C++ and Eigen."
url: "https://hashnode.com/posts/singular-value-decomposition-cpp-eigen/6abcbbfcb50bc14631e37193"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Singular Value Decomposition: From the Math to C++ with Eigen](https://abulasar.com/singular-value-decomposition-cpp-eigen?utm_source=hashnode&utm_medium=feed)

Understand SVD through a movie ticket example, derive its matrices step by step, and verify the result with C++ and Eigen.

Sep 30 · 15 min read · abulasar.com  
Read the article

-   [#svd](https://hashnode.com/tag/svd)
-   [#linear-algebra](https://hashnode.com/tag/linear-algebra)
-   [#cpp](https://hashnode.com/tag/cpp)
-   [#eigen](https://hashnode.com/tag/eigen)
-   [#mathematics](https://hashnode.com/tag/mathematics)
-   [#machine-learning](https://hashnode.com/tag/machine-learning)

## Written by

[AbulAsar S.](https://hashnode.com/@abulasar)

@abulasar · Mumbai, India

  
[View profile](https://hashnode.com/@abulasar)

Elixir |> JS/TS |> C++ |> AI enthusiast

I am a Software Engineer from Mumbai, India. In love with Functional programming ( precisely Elixir). Love to share the knowledge that I learn while developing things.

## Responses 2

Markdown supported · ⌘↵ to post

[Kartik N V J K](https://hashnode.com/@kartik-nvj)

[Oct 1](https://hashnode.com/posts/singular-value-decomposition-cpp-eigen/6abcbbfcb50bc14631e37193/comment/6abead42fdb064aa091862c5)

The ticket-sales matrix is a clean way into this. One thing I would flag for anyone taking it to larger matrices: forming AᵀA explicitly squares the condition number, so for anything ill-conditioned, running Eigen's JacobiSVD or BDCSVD on A directly is more numerically stable than going through the eigen-decomposition of AᵀA. Did you stay with the AᵀA route mainly for the clarity of the derivation?

[AbulAsar S.](https://hashnode.com/@abulasar)

[Oct 1](https://hashnode.com/posts/singular-value-decomposition-cpp-eigen/6abcbbfcb50bc14631e37193/comment/6abead42fdb064aa091862c5#reply-6abec606d3e48dda9f767991)

Yes, exactly. I used the AᵀA route mainly to make the mathematical derivation easier to understand and connect SVD with eigenvalues and eigenvectors. For practical applications, I would use Eigen’s `JacobiSVD` or `BDCSVD` directly on A. Thanks for highlighting it!
