• Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

mapcubi.h

Go to the documentation of this file.
00001 /// @addtogroup unifexp
00002 /// @{
00003 
00004 /////////////////////////////////////////////////////////////////////////////
00005 ///
00006 /// @file mapcubi.h
00007 ///
00008 /// This file contains the definition of the cubic map -x^3 + 3x - a
00009 /// on [-4,4] with the usage of interval arithmetic
00010 /// for rigorous computations.
00011 ///
00012 /// @author Pawel Pilarczyk
00013 ///
00014 /////////////////////////////////////////////////////////////////////////////
00015 
00016 // Copyright (C) 2007 by Pawel Pilarczyk.
00017 //
00018 // This file is part of my research program package.  This is free software;
00019 // you can redistribute it and/or modify it under the terms of the GNU
00020 // General Public License as published by the Free Software Foundation;
00021 // either version 2 of the License, or (at your option) any later version.
00022 //
00023 // This software is distributed in the hope that it will be useful,
00024 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00026 // GNU General Public License for more details.
00027 //
00028 // You should have received a copy of the GNU General Public License along
00029 // with this software; see the file "license.txt".  If not, write to the
00030 // Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00031 // MA 02111-1307, USA.
00032 
00033 // Started on August 24, 2007. Last revision: February 3, 2013.
00034 
00035 #ifndef _mapcubi_h_
00036 #define _mapcubi_h_
00037 
00038 #include <string>
00039 #include <iostream>
00040 #include "maptype.h"
00041 #include "intvcapd.h"
00042 
00043 
00044 namespace unifexp {
00045 
00046 // --------------------------------------------------
00047 // ----------------- the cubic map ------------------
00048 // --------------------------------------------------
00049 
00050 /// This class defines the cubic map -x^3 + 3x - a on [-4,4]
00051 /// with the usage of interval arithmetic.
00052 /// It is suitable for rigorous computations.
00053 /// Good values of the parameter are between 0 and 2,
00054 /// more or less (the optimal value is 2, I think).
00055 template <class numType>
00056 class mapCubicIntv: public mapType<numType>
00057 {
00058 public:
00059         /// The constructor.
00060         mapCubicIntv ();
00061 
00062         /// Returns the name of the object.
00063         std::string name () const;
00064 
00065         /// Returns the number of critical points.
00066         int countCritical () const;
00067 
00068         /// Returns the subsequent critical points.
00069         numType criticalPoint (int n) const;
00070 
00071         /// Returns the left bound of the domain of the map.
00072         numType leftBound () const;
00073 
00074         /// Returns the right bound of the domain of the map.
00075         numType rightBound () const;
00076 
00077         /// Computes an enclosure of the image of the given interval.
00078         void image (const numType &x1, const numType &x2,
00079                 numType &y1, numType &y2) const;
00080 
00081         /// Computes the minimal log of the derivative over those points
00082         /// in the interval [x1,x2] whose images may fall into [y1,y2]
00083         numType minLogDerivative (const numType &x1, const numType &x2,
00084                 const numType &y1, const numType &y2) const;
00085 
00086 }; /* mapCubicIntv */
00087 
00088 // --------------------------------------------------
00089 
00090 template <class numType>
00091 inline mapCubicIntv<numType>::mapCubicIntv ()
00092 {
00093         return;
00094 } /* mapCubicIntv::mapCubicIntv */
00095 
00096 template <class numType>
00097 inline std::string mapCubicIntv<numType>::name () const
00098 {
00099         return std::string ("cubic-intv");
00100 } /* mapCubicIntv::name */
00101 
00102 template <class numType>
00103 inline int mapCubicIntv<numType>::countCritical () const
00104 {
00105         return 2;
00106 } /* mapCubicIntv::countCritical */
00107 
00108 template <class numType>
00109 inline numType mapCubicIntv<numType>::criticalPoint (int n) const
00110 {
00111         return n ? 1 : -1;
00112 } /* mapCubicIntv::criticalPoint */
00113 
00114 template <class numType>
00115 inline numType mapCubicIntv<numType>::leftBound () const
00116 {
00117         return -4;
00118 } /* mapCubicIntv::leftBound */
00119 
00120 template <class numType>
00121 inline numType mapCubicIntv<numType>::rightBound () const
00122 {
00123         return 4;
00124 } /* mapCubicIntv::rightBound */
00125 
00126 template <class numType>
00127 inline void mapCubicIntv<numType>::image (const numType &x1,
00128         const numType &x2, numType &y1, numType &y2) const
00129 {
00130         if (x2 < x1)
00131                 throw "Image computation: Wrong interval for 'x'.";
00132         IntervalType x1i (x1, x1);
00133         IntervalType x2i (x2, x2);
00134         if ((x2 <= -1) || (1 <= x1))
00135         {
00136                 y1 = (-(x2i * x2i - 3) * x2i - this -> paramMax).
00137                         leftBound ();
00138                 y2 = (-(x1i * x1i - 3) * x1i - this -> paramMin).
00139                         rightBound ();
00140         }
00141         else if ((-1 <= x1) && (x2 <= 1))
00142         {
00143                 y1 = (-(x1i * x1i - 3) * x1i - this -> paramMax).
00144                         leftBound ();
00145                 y2 = (-(x2i * x2i - 3) * x2i - this -> paramMin).
00146                         rightBound ();
00147         }
00148         else if (x2 <= 1)
00149         {
00150                 const IntervalType y3 = -(x1i * x1i - 3) * x1i;
00151                 const IntervalType y4 = -(x2i * x2i - 3) * x2i;
00152                 y1 = (IntervalType (-2, -2) - this -> paramMax).
00153                         leftBound ();
00154                 y2 = (((y3. rightBound () < y4. rightBound ()) ? y4 : y3) -
00155                         this -> paramMin). rightBound ();
00156         }
00157         else if (-1 <= x1)
00158         {
00159                 const IntervalType y3 = -(x1i * x1i - 3) * x1i;
00160                 const IntervalType y4 = -(x2i * x2i - 3) * x2i;
00161                 y1 = (((y3. leftBound () < y4. leftBound ()) ? y3 : y4) -
00162                         this -> paramMax). leftBound ();
00163                 y2 = (IntervalType (4, 4) - this -> paramMin). rightBound ();
00164         }
00165         else
00166                 throw "Cubic map: Too large domain interval.";
00167         resetRounding ();
00168         return;
00169 } /* mapCubicIntv::image */
00170 
00171 template <class numType>
00172 inline numType mapCubicIntv<numType>::minLogDerivative (const numType &x1,
00173         const numType &x2, const numType &y1, const numType &y2) const
00174 {
00175         // make sure the input data is correct
00176         if (x2 < x1)
00177                 throw "MinLogDerivative: Wrong interval for 'x'.";
00178         if (y2 < y1)
00179                 throw "MinLogDerivative: Wrong interval for 'y'.";
00180 
00181         // NOTE: Since it is not so easy to compute the preimage of the
00182         // interval [y1,y2] with respect to the cubic polynomial map,
00183         // the lower bound for the log of the derivative is computed
00184         // solely based on the interval [x1,x2]
00185         IntervalType x1i (x1, x1);
00186         IntervalType x2i (x2, x2);
00187         numType result;
00188         if (x2 < -1)
00189         {
00190                 result = log (3 * x2i * x2i + 3). leftBound ();
00191         }
00192         else if (1 < x1)
00193         {
00194                 result = log (3 * x1i * x1i + 3). leftBound ();
00195         }
00196         else if ((-1 < x1) && (x2 < 1))
00197         {
00198                 if (0 < x1)
00199                         result = log (-3 * x2i * x2i + 3). leftBound ();
00200                 else if (x2 < 0)
00201                         result = log (-3 * x1i * x1i + 3). leftBound ();
00202                 else
00203                 {
00204                         result = log (-3 * ((x1 < x2) ? (x2i * x2i) :
00205                                 (x1i * x1i)) + 3). leftBound ();
00206                 }
00207         }
00208         else
00209         {
00210                 throw "Log of interval containing zero.";
00211                 result = 0;
00212         }
00213         resetRounding ();
00214         return result;
00215 } /* mapCubicIntv::minLogDerivative */
00216 
00217 
00218 } // namespace unifexp
00219 
00220 #endif // _mapcubi_h_
00221 
00222 /// @}
00223 

Generated on Sun Feb 3 2013 12:40:31 for The Uniform Expansion Software by  doxygen 1.7.2