1 view (last 30 days)
Mayur Punekar on 18 May 2015
Commented: Mayur Punekar on 24 May 2015
I inverted a matrix H with entries from quadratic field, e.g., Q(sqrt(3)) and the inverted matrix G gives me entries also from Q(sqrt(3)), e.g., entry at (1,1) is 12 - 8*3^(1/2). However, is there a way to decouple integer coefficient 12 and -8? I want to store these integer values separately.
In fact I want to generate two integer matrices G1 and G2 from G which contains integer coefficients of each entry in G.
Can anyone suggest how can I do it??

Nalini Vishnoi on 20 May 2015
Hi Mayur,
I can think of one way to do what you asked by using Symbolic Math toolbox. It has a function coeffs which can return the coefficients of a polynomial. I have included a small example below demonstrating how to do it.
syms x; % Create a symbolic variable
G = repmat(12-8*x, 10,2); % Create a matrix of polynomials
for i = 1:size(G,2), % Use coeffs column by column
[C(:,i)] = arrayfun(@(z) coeffs(z,x), G(:,i),'Uniformoutput', false);
end
G1 = cellfun(@(x) double(x(1)), C, 'UniformOutput', false); % extract the coefficients as doubles
G1 = cell2mat(G1); % Convert the cell to a matrix
G2 = cellfun(@(x) double(x(2)), C, 'UniformOutput', false);
G2 = cell2mat(G2);
Please note that you can use subs to substitute symbolic variable 'x' with sqrt(3).
I hope this helps.
Nalini
Mayur Punekar on 24 May 2015
Hello Nalini,
Thanks for the reply but unfortunately it didn't solve my problem.
I state my problem more explicitly here. I have a matrix H which has entries from quadratic field Q(3^(1/2)) i.e., entries are in form of h(i,j) = a+b*3^(1/2), where a,b are integers.
H = [0, 0, 1/x, 0, 0, 1/x, 0, 1; 1/x, 0, 0, 0, 0, 1, 0, 1/x; 0, 0, 1, 1/x, 0, 0, 1/x, 0; 0, 1/x, 0, 1, 1/x, 0, 0, 0; 1/x, 1, 0, 0, 0, 1/x, 0, 0; 0, 1/x, 0, 0, 1/x, 0, 1, 0; 0, 0, 0, 1/x, 1, 0, 0, 1/x; 1, 0, 1/x, 0, 0, 0, 1/x, 0];
Now I want to invert this matrix in such a way that the inverted matrix G still has entries of the form G(i,j) = a+b*3^(1/2).
As far as I know, theory suggests that any matrix with entries in Q(3^(1/2)) (or in general Q(D^(1/2)) can be inverted so that the inverted matrix also contains entries from the same field.
I tried many methods but couldn't find a way to get desired results with matlab. Can you suggest a method to solve this problem?
Thanks !

### Categories

Find more on Calculus in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!
{"ft_lang_label":"__label__en","ft_lang_prob":0.829877,"math_prob":0.9862468,"size":1664,"snap":"2023-14-2023-23","text_gpt3_token_len":461,"char_repetition_ratio":0.08915663,"word_repetition_ratio":0.0,"special_character_ratio":0.28665864,"punctuation_ratio":0.14647888,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99355036,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-05-29T15:37:01Z\",\"WARC-Record-ID\":\"<urn:uuid:25d653b8-61b4-4c0f-b078-4de74afca06b>\",\"Content-Length\":\"121881\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a237fd42-ac71-476b-96a9-a9f7bc93d5c1>\",\"WARC-Concurrent-To\":\"<urn:uuid:17dab2b3-2179-4b0c-b93f-94caf60ab77a>\",\"WARC-IP-Address\":\"104.86.80.92\",\"WARC-Target-URI\":\"https://in.mathworks.com/matlabcentral/answers/217386-quadratic-numbers-in-matlab\",\"WARC-Payload-Digest\":\"sha1:4WOTDJBYMUGORMJRQWIG3AM36CYYUGF3\",\"WARC-Block-Digest\":\"sha1:ASPO3TOKN2DQA2QRK3QBVZUT7QFJFOK7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224644867.89_warc_CC-MAIN-20230529141542-20230529171542-00005.warc.gz\"}"}