📄 peaksfunc.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head> <title>Description of peaksFunc</title> <meta name="keywords" content="peaksFunc"> <meta name="description" content="peaksFunc: Peaks function's value, gradient and Hessian."> <meta http-equiv="Content-Type" content="text/html; charset=big5"> <meta name="generator" content="m2html © 2003 Guillaume Flandin"> <meta name="robots" content="index, follow"> <link type="text/css" rel="stylesheet" href="../m2html.css"></head><body><a name="_top"></a><div><a href="../index.html">Home</a> > <a href="index.html">dcpr</a> > peaksFunc.m</div><!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td><td align="right"><a href="index.html">Index for dcpr <img alt=">" border="0" src="../right.png"></a></td></tr></table>--><h1>peaksFunc</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>peaksFunc: Peaks function's value, gradient and Hessian.</strong></div><h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>function out = peaksFunc(x, y, mode) </strong></div><h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre class="comment"> peaksFunc: Peaks function's value, gradient and Hessian. This function is mainly used in gdDemo.m. All the derivatives were found by using Symbolic Math Toolbox. See the end of this file for details. See also <a href="gdDemo.html" class="code" title="">gdDemo</a>.</pre></div><!-- crossreference --><h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>This function calls:<ul style="list-style-image:url(../matlabicon.gif)"></ul>This function is called by:<ul style="list-style-image:url(../matlabicon.gif)"></ul><!-- crossreference --><h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function out = peaksFunc(x, y, mode)</a>0002 <span class="comment">% peaksFunc: Peaks function's value, gradient and Hessian.</span>0003 <span class="comment">% This function is mainly used in gdDemo.m.</span>0004 <span class="comment">%</span>0005 <span class="comment">% All the derivatives were found by using Symbolic Math Toolbox.</span>0006 <span class="comment">% See the end of this file for details.</span>0007 <span class="comment">%</span>0008 <span class="comment">% See also gdDemo.</span>0009 0010 <span class="comment">% J.-S. Roger Jang, 19960612, 20080801</span>0011 0012 <span class="keyword">if</span> nargin<3, mode=0; <span class="keyword">end</span>0013 0014 <span class="keyword">if</span> mode==0, <span class="comment">% return function value</span>0015 out = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) <span class="keyword">...</span><span class="comment"> </span>0016 - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) <span class="keyword">...</span><span class="comment"> </span>0017 - 1/3*exp(-(x+1).^2 - y.^2); 0018 <span class="keyword">elseif</span> mode==1, <span class="comment">% return gradient</span>0019 fx=-6*(1-x)*exp(-x^2-(y+1)^2)-6*(1-x)^2*x*exp(-x^2-(y+1)^2)-10*(1/5-3*x^2)*exp(-x^2-y^2)+20*(1/5*x-x^3-y^5)*x*exp(-x^2-y^2)-1/3*(-2*x-2)*exp(-(x+1)^2-y^2);0020 fy=3*(1-x)^2*(-2*y-2)*exp(-x^2-(y+1)^2)+50*y^4*exp(-x^2-y^2)+20*(1/5*x-x^3-y^5)*y*exp(-x^2-y^2)+2/3*y*exp(-(x+1)^2-y^2);0021 out = [fx; fy];0022 <span class="keyword">elseif</span> mode==2, <span class="comment">% return Hessian</span>0023 fxx=36*x*exp(-x^2-(y+1)^2)-18*x^2*exp(-x^2-(y+1)^2)-24*x^3*exp(-x^2-(y+1)^2)+12*x^4*exp(-x^2-(y+1)^2)+72*x*exp(-x^2-y^2)-148*x^3*exp(-x^2-y^2)-20*y^5*exp(-x^2-y^2)+40*x^5*exp(-x^2-y^2)+40*x^2*exp(-x^2-y^2)*y^5-2/3*exp(-(x+1)^2-y^2)-4/3*exp(-(x+1)^2-y^2)*x^2-8/3*exp(-(x+1)^2-y^2)*x;0024 fxy=-6*(1-x)*(-2*y-2)*exp(-x^2-(y+1)^2)-6*(1-x)^2*x*(-2*y-2)*exp(-x^2-(y+1)^2)+20*(1/5-3*x^2)*y*exp(-x^2-y^2)-100*y^4*x*exp(-x^2-y^2)-40*(1/5*x-x^3-y^5)*x*y*exp(-x^2-y^2)+2/3*(-2*x-2)*y*exp(-(x+1)^2-y^2);0025 fyy=-6*(1-x)^2*exp(-x^2-(y+1)^2)+3*(1-x)^2*(-2*y-2)^2*exp(-x^2-(y+1)^2)+200*y^3*exp(-x^2-y^2)-200*y^5*exp(-x^2-y^2)+20*(1/5*x-x^3-y^5)*exp(-x^2-y^2)-40*(1/5*x-x^3-y^5)*y^2*exp(-x^2-y^2)+2/3*exp(-(x+1)^2-y^2)-4/3*y^2*exp(-(x+1)^2-y^2);0026 out=[fxx fxy; fxy fyy];0027 <span class="keyword">else</span>0028 error(<span class="string">'Wrong mode value!'</span>);0029 <span class="keyword">end</span>0030 0031 <span class="comment">% The following are commands for symbolic toolbox</span>0032 <span class="comment">%f='3*(1-x)^2*exp(-(x^2)-(y+1)^2)-10*(x/5-x^3-y^5)*exp(-x^2-y^2)-1/3*exp(-(x+1)^2-y^2)';</span>0033 <span class="comment">%fx=simple(diff(f, 'x'))</span>0034 <span class="comment">%fy=simple(diff(f, 'y'))</span>0035 <span class="comment">%fxx=simple(diff(fx, 'x'))</span>0036 <span class="comment">%fxy=simple(diff(fx, 'y'))</span>0037 <span class="comment">%fyy=simple(diff(fy, 'y'))</span></pre></div><hr><address>Generated on Thu 30-Oct-2008 12:53:56 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -