bugGNU Octave - Bugs: bug #53111, [octave forge] (symbolic): does...

 
 

bug #53111: [octave forge] (symbolic): does not simplify results the same as matlab

Submitter:  None
Submitted:  Fri 09 Feb 2018 07:58:18 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.2.1
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 19 Mar 2018 07:27:55 AM UTC, comment #3: 

Thanks, I filed https://savannah.gnu.org/patch/?9604 for the expand thing.

The various simplify operations are not mathematically precise so we don't expect them to be the same between different software (or even different versions of the same software).

Colin Macdonald <cbm>
Sat 10 Feb 2018 07:28:46 AM UTC, comment #2: 

Thank you, this is significantly better.

matlab must internally simplify prior to printing to the command window.


So for me this is an easy fix.

x_d_a=simplify(diff(x,a))


I think this can be closed, and I will just do the above from now on.

---------------------------------------------

I agree with your thoughts about compatibility, since placing the same values in the equation will produce the same final solution.
However, in coursework a professor (or computer) may just see the equations are different, and not award credit.

---------------------------------------------
For some reason I thought if I could expand then everything would go away. So I tried.

help expand
error: help: 'expand' not found


I did not think of:

help simplify
error: help: 'simplify' is a method of class 'sym'; it must be called with a 'sym'
argument (see 'help @sym/simplify').

Please read <http://www.octave.org/missing.html> to learn how you can
contribute missing functionality.




 help @sym/simplify
.
.
.
See also: @sym/isAlways, @sym/factor, @sym/expand, @sym/rewrite




 help @sym/expand
.
.
.
See also: @sym/factor.



Anonymous
Fri 09 Feb 2018 09:23:50 PM UTC, comment #1: 

I don't think it's a compatibility issue if SymPy doesn't expand or combine factors in exactly the same way as Matlab. But I think Colin can speak to this better.

Btw, try


>> simplify (x_d_a)
ans = (sym)

    ⎛   2              2    2              2⎞
  c⋅⎝- X  + 2⋅X⋅X₀ - X₀  - Y  + 2⋅Y⋅Y₀ - Y₀ ⎠
  ───────────────────────────────────────────
                                         2
     ((X - X₀)⋅sin(a) + (-Y + Y₀)⋅cos(a))



This is a little more compact and closer to the Matlab result you have cited.

Mike Miller <mtmiller>
Group Member
Fri 09 Feb 2018 07:58:18 PM UTC, original submission:  

Using
symbolic v2.6.0
sympy v1.1.1



syms c a X X0 Y Y0
U=(X-X0)*cos(a)+(Y-Y0)*sin(a);
W=-(X-X0)*sin(a)+(Y-Y0)*cos(a);
x=-c*(U/W);
x_d_a=diff(x,a)


matlab:From others


x_d_a =
- c - (c*(cos(a)*(X - X0) + sin(a)*(Y - Y0))^2)/(cos(a)*(Y - Y0) - sin(a)*(X - X0))^2


octave: Me

x_d_a = (sym)
    c⋅(-(X - X₀)⋅sin(a) + (Y - Y₀)⋅cos(a))   c⋅(-(-X + X₀)⋅cos(a) + (Y - Y₀)⋅sin(a))⋅((X - X₀)⋅cos(a) + (Y - Y₀)⋅sin(a))
  - ────────────────────────────────────── - ───────────────────────────────────────────────────────────────────────────
      (-X + X₀)⋅sin(a) + (Y - Y₀)⋅cos(a)                                                            2
                                                                ((-X + X₀)⋅sin(a) + (Y - Y₀)⋅cos(a))



Note: the final value is good

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by cbm (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-02-11 mtmiller StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2018-02-09 mtmiller SummarySymbolic does not simplify results the same as matlab [octave forge] (symbolic): does not simplify results the same as matlab
    2018-02-09 rik5 Carbon-CopyRemoved 72865 -
    2018-02-09 rik5 CategoryNone Octave Package

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code