5f892713c3 2021-03-03 trnsz@pobox.c: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 trnsz@pobox.c: % WELCOME TO iCAS
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % The core of iCAS is based on REDUCE, a powerful CAS system with comparable capabilities
5f892713c3 2021-03-03 trnsz@pobox.c: % to Maple and Mathematica with a track record spanning over 40 years in academic and research
5f892713c3 2021-03-03 trnsz@pobox.c: % institutions. iCAS brings all the capabilities of REDUCE and the embedded gnuplot plotting
5f892713c3 2021-03-03 trnsz@pobox.c: % engine to your iPad. Best of all, iCAS is entirely self-contained and runs natively on your iPad
5f892713c3 2021-03-03 trnsz@pobox.c: % so no internet connection is required to harness its power.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % This file is written as a short tutorial to walk you through some simple examples to become
5f892713c3 2021-03-03 trnsz@pobox.c: % familiar with the app and help you get started.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 trnsz@pobox.c: % BASIC USAGE
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Enter the desired command or operation and press return to execute the command or operation.
5f892713c3 2021-03-03 trnsz@pobox.c: % Try it by tapping to the right of the semicolon on the line below and then tapping return.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: 6 * 7;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % If fancy output is enabled, the results can be viewed in a typeset format by tapping a translucent
5f892713c3 2021-03-03 trnsz@pobox.c: % button that appears on the upper right hand corner of this view when there is fancy output or
5f892713c3 2021-03-03 trnsz@pobox.c: % iCAS detects LaTeX content. The output view can be zoomed using the standard pinch gestures.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Fancy output can be globally enabled with the "Create Fancy Output" option or on a case by case
5f892713c3 2021-03-03 trnsz@pobox.c: % basis using the fancy switch. If fancy output is enabled and the "Automatically Show" option is
5f892713c3 2021-03-03 trnsz@pobox.c: % enabled, iCAS will automatically show the rendered fancy output when it is generated.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Execute the following lines (i.e. place the cursor to the right of the semicolon and tap the return
5f892713c3 2021-03-03 trnsz@pobox.c: % key) to see the difference between plain and fancy output.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: df(x^x,x);
5f892713c3 2021-03-03 trnsz@pobox.c: on fancy;
5f892713c3 2021-03-03 trnsz@pobox.c: df(x^x,x);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Notice the pseudo-LaTeX output format and the "TeX" translucent button that appeared on the
5f892713c3 2021-03-03 trnsz@pobox.c: % top right of the window. Tapping the "TeX" button generates a typeset version of the file that
5f892713c3 2021-03-03 trnsz@pobox.c: % can be optionally emailed as a LaTeX source file for publishing, presentation, and/or sharing with
5f892713c3 2021-03-03 trnsz@pobox.c: % colleagues.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Fancy output works best with a line length of 80 or more. iCAS sets the linelength to the optimal
5f892713c3 2021-03-03 trnsz@pobox.c: % width for plain output when a CAS session is started based on the font style and size settings.
5f892713c3 2021-03-03 trnsz@pobox.c: % Therefore, we recommend setting the linelength to 80 when using fancy output. iCAS provides a
5f892713c3 2021-03-03 trnsz@pobox.c: % convenience command called fancy_output that sets the fancy switch and sets the linelength to 80
5f892713c3 2021-03-03 trnsz@pobox.c: % characters. Note that turning the fancy switch off does not affect the linelength so you may need
5f892713c3 2021-03-03 trnsz@pobox.c: % to set the linelength to an appropriate value after using fancy output. The linelength is reset when
5f892713c3 2021-03-03 trnsz@pobox.c: % a new CAS session is initiated (e.g. by using either the "bye" or "quit" command).
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 trnsz@pobox.c: % KEYBOARD USAGE
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % By default, iCAS uses the system keyboard. A user configurable macro keyboard and a
5f892713c3 2021-03-03 trnsz@pobox.c: % numerical keyboard are also optionally available. The enabled keyboards and the default
5f892713c3 2021-03-03 trnsz@pobox.c: % keyboard can be configured in the app Settings. The app Settings can be accessed either through the
5f892713c3 2021-03-03 trnsz@pobox.c: % global Settings app or by tapping the Settings button on the top right corner of the screen.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % To switch between the enabled keyboards, use a horizontal swipe gesture in the text area when a
5f892713c3 2021-03-03 trnsz@pobox.c: % keyboard is active.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % By default, tapping a button other than the "CLEAR" or "BATCH" buttons on the macro
5f892713c3 2021-03-03 trnsz@pobox.c: % keyboard causes the active keyboard to automatically switch to the system keyboard to allow
5f892713c3 2021-03-03 trnsz@pobox.c: % entry of variables, parameters, arguments, etc. This behavior can be enabled/disabled using the
5f892713c3 2021-03-03 trnsz@pobox.c: % "Auto Hide Macros" setting.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Tap the clear line below to active the keyboard and swipe from right to left to reveal the macro
5f892713c3 2021-03-03 trnsz@pobox.c: % keyboard. Now tap the "integral" button.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Now double tap "function" and replace it with some function of x, say x, to keep it quick and
5f892713c3 2021-03-03 trnsz@pobox.c: % simple. Then execute the line. Unless you've disabled fancy output, iCAS will have output a
5f892713c3 2021-03-03 trnsz@pobox.c: % pseudo-LaTeX output that you can view by tapping the "TeX" button at the top right. Go ahead
5f892713c3 2021-03-03 trnsz@pobox.c: % and tap it to see the output in the LaTeX viewer.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Tapping return on the system keyboard can be configured to automatically switch to the macro
5f892713c3 2021-03-03 trnsz@pobox.c: % keyboard to enable the entry of other CAS commands. This is controlled by the "Return Shows
5f892713c3 2021-03-03 trnsz@pobox.c: % Macros" setting.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % To edit the contents of a macro button, tap and hold down the button for 1 second or longer.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Instances of \n in macros get automatically converted into new lines. This makes it possible to
5f892713c3 2021-03-03 trnsz@pobox.c: % create macros with text spanning multiple lines.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Assigning \r to a macro button turns that button into a silent return key. That is, it inserts a
5f892713c3 2021-03-03 trnsz@pobox.c: % new line character without processing the contents of the line.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Assigning \b to a macro button turns that button into a backspace/delete key.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Assigning \c to a macro button turns that button into a clear key.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Assigning \cb to a macro button turns that button into a clear batch output key. The macro has
5f892713c3 2021-03-03 trnsz@pobox.c: % no effect if there is no batch output.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % The cursor placement within a macro can be optionally specified by including \^ in the macro where
5f892713c3 2021-03-03 trnsz@pobox.c: % the cursor should be after the macro is inserted. For example, the macro “(\^)” will cause the
5f892713c3 2021-03-03 trnsz@pobox.c: % cursor to be placed between the two parentheses.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % The macro buttons can be optionally labelled by including the desired label surrounded by the #
5f892713c3 2021-03-03 trnsz@pobox.c: % character in the macro text. For example, if a macro contains #LABEL#, the button will display
5f892713c3 2021-03-03 trnsz@pobox.c: % LABEL in a larger font instead of the actual contents of the macro.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % The following labels (in uppercase) are automatically displayed with the mathematical symbol for
5f892713c3 2021-03-03 trnsz@pobox.c: % the corresponding CAS operator/constant: DF, E, I, INFINITY, INT, PI, PROD, and SUM.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % The default integral, derivative, pi, and infinity buttons are examples that utilize these features.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 trnsz@pobox.c: % PLOTTING
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % iCAS includes a full implementation of gnuplot that can be accessed in CAS mode using the
5f892713c3 2021-03-03 trnsz@pobox.c: % gnuplot package or directly in plot mode (more on modes later). By default, iCAS loads the
5f892713c3 2021-03-03 trnsz@pobox.c: % gnuplot package so unless you changed the "Always Load gnuplot" setting, it should already be
5f892713c3 2021-03-03 trnsz@pobox.c: % loaded.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % By default, iCAS automatically shows newly generated or updated plots. This behavior can be
5f892713c3 2021-03-03 trnsz@pobox.c: % disabled in the global settings.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Plots can be magnified using the standard pinch gestures. iCAS supports landscape orientations
5f892713c3 2021-03-03 trnsz@pobox.c: % in all its views so plots can be viewed in either portrait or landscape orientations. Execute the
5f892713c3 2021-03-03 trnsz@pobox.c: % line below to see plotting in action and use the pinch gesture to zoom in/out and swipe gestures
5f892713c3 2021-03-03 trnsz@pobox.c: % to pan around the plot while zoomed in.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: plot(sin(x));
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Unless specified, iCAS uses the title "iCAS Plot" and the file name "CASPlot" for plot files. The
5f892713c3 2021-03-03 trnsz@pobox.c: % default plot title can be changed in the global settings and can also be set on a per plot basis.
5f892713c3 2021-03-03 trnsz@pobox.c: % Execute the below line to see an example.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: plot(cos(x), title="cos(x)", output="cos(x)");
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Plot files can be accessed by tapping the "folder" button on the right side of the menu bar. Go
5f892713c3 2021-03-03 trnsz@pobox.c: % ahead and tap the button now.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % The files organizer picker has four wheels. One for text files such as this one, one for plot files,
5f892713c3 2021-03-03 trnsz@pobox.c: % one for REDUCE inout files, and one for macro keyboard files. Aim the left picker wheel to view the
5f892713c3 2021-03-03 trnsz@pobox.c: % corresponding files. Files can be deleted, mailed, or viewed/selected with the buttons above the
5f892713c3 2021-03-03 trnsz@pobox.c: % picker wheels.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % The displayed contents can be emailed, copied, or printed by tapping the "send" button button on
5f892713c3 2021-03-03 trnsz@pobox.c: % the right side of the bottom toolbar. Text files are emailed using the active font style. The
5f892713c3 2021-03-03 trnsz@pobox.c: % font style, font size, and colors can be configured using the styles panel revealed by tapping the
5f892713c3 2021-03-03 trnsz@pobox.c: % "styles" button on the left of the bottom toolbar. The available font styles are "Helvetica", "Times",
5f892713c3 2021-03-03 trnsz@pobox.c: % and "Courier". Although not the prettiest, Courier can be optimal as it is the closest to a monospace
5f892713c3 2021-03-03 trnsz@pobox.c: % font on iOS devices.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Plots can be emailed in SVG format which is a resolution independent format supported by major
5f892713c3 2021-03-03 trnsz@pobox.c: % major browsers including Safari and FireFox.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 trnsz@pobox.c: % OPERATION MODES
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % iCAS supports three operation modes.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % • CAS Mode
5f892713c3 2021-03-03 trnsz@pobox.c: % • Plot Mode
5f892713c3 2021-03-03 trnsz@pobox.c: % • Text Editor Mode
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % By default, the application's color theme changes to indicate the active mode. This color feedback
5f892713c3 2021-03-03 trnsz@pobox.c: % behavior can be disabled in the app Settings, if desired.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % In CAS mode (the current mode unless you've changed the mode with the mode controls switch
5f892713c3 2021-03-03 trnsz@pobox.c: % in the middle of the toolbar), iCAS behaves as a terminal interface to the CAS engine.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % In Plot mode, iCAS behaves as a direct terminal interface to the gnuplot engine. Go ahead and
5f892713c3 2021-03-03 trnsz@pobox.c: % dismiss the keyboard and tap the "plot" mode button (the button with a graph) to switch to Plot
5f892713c3 2021-03-03 trnsz@pobox.c: % mode. Then execute each of the following lines in sequence. This is an example straight from the
5f892713c3 2021-03-03 trnsz@pobox.c: % gnuplot demonstration samples web page.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: set output "3D Log"
5f892713c3 2021-03-03 trnsz@pobox.c: set title "3D Log"
5f892713c3 2021-03-03 trnsz@pobox.c: set samples 30; set isosamples 30
5f892713c3 2021-03-03 trnsz@pobox.c: set hidden3d
5f892713c3 2021-03-03 trnsz@pobox.c: set pm3d
5f892713c3 2021-03-03 trnsz@pobox.c: set surface
5f892713c3 2021-03-03 trnsz@pobox.c: set view 50,220
5f892713c3 2021-03-03 trnsz@pobox.c: set xrange [-2:2]
5f892713c3 2021-03-03 trnsz@pobox.c: set yrange [-2:2]
5f892713c3 2021-03-03 trnsz@pobox.c: splot log(x*x*y*y)
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % As you can see, iCAS accepts gnuplot commands directly.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % In Text Editor mode, iCAS behaves as a plain text editor. Pressing return does not invoke either
5f892713c3 2021-03-03 trnsz@pobox.c: % CAS or plot operations. This mode is useful for general-purpose text editing, to create input files
5f892713c3 2021-03-03 trnsz@pobox.c: % for batch execution (described below), to create/preview LaTeX documents, etc.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % The active file is automatically saved when the application is quit/placed in the background or
5f892713c3 2021-03-03 trnsz@pobox.c: % when a new file is opened.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % There may be times when you need to abort the active CAS session. To abort a CAS session that is
5f892713c3 2021-03-03 trnsz@pobox.c: % idle, simply use the REDUCE "bye" or "quit" command. A new session will be automatically
5f892713c3 2021-03-03 trnsz@pobox.c: % restarted. To abort a CAS session that is busy, tap the "Abort" button that replaces the
5f892713c3 2021-03-03 trnsz@pobox.c: % "Settings" button while iCAS is busy. Set the mode to CAS mode using the mode buttons and go
5f892713c3 2021-03-03 trnsz@pobox.c: % ahead and abort the CAS session using the following example that intentionally invokes a very long
5f892713c3 2021-03-03 trnsz@pobox.c: % for-loop.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: for i:=0:10000000 do j:=i;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 trnsz@pobox.c: % BATCH OPERATION
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % In addition to the interactive operation that we've just used, iCAS supports batch execution of
5f892713c3 2021-03-03 trnsz@pobox.c: % entire file contents. That is, iCAS can process the entire contents of the active file either in CAS
5f892713c3 2021-03-03 trnsz@pobox.c: % mode or Plot mode. To do so, use the special "BATCH" macro keyboard button. Unlike
5f892713c3 2021-03-03 trnsz@pobox.c: % interactive results which are output at the current cursor location, CAS mode batch execution
5f892713c3 2021-03-03 trnsz@pobox.c: % results are appended to the end of the file surrounded by "%%% Begin Batch Results" and
5f892713c3 2021-03-03 trnsz@pobox.c: % "%%% End Batch Results" so they can be easily located with a quick search.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Plot mode results are of course the creation of plot files. Note that plot files are not
5f892713c3 2021-03-03 trnsz@pobox.c: % automatically shown when they are generated in batch mode. To view batch generated plot
5f892713c3 2021-03-03 trnsz@pobox.c: % files, please use the files picker.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Now, this file contains interactive output from the examples that we've run so if you process this
5f892713c3 2021-03-03 trnsz@pobox.c: % file in batch mode, it will result in errors. Therefore, please try batch execution using one of the
5f892713c3 2021-03-03 trnsz@pobox.c: % example files.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 trnsz@pobox.c: % FOR MORE INFORMATION
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % We hope that you found this tutorial helpful. You'll find more examples for various areas in the
5f892713c3 2021-03-03 trnsz@pobox.c: % files picker. You will also find more information in the iCAS FAQ at the following URL.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % http://alsoftiphone.com/iCAS/faq
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Last but not least, if you have any questions or feedback, please don't hesitate to contact us at
5f892713c3 2021-03-03 trnsz@pobox.c: % support@alsoftiphone.com. You can quickly do so by either tapping the "i" button on the bottom
5f892713c3 2021-03-03 trnsz@pobox.c: % right corner and then tapping the "Feedback" button or by tapping the "Contact Support" button at
5f892713c3 2021-03-03 trnsz@pobox.c: % the bottom of the app Settings.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % We hope that you will find iCAS a useful companion for your computation needs.
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: % Best Regards,
5f892713c3 2021-03-03 trnsz@pobox.c: % AL Software
5f892713c3 2021-03-03 trnsz@pobox.c: %
5f892713c3 2021-03-03 trnsz@pobox.c: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%