bugGNU Octave - Bugs: bug #38585, jacobs(x,f) in optim fails on...

 
 

bug #38585: jacobs(x,f) in optim fails on n>2 functions

Submitter:  None
Submitted:  Mon 25 Mar 2013 08:11:01 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  None Assigned to:  None
Originator Name:  Hershal Bhave Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.6.3
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 14 May 2013 06:01:23 AM UTC, comment #3: 

Could someone please close this bug?

Olaf

Olaf Till <i7tiol>
Group Member
Mon 08 Apr 2013 06:42:47 PM UTC, comment #2: 


> BTW, use .' for simple transposing.


This doesn't make a difference here, since idx is the output of find(). I think using ' instead of .' is better in this instance, easier to understand, or at least to me it is.

Jordi GutiƩrrez Hermoso <jordigh>
Group Member
Mon 08 Apr 2013 11:57:57 AM UTC, comment #1: 

I applied the fix, it will be in the next release. Thank you.

BTW, use .' for simple transposing.

Olaf Till <i7tiol>
Group Member
Mon 25 Mar 2013 08:11:01 AM UTC, original submission:  

Hello,

I'm having an issue with jacobs(x,f) in the optim package. The jacobs(x,f) method fails to generate the Jacobian for functions larger than n=2. I can reproduce this behavior by going through one of the examples in my Numerical Analysis 9th Edition Textbook by Burden and Faires (page 651):


f=@(x) [3*x(1)-cos(x(2)*x(3))-1/2; x(1)^2-81*(x(2)+.1)^ 2+sin(x(3))+1.06; exp(-x(1)*x(2))+20*x(3)+(10*pi-3)/3];
x=[.1 .1 -.1];


jacobs(x,f) gives the following error message:

octave:22> jacobs(x,f)
error: jacobs: A(I,J,...) = X: dimensions mismatch
error: called from:
error:   /usr/share/octave/packages/optim-1.2.2/jacobs.m at line 114, column 18


This is due specifically to these lines:

for count = idx(2:end)
  Df(:, count) = imag (f (x(:, count))(:));
endfor


I was able to copy the relevant portions of the code and by replacing "idx(2:end)" with "idx(2:end)'" (I added the Transpose symbol), the correct result was achieved and verified by the example in the book, where "jac(x,f)" is the modified "jacobs(x,f)" method:
octave:23> jac(x,f)
ans =

   3.0000e+00   9.9998e-04  -9.9998e-04
   2.0000e-01  -3.2400e+01   9.9500e-01
  -9.9005e-02  -9.9005e-02   2.0000e+01

I looked into the latest version of the optim package (1.2.2) on this site as well as the one residing in the Arch Linux AUR (1.2.2-1) and was able to reproduce the same bug (the jacobs.m files are exactly the same). The version of Octave in the Arch Linux "extra" repository is marked "out-of-date" (3.6.3-2), so I'm not sure if this is the cause of the error or not, but I think it should be looked into further. Forgive me if the patch file is not correct, I'm pretty new to open-source contributing.

Thank you for your time.

- Hershal

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #27673:  jacobs.m.patch added by None (298B - text/x-patch - Patchfile for jacobs.m)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by cdf (Updated the item)
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by i7tiol (Posted a comment)
  • -email is unavailable- added by None (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-05-14 cdf Open/ClosedOpen Closed
    2013-03-25 None Attached File- Added jacobs.m.patch, #27673

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code