Quantitative finance collector
C++ Matlab VBA/Excel Java Mathematica R/Splus Net Code Site Other
Oct 6

Is NAG Toolbox Faster Than MATLAB's Fsolve Part II

Posted by abiao at 11:13 | Code » Matlab | Comments(2) | Reads(7847)
This is a follow-up of my post Is NAG Toolbox Faster Than MATLAB's Fsolve? I got a few reply immediately after that, here is a short summary:

1, NAG's c05nb is faster than Matlab's fsolve with almost the same accuracy, but at the cost of additional programming. As mentioned by Michael at his replied post, c05nb speeds up overall computation time by a factor of 3 from 6.5 seconds to 2.32 seconds on average, which is excellent, but he also realizes "It’s pretty clear that the NAG function isn’t as easy to use as MATLAB’s fsolve function", such as transposition problems and the necessity to set global variables. Luckily, Michael confirms it is currently with NAG technical support and should be updated soon.

2, there are other ways to speed up, for example, two vectorization method proposed by Michael at http://www.walkingrandomly.com/?p=2907 and VoR at http://rationalize-this.blogspot.com/2010/10/is-nag-toolbox-faster-than-matlabs.html. It is perfectly fine to use vectorization in Matlab, I didn't pay attention to that since the solo purpose of my original post was to compare the performance of c05nb and fsolve, with the same codes except replacing one command with the other.

Thanks for all your reply and attention, testing process is fun.


Tags: , ,
It looks like the original problem can be rephrased as: A = [[rCOV, -r', -ones(NumAsset,1)];  [r 0 0]; [ones(1,NumAsset) 0 0]];  b = [zeros(NumAsset,1); targetR; 1];    x = Ab;    (see my comment to Mike\'s post)    However, this approach gives a different answer to the fsolve one.  Any thoughts?
@mattmcd, I apologize, there was an error in my code, it should be F(i) = sum(weight.*rCOV(i,:))-lambda*r(i)-mu;
sorry for that.
Pages: 1/1 First page 1 Final page
Add a comment
Emots
Enable HTML
Enable UBB
Enable Emots
Hidden
Remember
Nickname   Password   Optional
Site URI   Email   [Register]