[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #65032] [Octave Forge] (Symbolic) @sym/qr outp
From: |
Liang Tang |
Subject: |
[Octave-bug-tracker] [bug #65032] [Octave Forge] (Symbolic) @sym/qr outputs q1 of q=[q1 q2] |
Date: |
Thu, 14 Dec 2023 08:51:29 -0500 (EST) |
URL:
<https://savannah.gnu.org/bugs/?65032>
Summary: [Octave Forge] (Symbolic) @sym/qr outputs q1 of
q=[q1 q2]
Group: GNU Octave
Submitter: lt1234
Submitted: Thu 14 Dec 2023 01:51:27 PM UTC
Category: Octave Forge Package
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: None
Assigned to: None
Originator Name: lt1234
Originator Email:
Open/Closed: Open
Release: 8.2.0
Discussion Lock: Any
Operating System: Microsoft Windows
Fixed Release: None
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Thu 14 Dec 2023 01:51:27 PM UTC By: Liang Tang <lt1234>
Hi,
There is no Octave compatibility option for me to pick for reporting.
Therefore I picked the matlab compatibility instead.
@sym/qr clearly documents the differences of @sym/qr compared to Octave/qr. [q
r]=@sym/qr(A) behaves the same as Octave [q r] = qr(A, 'econ'). There is no
input argument for @sym/qr to force @sym/qr to output the full q=[q1 q2].
Effectively, for numeric variables, @sym/qr output is a subset of Octave qr.
By reading the documentation, matlab qr and matlab symbolic qr appear to be
equivalent in syntax. It is also known that Octave/qr and Matlab/qr are
compatible. That leaves @sym/qr inconsistent in definition and output, i.e.,
same inputs but different (or subset of) results.
@sym/qr returns the q equivalent to the q of qr with 'econ' argument. There is
no option to output the full q matrix.
sympy 1.12 documentation page 1330 states the same limitation. So the 'econ'
limitation is at sympy, not the symbolic package.
sympy recommends post process the symbolic q1 of the q=[q1 q2] for the full q.
There are three items to note:
(1) sympy recommends Gram-Schmidt but I can not identify the availability of
symbolic Gram-Schmidt in the symbolic package. I think Gram-Schmidt is a
method of sympy matrix object,
similar to a method of an Octave class. Since I have not found any mean to
access the GS method in @sym, with a m file, only numeric values from @sym/qr
can be processed.
(2) The null space of the input matrix A to qr is not unique. Therefore the
q2 of q=[q1 q2] from Octave/qr may not be reproduced. In addition, I think
both Octave and Matlab qr are built-in. It is unclear to me for what a user
can do.
(3) Knowing the matrix null space is not unique, we also find null of @sym and
null of Octave produce different results. I may be able to replace Octave q2
with Octave null(A). But the same cannot be done for @sym. Mathematically
both codes are correct but output values are different. It is about
compatibility, not incorrect results.
I would like you to consider the following. Thanks.
(A) @sym/syntax: delete this option -- Method on @sym: [Q, R] = qr (M).
(B) @sym/syntax: modify this option -- Method on @sym: R = qr (M), replaced
with @sym: R = qr (M, 0)
(C) Documentation: If you agree with the deletion/modification, please update
the text accordingly. Give workaround for the full q if possible.
(D) Investigate the feasibility to implement the @sym/qr [Q, R] = qr (M)
according to the definition of Octave [Q, R] = qr (M).
Example:
% sym qr
ver('symbolic')
pkg load symbolic
% @sym/qr outputs q1
A=sym('A'); A=[sym(1/sqrt(2)) 1/sqrt(2) 0]';
[q_s, r_s]=qr(A);
double(q_s), double(q_s)*double(q_s)', double(q_s)'*double(q_s)
% Octave qr (full q)
[q r ]= qr([1/sqrt(2) 1/sqrt(2) 0]');
q, q*q'
% Octave qr + econ = @sym/qr
[q_e r_e ]= qr([1/sqrt(2) 1/sqrt(2) 0]', 'econ');
q_e, q_e*q_e', q_e'*q_e
% @sym q1 + modified GS, per sympy
[q_G, r_G] = mgson([q(:,1)'; 1 2 3; 4 5 6]') ; % mgson (modofied GS)
downloaded from github for demo purpose
%{
q_G = ...
[-0.7071 -0.1622 0.6882;
-0.7071 0.1622 -0.6882;
0 0.9733 0.2294];
%}
q_G, q_G*q_G'
% this shows the difference for null (same null space uniqueness discussion)
[q r]=qr([1 2 3]'); q(:, 2:end), null([1 2 3]), null([sym('1') sym('2')
sym('3')])
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?65032>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #65032] [Octave Forge] (Symbolic) @sym/qr outputs q1 of q=[q1 q2],
Liang Tang <=