I want to write a programm on Matlab, without using implemented functions. This programm should be similiar to the Matlab function roots. But I am not sure what roots does, is there any possibility to read something like a pseudo-code of roots or eig? Or is it possible to find .m file that fullfills this conditions?
Is roots simply using the QR decomposition with shifts ?

 採用された回答

Sean de Wolski
Sean de Wolski 2015 年 8 月 5 日
編集済み: Sean de Wolski 2015 年 8 月 5 日

0 投票

>>edit roots

7 件のコメント

James Tursa
James Tursa 2015 年 8 月 5 日
Or "type roots" to avoid inadvertently changing the original.
Thomas Waljor
Thomas Waljor 2015 年 8 月 5 日
編集済み: Thomas Waljor 2015 年 8 月 5 日
Already tried this, but Matlab simply uses eig to compute the roots of a polynomial.
If i type in "edit eig", i only see what eig produces and not how eig works.
Same thing with "type roots"
Steven Lord
Steven Lord 2015 年 8 月 5 日
EIG is a built-in function and we do not distribute that source code.
By the way, please ask your professor (I'm assuming this is homework) to be more specific than "without using implemented functions" in his or her assignments. Technically your code will violate that requirement as soon as you assemble the coefficient vector.
x = [1 2 3]; % This concatenates using the built-in HORZCAT function
Thomas Waljor
Thomas Waljor 2015 年 8 月 5 日
It is for my bachelor thesis. I wrote a matlab programm to compute the roots of a polynomial and in the last part of my bachelor thesis I have to compare it to the in Matlab implemented "roots" function. I guess the implemented roots function is writen in C, since I have to reproduce a Matlab code, that is similiar to the roots function to compare my algortihm with the way the "roots" algorithm is computing roots of a polynomial.
Thus I am trying to find out how "roots" / "eig" works.
James Tursa
James Tursa 2015 年 8 月 5 日
編集済み: James Tursa 2015 年 8 月 5 日
@Thomas: You really don't want to write your own code to replace eig ... that is going to be way too involved. What is the reason you want to write an equivalent to roots from scratch?
Thomas Waljor
Thomas Waljor 2015 年 8 月 5 日
For my bachelor thesis I wrote a programm that computes the roots of a polynomial quiet fast. One part of mine assignment is to compare this algorithm with the in Matlab implemented roots function. It is impossible to compare them directly, since I had to use Matlab to programm the first algorithm. Right now I try to figure out how roots computes the roots of a polynomial.
James Tursa
James Tursa 2015 年 8 月 5 日
By looking at the code for roots you have that answer. It constructs a matrix where the characteristic polynomial of that matrix is your polynomial. Then it uses eig to find eigenvalues of that matrix, which will be equal to the roots of the characteristic polynomial.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by