<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic QUAD function evaluation for a complex objective function in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/QUAD-function-evaluation-for-a-complex-objective-function/m-p/198354#M2057</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The following code finds the root of an objective function when the INTERVAL (see in red below) is chosen carefully to be {1,3} but fails to produce when the interval is chosen as {0 3} for example. The problem is that in order for function FUN1 to work (C+ZBETA1-U) has to be &amp;gt; 0; is there any way to specify a general interval like {-3,3} but the code can still work?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC IML;&lt;/P&gt;&lt;P&gt;START FUN1(U) GLOBAL(C,ZBETA1,H,K,ALPHA);&lt;/P&gt;&lt;P&gt;/*SELECT THE VALUE OF C SUCH THAT THE DENOMINATOR BECOMES POSITIVE*/;&lt;/P&gt;&lt;P&gt;IF (C+ZBETA1-U)&amp;gt;0 THEN DO;&lt;/P&gt;&lt;P&gt;ARG = (C*(C+ZBETA1)-U**2)/SQRT((C+ZBETA1)**2-U**2);&lt;/P&gt;&lt;P&gt;YY = CDF("NORMAL", ARG)*PDF("NORMAL", U);&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;IF (C+ZBETA1-U)&amp;lt;=0 THEN RETURN(0);;&lt;/P&gt;&lt;P&gt;RETURN(YY);&lt;/P&gt;&lt;P&gt;FINISH;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START FUN2(PARAM) GLOBAL(C,ZBETA1,H,K,ALPHA);&lt;/P&gt;&lt;P&gt;C = PARAM;&lt;/P&gt;&lt;P&gt;K1 = K&amp;gt;&amp;lt;(C+ZBETA1);&lt;/P&gt;&lt;P&gt;CALL QUAD(INT,"FUN1", H || K1);&lt;/P&gt;&lt;P&gt;FF = 1 - CDF("NORMAL",H) - ALPHA - INT;&lt;/P&gt;&lt;P&gt;RETURN(FF);&lt;/P&gt;&lt;P&gt;FINISH;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;H = 1; &lt;/P&gt;&lt;P&gt;K = 2.76;&lt;/P&gt;&lt;P&gt;ALPHA = 0.025;&lt;/P&gt;&lt;P&gt;BETA1 = 0.2;&lt;/P&gt;&lt;P&gt;ZBETA1 = QUANTILE("NORMAL",1-BETA1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;INTERVALS = {0,3}; /*THIS INTERVAL SHOULD BE SET SUCH THAT THE DENOMINATOR OF INTEGRAND REMAINS POSITIVE*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Z = FROOT("FUN2", INTERVALS);&lt;/P&gt;&lt;P&gt;PRINT Z;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;QUIT;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Mar 2015 17:33:41 GMT</pubDate>
    <dc:creator>KPatra</dc:creator>
    <dc:date>2015-03-10T17:33:41Z</dc:date>
    <item>
      <title>QUAD function evaluation for a complex objective function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/QUAD-function-evaluation-for-a-complex-objective-function/m-p/198354#M2057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The following code finds the root of an objective function when the INTERVAL (see in red below) is chosen carefully to be {1,3} but fails to produce when the interval is chosen as {0 3} for example. The problem is that in order for function FUN1 to work (C+ZBETA1-U) has to be &amp;gt; 0; is there any way to specify a general interval like {-3,3} but the code can still work?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC IML;&lt;/P&gt;&lt;P&gt;START FUN1(U) GLOBAL(C,ZBETA1,H,K,ALPHA);&lt;/P&gt;&lt;P&gt;/*SELECT THE VALUE OF C SUCH THAT THE DENOMINATOR BECOMES POSITIVE*/;&lt;/P&gt;&lt;P&gt;IF (C+ZBETA1-U)&amp;gt;0 THEN DO;&lt;/P&gt;&lt;P&gt;ARG = (C*(C+ZBETA1)-U**2)/SQRT((C+ZBETA1)**2-U**2);&lt;/P&gt;&lt;P&gt;YY = CDF("NORMAL", ARG)*PDF("NORMAL", U);&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;IF (C+ZBETA1-U)&amp;lt;=0 THEN RETURN(0);;&lt;/P&gt;&lt;P&gt;RETURN(YY);&lt;/P&gt;&lt;P&gt;FINISH;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START FUN2(PARAM) GLOBAL(C,ZBETA1,H,K,ALPHA);&lt;/P&gt;&lt;P&gt;C = PARAM;&lt;/P&gt;&lt;P&gt;K1 = K&amp;gt;&amp;lt;(C+ZBETA1);&lt;/P&gt;&lt;P&gt;CALL QUAD(INT,"FUN1", H || K1);&lt;/P&gt;&lt;P&gt;FF = 1 - CDF("NORMAL",H) - ALPHA - INT;&lt;/P&gt;&lt;P&gt;RETURN(FF);&lt;/P&gt;&lt;P&gt;FINISH;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;H = 1; &lt;/P&gt;&lt;P&gt;K = 2.76;&lt;/P&gt;&lt;P&gt;ALPHA = 0.025;&lt;/P&gt;&lt;P&gt;BETA1 = 0.2;&lt;/P&gt;&lt;P&gt;ZBETA1 = QUANTILE("NORMAL",1-BETA1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;INTERVALS = {0,3}; /*THIS INTERVAL SHOULD BE SET SUCH THAT THE DENOMINATOR OF INTEGRAND REMAINS POSITIVE*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Z = FROOT("FUN2", INTERVALS);&lt;/P&gt;&lt;P&gt;PRINT Z;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;QUIT;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 17:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/QUAD-function-evaluation-for-a-complex-objective-function/m-p/198354#M2057</guid>
      <dc:creator>KPatra</dc:creator>
      <dc:date>2015-03-10T17:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: QUAD function evaluation for a complex objective function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/QUAD-function-evaluation-for-a-complex-objective-function/m-p/198355#M2058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What problem are you trying to solve?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 18:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/QUAD-function-evaluation-for-a-complex-objective-function/m-p/198355#M2058</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-03-10T18:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: QUAD function evaluation for a complex objective function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/QUAD-function-evaluation-for-a-complex-objective-function/m-p/198356#M2059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 14.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Hi Rick,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The basic problem is to find the value of C from the equation below where h, k, alpha are provided, capital/small phi are CDF/PDF of normal. The value of C is known to be 1.923 for beta1 = 0.2.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;&lt;IMG alt="a.jpg" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/9525_a.jpg" width="450" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 19:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/QUAD-function-evaluation-for-a-complex-objective-function/m-p/198356#M2059</guid>
      <dc:creator>KPatra</dc:creator>
      <dc:date>2015-03-10T19:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: QUAD function evaluation for a complex objective function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/QUAD-function-evaluation-for-a-complex-objective-function/m-p/198357#M2060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do the limits of integration, H and K, depend on C? The integrand is defined only when&amp;nbsp; -(C+Z) &amp;lt; u &amp;lt; C+Z, so the integral does not make sense if H and K are outside of that interval.&amp;nbsp; In FUN1, you are trying to protect against negative square roots by declaring that FUN1=0 when the term under the square root is negative. This creates a point of discontinuity since lim u-&amp;gt;C+Z from the left is -infinity, but from the right is zero (because of your artificial definition)..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I would try to determine valid values for H and K inside of FUN2 and avoid setting FUN1=0 when the integrand is undefined.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 22:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/QUAD-function-evaluation-for-a-complex-objective-function/m-p/198357#M2060</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-03-10T22:00:23Z</dc:date>
    </item>
  </channel>
</rss>

