mapquadi.h

Go to the documentation of this file.
00001 /// @addtogroup unifexp
00002 /// @{
00003 
00004 /////////////////////////////////////////////////////////////////////////////
00005 ///
00006 /// @file mapquadi.h
00007 ///
00008 /// This file contains the definition of the quadratic map f(x)=x^2-a
00009 /// with the use of interval arithmetic for rigorous computations.
00010 ///
00011 /// @author Pawel Pilarczyk
00012 ///
00013 /////////////////////////////////////////////////////////////////////////////
00014 
00015 // Copyright (C) 2007 by Pawel Pilarczyk.
00016 //
00017 // This file is part of my research program package.  This is free software;
00018 // you can redistribute it and/or modify it under the terms of the GNU
00019 // General Public License as published by the Free Software Foundation;
00020 // either version 2 of the License, or (at your option) any later version.
00021 //
00022 // This software is distributed in the hope that it will be useful,
00023 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025 // GNU General Public License for more details.
00026 //
00027 // You should have received a copy of the GNU General Public License along
00028 // with this software; see the file "license.txt".  If not, write to the
00029 // Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00030 // MA 02111-1307, USA.
00031 
00032 // Started on March 8, 2007. Last revision: July 10, 2007.
00033 
00034 // NOTE: This module uses the CAPD library.
00035 
00036 #ifndef _mapquadi_h_
00037 #define _mapquadi_h_
00038 
00039 #include <string>
00040 #include <iostream>
00041 #include "maptype.h"
00042 
00043 // the "interval" package from the CAPD library
00044 #include "interval/doubleInterval.h"
00045 
00046 
00047 namespace unifexp {
00048 
00049 // --------------------------------------------------
00050 // --------------- the quadratic map ----------------
00051 // ------------ with interval arithmetic ------------
00052 // --------------------------------------------------
00053 
00054 /// This class defines the quadratic map with the use of interval arithmetic.
00055 /// It is suitable for doing rigorous computations.
00056 template <class numType>
00057 class mapQuadrIntv: public mapType<numType>
00058 {
00059 public:
00060         /// The constructor.
00061         mapQuadrIntv ();
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 }; /* mapQuadrIntv */
00088 
00089 // --------------------------------------------------
00090 
00091 template <class numType>
00092 mapQuadrIntv<numType>::mapQuadrIntv ()
00093 {
00094         return;
00095 } /* mapQuadrIntv::mapQuadrIntv */
00096 
00097 template <class numType>
00098 std::string mapQuadrIntv<numType>::name () const
00099 {
00100         return std::string ("quadratic-intv");
00101 } /* mapQuadrIntv::name */
00102 
00103 template <class numType>
00104 inline int mapQuadrIntv<numType>::countCritical () const
00105 {
00106         return 1;
00107 } /* mapQuadrIntv::countCritical */
00108 
00109 template <class numType>
00110 inline numType mapQuadrIntv<numType>::criticalPoint (int n) const
00111 {
00112         return 0.0;
00113 } /* mapQuadrIntv::criticalPoint */
00114 
00115 template <class numType>
00116 inline numType mapQuadrIntv<numType>::leftBound () const
00117 {
00118         return -2;
00119 //      return -this -> paramMax;
00120 } /* mapQuadrIntv::leftBound */
00121 
00122 template <class numType>
00123 inline numType mapQuadrIntv<numType>::rightBound () const
00124 {
00125         return 2;
00126 //      numType result = (power (interval (this -> paramMax,
00127 //              this -> paramMax), 2) - this -> paramMin). rightBound ();
00128 //      capd::rounding::DoubleRounding::roundNearest ();
00129 //      return result;
00130 } /* mapQuadrIntv::rightBound */
00131 
00132 template <class numType>
00133 void mapQuadrIntv<numType>::image (const numType &x1, const numType &x2,
00134         numType &y1, numType &y2) const
00135 {
00136         if (x2 < x1)
00137                 throw "Image computation: Wrong interval for 'x'.";
00138         interval img = power (interval (x1, x2), 2) -
00139                 interval (this -> paramMin, this -> paramMax);
00140         y1 = img. leftBound ();
00141         y2 = img. rightBound ();
00142         capd::rounding::DoubleRounding::roundNearest ();
00143         return;
00144 } /* mapQuadrIntv::image */
00145 
00146 template <class numType>
00147 numType mapQuadrIntv<numType>::minLogDerivative (const numType &x1,
00148         const numType &x2, const numType &y1, const numType &y2) const
00149 {
00150         // make sure the input data is correct
00151         if (x2 < x1)
00152                 throw "MinLogDerivative: Wrong interval for 'x'.";
00153         if (y2 < y1)
00154                 throw "MinLogDerivative: Wrong interval for 'y'.";
00155 
00156         // compute the positive preimage of the interval [y1,y2],
00157         // intersect the computed preimage with the interval [x1,x2],
00158         // and return the log of the derivative at the minimal endpoint
00159         const numType sum1 = (interval (y1, y1) + this -> paramMin).
00160                 leftBound ();
00161         const numType left1 = (0 < sum1) ?
00162                 (sqrt (interval (sum1, sum1))). leftBound () : 0;
00163         numType result;
00164         if (0 < x1)
00165         {
00166                 const numType left = (left1 > x1) ? left1 : x1;
00167                 result = (log (2 * interval (left, left))). leftBound ();
00168         }
00169         else if (x2 < 0)
00170         {
00171                 const numType left = (left1 > -x2) ? left1 : -x2;
00172                 result = (log (2 * interval (left, left))). leftBound ();
00173         }
00174         else
00175         {
00176                 throw "Log of interval containing zero.";
00177                 result = 0;
00178         }
00179         capd::rounding::DoubleRounding::roundNearest ();
00180         return result;
00181 } /* mapQuadrIntv::minLogDerivative */
00182 
00183 
00184 } // namespace unifexp
00185 
00186 #endif // _mapquadi_h_
00187 
00188 /// @}
00189 

Generated on Wed Nov 21 11:08:41 2007 for The Uniform Expansion Software by  doxygen 1.5.3