octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #38585] jacobs(x, f) in optim fails on n>2 fun


From: anonymous
Subject: [Octave-bug-tracker] [bug #38585] jacobs(x, f) in optim fails on n>2 functions
Date: Mon, 25 Mar 2013 08:11:03 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22

URL:
  <http://savannah.gnu.org/bugs/?38585>

                 Summary: jacobs(x,f) in optim fails on n>2 functions
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Mon 25 Mar 2013 08:11:01 AM UTC
                Category: Octave Forge Package
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Regression
                  Status: None
             Assigned to: None
         Originator Name: Hershal Bhave
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.6.3
        Operating System: GNU/Linux

    _______________________________________________________

Details:

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



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Mon 25 Mar 2013 08:11:01 AM UTC  Name: jacobs.m.patch  Size: 298B   By:
None
Patchfile for jacobs.m
<http://savannah.gnu.org/bugs/download.php?file_id=27673>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?38585>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]