Comments on: Double Integration in MATLAB – Understanding Tolerances https://blogs.mathworks.com/loren/2013/12/26/double-integration-in-matlab-understanding-tolerances/?s_tid=feedtopost Loren Shure is interested in the design of the MATLAB language. She is an application engineer and writes here about MATLAB programming and related topics. Tue, 25 Mar 2014 13:01:28 +0000 hourly 1 https://wordpress.org/?v=6.2.2 By: Ben Petschel https://blogs.mathworks.com/loren/2013/12/26/double-integration-in-matlab-understanding-tolerances/#comment-39775 Tue, 25 Mar 2014 13:01:28 +0000 https://blogs.mathworks.com/loren/?p=825#comment-39775 John, you might like to try the evaluation monitor utility PEEK (FEX #44120). For example:

F = @(x,y)exp(10*x).*tan(y)
Fpeek = @(x,y)peek(F(x,y),x,y)
Q1 = integral2(Fpeek,0,1,0,pi/4)
[Fe,Xe,Ye] = peek()

shows that integral2 used 6 function calls on mesh grids of size 14×14, 2×3, 14×14 etc. in R2013b, and you can plot the mesh grids coloured according to their iteration number with:

figure;view(3);colorbar;hold all;
cellfun(@surf,Xe,Ye,Fe,arrayfun(@(k)repmat(k,size(Fe{k})),1:numel(Fe),’Unif’,0)’);

Ben

]]>
By: Mike Hosea https://blogs.mathworks.com/loren/2013/12/26/double-integration-in-matlab-understanding-tolerances/#comment-39305 Fri, 27 Dec 2013 17:11:11 +0000 https://blogs.mathworks.com/loren/?p=825#comment-39305 Hi, John. Thanks for the suggestions. There’s a little bit of “keep it simple” in the interface design of the new integral functions, and I agree that some additional features for programming uses would be helpful. In particular, a return flag or some data structure with information about how the integration went is sometimes what one needs. Conversely, when programming, warnings are more likely to be a nuisance that you have to deal with than something you can use.

As an aside, the number of function evaluations in particular is a traditional metric, but here it is difficult to interpret or use. This is because integral2 houses more than one method, and both methods are highly vectorized.

]]>
By: Loren Shure https://blogs.mathworks.com/loren/2013/12/26/double-integration-in-matlab-understanding-tolerances/#comment-39303 Fri, 27 Dec 2013 02:20:33 +0000 https://blogs.mathworks.com/loren/?p=825#comment-39303 Thanks for the suggestions, John. Will enter them for the team.

–Loren

]]>
By: John D'Errico https://blogs.mathworks.com/loren/2013/12/26/double-integration-in-matlab-understanding-tolerances/#comment-39302 Thu, 26 Dec 2013 20:32:01 +0000 https://blogs.mathworks.com/loren/?p=825#comment-39302 Hi Loren,

I just learned about these tools from this blog, so thanks for the updates. Sometimes we miss the new features in each release, so these are a great way to learn. A few thoughts…

I’d like to see more output information, for example, how many function evals were taken? A nice idea is to return an exit flag, much as the optimization tools do. That flag might indicate whether the result meets the stopping tolerances, or if some problem was identified. So if an exitflag output is returned, then no warning messages need be generated, allowing the user to gather that information via an output argument.

John

]]>