Sunday, May 29, 2016

Solving the Boundary Value Problem of Gilat and Subramaniam's Example 9.5

Jsun Yui Wong

The following computer program seeks to solve the discrete boundary value problem of Gilat and Subramaniam's Example 9.5  [7]. Also see Gilat and Subramaniam [8, Example 11.5].

0 DEFDBL A-Z
3 DEFINT J, K
4 DIM X(32768), A(32768), P(32768), K(32768)
5 FOR JJJJ = -32000 TO 32000

    14 RANDOMIZE JJJJ
    16 M = -1D+50

    55 H = 1 / 8


    91 FOR KK = 1 TO 9


        94 IF RND < .5 THEN A(KK) = 1 - RND ELSE A(KK) = 1 + RND


    95 NEXT KK

    128 FOR I = 1 TO 100000 STEP 1


        129 FOR K = 1 TO 9


            131 X(K) = A(K)
        132 NEXT K

        155 FOR IPP = 1 TO FIX(1 + RND * 3)
            181 B = 1 + FIX(RND * 9)



            183 R = (1 - RND * 2) * A(B)
            188 IF RND < .2 THEN X(B) = A(B) + RND * R ELSE IF RND < .25 THEN X(B) = A(B) + RND ^ 3 * R ELSE IF RND < .333 THEN X(B) = A(B) + RND ^ 5 * R ELSE IF RND < .5 THEN X(B) = A(B) + RND ^ 7 * R ELSE X(B) = A(B) + RND ^ 9 * R


        199 NEXT IPP

        571 X(1) = 1


        580 X(3) = ((4 + H ^ 2) * X(2) - 2 - H ^ 2 * EXP(-.2 * H)) / 2




        581 FOR J44 = 4 TO 9 STEP 1
            582 X(J44) = (-2 * X(J44 - 2) + (4 + H ^ 2) * X(J44 - 1) - H ^ 2 * EXP(-.2 * (J44 - 2) * H)) / 2


        584 NEXT J44


        610 PNEW = ABS(2 * H * X(9) + X(7) - 4 * X(8) + 3 * X(9))


        1111 P = -PNEW

        1451 IF P <= M THEN 1670
        1657 FOR KEW = 1 TO 9


            1658 A(KEW) = X(KEW)
        1659 NEXT KEW
        1661 M = P
    1670 NEXT I
    1890 REM IF M < -.1 THEN 1999
    1911 PRINT A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), M, JJJJ

1999 NEXT JJJJ

This computer program was run with qb64v1000-win [19]. Copied by hand from the screen, the computer program’s output through JJJJ= -31997 is shown below.

 1                                          .943153486079235             .8860557500807424
 .828448844750844                .7700662000336197            .7106306551757421
 .649852405260003                .5874268461945267            .5230323013901858
-1.110223024625157D-16             -32000

 1                                          .943153486079235             .8860557500807424
 .828448844750844                .7700662000336197            .7106306551757421
 .649852405260003                .5874268461945267            .5230323013901858
-1.110223024625157D-16             -31999

 1                                          .943153486079235             .8860557500807424
 .828448844750844                .7700662000336197            .7106306551757421
 .649852405260003                .5874268461945267            .5230323013901858
-1.110223024625157D-16             -31998

 1                                          .943153486079235             .8860557500807424
 .828448844750844                .7700662000336197            .7106306551757421
 .649852405260003                .5874268461945267            .5230323013901858
-1.110223024625157D-16             -31997

Above there is no rounding by hand; it is just straight copying by hand from the screen.

On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and with qb64v1000-win [19], the wall-clock time for obtaining the output through JJJJ= -31997 was fifteen seconds.

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1] C. G. Broyden, A Class of Methods for Solving Nonlinear Simultaneous Equations, Mathematics of Computation, Vol. 19, Number 92, pp. 577-593, 1965.

[2] R. L. Burden, J. D. Faires, Annette M. Burden. Numerical Analysis, Tenth Edition. Cengage Learning, 2016.

[3] Huiping Cao, Global Convergence of Schubert’s Method for Solving Sparse Nonlinear Equations, Abstract and Applied Analysis, Volume 2014, Article ID 251587, 12 pages. Hindawi Publishing Corporation. http://dx.doi.org/10.1155/2014/251587.

[4] Steven C. Chapra, Applied Numerical Methods with MATLAB for Engineers and Scientists, Third Edition. McGraw-Hill, 2012. http://www.learngroup.org/uploads/2014-10-27/Applied_Num_Methods_with_MATLAB_for_Engineers_3ed1.pdf.

[5] C. A. Floudas, Deterministic Global Optimization. Kluwer Academic Publishers, 2000.

[6] Rendong Ge, Lijun Liu, Yi Xu, Neural Network Approach for Solving Singular Convex Optimization with Bounded Variables, Open Journal of Applied Sciences, 2013, 3, 285-292. Published Online July 2013. http://www.scirp.org/journal/ojapps.

[7] Amos Gilat, Vish Subramaniam, Numerical Methods for Engineers and Scientists: An Introduction with Applications Using MATLAB. Wiley, 2008.

[8] Amos Gilat, Vish Subramaniam, Numerical Methods for Engineers and Scientists: An Introduction with Applications Using MATLAB, 3rd Edition. Wiley, 2014.

[9] Tianmin Han, Yuhuan Han, Solving Large Scale Nonlinear Equations by a New ODE Numerical Integration Method, Applied Mathematics, 2010, 1, 222-229. http://www.SciRP.org/journal/am.

[10] William La Cruz, Jose Mario Martinez, Marcos Raydan, Spectral residual method without gradient information for solving large-scale nonlinear systems of equations: Theory and experiments. Technical Report RT-04-08, July 2004.
http://www.ime.unicamp.br/~martinez/lmrreport.pdf.

[11] William La Cruz, Jose Mario Martinez, Marcos Raydan, Spectral residual method without gradient information for solving large-scale nonlinear systems of equations, Mathematics of Computation, vol. 75, no. 255, pp.1429-1448, 2006.

[12] Guangye Li (1989) Successive column correction algorithms for solving sparse nonlinear systems of equations, Mathematical Programming, 43, pp. 187-207.

[13] Microsoft Corp. BASIC, second edition (May 1982), Version 1.10. Boca Raton, Florida: IBM Corp., Personal Computer, P. O. Box 1328-C, Boca Raton, Florida 33432, 1981.

[14 J. J. More, B. S. Garbow, K. E. Hillstrom (1981) Testing Unconstrained Optimization Software. ACM Transactions on Mathematical Software, Vol. 7, Pages 17-41.

[15] Alexander P. Morgan, A Method for Computing All Solutions to Systems of Polynomial Equations, ACM Transactions on Mathematical Software, Vol. 9, No. 1, March 1983, Pages 1-17. https://folk.uib.no/ssu029/pdf_file/Morgan83.pdf.

[16] NAG, NAG Fortran Library Routine Document, C05PDF/C05PDA.
http://www.nag.com/numeric/FL/manual/pdf/C05/c05pdf.pdf.

[17] W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery. Numerical recipes: the art of scientific computing, third ed. Cambridge University Press, 2007.

[18] J. Rice. Numerical Methods, Software, and Analysis, Second Edition. Academic Press, 1993.

[19] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64.

[20] J. Y. Wong. April 27 2016. The Domino Method of Nonlinear Integer/Continuous/Discrete Programming Seeking To
Solve a 19X19 System of Nonlinear Equations, Fourth Edition.
http://myblogsubstance.typepad.com/substance/2016/04/-the-domino-method-of-nonlinear-integercontinuousdiscrete-programming-seeking-to-solve-a-19x19-syste.html.

[21] M. Ziani, F. Guyomarc’h, An Autoadaptive Limited Memory Broyden’s Method To Solve Systems of Nonlinear Equations, Applied Mathematics and Computation 205 (2008) pp. 202-211. web.info.uvt.ro/~cristiana.drogoescu/MC/broyden.pdf.

Monday, May 23, 2016

Solving a Boundary Value Problem, Part 2

Jsun Yui Wong

The following computer program seeks to solve the system of nonlinear equations of the discrete boundary value problem on pp. 402-405 of Gilat and Subramanian [6, Example 9.4].  Also see Gilat and Subramanian [7].  While the preceding paper has five sub-intervals, the present paper has twenty sub-intervals.  

0 DEFDBL A-Z
3 DEFINT J, K
4 DIM X(32768), A(32768), P(32768), K(32768)
5 FOR JJJJ = -32000 TO 32000

    14 RANDOMIZE JJJJ
    16 M = -1D+50

    33 betaa = (40 * .016) / (240 * 1.6D-05)

    35 betab = (.4 * 5.67D-08 * .016) / (240 * 1.6D-05)


    91 FOR KK = 1 TO 21


        94 A(KK) = 293 + RND * 200


    95 NEXT KK

    128 FOR I = 1 TO 20000000 STEP 1


        129 FOR K = 1 TO 21


            131 X(K) = A(K)
        132 NEXT K

        155 FOR IPP = 1 TO FIX(1 + RND * 3)
            181 B = 1 + FIX(RND * 22)


            183 R = (1 - RND * 2) * A(B)
            188 IF RND < .2 THEN X(B) = A(B) + RND * R ELSE IF RND < .25 THEN X(B) = A(B) + RND ^ 3 * R ELSE IF RND < .333 THEN X(B) = A(B) + RND ^ 5 * R ELSE IF RND < .5 THEN X(B) = A(B) + RND ^ 7 * R ELSE X(B) = A(B) + RND ^ 9 * R


        199 NEXT IPP
        566 X(1) = 473

        577 X(21) = 293


        605 FOR J49 = 21 TO 3 STEP -1

            610 P(J49) = X(J49 - 2) - (2 + .005 ^ 2 * betaa) * X(J49 - 1) - .005 ^ 2 * betab * X(J49 - 1) ^ 4 + X(J49) + .005 ^ 2 * (betaa * 293 + betab * 293 ^ 4)

        612 NEXT J49

        660 PS = 0

        661 FOR J33 = 21 TO 3 STEP -1


            663 PS = PS + ABS(P(J33))


        668 NEXT J33


        1111 P = -PS



        1451 IF P <= M THEN 1670
        1657 FOR KEW = 1 TO 21


            1658 A(KEW) = X(KEW)
        1659 NEXT KEW
        1661 M = P
    1670 NEXT I
    1890 REM IF M < -.1 THEN 1999


    1911 PRINT A(1), A(2), A(3), A(4), A(5)

    1912 PRINT A(6), A(7), A(8), A(9), A(10)

    1913 PRINT A(11), A(12), A(13), A(14), A(15)

    1914 PRINT A(16), A(17), A(18), A(19), A(20)

    1919 PRINT A(21), M, JJJJ

1999 NEXT JJJJ

This computer program was run with qb64v1000-win [18]. Copied by hand from the screen, the computer program’s complete output through JJJJ= -32000 is shown below.

473                                    459.455895068255           446.6932249241943
434.6475924043841         423.2590645622598
412.4716933656588         402.2330921869252         392.4940590698486
383.2082393784908         374.331821732474
365.8232621978106         357.6430325441322         349.7533890177581
342.1181586515432         334.7025405843482
327.4729202056817         320.3966942320405         313.442105080995
306.5780831026808         299.7740953874252
293                                   -2.877462553516411D-08         -32000

Above there is no rounding by hand; it is just straight copying by hand from the screen.

On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and with qb64v1000-win [18], the wall-clock time for obtaining the output through JJJJ= -32000 was four minutes.

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1] C. G. Broyden, A Class of Methods for Solving Nonlinear Simultaneous Equations, Mathematics of Computation, Vol. 19, Number 92, pp. 577-593, 1965.

[2] R. L. Burden, J. D. Faires, Annette M. Burden. Numerical Analysis, Tenth Edition. Cengage Learning, 2016.

[3] Huiping Cao, Global Convergence of Schubert’s Method for Solving Sparse Nonlinear Equations, Abstract and Applied Analysis, Volume 2014, Article ID 251587, 12 pages. Hindawi Publishing Corporation. http://dx.doi.org/10.1155/2014/251587.

[4] C. A. Floudas, Deterministic Global Optimization. Kluwer Academic Publishers, 2000.

[5] Rendong Ge, Lijun Liu, Yi Xu, Neural Network Approach for Solving Singular Convex Optimization with Bounded Variables, Open Journal of Applied Sciences, 2013, 3, 285-292. Published Online July 2013. http://www.scirp.org/journal/ojapps.

[6] Amos Gilat, Vish Subramaniam, Numerical Methods for Engineers and Scientists: An Introduction with Applications Using MATLAB.  Wiley, 2008.

[7] Amos Gilat, Vish Subramaniam, Numerical Methods for Engineers and Scientists: An Introduction with Applications Using MATLAB, 3rd Edition.  Wiley, 2014.

[8] Tianmin Han, Yuhuan Han, Solving Large Scale Nonlinear Equations by a New ODE Numerical Integration Method, Applied Mathematics, 2010, 1, 222-229.  http://www.SciRP.org/journal/am.

[9] William La Cruz, Jose Mario Martinez, Marcos Raydan, Spectral residual method without gradient information for solving large-scale nonlinear systems of equations: Theory and experiments. Technical Report RT-04-08, July 2004.
http://www.ime.unicamp.br/~martinez/lmrreport.pdf.

[10] William La Cruz, Jose Mario Martinez, Marcos Raydan, Spectral residual method without gradient information for solving large-scale nonlinear systems of equations, Mathematics of Computation, vol. 75, no. 255, pp.1429-1448, 2006.

[11] Guangye Li (1989) Successive column correction algorithms for solving sparse nonlinear systems of equations, Mathematical Programming, 43, pp. 187-207.

[12] Microsoft Corp. BASIC, second edition (May 1982), Version 1.10. Boca Raton, Florida: IBM Corp., Personal Computer, P. O. Box 1328-C, Boca Raton, Florida 33432, 1981.

[13 J. J. More, B. S. Garbow, K. E. Hillstrom (1981) Testing Unconstrained Optimization Software. ACM Transactions on Mathematical Software, Vol. 7, Pages 17-41.

[14] Alexander P. Morgan, A Method for Computing All Solutions to Systems of Polynomial Equations, ACM Transactions on Mathematical Software, Vol. 9, No. 1, March 1983, Pages 1-17. https://folk.uib.no/ssu029/pdf_file/Morgan83.pdf.

[15] NAG, NAG Fortran Library Routine Document, C05PDF/C05PDA.
http://www.nag.com/numeric/FL/manual/pdf/C05/c05pdf.pdf.

[16] W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery. Numerical recipes: the art of scientific computing, third ed. Cambridge University Press, 2007.

[17] J. Rice. Numerical Methods, Software, and Analysis, Second Edition. Academic Press, 1993.

[18] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64.

[19] J. Y. Wong. April 27 2016. The Domino Method of Nonlinear Integer/Continuous/Discrete Programming Seeking To
Solve a 19X19 System of Nonlinear Equations, Fourth Edition.
http://myblogsubstance.typepad.com/substance/2016/04/-the-domino-method-of-nonlinear-integercontinuousdiscrete-programming-seeking-to-solve-a-19x19-syste.html.

[20] M. Ziani, F. Guyomarc’h, An Autoadaptive Limited Memory Broyden’s Method To Solve Systems of Nonlinear Equations, Applied Mathematics and Computation 205 (2008) pp. 202-211. web.info.uvt.ro/~cristiana.drogoescu/MC/broyden.pdf.

Sunday, May 22, 2016

Solving a Boundary Value Problem

Jsun Yui Wong

The following computer program seeks to solve the system of nonlinear equations of the discrete boundary value problem on pages 402-405 of Gilat and Subramanian [6, Example 9.4].  Also see Gilat and Subramanian [7].    

0 DEFDBL A-Z
3 DEFINT J, K
4 DIM X(32768), A(32768), P(32768), K(32768)
5 FOR JJJJ = -32000 TO 32000

    14 RANDOMIZE JJJJ
    16 M = -1D+50

    33 betaa = (40 * .016) / (240 * 1.6D-05)

    35 betab = (.4 * 5.67D-08 * .016) / (240 * 1.6D-05)

    91 FOR KK = 1 TO 6


        94 A(KK) = 293 + RND * 200

    95 NEXT KK

    128 FOR I = 1 TO 100000 STEP 1


        129 FOR K = 1 TO 6

            131 X(K) = A(K)
        132 NEXT K

        155 FOR IPP = 1 TO FIX(1 + RND * 3)
            181 B = 1 + FIX(RND * 6)

            183 R = (1 - RND * 2) * A(B)
            188 IF RND < .2 THEN X(B) = A(B) + RND * R ELSE IF RND < .25 THEN X(B) = A(B) + RND ^ 3 * R ELSE IF RND < .333 THEN X(B) = A(B) + RND ^ 5 * R ELSE IF RND < .5 THEN X(B) = A(B) + RND ^ 7 * R ELSE X(B) = A(B) + RND ^ 9 * R

        199 NEXT IPP
        566 X(1) = 473

        577 X(6) = 293



        605 FOR J49 = 6 TO 3 STEP -1

            610 P(J49) = X(J49 - 2) - (2 + .02 ^ 2 * betaa) * X(J49 - 1) - .02 ^ 2 * betab * X(J49 - 1) ^ 4 + X(J49) + .02 ^ 2 * (betaa * 293 + betab * 293 ^ 4)


        612 NEXT J49

        660 PS = 0

        661 FOR J33 = 6 TO 3 STEP -1


            663 PS = PS + ABS(P(J33))


        668 NEXT J33


        1111 P = -PS



        1451 IF P <= M THEN 1670
        1657 FOR KEW = 1 TO 6

            1658 A(KEW) = X(KEW)
        1659 NEXT KEW
        1661 M = P
    1670 NEXT I
    1890 REM IF M < -.1 THEN 1999

    1911 PRINT A(1), A(2), A(3), A(4), A(5)

    1919 PRINT A(6), M, JJJJ

1999 NEXT JJJJ

This computer program was run with qb64v1000-win [18]. Copied by hand from the screen, the computer program’s complete output through JJJJ= -31999 is shown below.

473                                    423.3441267021215           383.3134062263356    
349.8410248260544         320.4456637140555    
293                                   -3.890045567611633D-07    -32000

473                                    423.3441269631637           383.313406594297    
349.8410252159446         320.4456639230223    
293                                   -1.725536257490834D-07    -31999

Above there is no rounding by hand; it is just straight copying by hand from the screen.

On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and with qb64v1000-win [18], the wall-clock time for obtaining the output through JJJJ= -31999 was five seconds, not including "Creating .EXEC file..." time.

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1] C. G. Broyden, A Class of Methods for Solving Nonlinear Simultaneous Equations, Mathematics of Computation, Vol. 19, Number 92, pp. 577-593, 1965.

[2] R. L. Burden, J. D. Faires, Annette M. Burden. Numerical Analysis, Tenth Edition. Cengage Learning, 2016.

[3] Huiping Cao, Global Convergence of Schubert’s Method for Solving Sparse Nonlinear Equations, Abstract and Applied Analysis, Volume 2014, Article ID 251587, 12 pages. Hindawi Publishing Corporation. http://dx.doi.org/10.1155/2014/251587.

[4] C. A. Floudas, Deterministic Global Optimization. Kluwer Academic Publishers, 2000.

[5] Rendong Ge, Lijun Liu, Yi Xu, Neural Network Approach for Solving Singular Convex Optimization with Bounded Variables, Open Journal of Applied Sciences, 2013, 3, 285-292. Published Online July 2013. http://www.scirp.org/journal/ojapps.

[6] Amos Gilat, Vish Subramaniam, Numerical Methods for Engineers and Scientists: An Introduction with Applications Using MATLAB.  Wiley, 2008.

[7] Amos Gilat, Vish Subramaniam, Numerical Methods for Engineers and Scientists: An Introduction with Applications Using MATLAB, 3rd Edition.  Wiley, 2014.

[8] Tianmin Han, Yuhuan Han, Solving Large Scale Nonlinear Equations by a New ODE Numerical Integration Method, Applied Mathematics, 2010, 1, 222-229.  http://www.SciRP.org/journal/am.

[9] William La Cruz, Jose Mario Martinez, Marcos Raydan, Spectral residual method without gradient information for solving large-scale nonlinear systems of equations: Theory and experiments. Technical Report RT-04-08, July 2004.
http://www.ime.unicamp.br/~martinez/lmrreport.pdf.

[10] William La Cruz, Jose Mario Martinez, Marcos Raydan, Spectral residual method without gradient information for solving large-scale nonlinear systems of equations, Mathematics of Computation, vol. 75, no. 255, pp.1429-1448, 2006.

[11] Guangye Li (1989) Successive column correction algorithms for solving sparse nonlinear systems of equations, Mathematical Programming, 43, pp. 187-207.

[12] Microsoft Corp. BASIC, second edition (May 1982), Version 1.10. Boca Raton, Florida: IBM Corp., Personal Computer, P. O. Box 1328-C, Boca Raton, Florida 33432, 1981.

[13 J. J. More, B. S. Garbow, K. E. Hillstrom (1981) Testing Unconstrained Optimization Software. ACM Transactions on Mathematical Software, Vol. 7, Pages 17-41.

[14] Alexander P. Morgan, A Method for Computing All Solutions to Systems of Polynomial Equations, ACM Transactions on Mathematical Software, Vol. 9, No. 1, March 1983, Pages 1-17. https://folk.uib.no/ssu029/pdf_file/Morgan83.pdf.

[15] NAG, NAG Fortran Library Routine Document, C05PDF/C05PDA.
http://www.nag.com/numeric/FL/manual/pdf/C05/c05pdf.pdf.

[16] W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery. Numerical recipes: the art of scientific computing, third ed. Cambridge University Press, 2007.

[17] J. Rice. Numerical Methods, Software, and Analysis, Second Edition. Academic Press, 1993.

[18] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64.

[19] J. Y. Wong. April 27 2016. The Domino Method of Nonlinear Integer/Continuous/Discrete Programming Seeking To Solve a 19X19 System of Nonlinear Equations, Fourth Edition.
http://myblogsubstance.typepad.com/substance/2016/04/-the-domino-method-of-nonlinear-integercontinuousdiscrete-programming-seeking-to-solve-a-19x19-syste.html.

[20] M. Ziani, F. Guyomarc’h, An Autoadaptive Limited Memory Broyden’s Method To Solve Systems of Nonlinear Equations, Applied Mathematics and Computation 205 (2008) pp. 202-211. web.info.uvt.ro/~cristiana.drogoescu/MC/broyden.pdf.