bugGNU Octave - Bugs: bug #49950, ode scripts: error on NormControl

 
 

bug #49950: ode scripts: error on NormControl

Submitter:  Chiara Segala <chiarasegala>
Submitted:  Thu 29 Dec 2016 04:05:00 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.2.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 09 Jan 2017 11:02:04 PM UTC, comment #2: 

It doesn't seem like the calculation, when norm was on, was at all correct.  The Matlab stopping condition is at http://www.mathworks.com/help/matlab/ref/odeset.html and is


norm(e(i)) <= max(RelTol*norm(y(i)),AbsTol(i))


I changed the code to


  if (normcontrol)
    sc = max (AbsTol, RelTol * max (sqrt (sumsq (x)), sqrt (sumsq (x_old))));
    retval = sqrt (sumsq ((x - y))) / sc;
  else
    sc = max (AbsTol, RelTol .* max (abs (x), abs (x_old)));
    retval = max (abs (x - y) ./ sc);
  endif


and checked it in here (http://hg.savannah.gnu.org/hgweb/octave/rev/4b5efc5d52a9).

Rik <rik5>
Group administrator
Thu 29 Dec 2016 11:38:33 PM UTC, comment #1: 

Adding Carlo to the CC list for this bug report.  The diagnosis by Chiara looks correct and the if branches need to be flipped in AbsRel_norm.m.

Rik <rik5>
Group administrator
Thu 29 Dec 2016 04:05:00 PM UTC, original submission:  

The help of odeset.m says
"NormControl
Control error relative to the 2-norm of the solution, rather than its
absolute value."
But then does the opposite.
In integrate_adaptive.m:

dt = starting_stepsize (order, func, t, x,
                            options.AbsTol, options.RelTol,
                            strcmp (options.NormControl, "on"),
                            options.funarguments);

in AbsRel_norm.m:

  if (normcontrol)
    retval = max (abs (x - y) ./ sc);
  else
    retval = sqrt ((1 / n) * sumsq ((x - y) ./ sc));
  endif

It needs to flip the previous "if".

Chiara Segala <chiarasegala>

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by chiarasegala (Submitted the item)
  •  

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

    Date Changed by Updated Field Previous Value => Replaced by
    2017-01-09 rik5 StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2016-12-29 rik5 StatusNone In Progress
        Carbon-Copy- Added cdf

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code