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

 
 

bug #57726: [octave forge] (symbolic) dsolve should return expression instead of equation

Submitter:  Jing-Chen Peng <jcpeng>
Submitted:  Sun 02 Feb 2020 03:49:13 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  jcpeng Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 12 Sep 2022 12:29:53 PM UTC, comment #11: 

yes, appears to have been fixed with https://github.com/cbm755/octsympy/pull/1168

closing report.

Nicholas Jankowski <nrjank>
Group Member
Sun 11 Sep 2022 11:58:20 PM UTC, comment #10: 

Looks complete.

https://github.com/cbm755/octsympy/issues/1003
Was closed on July 4 2022

Anonymous
Mon 03 Feb 2020 11:29:53 PM UTC, comment #9: 

Thanks! I'll look into it there.

Jing-Chen Peng <jcpeng>
Mon 03 Feb 2020 11:26:48 PM UTC, comment #8: 

If you are comfortable with GitHub, you can also report the details as an issue here: https://github.com/cbm755/octsympy/issues. And if you're interested in helping to fix this, I'm sure a patch or a PR would be very welcome.

Mike Miller <mtmiller>
Group Member
Mon 03 Feb 2020 10:48:46 PM UTC, comment #7: 

Yes, that looks correct.

Thanks!

Jing-Chen Peng <jcpeng>
Mon 03 Feb 2020 10:42:07 PM UTC, comment #6: 

Ok, I verified that the complete example does run in Matlab, thank you. If you look closer, you can see that the main difference is the return value of 'dsolve'. In Matlab, 'dsolve' returns an expression, but Octave 'dsolve' returns an equality.

If you run 'rhs' on the return value of Octave 'dsolve', you get the same answer as Matlab.

So the compatibility bug here is that 'dsolve' should not return an equality like "y(t) == expr", it should just return "expr". Does that look right to you?

Reopening and changing the summary.

Mike Miller <mtmiller>
Group Member
Mon 03 Feb 2020 10:27:23 PM UTC, comment #5: 

The following code runs just fine in matlab:

clear all
clc
syms y(t)
dy = diff(y)
deq = diff(y, 2) + dy + y == 0
soln = dsolve(deq, y(0) == 1, dy(0) ==  0)
y_eval = double(vpa(subs(soln, t, 4)))

Sorry for the messy post / double post, first time on the forums and having a bit of trouble getting around haha

Jing-Chen Peng <jcpeng>
Mon 03 Feb 2020 10:13:59 PM UTC, comment #4: 

Ok, this also doesn't work in Matlab. As far as I can tell this type of expression is not meant to work, conversion from an equality to a double constant does not automatically extract the right-hand side of the equation. Do you have evidence or examples that work in Matlab that show it should work?

In the future, please paste a plain text example instead of a screenshot, so that another user like me can copy and paste the text instead of having to retype from the screenshot.

I don't think this change is appropriate since it is already quite simple for the user to get the double value by using the 'rhs' function. Closing as won't fix.

Mike Miller <mtmiller>
Group Member
Mon 03 Feb 2020 08:58:23 AM UTC, comment #3: 


comment #2:

>
> comment #1:
> > Thank you for your bug report. Can you please complete it by giving a small self contained example that demonstrates the original error with 'vpa' and 'double' that you found?
>
>

Jing-Chen Peng <jcpeng>
Mon 03 Feb 2020 08:56:09 AM UTC, comment #2: 


comment #1:

> Thank you for your bug report. Can you please complete it by giving a small self contained example that demonstrates the original error with 'vpa' and 'double' that you found?



Jing-Chen Peng <jcpeng>
Mon 03 Feb 2020 08:26:59 AM UTC, comment #1: 

Thank you for your bug report. Can you please complete it by giving a small self contained example that demonstrates the original error with 'vpa' and 'double' that you found?

Mike Miller <mtmiller>
Group Member
Sun 02 Feb 2020 03:49:13 PM UTC, original submission:  

I was messing around with the symbolic package and wanted to evaluate a symbolic expression with subs(), vpa(), and double(), but vpa() in octave returns an equality object which can't be converted to a complex or floating point number directly in python.

The new python code for double():
  cmd = { '(x,) = _ins'
          'if x == zoo:'  % zoo -> Inf + Infi
          '    return (float(sp.oo), float(sp.oo))'
          'if x == nan:'
          '    return (float(nan), 0.0)'
          % Adding check for Eq type to evaluate vpa()'d symbolic
          %     variables.
          'if isinstance(x, Eq):'
          '    x = complex(x.rhs)'
          '    return (x.real, x.imag)'
          'x = complex(x)'
          'return (x.real, x.imag)'
        };

Jing-Chen Peng <jcpeng>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #48342:  matlab.m added by jcpeng (155B - application/octet-stream - The following code works in matlab.)
file #48336:  octave.png added by jcpeng (16KiB - image/png - Hi, I've attached an image that sums up everything. I created a differential equation with the symbolic package and solved it, but when I tried to extract the result as a double precision value it would fail because even the vpa())

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by jcpeng (Submitted the item)
  • -email is unavailable- added by jcpeng
  •  

    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 16 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-09-12 nrjank StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2020-02-03 mtmiller Item GroupOther Matlab Compatibility
        StatusWont Fix Confirmed
        Open/ClosedClosed Open
        Release5.1.0 dev
        Operating SystemMicrosoft Windows Any
        Summary[octave forge] (symbolic) double not working on symbolic expressions [octave forge] (symbolic) dsolve should return expression instead of equation
    2020-02-03 jcpeng Attached File- Added matlab.m, #48342
    2020-02-03 mtmiller StatusNeed Info Wont Fix
        Open/ClosedOpen Closed
    2020-02-03 jcpeng Attached File- Added octave.png, #48336
    2020-02-03 mtmiller CategoryOctave Function Octave Package
        StatusNone Need Info
        Summarydouble() not working on the symbolic expressions [octave forge] (symbolic) double not working on symbolic expressions
    2020-02-02 jcpeng Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code