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

mapcub.h

Go to the documentation of this file.
00001 /// @addtogroup unifexp
00002 /// @{
00003 
00004 /////////////////////////////////////////////////////////////////////////////
00005 ///
00006 /// @file mapcub.h
00007 ///
00008 /// This file contains the definition of the cubic map -x^3 + 3x - a
00009 /// on [-4,4] without using interval arithmetic
00010 /// for non-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: August 24, 2007.
00034 
00035 #ifndef _mapcub_h_
00036 #define _mapcub_h_
00037 
00038 #include <string>
00039 #include <iostream>
00040 #include "maptype.h"
00041 
00042 
00043 namespace unifexp {
00044 
00045 // --------------------------------------------------
00046 // ----------------- the cubic map ------------------
00047 // --------------------------------------------------
00048 
00049 /// This class defines the cubic map -x^3 + 3x - a on [-4,4]
00050 /// without using interval arithmetic.
00051 /// It is suitable for non-rigorous computations.
00052 /// See the class "mapCubicIntv" for a rigorous version which does use
00053 /// interval arithmetic.
00054 /// Good values of the parameter are between 0 and 2,
00055 /// more or less (the optimal value is 2, I think).
00056 template <class numType>
00057 class mapCubic: public mapType<numType>
00058 {
00059 public:
00060         /// The constructor.
00061         mapCubic ();
00062 
00063         /// Returns the name of the object.
00064         std::string name () const;
00065 
00066         /// Returns the number of critical points.
00067         int countCritical () const;
00068 
00069         /// Returns the subsequent critical points.
00070         numType criticalPoint (int n) const;
00071 
00072         /// Returns the left bound of the domain of the map.
00073         numType leftBound () const;
00074 
00075         /// Returns the right bound of the domain of the map.
00076         numType rightBound () const;
00077 
00078         /// Computes an enclosure of the image of the given interval.
00079         void image (const numType &x1, const numType &x2,
00080                 numType &y1, numType &y2) const;
00081 
00082         /// Computes the minimal log of the derivative over those points
00083         /// in the interval [x1,x2] whose images may fall into [y1,y2]
00084         numType minLogDerivative (const numType &x1, const numType &x2,
00085                 const numType &y1, const numType &y2) const;
00086 
00087 }; /* mapCubic */
00088 
00089 // --------------------------------------------------
00090 
00091 template <class numType>
00092 inline mapCubic<numType>::mapCubic ()
00093 {
00094         return;
00095 } /* mapCubic::mapCubic */
00096 
00097 template <class numType>
00098 inline std::string mapCubic<numType>::name () const
00099 {
00100         return std::string ("cubic");
00101 } /* mapCubic::name */
00102 
00103 template <class numType>
00104 inline int mapCubic<numType>::countCritical () const
00105 {
00106         return 2;
00107 } /* mapCubic::countCritical */
00108 
00109 template <class numType>
00110 inline numType mapCubic<numType>::criticalPoint (int n) const
00111 {
00112         return n ? 1 : -1;
00113 } /* mapCubic::criticalPoint */
00114 
00115 template <class numType>
00116 inline numType mapCubic<numType>::leftBound () const
00117 {
00118         return -4;
00119 } /* mapCubic::leftBound */
00120 
00121 template <class numType>
00122 inline numType mapCubic<numType>::rightBound () const
00123 {
00124         return 4;
00125 } /* mapCubic::rightBound */
00126 
00127 template <class numType>
00128 inline void mapCubic<numType>::image (const numType &x1, const numType &x2,
00129         numType &y1, numType &y2) const
00130 {
00131         if (x2 < x1)
00132                 throw "Image computation: Wrong interval for 'x'.";
00133         if ((x2 <= -1) || (1 <= x1))
00134         {
00135                 y1 = -(x2 * x2 - 3) * x2 - this -> paramMax;
00136                 y2 = -(x1 * x1 - 3) * x1 - this -> paramMin;
00137         }
00138         else if ((-1 <= x1) && (x2 <= 1))
00139         {
00140                 y1 = -(x1 * x1 - 3) * x1 - this -> paramMax;
00141                 y2 = -(x2 * x2 - 3) * x2 - this -> paramMin;
00142         }
00143         else if (x2 <= 1)
00144         {
00145                 const numType y3 = -(x1 * x1 - 3) * x1;
00146                 const numType y4 = -(x2 * x2 - 3) * x2;
00147                 y1 = -2 - this -> paramMax;
00148                 y2 = ((y3 < y4) ? y4 : y3) - this -> paramMin;
00149         }
00150         else if (-1 <= x1)
00151         {
00152                 const numType y3 = -(x1 * x1 - 3) * x1;
00153                 const numType y4 = -(x2 * x2 - 3) * x2;
00154                 y1 = ((y3 < y4) ? y3 : y4) - this -> paramMax;
00155                 y2 = 4 - this -> paramMin;
00156         }
00157         else
00158                 throw "Cubic map: Too large domain interval.";
00159         return;
00160 } /* mapCubic::image */
00161 
00162 template <class numType>
00163 inline numType mapCubic<numType>::minLogDerivative (const numType &x1,
00164         const numType &x2, const numType &y1, const numType &y2) const
00165 {
00166         // make sure the input data is correct
00167         if (x2 < x1)
00168                 throw "MinLogDerivative: Wrong interval for 'x'.";
00169         if (y2 < y1)
00170                 throw "MinLogDerivative: Wrong interval for 'y'.";
00171 
00172         // NOTE: Since it is not so easy to compute the preimage of the
00173         // interval [y1,y2] with respect to the cubic polynomial map,
00174         // the lower bound for the log of the derivative is computed
00175         // solely based on the interval [x1,x2]
00176         if (x2 < -1)
00177         {
00178                 return log (3 * x2 * x2 + 3);
00179         }
00180         else if (1 < x1)
00181         {
00182                 return log (3 * x1 * x1 + 3);
00183         }
00184         else if ((-1 < x1) && (x2 < 1))
00185         {
00186                 if (0 < x1)
00187                         return log (-3 * x2 * x2 + 3);
00188                 else if (x2 < 0)
00189                         return log (-3 * x1 * x1 + 3);
00190                 else
00191                 {
00192                         return log (-3 * ((x1 < x2) ?
00193                                 (x2 * x2) : (x1 * x1)) + 3);
00194                 }
00195         }
00196         else
00197         {
00198                 throw "Log of interval containing zero.";
00199                 return 0;
00200         }
00201 } /* mapCubic::minLogDerivative */
00202 
00203 
00204 } // namespace unifexp
00205 
00206 #endif // _mapcub_h_
00207 
00208 /// @}
00209 

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