Calcpad.Wpf
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||
<!DOCTYPE html> <html lang="en"> <head> <title>Calcpad Readme</title> <meta charset="UTF-8"> <style> .menu{ position:fixed; left:780px; top:0; font-size:11pt; list-style:none; } .menu li{ margin-left:-14px; } .menu li ul{ font-size: 11pt; list-style: none; display: none; } .active{ color: black !Important; font-weight: bold; font-size:11pt; } table {border-collapse: collapse;} body {font-size: 11pt; font-family: "Segoe UI";} .body { width: 700px; max-width: 85%; background: white; margin: 12px; padding: 12px 24px 12px 30px; } th {background-color:#F0F0F0; border: solid 1px #AAAAAA; padding:6px;} td {border: solid 1px #cccccc; padding:6px;} .nb td {border: none;} .tr td {text-align:right;} p {line-height: 150%;} ul {padding-left: 24px;} li ul {padding-left: 12px;} h1 {font-family: "Calibri Light"; font-weight: normal; font-size: 32pt; margin: 0;} h1 img { margin-top: -6px;} li {margin: 6px;} .menu li ul {padding-left: 42px;} var {color:#06c; font-family: "Times New Roman"; font-size: 12.5pt} i {color:#086; font-family:Times New Roman; font-style: normal; font-size: 11.5pt;} img {vertical-align: middle; max-width:100%;} u {background-color: LightYellow;} .comment {color: green;} .root {font-family: Times New Roman; font-size: 14pt;} .ovr {border-top: solid 1px; padding-left: 1pt; padding-top: -2pt;} code .ovr {padding-top: 2pt; font-family: "Consolas"; font-size: 10pt;} .dvc {display: inline-block; vertical-align: middle; text-align: center; line-height:110%; white-space: nowrap;} .dvl {display: block; border-bottom: solid 1px black;} .dvc.down {position: relative; top:0.5em;} .dvc.up {position: relative; bottom:0.6em;} .cond {color: magenta;} .macro {color: darkMagenta;} .err {color: red;} .toc {color: #888888; text-decoration:none; font-size:10.5pt;} .toc:hover {text-decoration: underline; color: black;} .fold {height: 2.4em; overflow: hidden;} .unfold {height: auto; overflow: auto;} .fold > :first-child, .unfold > :first-child {cursor: pointer;} .fold > :first-child:hover, .unfold > :first-child:hover {color: #0066bb; text-decoration: underline;} .fold > :first-child::after {content: " ... ▼"; font-size: 80%;} .unfold > :first-child::after {content: " ▲"; font-size: 80%;} #Units{float:right; margin-top:12px;} input[type="text"], select { font-size: 11pt; padding: 0.15em 0.3em; border: 0.5pt solid #CCC; border-radius: 0.35em; text-align: right; box-shadow: 0.06em 0.06em 0.5em #ddd; background-color: LightYellow; } input[type="checkbox"], input[type="radio"] { --ssf: 1.1; zoom: var(--ssf); -moz-transform: scale(var(--ssf)); -webkit-transform: scale(var(--ssf)); transform: scale(var(--ssf)); transform-origin: top; position: relative; bottom: -1pt; margin-right: 1pt; } input[type="checkbox"].post:disabled:not(:checked), input[type="checkbox"].post:disabled:not(:checked) + label, input[type="radio"].post:disabled:not(:checked), input[type="radio"].post:disabled:not(:checked) + label { display: none; } select.post:disabled { font-size: 12pt; border: none; box-shadow: none; color: red; background: none; appearance: none; -webkit-appearance: none; -moz-appearance: none; } select.post:disabled::-ms-expand {display: none;} input[type="text"]:focus {box-shadow: 0.1em 0.1em 1em #ccc; color: black;} .exp { display: inline-block; height: 13pt; line-height: 80%; font-size: 12pt; font-weight: bold; border: solid 1px #cccccc; padding: 0 1.5pt 0 1.5pt; margin-right: 4pt; border-radius: 4pt; } .exp:hover { cursor: pointer; box-shadow: #cccccc 0 0 4px; } sub {font-family: Arial Nova; font-size:70%; padding-left:0.5pt; padding-right:0.5pt;} @media screen and (max-width: 960px){ .menu{display:none;} } </style> </head> <body> <ul class="menu"> <li style="font-size:13pt; font-weight:bold; border-bottom: solid 1px gray; padding-bottom:3px; margin-bottom:6px;">Table Of Contents</li> <li><a class="toc" href="#TOC_101">About Calcpad</a></li> <li><a class="toc" href="#TOC_102">Fields of application</a></li> <li><a class="toc" href="#TOC_103">Installation</a></li> <li><a class="toc" href="#TOC_104">Licensing and terms of use</a></li> <li><a class="toc" href="#TOC_105">How it works</a></li> <li><a class="toc" href="#TOC_106">Theoretical background</a></li> <li><span class="exp" id="button2">+</span><a class="toc" href="#TOC_200">Writing code</a><br /> <ul id="list2"> <li><a class="toc" href="#TOC_201">Numeric keypad</a></li> <li><a class="toc" href="#TOC_202">Moving inside the text</a></li> <li><a class="toc" href="#TOC_203">Select</a></li> <li><a class="toc" href="#TOC_204">Delete</a></li> <li><a class="toc" href="#TOC_205">Copy</a></li> <li><a class="toc" href="#TOC_206">Paste</a></li> <li><a class="toc" href="#TOC_207">Undo</a></li> <li><a class="toc" href="#TOC_208">Redo</a></li> <li><a class="toc" href="#TOC_209">Find</a></li> </ul> </li> <li><span class="exp" id="button3">+</span><a class="toc" href="#TOC_300">Coding aids</a><br /> <ul id="list3"> <li><a class="toc" href="#TOC_301">Syntax highlighting</a></li> <li><a class="toc" href="#TOC_302">Auto-indentation</a></li> <li><a class="toc" href="#TOC_303">Auto-complete</a></li> <li><a class="toc" href="#TOC_304">Bracket matching</a></li> <li><a class="toc" href="#TOC_305">Greek letters</a></li> <li><a class="toc" href="#TOC_306">Working with Notepad++</a></li> </ul> </li> <li><span class="exp" id="button4">+</span><a class="toc" href="#TOC_400">Expressions</a><br /> <ul id="list4"> <li><a class="toc" href="#TOC_401">Constants</a></li> <li><a class="toc" href="#TOC_402">Variables</a></li> <li><a class="toc" href="#TOC_403">Operators</a></li> <li><a class="toc" href="#TOC_404">Brackets</a></li> <li><a class="toc" href="#TOC_405">Functions</a></li> <li><a class="toc" href="#TOC_406">Plotting</a></li> <li><a class="toc" href="#TOC_407">Numerical methods</a></li> <li><a class="toc" href="#TOC_408">Iterative procedures</a></li> <li><a class="toc" href="#TOC_409">Units</a></li> </ul> </li> <li><span class="exp" id="button5">+</span><a class="toc" href="#TOC_500">Reporting</a><br /> <ul id="list5"> <li><a class="toc" href="#TOC_501">Headings</a></li> <li><a class="toc" href="#TOC_502">Text/comments</a></li> <li><a class="toc" href="#TOC_503">Units in comments</a></li> <li><a class="toc" href="#TOC_504">Formatting with Html and CSS</a></li> <li><a class="toc" href="#TOC_505">Images</a></li> </ul> </li> <li><span class="exp" id="button6">+</span><a class="toc" href="#TOC_600">Programming</a><br /> <ul id="list6"> <li><a class="toc" href="#TOC_601">Input forms</a></li> <li><a class="toc" href="#TOC_602">Output control</a></li> <li><a class="toc" href="#TOC_603">Conditional execution</a></li> <li><a class="toc" href="#TOC_604">Iteration blocks</a></li> <li><a class="toc" href="#TOC_605">Interactive (step-by-step) execution</a></li> <li><a class="toc" href="#TOC_606">Modules (include)</a></li> <li><a class="toc" href="#TOC_607">Macros and string variables</a></li> </ul> </li> <li><span class="exp" id="button7">+</span><a class="toc" href="#TOC_700">Results</a><br /> <ul id="list7"> <li><a class="toc" href="#TOC_701">Substitution</a></li> <li><a class="toc" href="#TOC_702">Rounding</a></li> <li><a class="toc" href="#TOC_703">Formatting</a></li> <li><a class="toc" href="#TOC_704">Scaling</a></li> <li><a class="toc" href="#TOC_705">Saving</a></li> <li><a class="toc" href="#TOC_706">Printing</a></li> <li><a class="toc" href="#TOC_707">Coping</a></li> <li><a class="toc" href="#TOC_708">Export to Word</a></li> <li><a class="toc" href="#TOC_709">Export to PDF</a></li> </ul> </li> <li><span class="exp" id="button8">+</span><a class="toc" href="#TOC_800">Files</a><br /> <ul id="list8"> <li><a class="toc" href="#TOC_801">New</a></li> <li><a class="toc" href="#TOC_802">Open</a></li> <li><a class="toc" href="#TOC_803">Save</a></li> <li><a class="toc" href="#TOC_804">Save As…</a></li> </ul> </li> </ul> <div class="body"> <ul style="float:right; font-size:9pt; list-style:none;"> <li><img alt="Logo" src="Images/Logo.png" height="32"><span style="font-size:130%">®</span></li> <li>34-36 Peyo Yavorov blvd, Sofia 1164, Bulgaria</li> <li>+359 2 423 4455</li> <li><a href="mailto:[email protected]">[email protected]</a></li> </ul> <h1><img alt="Calcpad.png" src="Images/Calcpad.png" height="32"> Calcpad</h1> <p style="margin-left:42px; margin-top:0;">Version 6.2 Readme!</p> <h2 id="TOC_101">About Calcpad</h2> <p>Calcpad is free software for mathematical and engineering calculations. It represents a flexible and modern programmable calculator with Html report generator. It is simple and easy to use, but it also includes many advanced features:</p> <ul> <li>real and complex numbers;</li> <li>units of measurement (SI, Imperial and USCS);</li> <li>custom variables and units;</li> <li>built-in library with common math functions;</li> <li>custom functions of multiple parameters f(x; y; z; …);</li> <li>powerful numerical methods for root and extremum finding, numerical integration and differentiation;</li> <li>finite sum, product and iteration procedures;</li> <li>modules, macros and string variables;</li> <li>program flow control with conditions and loops;</li> <li>"titles" and 'text' comments in quotes;</li> <li>support for Html and CSS in comments for rich formatting;</li> <li>function plotting, images, tables, parametric SVG drawings, etc.;</li> <li>automatic generation of Html forms for data input;</li> <li>professional looking Html reports for viewing printing;</li> <li>export to Word (*.docx) and PDF documents;</li> <li>variable substitution and smart rounding of numbers;</li> <li>output visibility control and content folding;</li> <li>support for plain text (*.txt, *.cpd) and binary (*.cpdz) file formats.</li> </ul> <p>This software is developed using the C# programming language and latest computer technologies. It automatically parses the input, substitutes the variables, calculates the expressions and displays the output. All results are sent to a professional looking Html report for viewing and printing.</p> <p style="text-align:center;"><img alt="Calcpad" src="Images/Sample.png" width="650"></p> <h2 id="TOC_102">Fields of application</h2> <p>This software is suitable for engineers and other professionals that need to perform repetitive calculations and present them in official documentation such as calculation notes. They can automate this task efficiently by creating powerful and reliable Calcpad worksheets. It can also help teachers to prepare calculation examples, papers, manuals, books etc. Students can use it to solve various problems, prepare homeworks, phd theses etc.</p> <h2 id="TOC_103">Installation</h2> <p>Installation is performed by the automated setup program <a target="_blank" href="https://calcpad.eu/download/calcpad-setup-en-x64.zip">calcpad-setup-en-x64.exe</a>. Follow the instruction of the setup wizard. The software requires a 64 bit computer with Windows 10/11 and <a target="_blank" href="https://dotnet.microsoft.com/en-us/download/dotnet/8.0">Microsoft .NET 8.0</a>.</p> <h2 id="TOC_104">Licensing and terms of use</h2> <p>This software is free for both commercial and non-commercial use. It is distributed under the MIT license:</p> <p>Copyright © 2021 PROEKTSOFT EOOD®</p><hr /> <p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p> <p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p> <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p><hr /> <p>The source code is available on GitHub:</p> <p><a title="GitHub repository" href="https://github.com/Proektsoftbg/Calcpad">https://github.com/Proektsoftbg/Calcpad</a></p> <p>or in our SourceForge repository:</p> <p><a title="SourceForge repository" href="https://sourceforge.net/p/calyx/code/ci/master/tree/">https://sourceforge.net/p/calyx/code/ci/master/tree/</a></p> <p>Any scripts, developed with Calcpad are property of the respective authors. They can be used without additional limitations except those appointed by the authors themselves.</p> <h3>Acknowledgments</h3> <p>This project uses some additional third party components, software and design. They are re-distributed free of charge, under the license conditions, provided by the respective authors.</p> <p>1. The new and beautiful icons are created using <a target="_blank" href="https://icons8.com">icons8.com</a>. </p> <p>2. The pdf export was made possible thanks to the <a target="_blank" href="https://wkhtmltopdf.org/">wkhtmltopdf.org</a> project. </p> <p>3. Some symbols are displayed, using the Jost* font family by <a href="https://indestructibletype.com/">indestructible type*</a>, under the <a href="https://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web">SIL open font license</a>. Square brackets are slightly modified to suit the application needs. <h2 id="TOC_105">How it works</h2> <p>The software is quick and easy to use. Just follow these simple steps:</p> <ol> <li><strong>Enter</strong> text and formulas into the "<strong>Code</strong>" box on the left.</li> <li>Press <b>F5</b> or click <img alt="Play" height="24" src="Images/Play.png"> to calculate. Results will appear in the "<b>Output</b>" box on the right as a professionally formatted Html <b>report</b>.</li> <li>Click <img alt="PrintPreview" height="24" src="Images/PrintPreview.png"> to <b>print</b> or <img alt="Copy" height="24" src="Images/Copy.png"> to <b>copy</b> the output.<br />You can also <b>export</b> it to <b>Html</b> <img alt="Html" height="24" src="Images/Save.png">, <b>PDF</b> <img alt="PDF" height="24" src="Images/Pdf.png"> or <b>MS Word</b> <img alt="Word" height="24" src="Images/Word.png"> document.</li> </ol> <p>The program can be used in two different modes:</p> <ul> <li><b>Calculator</b> - the source code is available for editing in the left box. After calculations, the results are displayed into the right box. This mode is suitable for short ans simple problems without complex formatting.</li> <li><b>Input Form</b> - the source code is not accessible. Instead, an Html input form is displayed. It contains input fields for all parameters, required for the calculations. The remaining content is locked for editing. This mode is more convenient for complex problems with rich formatting, that are frequently used. It makes clear which are the required input parameters and protects the source code from accidental damage.</li> </ul> <p>In "<b>Input Form</b>" mode, you need to fill the input data and click the <img alt="Play" height="24" src="Images/Play.png"> button. You can create such a from very easy, directly out of the source code. Just put the "<b>?</b>" symbol wherever you need to enter a value. Then save the problem as "*.cpd" file. You can find additional information about forms further in this manual.</p> <h2 id="TOC_106">Theoretical basis</h2> <p style="font-style: italic;">(you can skip this if you find it boring)</p> <p>How does Calcpad actually work? There is a sophisticated math parser inside, that does most of the job. First, the source code is scanned and the sequence of bytes is converted into a list of tokens, using lexical analysis. Each token is represented by data and type (purpose, role).</p> <p>Then the parser checks if all tokens are in the correct order. We need to know if the expression is mathematically correct and can be computed. Otherwise, a comprehensible error message should be generated. For example, "3 + a / 5" is a correct expression and "3 a + / 5" is not. For that purpose, the standard mathematical notation is represented by a formal language with context-free grammar and syntax analysis is used.</p> <p>Arithmetic expressions are usually written in infix notation. It means that each operator is located between the respective operands (e.g. "5*3 + 2"). The problem is that, unlike humans, computers are difficult to understand such expressions. The main problems are the operator precedence and the use of brackets. For example, the above expression makes "17", while "5*(3 + 2)" makes "25". That is why, the expression is converted into different type of notation, called "postfix" or Reverse Polish Notation (RPN). It is very easy for a computer to read this one. For example, the expression "5*(3 + 2)" is written in RPN as "5 3 2 + *". The main advantage is that the order of operations can be clearly specified without the need of brackets.</p> <p>There is a simple and powerful algorithm for evaluation of expressions, written in reverse polish notation (RPN). It is used by almost all calculators. However, Calcpad includes additional functionality for processing parameters, functions, macros, conditional execution, loops, etc.</p> <p>This was a brief and simple explanation. If you are more curious about these topic, you can find additional information in specialized books, papers or websites. Wikipedia is a good place to start with: <p style="margin-left: 2em;"><a target="_blank" href="https://en.wikipedia.org/wiki/Parsing">https://en.wikipedia.org/wiki/Parsing</a></p> <p style="margin-left: 2em;"><a target="_blank" href="https://en.wikipedia.org/wiki/Lexical_analysis">https://en.wikipedia.org/wiki/Lexical_analysis</a></p> <p style="margin-left: 2em;"><a target="_blank" href="https://en.wikipedia.org/wiki/Context-free_grammar">https://en.wikipedia.org/wiki/Context-free_grammar</a></p> <p style="margin-left: 2em;"><a target="_blank" href="https://en.wikipedia.org/wiki/Shunting-yard_algorithm">https://en.wikipedia.org/wiki/Shunting-yard_algorithm</a></p> <p style="margin-left: 2em;"><a target="_blank" href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">https://en.wikipedia.org/wiki/Reverse_Polish_notation</a></p> <h2 id="TOC_200">Writing code</h2> <p>Enter the code into the "<b>Code</b>" input window. Spacing and indent are maintained automatically. You can use the computer keyboard or the "<b>Numeric Keypad</b>" below. You can copy text from and to the input window or any external program (e.g. <b>Word</b>). There is a toolbar above the input window with some useful editing commands: Copy, Paste, Undo, Redo and Insert Image.</p> <p>The source code is logically divided into lines, which are numbered automatically. Each expression should be on a separate line. By exception, it is possible to have several expressions on the same line, but they must be separated by comments. When you finish the line, press "<b>Enter</b>" to start a new line. Syntax highlighting is performed automatically. Different code elements are displayed with different colors depending on their type. For example, comments are colored in green and errors are colored in red. All comments must be enclosed in quotes. They can include both plain text and <b>Html</b>. You can use Html to add pictures, tables and format the report.</p> <h3 id="TOC_201">Numeric Keypad</h3> <p><img alt="Keyboard" height="180" src="Images/Keyboard.png"></p> <p>The numeric keypad is useful when you work on a tablet or laptop with touch screen. When you press a button, the respective symbols are inserted at the place of the cursor. The keypad is separated into four sections: "<b>Numbers</b>", "<b>Operators</b>", "<b>Functions</b>" and "<b>Other</b>". The "<b>=</b>" key does not calculate the answer as on simple calculators. This is the assignment operator (e.g. "<var>a</var> = 4"). If you need to check the equality of two numbers, use the "<b>≡</b>" operator (for example, "<var>a</var> ≡ <var>b</var>" means: "Is <var>a</var> equal to <var>b</var>?"). The "<b>e</b>", "<b>π</b>" and "<b>g</b>" keys insert the respective built-in constants <var>e</var> ≈ 2.7183, <var>π</var> ≈ 3.1416 and <var>g</var> ≈ 9.8066.</p> <p>If you don't need the keypad and want to free some space, you can hide it with the <img alt="Calc" height="24" src="Images/Calc.png"> button. Click again to show the keypad back.</p> <p>The "<b style="color:red">C</b>" button deletes the previous symbol and "<b style="color:red">AC</b>" deletes a whole line. If you double click this button, you will clear the whole text. If you have done this accidentally, you can use <b>Undo</b> <img alt="Undo" height="24" src="Images/Undo.png"> to restore.</p> <h3 id="TOC_202">Moving inside the text</h3> <p>Writing and editing text in Calcpad is not much different than any other Windows program. If you have some experience in that, you can skip this and go straight to "<b>Expressions</b>".</p> <p>You can type at arbitrary position inside the text. The place where symbols are inserted is called "<b>text cursor</b>" (the blinking vertical line "<b>|</b>"). You can change the cursor position by clicking with the mouse or using the arrows "← → ↑ ↓" from the keyboard. Arrows will move the cursor one symbol left or right and one line up or down. If you hold the "<b>Ctrl</b>" key and press an arrow, the cursor will move with a whole word. "<b>Home</b>" and "<b>End</b>" keys will send you to the beginning or the end of the current line, respectively. If you hold "<b>Ctrl</b>" beforehand, you will go to the beginning or the end of the entire text.</p> <h3 id="TOC_203">Selecting text</h3> <p>Most editing commands require you to select some text to which the command will be applied. The selected text is usually displayed with <span style="background-color:LightSkyBlue;">blue background</span> (it may look different depending on your system settings). You can select text with the mouse as follows: Press the left mouse button at the start position of the text to be selected. Hold the button and move the mouse to the end position. Then release the button. Alternatively, you can click at the start, press <b>Shift</b> and then click at the end. You can also use the computer keyboard. Hold <b>Shift</b> and press arrows or "<b>Home</b>", "<b>End</b>", "<b>Page Up</b>", "<b>Page Down</b>".</p> <h3 id="TOC_204">Deleting text</h3> <p>You can delete a single symbol by pressing the "<b>Delete</b>" ("Del") or "<b>Backspace</b>" ("Bkspc") keys. The difference is that "Delete" removes the symbol after the cursor, and "Backspace" - before the cursor. If you hold "<b>Ctrl</b>" beforehand, you can delete a whole words instead of separate symbols. If you need to delete a larger part of the text, you can select it and press either "Delete" or "Backspace" after that.</p> <h3 id="TOC_205">Copy</h3> <p>If some part of the text is repeated, you can copy it instead of typing it again. That requires two steps: "Copy" and "Paste". At the first step (Copy), the selected text is sent to memory called <b>Clipboard</b>. At the second step (Paste), the text is inserted at the new places. Once copied, you can paste the text at multiple places.</p> <p>You can copy the selected text to the Clipboard by pressing "<b>Ctrl+C</b>" or by clicking the <img alt="Copy" height="24" src="Images/Copy.png"> button.</p> <h3 id="TOC_206">Paste</h3> <p>Before you paste a text from the Clipboard you have to position the cursor at the required place. Then press "<b>Ctrl+V</b>" or the <img alt="Paste" height="24" src="Images/Paste.png"> button. You can copy text from Calcpad and paste it to other programs and vice-versa. For example, you can take some formulas from Word, calculate them in Calcpad and return the results back to Word.</p> <h3 id="TOC_207">Undo</h3> <p>This command undoes the result from the last editing command and restores the previous state. You can undo up to 10 steps back. Just press "<b>Ctrl+Z</b>" or click the <img alt="Undo" height="24" src="Images/Undo.png"> button.</p> <h3 id="TOC_208">Redo</h3> <p>"Redo" performs in the opposite way to "Undo". It restores a command that has been undone. Redo must follow immediately the last Undo. If you enter or edit some text meanwhile, you will lose the ability to redo. Click the <img alt="Redo" height="24" src="Images/Redo.png"> button to redo.</p> <h3 id="TOC_209">Find</h3> <p>You can search for a certain text inside the code and replace it with another, if needed. Select the "<b>Edit/Find</b>" menu, click the <img alt="Find" height="24" src="Images/Search.png"> button or press "<b>Ctrl+F</b>". The "<b>Find And Replace</b>" dialog will appear.</p> <p><img alt="Find Dialog" width="450" src="Images/FindDialog.png"></p> <p>Enter a word or phrase to search for and click "<b>Find Next</b>". The programs starts from the current position and finds the first occurrence in the selected direction. If the searched phrase is found, it is highlighted and the search is stopped. To find the next occurrence, click "<b>Find Next</b>" again. You can also press "<b>F3</b>" to continue searching even after you close the dialog.</p> <p>If you need to replace the searched text, click the "<b>Replace</b>" tab and fill in the "<b>Replace with</b>" box. Then click the "<b>Replace</b>" button. The program will replace the current occurrence and will automatically move to the next one. If you want to replace all occurrence in the code, click the respective button instead. </p> <p>There are several options that affect the search results, as follows:</p> <ul> <li><b>Direction</b>: "Up", "Down" and "All". Both "All" and "Down" search towards the end of the document. The difference is that "All" jumps to the beginning and starts over, after it reaches the end of the document.</li> <li><b>Selection</b>: It works only with the "<b>Replace All</b>" command. You need to make the selection first and then to display the "<b>Find And Replace</b>" dialog. Then, if you check the "<b>Selection</b>" options, all the replacements will be made only inside the selected text.</li> <li><b>Match case</b>: If selected, the search will make difference between capital and small letters. By default, the case is neglected.</li> <li><b>Whole words</b>: If selected, the program will search only for sequences that represent whole words. </li> </ul> <h2 id="TOC_300">Coding aids</h2> <h3 id="TOC_301">Syntax highlighting</h3> <p>Syntax highlighting applies different colors to different components of the programming language: functions, variables, operators, etc. It runs automatically in the background, each time you edit and leave the current line. All errors are highlighted in red. The program makes difference between defined and undefined variables and functions. The color palette is predefined and cannot be changed. Currently, Calcpad does not support custom styles and themes.</p> <h3 id="TOC_302">Auto-indentation</h3> <p>The indentation of the separate lines in the code is maintained automatically by the program. All lines that are inside conditional and loop blocks are indented accordingly. Additionally, you can add spaces at the beginning of each line. Although spacing is also handled automatically, the leading spaces are not affected.</p> <h3 id="TOC_303">Auto-complete</h3> <p>When you start typing, the program displays a drop-down list with suggestions that match what you have just typed. It contains keywords, units of measurement, built in function and all custom variables and functions that are defined above the current line. The list is dynamically filtered ans sorted while you are typing. The current suggestion in the list is highlighted. If that is what you need, just press "<b>Tab</b>" to insert it at the current position. Click on the list to insert some of the other suggestions. Alternatively, you can press "<b>Down Arrow</b>" to browse the available suggestions and "<b>Enter</b>" to insert the selected one. If the list is above the current line, press "<b>Up Arrow</b>" instead.</p> <h3 id="TOC_304">Bracket matching</h3> <p>The program can find the matching opening and closing brackets. If you position the cursor next or before one of them, both brackets are highlighted. If theere is no corresponding bracket, nothing is highlighted.</p> <h3 id="TOC_305">Greek letters</h3> <p>You can insert Greek letters by clicking the respective symbol bellow the code editor. Alternatively, type the Latin equivalent from the table below and press "<b>Ctrl+G</b>". If you press it again, you will convert the letter back from Greek to Latin. Since "j"/"J" and "V" remain unused, they are mapped to "ø"/"Ø" and "∡", respectively.</p> <table class="bordered"> <tr><th>Name </th><th>greek</th><th>latin</th><th>Greek</th><th>Latin</th> <tr><td>alpha </td><td>α</td><td>a</td><td>Α</td><td>A</td></tr> <tr><td>beta </td><td>β</td><td>b</td><td>Β</td><td>B</td></tr> <tr><td>gamma </td><td>γ</td><td>g</td><td>Γ</td><td>G</td></tr> <tr><td>delta </td><td>δ</td><td>d</td><td>Δ</td><td>D</td></tr> <tr><td>epsilon </td><td>ε</td><td>e</td><td>Ε</td><td>E</td></tr> <tr><td>zeta </td><td>ζ</td><td>z</td><td>Ζ</td><td>Z</td></tr> <tr><td>eta </td><td>η</td><td>h</td><td>Η</td><td>H</td></tr> <tr><td>theta </td><td>θ</td><td>q</td><td>Θ</td><td>Q</td></tr> <tr><td>theta-alt </td><td>ϑ</td><td>v</td><td>∡</td><td>V</td></tr> <tr><td>iota </td><td>ι</td><td>i</td><td>Ι</td><td>I</td></tr> <tr><td>kappa </td><td>κ</td><td>k</td><td>Κ</td><td>K</td></tr> <tr><td>lambda </td><td>λ</td><td>l</td><td>Λ</td><td>L</td></tr> <tr><td>mu </td><td>μ</td><td>m</td><td>Μ</td><td>M</td></tr> <tr><td>nu </td><td>ν</td><td>n</td><td>Ν</td><td>N</td></tr> <tr><td>xi </td><td>ξ</td><td>x</td><td>Ξ</td><td>X</td></tr> <tr><td>omicron </td><td>ο</td><td>o</td><td>Ο</td><td>O</td></tr> <tr><td>pi </td><td>π</td><td>p</td><td>Π</td><td>P</td></tr> <tr><td>rho </td><td>ρ</td><td>r</td><td>Ρ</td><td>R</td></tr> <tr><td>sigma </td><td>σ</td><td>s</td><td>Σ</td><td>S</td></tr> <tr><td>tau </td><td>τ</td><td>t</td><td>Τ</td><td>T</td></tr> <tr><td>upsilon </td><td>υ</td><td>u</td><td>Υ</td><td>U</td></tr> <tr><td>phi </td><td>φ</td><td>f</td><td>Φ</td><td>F</td></tr> <tr><td>chi </td><td>χ</td><td>c</td><td>Χ</td><td>C</td></tr> <tr><td>psi </td><td>ψ</td><td>y</td><td>Ψ</td><td>Y</td></tr> <tr><td>omega </td><td>ω</td><td>w</td><td>Ω</td><td>W</td></tr> <tr><td>phi-diam </td><td>ø</td><td>j</td><td>Ø</td><td>J</td></tr> </table> <h3 id="TOC_306">Using Notepad++</h3> <p><b>Notepad++</b> is a popular text/code editor. It is free and open source and can be downloaded from the official website <a href="https://notepad-plus-plus.org" target="_blank">https://notepad-plus-plus.org</a>. It supports many programming or scripting languages. Its text editing capabilities are much more powerful than Calcpad. It is also very useful for writing Html code. <b>Calcpad</b> syntax can be also used with Notepad++. It is predefined as an XML file that can be inserted in Notepad++. You can do this by selecting the "<b>Language</b>" menu, then click "<b>Define your language</b>" and then, "<b>Import…</b>". Find the <b>Calcpad</b> folder inside your <b>Program Files</b> directory or wherever Calcpad is installed and select the file named <a href="https://calcpad.eu/download/Notepadpp.zip" target="_blank">Calcpad-syntax-for-Notepad++.xml</a>.</p> <h2 id="TOC_400">Expressions</h2> <p>The main purpose of Calcpad is to perform calculations. That is why, everything inside the input window is assumed to be mathematical expressions, unless it is enclosed in quotes. Then it is treated as comments. By default, each expression has to be in a separate line, e.g.:</p> <ul style="list-style: none;"> <li><code>2 + 3</code></li> <li><code>5*(3+1)</code></li> <li><code>15/2</code></li> </ul> <p>You must not add "=" at the end of each expression. This is the assignment operator. It is used to assign values to variables, e.g. "<var>a</var> = 2". Press the <img alt="Play" height="24" src="Images/Play.png"> button, to see the results in the output window:</p> <ul style="list-style: none;"> <li><code>2 + 3 = 5</code></li> <li><code>5∙(3 + 1) = 20</code></li> <li><code>15/2 = 7.5</code></li> </ul> <p>Alternatively, you can have several expressions in a single line, but they must be separated by comments, e.g.:</p> <p style="margin-left: 2em;"><code><span class="comment">'Length -'</span><var>a</var> = 3 <i>m</i><span class="comment">', Width -'</span><var>b</var> = 2*<var>a</var><span class="comment">', Height -'</span><var>c</var> = 5 <i>m</i></code></p> <p>Each expression can include constants (numbers), variables, operators, functions and brackets. They must be arranged properly in order to represent a valid expression. The commonly accepted mathematical notation and operator precedence is used as it is taught in school. Detailed description of the expression components is provided bellow.</p> <p>You can calculate separate unrelated expressions as with simple calculator or write a complete program that solves a specific problem. You can define variables and assign values to them. Further, you can use them to define other variables and so on until you reach the final result. You can also add text, Html and images to create detailed and professional-looking calculation report. You can save it to a file and use it multiple times to solve similar problems. Bellow, you can see a sample program for solving a quadratic equation:</p> <p><img alt="Sample1" src="Images/Sample1.png"></p> <h3 id="TOC_401">Constants</h3> <h4>Real</h4> <p>Real constants can be positive and negative integer and decimal numbers. They can include digits "<b>0</b>" - "<b>9</b>" and decimal point "<b>.</b>". You can also enter numbers as fractions like "<b>3/4</b>". However, the program will treat them as expressions (division of two numbers). You cannot define numbers in floating point format: "<b>3.4e+6</b>". You have to use an expression like "<b>3.4*10^6</b>" instead.</p> <p>All constants and variables are internally stored as "double-precision floating point" numbers. Their values are ranged from <b>-1.7976931348623157E+308</b> to <b>1.7976931348623157E+308</b>. If a result is out of the above interval, the program returns "<span class="err">-∞</span>" or "<span class="err">+∞</span>, respectively". Division by zero gives the same result, but "<b>0/0</b>" = "<span class="err">Undefined</span>". The smallest positive number is <b>4.94065645841247E-324</b>. Smaller values are rounded exactly to 0.</p> <h4>Complex</h4> <p>If you select "<b>Complex</b>" mode, you can use complex numbers in calculations. Otherwise, only real arithmetic is applied. Each complex number is represented by the ordered couple (<b>a</b>; <b>b</b>), where "<b>a</b>" is real number, and "<b>b</b> = |<b>b</b>|<b><var>i</var></b>" is called "imaginary". It can be written in so called algebraic form: ±<b>a</b> ± <b>b<var>i</var></b> (e.g. "2 + 3<var>i</var>"). You can also use other forms, such as polar or exponential from, by entering the respective expressions. In Calcpad, the imaginary unit can be entered either as "<var>i</var>" or "1<var>i</var>" in case you have a variable named "<var>i</var>". The imaginary unit is a special number that satisfies the expression <var>i</var><sup> 2</sup> = -1.</p> <h3 id="TOC_402">Variables</h3> <p>A variable is defined by its name and value using expressions like "<var>a</var> = 4". The "<b>=</b>" symbol is the assignment operator. On the left side, only a single variable name is allowed. On the right side, you can have any valid mathematical expression, e.g. "<var>b</var> = <var>a</var> + 4". A variable "lives" from the place of its definition to the end of the program. That is why you cannot use a variable before it is defined. This will raise an error. If you redefine an existing variable with a new value, it will replace the old one and the new value will be used further on.</p> <p>Variable names can include small or capital Latin letters "<var>a</var>" - "<var>z</var>", "<var>A</var>" - "<var>Z</var>", Greek letters "<var>α</var>" - "<var>ω</var>", "<var>Α</var>" - "<var>Ω</var>" and digits. Names are case sensitive. For example "<var>a</var>" and "<var>A</var>" are different variables. A name must start with a letter or ∡. You can also use "," (comma), "<b>‾</b>" (overline), "<b>_</b>" (underscore), superscripts: " <b>⁰</b> " - " <b>⁹</b> ", " <b>ⁿ</b> ", " <b>⁺</b> ", " <b>⁻</b> " and other symbols: " <b>′</b> ", " <b>″</b> ", " <b>‴</b> ", " <b>⁗</b> ", " <b>ø</b> ", "<b>Ø</b>", " <b>°</b> ", "<b>∡</b>". The first occurrence of an underscore in a name starts a subscript. For example, "a_1_1" will be formatted as "<var>a</var><sub>1_1</sub>". Variables can store either real or complex numbers (in "Complex" mode).</p> <h3 id="TOC_403">Operators</h3> <p>The following operators are supported by the Calcpad language:</p> <ul> <li>Arithmetic: <ul style="list-style-type:none;"> <li>"<b>!</b>" - factorial;</li> <li>"<b>^</b>" - exponentiation;</li> <li>"<b>/</b>" - floating point division;</li> <li>"<b>\</b>" - integer division; </li> <li>"<b>÷</b>" - division bar; </li> <li>"<b style="font-size:80%;">⦼</b>" - modulo (%%, reminder);</li> <li>"<b>*</b>" - multiplication;</li> <li>"<b>-</b>" - subtraction; </li> <li>"<b>+</b>" - addition; </li> </ul> </li> <li>Relational (comparison): <ul style="list-style-type:none;"> <li>"<b>≡</b>" - equal to (==);</li> <li>"<b>≠</b>" - unequal to (!=);</li> <li>"<b><</b>" - less then;</li> <li>"<b>></b>" - greater than;</li> <li>"<b>≤</b>" - less or equal (<=);</li> <li>"<b>≥</b>" - greater or equal (>=);</li> </ul> </li> <li>Logical: <ul style="list-style-type:none;"> <li>"<b>∧</b>" - logical "and";</li> <li>"<b>∨</b>" - logical "or";</li> <li>"<b style="font-size:80%;">⊕</b>" - logical “xor”;</li> </ul> </li> <li>"<b>=</b>" - assignment.</li> </ul> <h4>Operator shortcuts</h4> <p>Instead of "≡", "≠", "≤"- and "≥", you can use the respective C-style equivalent operators, as follows: "==", "!=", "<=" and ">=". They will be automatically replaced by the corresponding Calcpad operators. The shortcut “%%” will be converted to the modulo operator “⦼”. This is necessary because “%” is reserved for the percent units. Since this symbol is not very common, it is rendered as “mod” in the output, e.g. “7 mod 5 = 2”, instead of “7 ⦼ 5 = 2”.</p> <h4>Operator precedence and associativity</h4> <p>The above operators are listed in the order of their precedence. This is the order they will be evaluated in an expression. When you have different types of operators in a single expression, exponentiation will be evaluated first, then division and multiplication, subtraction and addition and comparison will be the last. When we have a unary minus and exponentiaton, the exponentiaton is evaluated first. For example: "-2^2 = -(2^2) = -4" All relational operators are of equal precedence. If you need to change the order of evaluation, you can use brackets. For example, "5 + 2∙3" makes "11". If the addition have to be first, write "(5 + 2)∙3". You will get "7∙3 = 21". Operators with equal precedence are evaluated from left to right. This is called operator associativity. For example, "3 - 2 + 1" makes "(3 - 2) + 1 = 2" and not "3 - (2 + 1) = 0". Another good example is "2∙3 / 2∙3", which makes "9" and not "1".</p> <p>All operators in Calcpad are left-associative (calculations are performed from left to right). The only exception is exponentiation, which is right-associative. It is performed from right to left, which means that <var>x</var>^<var>a</var>^<var>b</var> will be evaluated as <var>x</var><sup>a<sup>b</sup></sup>. However, many hand calculators and spreadsheet software like Excel use left associativity for exponentiation. In this case <var>x</var>^<var>a</var>^<var>b</var> will be evaluated as <var>x</var><sup>a·b</sup>. If you need to have <var>x</var><sup>a<sup>b</sup></sup>, you will have to add brackets: <var>x</var>^(<var>a</var>^<var>b</var>).</p> <h4>Relational expressions</h4> <p>Relational operators can return only two values: "<b>1</b>" for "<b>true</b>" and "<b>0</b>" for "<b>false</b>". You can use them in expressions along with arithmetic operators. For example, you can get the greater of two numbers <var>a</var> and <var>b</var> by the expression: "<var>a</var>*(<var>a</var> ≥ <var>b</var>) + <var>b</var>*(<var>a</var> < <var>b</var>)". But you need to be careful. If you use "<b>≤</b>" instead of "<b><</b>", for the case of <var>a</var> equal to <var>b</var>, you will get <var>a</var> + <var>b</var>, which may be not exactly what you want. For that special purpose, it is better to use the built-in function <b>max</b>(<var>a</var>; <var>b</var>), logical operators or conditional execution (look further in this manual). Arithmetic operators are of higher precedence than relational, and both are evaluated before logical ones.</p> <h4>Logical expressions</h4> <p>Calcpad operates only with numerical data, and does not have special types for boolean data. Similar to relational ones, logical operators also uses "<b>1</b>" for "<b>true</b>" and "<b>0</b>" for "<b>false</b>". Any input value, different than 0 is also assumed to be "<b>true</b>". You can build logical expressions by using logical operators and/or logical functions (see further in this manual). They work as follows:</p> <ul style="list-style-type:none;"> <li>"∧" (and) returns 1 if both operands are 1 and 0 otherwise;</li> <li>"∨" (or) returns 1 if any of the operands is 1 and 0 if both are 0;</li> <li>"⊕" (xor) returns 1 if just one of the operands is 1 and 0 otherwise.</li> </ul> <p>The results from the above operators are presented in the following tables:</p> <table width="100%"><tr><td style="border:none;"> <p><b>And</b></p> <table width="60%" class="tr"> <tr><th>x</th><th>y</th><th>x∧y</th></tr> <tr><td>0</td><td>0</td><td>0</td></tr> <tr><td>0</td><td>1</td><td>0</td></tr> <tr><td>1</td><td>0</td><td>0</td></tr> <tr><td>1</td><td>1</td><td>1</td></tr> </table> </td><td style="border:none;"> <p><b>Or</b></p> <table width="60%" class="tr"> <tr><th>x</th><th>y</th><th>x∨y</th></tr> <tr><td>0</td><td>0</td><td>0</td></tr> <tr><td>0</td><td>1</td><td>1</td></tr> <tr><td>1</td><td>0</td><td>1</td></tr> <tr><td>1</td><td>1</td><td>1</td></tr> </table> </td><td style="border:none;"> <p><b>Xor</b></p> <table width="60%" class="tr"> <tr><th>x</th><th>y</th><th>x<span style="font-size:80%">⊕</span>y</th></tr> <tr><td>0</td><td>0</td><td>0</td></tr> <tr><td>0</td><td>1</td><td>1</td></tr> <tr><td>1</td><td>0</td><td>1</td></tr> <tr><td>1</td><td>1</td><td>0</td></tr> </table> </td></tr></table> <h4>Complex arithmetic</h4> <p>All operators support complex numbers except for factorial "<b>!</b>", integer division "<b>\</b>", reminder "<b>⦼</b>" and comparison: "<b><</b>", "<b>≤</b>", "<b>></b>", "<b>≥</b>". The evaluation of a complex expression is a little bit more difficult than real. The rules for the basic complex operations are given bellow:</p> <ul> <li>Addition: <code>(a + b<var>i</var>) + (c + d<var>i</var>) = (a + c) + (b + d)<var>i</var></code>;</li> <li>Subtraction: <code>(a + b<var>i</var>) − (c + d<var>i</var>) = (a − c) + (b − d)<var>i</var></code>;</li> <li>Multiplication: <code>(a + b<var>i</var>)·(c + d<var>i</var>) = (ac − bd) + (bc + ad)<var>i</var></code>;</li> <li>Division: <code>(a + b<var>i</var>)/(c + d<var>i</var>) = (ac + bd)/(c<sup>2</sup> + d<sup>2</sup>) + (bc − ad)/(c<sup>2</sup> + d<sup>2</sup>)<var>i</var></code>;</li> </ul> <h3 id="TOC_404">Brackets</h3> <p>Brackets are used in two cases: to change the order of calculations and to enclose arguments of functions. Only round brackets are allowed: "<b>(</b>" and "<b>)</b>". The software checks if the following rules are satisfied for each expression:</p> <ul> <li>The first bracket in an expression must be a left one;</li> <li>The count of left and right brackets must be equal;</li> <li>Only operator or function identifier are allowed before a left bracket;</li> <li>Right bracket is not allowed after operator or function identifier;</li> <li>A function identifier always must be followed by a left bracket.</li> </ul> <p>Calcpad uses "smart" bracket insertion while rendering the output. It means that brackets, which are duplicate or do not affect the order of calculations, are omitted from the output. On the other hand, there are places where brackets are added for clarity, although not required in the input. It happens mostly when negative or complex variables are substituted. For example:</p> <ul> <li>If <var>a</var> = -2, then <var>a</var><sup>2</sup> = (-2)<sup>2</sup> = 4, and not <var>a</var><sup>2</sup> = -2<sup>2</sup>. The second case is ambiguous and the sign can be applied after the exponentiation which will evaluate to -4. Also, brackets are added to exponentiation of a complex variable;</li> <li>If <var>a</var> = -2, then <var>b</var> = -<var>a</var> = -(-2) = 2, and not <var>b</var> = -<var>a</var> = --2 = 2;</li> <li>Brackets are also added in the case of multiplication and division to a negative variable: <var>a</var>·<var>b</var> = -2·(-3) = 6;</li> <li>Brackets are required almost every time we have to substitute complex variables: <var>a</var>·<var>b</var> = (2 + 3<var>i</var>)·(3 - 2<var>i</var>) = 12 + 5<var>i</var>.</li> </ul> <h3 id="TOC_405">Functions</h3> <h4>Library (built-in) functions</h4> <p>Calcpad includes a library with common math functions, ready to use:</p> <ul> <li>Trigonometric:<ul style="list-style-type:none;"> <li><code><b>sin</b>(<var>x</var>)</code> - sine;</li> <li><code><b>cos</b>(<var>x</var>)</code> - cosine;</li> <li><code><b>tan</b>(<var>x</var>)</code> - tangent = <code><b>sin</b>(<var>x</var>)/<b>cos</b>(<var>x</var>)</code>, for each <var>x</var> ≠ kπ, k=1, 2, 3…;</li> <li><code><b>csc</b>(<var>x</var>)</code> - cosecant = <code>1/<b>sin</b>(<var>x</var>)</code>, for each <var>x</var> ≠ kπ, k=1, 2, 3…;</li> <li><code><b>sec</b>(<var>x</var>)</code> - secant = <code>1/<b>cos</b>(<var>x</var>)</code>, for each <var>x</var> ≠ π/2 + kπ, k=1, 2, 3…;</li> <li><code><b>cot</b>(<var>x</var>)</code> - cotangent = <code><b>cos</b>(<var>x</var>)/<b>sin</b>(<var>x</var>)</code>, for each <var>x</var> ≠ π/2 + kπ, k=1, 2, 3…;</li> </ul></li><li>Hyperbolic:<ul style="list-style-type:none;"> <li><code><b>sinh</b>(<var>x</var>)</code> - hyperbolic sine = <code>(e<sup><var>x</var></sup> - e<sup>-<var>x</var></sup>)/2</code>;</li> <li><code><b>cosh</b>(<var>x</var>)</code> - hyperbolic cosine = <code>(e<sup><var>x</var></sup> + e<sup>-<var>x</var></sup>)/2</code>;</li> <li><code><b>tanh</b>(<var>x</var>)</code> - hyperbolic tangent = <code>(e<sup><var>x</var></sup> - e<sup>-<var>x</var></sup>)/(e<sup><var>x</var></sup> + e<sup>-<var>x</var></sup>)</code>;</li> <li><code><b>csch</b>(<var>x</var>)</code> - hyperbolic cosecant = <code>1/<b>sinh</b>(<var>x</var>)</code>;</li> <li><code><b>sech</b>(<var>x</var>)</code> - hyperbolic secant = <code>1/<b>cosh</b>(<var>x</var>)</code>;</li> <li><code><b>coth</b>(<var>x</var>)</code> - hyperbolic cotangent = <code>(e<sup><var>x</var></sup> + e<sup>-<var>x</var></sup>)/(e<sup><var>x</var></sup> - e<sup>-<var>x</var></sup>), for <var>x</var> ≠ 0</code>;</li> </ul></li><li>Inverse trigonometric:<ul style="list-style-type:none;"> <li><code><b>asin</b>(<var>x</var>)</code> - inverted sine, defined for -1 ≤ <var>x</var> ≤ 1;</li> <li><code><b>acos</b>(<var>x</var>)</code> - inverted cosine, defined for -1 ≤ <var>x</var> ≤ 1;</li> <li><code><b>atan</b>(<var>x</var>)</code> - inverted tangent;</li> <li><code><b>atan2</b>(<var>x</var>; <var>y</var>)</code> - the angle whose tangent is the quotient of <var>y</var> and <var>x</var>;</li> <li><code><b>acsc</b>(<var>x</var>)</code> - inverted cosecant = <code><b>asin</b>(1/<var>x</var>)</code>;</li> <li><code><b>asec</b>(<var>x</var>)</code> - inverted secant = <code><b>acos</b>(1/<var>x</var>)</code>;</li> <li><code><b>acot</b>(<var>x</var>)</code> - inverted cotangent;</li> </ul></li><li>Inverse hyperbolic:<ul style="list-style-type:none;"> <li><code><b>asinh</b> (<var>x</var>)</code> - inverted hyperbolic sine = <code><b>ln</b>(<var>x</var> + <span class="root">√</span><span class="ovr"><var>x</var><sup>2</sup> + 1</span>)</code>, defined for -∞ ≤ <var>x</var> ≤ +∞;</li> <li><code><b>acosh</b>(<var>x</var>)</code> - inverted hyperbolic cosine = <code><b>ln</b>(<var>x</var> + <span class="root">√</span><span class="ovr"><var>x</var> + 1</span>·<span class="root">√</span><span class="ovr"><var>x</var> - 1</span>)</code>, defined for <var>x</var> ≥ 1;</li> <li><code><b>atanh</b>(<var>x</var>)</code> - inverted hyperbolic tangent = <code>1/2·<b>ln</b>[(1 + <var>x</var>)/(1 - <var>x</var>)]</code>, for -1 < <var>x</var> < 1;</li> <li><code><b>acsch</b>(<var>x</var>)</code> - inverted hyperbolic cosecant = <code><b>atanh</b>(1/<var>x</var>)</code>;</li> <li><code><b>asech</b>(<var>x</var>)</code> - inverted hyperbolic secant = <code><b>acosh</b>(1/<var>x</var>)</code>;</li> <li><code><b>acoth</b>(<var>x</var>)</code> - inverted hyperbolic cotangent = <code>1/2·<b>ln</b>[(<var>x</var> + 1)/(<var>x</var> - 1)]</code>, for |<var>x</var>| > 1;</li> </ul></li><li>Logarithmic, exponential and roots:<ul style="list-style-type:none;"> <li><code><b>log</b>(<var>x</var>)</code> - decimal logarithm (with base 10), for each <var>x</var> > 0;</li> <li><code><b>ln</b>(<var>x</var>)</code> - natural logarithm (with base <var>e</var> ≈ 2.7183), for each <var>x</var> > 0;</li> <li><code><b>log_2</b>(<var>x</var>)</code> - binary logarithm (with base 2), for each <var>x</var> > 0;</li> <li><code><b>exp</b>(<var>x</var>)</code> - exponential function = <var>e</var> ˣ;</li> <li><code><b>sqr</b>(<var>x</var>)</code> or <code><b>sqrt</b>(<var>x</var>)</code> - square root (<span class="root">√</span><span class="ovr"><var>x</var></span> ), defined for each <var>x</var> ≥ 0;</li> <li><code><b>cbrt</b>(<var>x</var>)</code> - cubic root ( <sup><sup>3</sup></sup><span class="root">√</span><span class="ovr"><var>x</var></span> );</li> <li><code><b>root</b>(<var>x</var>; <var>n</var>)</code> - n-th root ( <sup><sup>n</sup></sup><span class="root">√</span><span class="ovr"><var>x</var></span> );</li> </ul></li><li>Rounding:<ul style="list-style-type:none;"> <li><code><b>round</b>(<var>x</var>)</code> - rounds to the nearest integer;</li> <li><code><b>floor</b>(<var>x</var>)</code> - rounds to the smaller integer (towards -∞);</li> <li><code><b>ceiling</b>(<var>x</var>)</code> - rounds to the greater integer (towards +∞);</li> <li><code><b>trunc</b>(<var>x</var>)</code> - rounds to the smaller integer (towards zero);</li> </ul></li><li>Integer:<ul style="list-style-type:none;"> <li><code><b>mod</b>(<var>x</var>; <var>y</var>)</code> - the reminder of an integer division;</li> <li><code><b>gcd</b>(<var>x</var>; <var>y</var>)</code> - the greatest common divisor of two integers;</li> <li><code><b>lcm</b>(<var>x</var>; <var>y</var>)</code> - the least common multiple of two integers;</li> </ul></li><li>Complex:<ul style="list-style-type:none;"> <li><code><b>abs</b>(<var>x</var>)</code> - absolute value (modulus) of a real number | <var>x</var> |;</li> <li><code><b>abs</b>(a + b<var>i</var>)</code> - complex modulus = <b>sqrt</b>(a<sup>2</sup> + b<sup>2</sup>);</li> <li><code><b>re</b>(a + b<var>i</var>)</code> - returns the real part only, <b>re</b>(a + b<var>i</var>) = a;</li> <li><code><b>im</b>(a + b<var>i</var>)</code> - returns the imaginary part as a real number, <b>im</b>(a + b<var>i</var>) = b;</li> <li><code><b>phase</b>(a + b<var>i</var>)</code> - complex number phase (argument) = <b>atan2</b>(a; b).</li> </ul></li><li>Aggregate and interpolation:<ul style="list-style-type:none;"> <li><code><b>min</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - the smallest of multiple values;</li> <li><code><b>max</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - the greatest of of multiple values;</li> <li><code><b>sum</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - sum of multiple values<code> = <var>x</var> + <var>y</var> + <var>z</var>…</code>;</li> <li><code><b>sumsq</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - sum of squares<code> = <var>x</var>² + <var>y</var>² + <var>z</var>²…</code>;</li> <li><code><b>srss</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - square root of sum of squares<code> = <b>sqrt</b>(<var>x</var>² + <var>y</var>² + <var>z</var>²…)</code>;</li> <li><code><b>average</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - average of multiple values<code> = (<var>x</var> + <var>y</var> + <var>z</var>…)/n</code>;</li> <li><code><b>product</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - product of multiple values<code> = <var>x</var>·<var>y</var>·<var>z</var>…;</code></li> <li><code><b>mean</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - geometric mean<code> = n-th <b>root</b>(<var>x</var>·<var>y</var>·<var>z</var>…)</code>;</li> <li><code><b>take</b>(<var>n</var>; <var>a</var>; <var>b</var>; <var>c</var>…)</code> - returns the n-th element from the list;</li> <li><code><b>line</b>(<var>x</var>; <var>a</var>; <var>b</var>; <var>c</var>…)</code> - performs linear interpolation among the specified values for parameter <var>x</var>;</li> <li><code><b>spline</b>(<var>x</var>; <var>a</var>; <var>b</var>; <var>c</var>…)</code> - performs Hermite spline interpolation;</li> </ul></li><li>Conditional and logical:<ul style="list-style-type:none;"> <li><code><b>if</b>(<<em>cond</em>>; <<em>value-if-true</em>>; <<em>value-if-false</em>>)</code> - if the condition <var>cond</var> is satisfied, the function returns the first value, otherwise it returns the second value. The condition is satisfied when it evaluates to any non-zero number;</li> <li><code><b>switch</b>(<<em>cond1</em>>; <<em>value1</em>>; <<em>cond2</em>>; <<em>value2</em>>;…; <<em>default-value</em>>)</code> - returns the value for which the respective condition is satisfied. Conditions are checked from left to right. If none is satisfied, it returns the default value in the end;</li> <li><code><b>not</b>(<var>x</var>)</code> - logical "not";</li> <li><code><b>and</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - logical "and";</li> <li><code><b>or</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - logical "or";</li> <li><code><b>xor</b>(<var>x</var>; <var>y</var>; <var>z</var>…)</code> - logical "xor";</li> </ul></li><li>Other:<ul style="list-style-type:none;"> <li><code><b>sign</b>(<var>x</var>)</code> - sign of a number = -1, if <var>x</var> < 0; 1, if <var>x</var> > 0, 0 if <var>x</var> = 0;</li> <li><code><b>random</b>(<var>x</var>)</code> - a random number between 0 and <var>x</var>.</li> </ul></li></ul> <p>Arguments must be enclosed in round brackets. They can be constants, variables or any valid expression. Multiple arguments must be separated by semicolons ";". When arguments are out of range, the function returns "<span class="err">Undefined</span>". Exceptions from this rule are "<b>cot</b>(0)" and "<b>coth</b>(0)", which return "<span class="err">+∞</span>".</p> <p>Arguments of trigonometric functions can be in <b>degrees</b>, <b>radians</b> or <b>grades</b>. The units for angles can be specified in three different ways:</p> <p>1. By the radio buttons above the output window (<small>🔘</small><b>D</b>, <small>🔘</small><b>R</b>, <small>🔘</small><b>G</b>).</p> <p>2. By compiler switches inside the code. You have to insert a separate line containing: <span class="cond">#deg</span> for degrees, <span class="cond">#rad</span> for radians or <span class="cond">#gra</span> for grades. This will affect all expressions after the current line to the end or until an alternative directive is found.</p> <p>3. By attaching native units to the value itself: <i>deg</i>, <i>°</i>, <i>′</i>, <i>″</i>, <i>rad</i>, <i>grad</i>, <i>rev</i> (see the “Units” section, further in this manual).</p> <p>Native units are of highest priority, followed by compiler switches in source code. Both override radio buttons settings, which are of lowest priority.</p> <p>All functions are also defined in the complex domain, except for <b>mod</b>(<var>x</var>; <var>y</var>), <b>gcd</b>(<var>x</var>; <var>y</var>), <b>lcm</b>(<var>x</var>; <var>y</var>), <b>min</b>(<var>x</var>; <var>y</var>) and <b>max</b>(<var>x</var>; <var>y</var>).</p> <p>Logical functions accept numerical values and return “<b>0</b>” for “<b>false</b>” and “<b>1</b>” for “<b>true</b>”. The results for two arguments (one for “<b>not</b>”) are presented in the following tables:</p> <table width="100%"><tr><td style="border:none; vertical-align:top;"> <table width="90%" class="tr"> <tr><th>x</th><th style="width:60%">not(x)</th></tr> <tr><td>0</td><td>1</td></tr> <tr><td>1</td><td>0</td></tr> </table> </td><td style="border:none;"> <table width="90%" class="tr"> <tr><th>x</th><th>y</th><th style="width:50%">and(x; y)</th></tr> <tr><td>0</td><td>0</td><td>0</td></tr> <tr><td>0</td><td>1</td><td>0</td></tr> <tr><td>1</td><td>0</td><td>0</td></tr> <tr><td>1</td><td>1</td><td>1</td></tr> </table> </td><td style="border:none;"> <table width="90%" class="tr"> <tr><th>x</th><th>y</th><th style="width:50%">or(x; y)</th></tr> <tr><td>0</td><td>0</td><td>0</td></tr> <tr><td>0</td><td>1</td><td>1</td></tr> <tr><td>1</td><td>0</td><td>1</td></tr> <tr><td>1</td><td>1</td><td>1</td></tr> </table> </td><td style="border:none;"> <table width="90%" class="tr"> <tr><th>x</th><th>y</th><th style="width:50%">xor(x; y)</th></tr> <tr><td>0</td><td>0</td><td>0</td></tr> <tr><td>0</td><td>1</td><td>1</td></tr> <tr><td>1</td><td>0</td><td>1</td></tr> <tr><td>1</td><td>1</td><td>0</td></tr> </table> </td></tr></table> <p>Any numerical value, different from 0, is treated as 1 (true). Multiple arguments are evaluated sequentially from left to right, according to the above tables. We start with the first and the second. Then, the obtained result and the next value are evaluated in turn, and so on.</p> <p>Rounding of midpoint values with <b>round</b>() evaluates to the nearest integer away from zero. The <b>floor</b>() function rounds to the smaller value (towards -∞). The <b>ceiling</b>() function rounds in the opposite direction to the larger value (towards +∞). Unlike <b>floor</b>(), <b>trunc</b>() rounds towards zero, which is equivalent to simply truncating the fractional part. Some examples for rounding of negative and positive numbers are provided in the table bellow:</p> <table width="70%"><tr><td style="border:none;"> <p><b>Positive</b></p> <table width="90%" class="tr"> <tr><th>Function</th><th style="width:30%">x</th><th>Result</th></tr> <tr><th>round(x)</th><td>4.5</td><td>5</td></tr> <tr><th>floor(x)</th><td>4.8</td><td>4</td></tr> <tr><th>ceiling(x)</th><td>4.2</td><td>5</td></tr> <tr><th>trunc(x)</th><td>4.8</td><td>4</td></tr> </table> </td><td style="border:none;"> <p><b>Negative</b></p> <table width="90%" class="tr"> <tr><th>Function</th><th style="width:30%">x</th><th>Result</th></tr> <tr><th>round(x)</th><td>-4.5</td><td>-5</td></tr> <tr><th>floor(x)</th><td>-4.8</td><td>-5</td></tr> <tr><th>ceiling(x)</th><td>-4.2</td><td>-4</td></tr> <tr><th>trunc(x)</th><td>-4.8</td><td>-4</td></tr> </table> </td></tr></table> <p>Rounding of complex numbers affects both real and imaginary parts.</p> <h4>Custom (user defined) functions</h4> <p>You can define your own functions, and use them further in the calculations. Custom functions can have unlimited number of parameters. They are specified after the function name, enclosed in brackets "(" … ")" and separated by semicolons ";". Each function is defined, using the following format: "<b>f</b> ( <var>x</var>; <var>y</var>; <var>z</var>; … ) = <b>expression</b>", where "<b>f</b>" is the function name and "<b>x</b>", "<b>y</b>" and "<b>z</b>" are function parameters. On the right side you can have any valid expression including constants, operators, variables and even other functions, e.g.:</p> <ul style="list-style-type:none;"> <li><code><b>f</b>(<var>x</var>) = <var>x</var>^2 + 2*x*<b>sin</b>(<var>x</var>)</code></li> <li><code><b>g</b>(<var>x</var>; <var>y</var>) = <b>f</b>(<var>x</var>)/(<var>y</var> - 4)</code></li> </ul> <p>Once defined, you can use a function in any expression by inserting a function call. Just write the function name and then specify the arguments in brackets, e. g. <var>b</var> = <b>g</b>(<var>a</var> + 2; 3) + 3. Function names must conform to the same rules as variable names. Arguments can be any valid expressions. You have to provide as many arguments as the number of function parameters. The life cycle of a function is from the place of definition to the end of the code. If you define a new function with the same name, the old one will be replaced. You cannot redefine a library function. For example, <b>sin</b>(<var>x</var>) = <var>x</var>^2 will return an error.</p> <p>It is not necessary to pre-define the variables that are used for parameters. However, if other variables are used inside the function body, they must be defined before the first call to the function. Parameters work as local level variables inside the function body. If a variable with the same name exists outside the function, a call to that function will not rewrite the value of the global variable. For example:</p> <ul style="list-style-type:none;"> <li>If you have a variable "<var>x</var> = 4"</li> <li>and a function "<b>f</b>(<var>x</var>) = <var>x</var><sup>2</sup>".</li> <li>When you call "<b>f</b>(2)", it will evaluate to <var>x</var><sup>2</sup> = 2<sup>2</sup> = 4, because local <var>x</var> = 2</li> <li>If you call "<var>x</var><sup>2</sup>" after that, it will return <var>x</var><sup>2</sup> = 4<sup>2</sup> = 16, because global <var>x</var> remains 4.</li> </ul> <p>User defined functions support both real and complex numbers.</p> <h3 id="TOC_406">Plotting</h3> <p>Besides functions, Calcpad provides special commands for advanced operations. They accept functions and expressions as arguments and perform plotting, iterative solutions and numerical methods. Their names start with "$" to be distinguished from normal functions. Their parameters must be enclosed in curly brackets: "{" and "}". Such is the plotting command <span class="cond">$Plot</span>. It can plot a function of one variable in the specified interval. It has the following format:</p> <p style="margin-left: 2em;"><code><span class="cond">$Plot</span>{<b>y</b>(<var>x</var>) @ <var>x</var> = <var>a</var> : <var>b</var>}</code></p> <p>, where:</p> <ul style="list-style-type:none;"> <li><b>y</b>(<var>x</var>) - the function to be plotted. Instead of <b>y</b>(<var>x</var>) you can put any valid expression. It will be used to calculate the ordinate values;</li> <li><var>x</var> - the name of the variable along the abscissa. You can put here only a single name. It is not required to define the variable preliminary;</li> <li><var>a</var> and <var>b</var> are the limits of the interval for the <var>x</var> variable. Instead of <var>a</var> and <var>b</var> you can put numbers, variables or any valid expressions.</li> </ul> <p>For example, if you enter: <code><span class="cond">$Plot</span>{<var>x</var>^2 - 5*<var>x</var> + 3 @ x = -1:6}</code>, you will get the following result:</p> <p style="text-align:center;"><img width="400" src="Images/Plot.png" alt="Plot.png"></p> <p>The above command plots only one function of one variable at a time. There are also other formats that you can use:</p> <p style="margin-left: 2em;"><code><span class="cond">$Plot</span>{<b>x</b>(<var>t</var>)|<b>y</b>(<var>t</var>) @ <var>t</var> = <var>a</var> : <var>b</var>}</code> - parametric plot: both coordinates are functions of a parameter;<br /> <code><span class="cond">$Plot</span>{<b>y</b><sub>1</sub>(<var>x</var>) & <b>y</b><sub>2</sub>(<var>x</var>) & … @ <var>x</var> = <var>a</var> : <var>b</var>}</code> - multiple: plots several functions on a single graph;<br /> <code><span class="cond">$Plot</span>{<b>x</b><sub>1</sub>(<var>t</var>)|<b>y</b><sub>1</sub>(<var>t</var>) & <b>x</b><sub>2</sub>(<var>t</var>)|<b>y</b><sub>2</sub>(<var>t</var>) & … @ <var>t</var> = <var>a</var> : <var>b</var>}</code> - multiple parametric;<br /> <code><span class="cond">$Map</span>{<b>f</b>(<var>x</var>; <var>y</var>) @ <var>x</var> = <var>a</var> : <var>b</var> & <var>y</var> = <var>c</var> : <var>d</var>}</code> - draws a 2D color map of a 3D surface, defined by <b>f</b>(<var>x</var>; <var>y</var>).</p> <p>The <span class="cond">$Plot</span>{…} function must be the first thing in a line. You can have only spaces and tabs before, not even comments. Otherwise, the program will return an error. Any text after the closing bracket "}" will be ignored. Plotting supports only real numbers. You can use it in complex mode, only if <var>x</var> and <var>y</var> are real and the function returns real result along the plotting interval.</p> <p>You can specify the size of the plot area by defining two variables: <var>PlotWidth</var> and <var>PlotHeight</var> in pixels. The default values are <var>PlotWidth</var> = 400 and <var>PlotHeight</var> = 250.</p> <p>The <span class="cond">$Map</span>{…} function can work with different color palettes. Select the preferred one from the "<b>Palette</b>" combo box on the bottom of the program window. If you select the "<b>Smooth</b>" checkbox, the scale will be displayed as a smooth gradient. Otherwise, the program will draw color strips. You can also add 3D effects to the graph by selecting the "<b>Shadows</b>" checkbox. You can also specify light direction by the respective combo.</p> <p>Examples of different plotting methods are provided bellow:</p> <table class="nb"> <tr><td style="line-height:150%;"> <b>Parametric</b><br /> Equation:<br /><br /> <code><b>r</b>(<var>θ</var>) = <b>cos</b>(5/2*<var>θ</var>)</code><br /> <code><span class="cond">$Plot</span>{<b>r</b>(<var>θ</var>)*<b>cos</b>(<var>θ</var>)|<b>r</b>(<var>θ</var>)*<b>sin</b>(<var>θ</var>) @ <var>θ</var> = 0:6*π}</code> </td><td style="line-height:150%;"> <b>Multiple</b><br /> Equation:<br /> <code><b>y</b><sub>1</sub>(<var>θ</var>) = <b>cos</b>(<var>θ</var>) - <b>sin</b>(<var>θ</var>)</code><br /> <code><b>y</b><sub>2</sub>(<var>θ</var>) = <b>cos</b>(<var>θ</var>) + <b>sin</b>(<var>θ</var>)</code><br /> <code><span class="cond">$Plot</span>{<b>cos</b>(<var>θ</var>) & <b>y</b><sub>1</sub>(<var>θ</var>) & <b>y</b><sub>2</sub>(<var>θ</var>) @ <var>θ</var> = 0:<var>π</var>}</code> </td></tr><tr><td> Result: "rose" curve<br /> <img style="height:220pt;" src="Images/Plot-Rose.png" alt="Plot-Rose.png"> </td><td> Result: leaf by three trigonometric functions<br /> <img style="height:220pt;" src="Images/Plot-Leaf.png" alt="Plot-Leaf.png"> </td></tr><tr><td style="line-height:150%;"> <b>Multiple parametric</b><br /> Equation:<br /> <code><b>x</b>(<var>θ</var>) = <b>sqr</b>(<var>θ</var>)*<b>cos</b>(<var>θ</var>)</code><br /> <code><b>y</b>(<var>θ</var>) = <b>sqr</b>(<var>θ</var>)*<b>sin</b>(<var>θ</var>)</code><br /> <code><span class="cond">$Plot</span>{<b>x</b>(<var>θ</var>)|<b>y</b>(<var>θ</var>) & -<b>x</b>(<var>θ</var>)|-<b>y</b>(<var>θ</var>) @ <var>θ</var> = 0:3*<var>π</var>}</code> </td><td style="line-height:150%;"> <b>Color map</b><br /> Equation:<br /><br /> <code><b>f</b>(<var>x</var>; <var>y</var>) = <b>cos</b>(<var>x</var>/3) + <b>sin</b>(<var>y</var>) - <b>sin</b>(<var>x</var>)*<b>cos</b>(<var>y</var>/4)</code><br /> <code><span class="cond">$Map</span>{<b>f</b>(<var>x</var>; <var>y</var>) @ <var>x</var> = -15 : 15 & <var>y</var> = -15 : 15}</code> </td></tr><tr><td> Result: double Fermat spiral<br /> <img style="height:220pt;" src="Images/Plot-Fermat.png" alt="Plot-Fermat.png"> </td><td> Result: 2D waves<br /> <img style="height:220pt;" src="Images/Map-Wave.png" alt="Plot-Wave.png"> </td></tr> </table> <h3 id="TOC_407">Numerical methods</h3> <p>Calcpad has a built in "<b>Solver</b>" module, which can solve more difficult problems using numerical methods. It can work only with real numbers but not complex. It includes the following functions:</p> <h4>Root finding</h4> <p style="margin-left: 2em;"><code><span class="cond">$Root</span>{<b>f</b>(<var>x</var>) = const @ <var>x</var> = <var>a</var> : <var>b</var>}</code></p> <p style="margin-left: 2em;"><code><span class="cond">$Root</span>{<b>f</b>(<var>x</var>) @ <var>x</var> = <var>a</var> : <var>b</var>}</code></p> <p>It finds a single root for an equation of type "<b>f</b>(<var>x</var>) = const" within the interval [<var>a</var>, <var>b</var>]. If "const" is zero, you can omit "= const". The program uses a <a href="https://iopscience.iop.org/article/10.1088/1757-899X/1276/1/012010">hybrid bracketing method</a>, which is a combination of Bisection and Anderson-Bjork's method. It subsequently narrows the interval around the root, until it gets smaller than the specified precision. It is required that the function "<b>f</b>(<var>x</var>) - const" has opposite signs at the ends of the interval. According to the Boltzano's theorem, if the function is continuous within the interval, at least one root exist. The bracketing algorithm will find an approximation after a finite number of iterations.</p> <p style="text-align:center;"><img style="height:130pt;" src="Images/Root.png" alt="Root.png"></p> <p>With this method, you can find only roots where the function crosses the line at "<var>y</var> = const". When "<b>f</b>(<var>x</var>) - const" is entirely positive or negative and only "touches" the line from one side, you cannot find the root by any bracketing method.</p> <p>If no roots exist inside the initial interval, the program returns an error. If there are several roots, it will find only one of them. In such case, it is better to plot the function first. Then, you can see the approximate location of roots and divide the interval into several parts - one for each root. Finally, you can call the function several times to find all the roots. In some cases, it is possible to develop an automated procedure for interval splitting.</p> <h4>Minimum</h4> <p style="margin-left: 2em;"><code><span class="cond">$Inf</span>{<b>f</b>(<var>x</var>) @ <var>x</var> = <var>a</var> : <var>b</var>}</code></p> <p>It finds the smallest value for a function <b>f</b>(<var>x</var>) within the specified interval [<var>a</var>, <var>b</var>]. The golden section search method is applied for that purpose. If the function contains a local minimum within the interval, it will be returned as a result. Otherwise, the function will return the smaller of the values at the ends of the interval: <b>f</b>(<var>a</var>) or <b>f</b>(<var>b</var>). If there are several local minimums, the program will return only one of them, but not necessarily the smallest one. In such cases, it is better to split the interval. The value of <var>x</var> where the minimum is found is stored into a variable <var>x</var><sub>inf</sub>. If you use different name for the argument, instead of <var>x</var>, it will add "_inf" at the end of that name.</p> <h4>Maximum</h4> <p style="margin-left: 2em;"><code><span class="cond">$Sup</span>{<b>f</b>(<var>x</var>) @ <var>x</var> = <var>a</var> : <var>b</var>}</code></p> <p>It works like the minimum finding function, but it finds the greatest value instead. The value of <var>x</var> where the maximum is located is stored in a variable named <var>x</var><sub>sup</sub>.</p> <h4>Numerical integration</h4> <p style="margin-left: 2em;"><code><span class="cond">$Area</span>{<b>f</b>(<var>x</var>) @ <var>x</var> = <var>a</var> : <var>b</var>}</code></p> <p>It calculates the value of the definite integral of a function <b>f</b>(<var>x</var>) within the specified interval [<var>a</var>, <var>b</var>]. Adaptive Gauss-Lobbato quadrature with Kronrod extension is applied for that purpose (<a target="_blank" href = "https://www.researchgate.net/publication/226706221_Adaptive_Quadrature-Revisited">Gander & Gautschi</a>, 2000).</p> <p style="margin-left: 2em;"><code><span class="cond">$Integral</span>{<b>f</b>(<var>x</var>) @ <var>x</var> = <var>a</var> : <var>b</var>}</code></p> <p>This command is similar to the above, but it uses the Tanh-Sinh quadrature (<a target="_blank" href="https://ems.press/content/serial-article-files/2719">Takahasi & Mori</a>, 1974) which has been additionally improved by <a target="_blank" href="https://www.ingentaconnect.com/content/tandf/jew/2016/00000030/00000003/art00001;jsessionid=55mdimh9e060a.x-ic-live-03">Michashki & Mosig</a> (2016) and <a target="_blank" href="https://www.genivia.com/files/qthsh.pdf">Van Engelen</a> (2022). Further improvements has been made in Calcpad, by precomputing and caching the abscissas and weights. This algorithm significantly outperforms <code class="cond">$Area</code> for <b>continuous</b> and <b>smooth</b> functions. However, if the function does not satisfy these requirements, you <b>should not</b> use the <code class="cond">$Integral</code> method. Then, you have two options:</p> <ol> <li>Divide the interval [<var>a</var>, <var>b</var>] into smaller parts, by using the points of discontinuities, apply the method for each part separately, and sum the results;</li> <li>If you are not sure where the discontinuities are, use the <code class="cond">$Area</code> method instead.</li> </ol> <h4>Numerical differentiation</h4> <p style="margin-left: 2em;"><code><span class="cond">$Slope</span>{<b>f</b>(<var>x</var>) @ <var>x</var> = <var>a</var>}</code></p> <p>It finds the value of the first derivative of a function <b>f</b>(<var>x</var>) at <var>x</var> = <var>a</var>. The derivative represents the slope of the tangent to the function at the respective point. The Richardson extrapolation method is used on a two point stencil.</p> <h4>General considerations</h4> <p>Unlike the plotting command, you can include numerical methods in expressions. They return values which can be used for further calculations. For example, you can store the result into a variable:</p> <p style="margin-left: 2em;"><code><var>y</var><sub>min</sub> = <span class="cond">$Inf</span>{<b>f</b>(<var>x</var>) @ <var>x</var> = <var>a</var> : <var>b</var>}</code></p> <p>Similarly to standard functions, "<var>x</var>" is local for all numerical methods and its global value is not modified after the method is called.</p> <h3 id="TOC_408">Iterative procedures</h3> <p>There are some other commands that allows you to calculate the result iteratively. Unlike numerical methods, they can work with complex numbers.</p> <h4>Sum</h4> <p style="margin-left: 2em;"><code><span class="cond">$Sum</span>{<b>f</b>(<var>k</var>) @ <var>k</var> = <var>a</var> : <var>b</var>}</code></p> <p>It sums the values of <b>f</b>(<var>k</var>) for all integer <var>k</var> between <var>a</var> and <var>b</var>. The values of <var>k</var> can only grow, so it should be satisfied that <var>a</var> < <var>b</var>. Instead of <b>f</b>(<var>k</var>) you can put any valid expression that includes <var>k</var>. Otherwise, it will simply sum the same value <var>k</var> times. For example, you can use series to calculate constants. Such is the Leibniz formula for calculation of π:</p> <p style="margin-left: 2em;"><code>4*<span class="cond">$Sum</span>{(-1)<sup><var>k</var>+1</sup>/(2*<var>k</var> - 1) @ <var>k</var> = 1:1000}= 3.1406</code></p> <p>You can also use series to define functions. Of course, they cannot be infinite. The number of iterations should be sufficient to provide the required precision of the result. The following pattern can be applied to approximate a function with Fourier series:</p> <p style="margin-left: 2em;"><code><b>f</b>(<var>x</var>) = <var>a</var><sub>0</sub>/2 + <span class="cond">$Sum</span>{<b>a</b>(<var>k</var>)*<b>cos</b>(<var>k</var>*<var>x</var>*π/<var>l</var>) @ <var>k</var> = 1:<var>n</var>} + <span class="cond">$Sum</span>{<b>b</b>(<var>k</var>)*<b>sin</b>(<var>k</var>*<var>x</var>*π/<var>l</var>) @ <var>k</var> = 1:<var>n</var>}</code></p> <p>As an example, we can take a straight line within the interval (0; 2*<var>l</var>), withs equation: f(<var>x</var>) = <var>x</var>/(2*<var>l</var>). The integration constants are <var>a</var>(<var>k</var>) = 0 and <var>b</var>(<var>k</var>) = -1/(<var>k</var>*π). If we plot the Fourier approximation for <var>n</var> = 5, we will get the following result:</p> <p style="text-align:center;"><img alt="Fourier" src="Images/Fourier.png" width="400"></p> <h4>Product</h4> <p style="margin-left: 2em;"><code><span class="cond">$Product</span>{<b>f</b>(<var>k</var>) @ <var>k</var> = <var>a</var> : <var>b</var>}</code></p> <p>It works like "<b>Sum</b>", but it multiplies the terms instead of adding them. For example, you can define your own factorial function:</p> <p style="margin-left: 2em;"><code><b>F</b>(<var>n</var>) = <span class="cond">$Product</span> {<var>k</var> @ <var>k</var> = 1 : <var>n</var>}</code></p> You can use it further to calculate binomial coefficients by the well-known formula: <b>C</b>(<var>n</var>; <var>k</var>) = <b>F</b>(<var>n</var>)/(<b>F</b>(<var>k</var>)*<b>F</b>(<var>n</var> - <var>k</var>)). However, it is much more efficient to define a special procedure that computes the coefficient directly without using factorials: <p style="margin-left: 2em;"><code><span class="cond">$Product</span>{(<var>i</var> + <var>n</var> - <var>k</var>)/<var>i</var> @ <var>i</var> = <var>1</var>:<var>k</var>}</code></p> <p>Also, the later will not overflow together with the factorials for greater values of <var>n</var>.</p> <h4>Repeat</h4> <p style="margin-left: 2em;"><code><span class="cond">$Repeat</span>{<b>f</b>(<var>k</var>) @ <var>k</var> = <var>a</var> : <var>b</var>}</code></p> <p>This is a general inline iterative procedure that repeatedly calculates <b>f</b>(<var>k</var>). It can be used for sums and products instead of the respective procedures, but it is not so efficient. However, there are expressions that can be calculated only by the "<b>Repeat</b>" command. Normally, such expressions will make sense if you assign the result to a variable to be used in the next iteration. So, the following pattern is more likely to be applied in practice:</p> <p style="margin-left: 2em;"><code><span class="cond">$Repeat</span>{<var>x</var> = <b>f</b>(<var>x</var>; <var>k</var>) @ <var>k</var> = <var>a</var> : <var>b</var>}</code></p> <p>For example, you can use this command to define the Mandelbrot set in a single line: <p style="margin-left: 2em;"><code><b>f</b>(<var>z</var>; <var>c</var>) = <span class="cond">$Repeat</span>{<var>z</var> = <var>z</var>^2 + <var>c</var> @ <var>i</var> = 1:100}</code></p> <p>You should not forget to switch to "Complex" mode. Then you can plot the result: <p style="margin-left: 2em;"><code><span class="cond">$Map</span>{<b>abs</b>(<b>f</b>(0; <var>x</var> + 1i*<var>y</var>)) @ <var>x</var> = -1.5:0.5 & <var>y</var> = -1:1}</code></p> <p style="text-align:center;"><img alt="Mandelbrot" src="Images/Mandelbrot.png" width="500"></p> <h3 id="TOC_409">Units</h3> <p>Calcpad provides a comprehensive support for physical units of measurement. The current version, supports metric (SI and compatible), US and Imperial units. There are seven basic units that correspond to the seven physical dimensions:</p> <ul> <li>mass - kilogram (<i>kg</i>)</li> <li>length - meter (<i>m</i>)</li> <li>time - second (<i>s</i>)</li> <li>electric current - ampere (<i>A</i>)</li> <li>temperature - degree Celsius (<i>°C</i>)</li> <li>amount of substance - mole (<i>mol</i>)</li> <li>luminous intensity - candela (<i>cd</i>)</li> </ul> <p>All other units are derivative. They are obtained by the respective laws of physics. For example, force = mass·acceleration, so Newton is obtained by <i>N</i> = <i>kg</i>·<i>m</i>/<i>s</i><sup>2</sup>. Multiples of units are also supported by adding the respective prefixes to units names. For example, <i>kN</i> = 10<sup>3</sup> <i>N</i>, <i>MN</i> = 10<sup>6</sup> <i>N</i> and so on.</p> <p>Additionally, there are some "dimensionless" units like percents, permilles and angles (degrees, radians, etc.) that do not include any physical dimensions. However, angles exist in a special (eighth) non-physical dimension, in order not to cancel and convert to percents, when mixed (which would be weird).</p> <p>You can attach units to numbers by typing the unit name after the value, e.g. 15 <i>kg</i>. Then, you can use them in expressions, just like any other values. Unit cancellation and conversion is performed automatically during calculations. For example, the following expression will be evaluated as:</p> <p style="margin-left: 2em;"><code>1.23 <i>m</i> + 35 <i>cm</i> + 12 <i>mm</i> = 1.59 <i>m</i></code>(and not: 1.23 + 35 + 12 = 48.23)</p> <p>The result is usually obtained into the first unit in the expression. If you want to use particular units, write a vertical bar "|" followed by the target units at the end:</p> <p style="margin-left: 2em;"><code>1.23 <i>m</i> + 35 <i>cm</i> + 12 <i>mm</i>|<i>cm</i></code></p> <p>The above expression will evaluate to 159.2 <i>cm</i>. If you simply want to convert units, just write the source and the target units, separated by a vertical bar, like:  <i>mm</i>|<i>cm</i> or 10 <i>m</i>/<i>s</i>|<i>km</i>/<i>h</i>.</p> <p>Unit consistency is also verified automatically. For example, you cannot add <i>m</i> and <i>s</i> (e.g. 6 <i>m</i> + 2 <i>s</i>), but you can multiply and divide them: 6 <i>m</i>/2 <i>s</i> = 3 <i>m</i>/<i>s</i>. </p> <p>Arguments for trigonometric, hyperbolic, logarithmic and exponential functions, must be unitless by definition. However, you can use units an any custom defined functions, if it makes any sense. You can also attach units to variables. If you specify the target units in a variable definition, they will be stored permanently inside the variable. Then, the selected units will be used further in the calculations with the respective value. In the next example, speed is calculated in <i>m</i>/<i>s</i>, but it is converted and stored as <i>km</i>/<i>h</i>:</p> <table border="1"> <thead> <tr> <th> Code </th> <th> Output </th> </tr> </thead> <tbody> <tr> <td style="line-height:180%;"> <code>'Distance -'<var>s</var>_1 = 50<i>m</i></code><br /> <code>'Time -'<var>t</var>_1 = 2<i>s</i></code><br /> <code>'Speed -'<var>V</var> = <var>s</var>_1/<var>t</var>_1|<i>km</i>/<i>h</i></code><br /> <code>'What distance you will travel for'<var>t</var>_2 = 5<i>s</i>'?</code><br /> <code><var>s</var> _2 = <var>V</var>*<var>t</var>_2|<i>m</i></code> </td> <td style="line-height:150%;"> Distance - <var>s</var><sub>1</sub> = 50 <i>m</i><br /> Time - <var>t</var><sub>1</sub> = 2 <i>s</i><br /> Speed - <var>V</var> = <var>s</var><sub>1</sub>/<var>t</var><sub>1</sub> = 50 <i>m</i>/2 <i>s</i> = 90 <i>km</i>/<i>h</i><br /> What distance you will travel for <var>t</var><sub>2</sub> = 5 <i>s</i> ? <br /> <var>s</var><sub>2</sub> = <var>V</var>·<var>t</var><sub>2</sub> = 90 <i>km</i>/<i>h</i>·5 <i>s</i> = 125 <i>m</i> </td> </tr> </tbody> </table> <h4>Predefined units</h4> <p>Calcpad includes a large collection of predefined units as follows:</p> <p>Dimensionless:</p> <ul> <li>Percent: <i title="percent" >%</i>;</li> <li>Permille: <i title="permille">‰</i>;</li> <li>Angles: <i title="degrees">°</i>, <i title="minutes">′</i>, <i title="seconds">″</i>, <i title="degrees">deg</i>, <i title="radians">rad</i>, <i title="grades" >grad</i>, <i title="revolutions">rev</i>; </li> </ul> <p>Metric units (SI and compatible):</p> <ul><li>Mass: <i title="gram" >g</i>, <i title="hectogram" >hg</i>, <i title="kilogram" >kg</i>, <i title="ton" >t</i>, <i title="kiloton" >kt</i>, <i title="megaton" >Mt</i>, <i title="gigaton" >Gt</i>, <i title="decigram" >dg</i>, <i title="centigram" >cg</i>, <i title="milligram" >mg</i>, <i title="microgram" >μg</i>, <i title="nanogram" >ng</i>, <i title="picogram" >pg</i>, <i title="Dalton" >Da</i> (or <i title="Dalton(alt)" >u</i>); </li><li>Length: <i title="meter" >m</i>, <i title="kilometer" >km</i>, <i title="decimeter" >dm</i>, <i title="centimeter" >cm</i>, <i title="millimeter" >mm</i>, <i title="micrometer" >μm</i>, <i title="nanometer" >nm</i>, <i title="picometer" >pm</i>, <i title="astronomical unit">AU</i>, <i title="light year" >ly</i>; </li><li>Time: <i title="second" >s</i>, <i title="millisecond" >ms</i>, <i title="microsecond" >μs</i>, <i title="nanosecond" >ns</i>, <i title="picosecond" >ps</i>, <i title="minute" >min</i>, <i title="hour" >h</i>, <i title="day" >d</i>, <i title="week" >w</i>, <i title="year" >y</i>; </li><li>Frequency: <i title="Hertz" >Hz</i>, <i title="kilohertz" >kHz</i>, <i title="megahertz" >MHz</i>, <i title="gigahertz" >GHz</i>, <i title="terahertz" >THz</i>, <i title="millihertz" >mHz</i>, <i title="microhertz" >μHz</i>, <i title="nanohertz" >nHz</i>, <i title="terahertz" >pHz</i>, <i title="rotations per minute">rpm</i>; </li><li>Speed: <i href="#0" data-text="kmh" title="kilometers per hour">kmh</i>; </li><li>Electric current: <i title="Ampere" >A</i>, <i title="kiloampere" >kA</i>, <i title="megaampere" >MA</i>, <i title="gigaampere" >GA</i>, <i title="teraampere" >TA</i>, <i title="milliampere" >mA</i>, <i title="microampere" >μA</i>, <i title="nanoampere" >nA</i>, <i title="picoampere" >pA</i>; </li><li>Temperature: <i title="degrees Celsius">°C</i>, <i title="difference in degrees Celsius">Δ°C</i>, <i title="Kelvin" >K</i>; </li><li>Amount of substance: <i title="Mole" >mol</i>; </li><li>Luminous intensity: <i title="Candela" >cd</i>; </li><li>Area: <i title="are" >a</i>, <i title="decare" >daa</i>, <i title="hectare" >ha</i>; </li><li>Volume: <i title="litre" >L</i>, <i title="decalitre" >daL</i>, <i title="hectolitre" >hL</i>, <i title="decilitre" >dL</i>, <i title="centilitre" >cL</i>, <i title="millilitre" >mL</i>, <i title="microlitre" >μL</i>, <i title="nanolitre" >nL</i>, <i title="picolitre" >pL</i>; </li><li>Force: <i title="Newthon" >N</i>, <i title="decanewthon" >daN</i>, <i title="hectonewthon" >hN</i>, <i title="kilonewthon" >kN</i>, <i title="meganewthon" >MN</i>, <i title="giganewthon" >GN</i>, <i title="teranewthon" >TN</i>, <i title="gram-force" >gf</i>, <i title="kilogram-force">kgf</i>, <i title="tonne-force" >tf</i>, <i title="dyne" >dyn</i>; </li><li>Moment: <i title="Newton-meter" >Nm</i>, <i title="kilonewton-meter">kNm</i>; </li><li>Pressure: <i title="Pascal" >Pa</i>, <i title="decapascal" >daPa</i>, <i title="hectpascal" >hPa</i>, <i title="kilopascal" >kPa</i>, <i title="megapascal" >MPa</i>, <i title="gigapascal" >GPa</i>, <i title="terapascal" >TPa</i>, <i title="decipascal" >dPa</i>, <i title="centipascal" >cPa</i>, <i title="micropascal" >mPa</i>, <i title="millipascal" >μPa</i>, <i title="nanopascal" >nPa</i>, <i title="picopascal" >pPa</i>, <br />     <i title="bar" >bar</i>, <i title="millibar" >mbar</i>, <i title="microbar" >μbar</i>, <i title="atmosphere" >atm</i>, <i title="technical atmosphere">at</i>, <i title="Torr" >Torr</i>, <i title="millimeters of mercury">mmHg</i>; </li><li>Viscosity: <i title="Poise" >P</i>, <i title="centipoise" >cP</i>, <i title="Stokes" >St</i>, <i title="centistokes" >cSt</i>; </li><li>Energy work: <i title="Joule" >J</i>, <i title="kilojoule" >kJ</i>, <i title="megajoule" >MJ</i>, <i title="gigajoule" >GJ</i>, <i title="terajoule" >TJ</i>, <i title="millijoule" >mJ</i>, <i title="microjoule" >μJ</i>, <i title="nanojoule" >nJ</i>, <i title="picojoule" >pJ</i>, <br />      <i title="watt-hour" >Wh</i>, <i title="kilowatt-hour" >kWh</i>, <i title="megawatt-hour" >MWh</i>, <i title="gigawatt-hour" >GWh</i>, <i title="terawatt-hour" >TWh</i>, <i title="milliwatt-hour" >mWh</i>, <i title="microwatt-hour" >μWh</i>, <i title="nanowatt-hour" >nWh</i>, <i title="picowatt-hour" >pWh</i>, <br />      <i title="electronvolt" >eV</i>, <i title="kiloelectronvolt" >keV</i>, <i title="megaelectronvolt" >MeV</i>, <i title="gigaelectronvolt" >GeV</i>, <i title="teraelectronvolt" >TeV</i>, <i title="petaelectronvolt" >PeV</i>, <i title="exaelectronvolt" >EeV</i>, <i title="calorie" >cal</i>, <i title="kilocalorie" >kcal</i>, <i title="erg" >erg</i>; </li><li>Power: <i title="Watt" >W</i>, <i title="kilowatt" >kW</i>, <i title="megawatt" >MW</i>, <i title="gigawatt" >GW</i>, <i title="terawatt" >TW</i>, <i title="milliwatt" >mW</i>, <i title="microwatt" >μW</i>, <i title="nanowatt" >nW</i>, <i title="picowatt" >pW</i>, <i title="horsepower (metric)">hpM</i>, <i title="horsepower (metric)">ks</i>, <br />    <i title="Volt-Ampere" >VA</i>, <i title="kilovolt-Ampere" >kVA</i>, <i title="megavolt-Ampere" >MVA</i>, <i title="gigavolt-Ampere" >GVA</i>, <i title="teravolt-Ampere" >TVA</i>, <i title="millivolt-Ampere" >mVA</i>, <i title="microvolt-Ampere" >μVA</i>, <i title="nanovolt-Ampere" >nVA</i>, <i title="picovolt-Ampere" >pVA</i>, <br />    <i title="Volt-Ampere (reactive)" >VAR</i>, <i title="kilovolt-Ampere (reactive)" >kVAR</i>, <i title="megavolt-Ampere (reactive)" >MVAR</i>, <i title="gigavolt-Ampere (reactive)" >GVAR</i>, <i title="teravolt-Ampere (reactive)" >TVAR</i>, <i title="millivolt-Ampere (reactive)">mVAR</i>, <i title="microvolt-Ampere (reactive)">μVAR</i>, <i title="nanovolt-Ampere (reactive)" >nVAR</i>, <i title="picovolt-Ampere (reactive)" >pVAR</i>; </li><li>Electric charge: <i href="#0" title="Coulomb" >C</i>, <i href="#0" title="kilocoulomb" >kC</i>, <i href="#0" title="megacoulomb" >MC</i>, <i href="#0" title="gigacoulomb" >GC</i>, <i href="#0" title="teracoulomb" >TC</i>, <i href="#0" title="millicoulomb">mC</i>, <i href="#0" title="microcoulomb">μC</i>, <i href="#0" title="nanocoulomb" >nC</i>, <i href="#0" title="picocoulomb" >pC</i>, <i href="#0" title="Ampere-hour" >Ah</i>, <i href="#0" title="milliampere-hour">mAh</i>; </li><li>Potential: <i title="Volt" >V</i>, <i title="kilovolt" >kV</i>, <i title="megavolt" >MV</i>, <i title="gigavolt" >GV</i>, <i title="teravolt" >TV</i>, <i title="millivolt" >mV</i>, <i title="microvolt" >μV</i>, <i title="nanovolt" >nV</i>, <i title="picovolt" >pV</i>; </li><li>Capacitance: <i title="Farad" >F</i>, <i title="kilofarad" >kF</i>, <i title="megafarad" >MF</i>, <i title="gigafarad" >GF</i>, <i title="terafarad" >TF</i>, <i title="millifarad" >mF</i>, <i title="microfarad" >μF</i>, <i title="nanofarad" >nF</i>, <i title="picofarad" >pF</i>; </li><li>Resistance: <i title="Ohm" >Ω</i>, <i title="kiloohm" >kΩ</i>, <i title="megaohm" >MΩ</i>, <i title="gigaohm" >GΩ</i>, <i title="teraohm" >TΩ</i>, <i title="milliohm" >mΩ</i>, <i title="microohm" >μΩ</i>, <i title="nanoohm" >nΩ</i>, <i title="picoohm" >pΩ</i>; </li><li>Conductance: <i title="Siemens" >S</i>, <i title="kilosiemens" >kS</i>, <i title="megasiemens" >MS</i>, <i title="gigasiemens" >GS</i>, <i title="terasiemens" >TS</i>, <i title="millisiemens">mS</i>, <i title="microsiemens">μS</i>, <i title="nanosiemens" >nS</i>, <i title="picosiemens" >pS</i>, <i title="mho" >℧</i>, <i title="kilomho" >k℧</i>, <i title="megamho" >M℧</i>, <i title="gigamho" >G℧</i>, <i title="teramho" >T℧</i>, <i title="millimho" >m℧</i>, <i title="micromho" >μ℧</i>, <i title="nanomho" >n℧</i>, <i title="picomho" >p℧</i>; </li><li>Magnetic flux: <i title="Weber" >Wb </i>, <i title="kiloweber" >kWb</i>, <i title="megaweber" >MWb</i>, <i title="gigaweber" >GWb</i>, <i title="teraweber" >TWb</i>, <i title="milliweber" >mWb</i>, <i title="microweber" >μWb</i>, <i title="nanoweber" >nWb</i>, <i title="picoweber" >pWb</i>; </li><li>Magnetic flux density: <i title="Tesla" >T</i>, <i title="kilotesla" >kT</i>, <i title="megatesla" >MT</i>, <i title="gigatesla" >GT</i>, <i title="teratesla" >TT</i>, <i title="millitesla" >mT</i>, <i title="microtesla" >μT</i>, <i title="nanotesla" >nT</i>, <i title="picotesla" >pT</i>; </li><li>Inductance: <i title="Henry" >H</i>, <i title="kilohenry" >kH</i>, <i title="megahenry" >MH</i>, <i title="gigahenry" >GH</i>, <i title="terahenry" >TH</i>, <i title="millihenry" >mH</i>, <i title="microhenry" >μH</i>, <i title="nanohenry" >nH</i>, <i title="picohenry" >pH</i>; </li><li>Luminous flux: <i title="lumen" >lm</i>; </li><li>Illuminance: <i title="lux" >lx</i>; </li><li>Radioactivity: <i title="Becquerel" >Bq</i>, <i title="kilobecquerel">kBq</i>, <i title="megacquerel" >MBq</i>, <i title="gigacquerel" >GBq</i>, <i title="teracquerel" >TBq</i>, <i title="millicquerel" >mBq</i>, <i title="microcquerel" >μBq</i>, <i title="nanocquerel" >nBq</i>, <i title="picocquerel" >pBq</i>, <i title="Curie" >Ci</i>, <i title="Rutherford" >Rd</i>; </li><li>Absorbed dose: <i title="Gray" >Gy</i>, <i title="kilogray" >kGy</i>, <i title="megagray" >MGy</i>, <i title="gigagray" >GGy</i>, <i title="teragray" >TGy</i>, <i title="milligray" >mGy</i>, <i title="microgray" >μGy</i>, <i title="nanogray" >nGy</i>, <i title="picogray" >pGy</i>; </li><li>Equivalent dose: <i title="Sievert" >Sv</i>, <i title="kilosievert" >kSv</i>, <i title="megasievert" >MSv</i>, <i title="gigasievert" >GSv</i>, <i title="terasievert" >TSv</i>, <i title="millisievert" >mSv</i>, <i title="microsievert" >μSv</i>, <i title="nanosievert" >nSv</i>, <i title="picosievert" >pSv</i>; </li><li>Catalytic activity: <i title="katal" >kat</i>; </li></ul> <p>Non-metric units (Imperial/US):</p> <ul><li>Mass: <i title="grain" >gr</i>, <i title="drachm" >dr</i>, <i title="ounce" >oz</i>, <i title="pound" >lb</i> (or <i title="pound-mass" >lbm</i>, <i title="pound-mass (alt)" >lb</i><sub>_m</sub>), <i title="kilopound-mass" >kipm</i> (or <i title="kilopound-mass (alt)" >kip</i><sub>_m</sub>), <i title="stone" >st</i>, <i title="quarter" >qr</i>, <br />    <i title="hundredweight" >cwt</i> (or <i title="hundredweight (UK)" >cwt</i><sub>_UK</sub>, <i title="hundredweight (US)" >cwt</i><sub>_US</sub>), <i title="ton" >ton</i> (or <i title="ton (UK)" >ton</i><sub>_UK</sub>, <i title="ton (US)" >ton</i><sub>_US</sub>), <i title="slug" >slug</i>; </li><li>Length: <i title="thou" >th</i>, <i title="inch" >in</i>, <i title="foot" >ft</i>, <i title="yard" >yd</i>, <i title="chain" >ch</i>, <i title="furlong" >fur</i>, <i title="mile" >mi</i>, <i title="fathom" >ftm</i> (or <i title="fathom (UK)" >ftm</i><sub>_UK</sub>, <i title="fathom (US)" >ftm</i><sub>_US</sub>), <br />     <i title="cable" >cable</i> (or <i title="cable (UK)" >cable</i><sub>_UK</sub>, <i title="cable (US)" >cable</i><sub>_US</sub>), <i title="nautical mile" >nmi</i>, <i title="link" >li</i>, <i title="rod" >rod</i>, <i title="pole" >pole</i>, <i title="perch" >perch</i>, <i title="league" >lea</i>; </li><li>Speed: <i title="miles per hour" >mph</i>, <i title="knots" >knot</i>; </li><li>Temperature: <i title="degrees Fahrenheit" >°F</i>, <i title="difference in °F" >Δ°F</i>, <i title="degrees Rankine" >°R</i>; </li><li>Area: <i title="rood" >rood</i>, <i title="acre" >ac</i>; </li><li>Volume, fluid: <i title="fluid ounce" >fl_oz</i>, <i title="gill" >gi</i>, <i title="pint" >pt</i>, <i title="quart" >qt</i>, <i title="gallon" >gal</i>, <i title="barrel" >bbl</i>, or: <br />       <i title="fluid ounce (UK)" >fl_oz</i><sub>_UK</sub>, <i title="gill (UK)" >gi</i><sub>_UK</sub>, <i title="pint (fluid, UK)" >pt</i><sub>_UK</sub>, <i title="quart (fluid, UK)" >qt</i><sub>_UK</sub>, <i title="gallon (fluid, UK)" >gal</i><sub>_UK</sub>, <i title="barrel (fluid, UK)" >bbl</i><sub>_UK</sub>, <br />       <i title="fluid ounce (US)" >fl_oz</i><sub>_US</sub>, <i title="gill (US)" >gi</i><sub>_US</sub>, <i title="pint (fluid, US)" >pt</i><sub>_US</sub>, <i title="quart (fluid, US)" >qt</i><sub>_US</sub>, <i title="gallon (fluid, US)" >gal</i><sub>_US</sub>, <i title="barrel (fluid, US)" >bbl</i><sub>_US</sub>; </li><li>Volume, dry: (US) <i title="pint (dry, US)" >pt</i><sub>_dry</sub>, (US) <i title="quart (dry, US)" >qt</i><sub>_dry</sub>, (US) <i title="gallon (dry, US)" >gal</i><sub>_dry</sub>, (US) <i title="barrel (dry, US)" >bbl</i><sub>_dry</sub>, <br />      <i title="peck" >pk</i> (or <i title="peck (UK)" >pk</i><sub>_UK</sub>, <i title="peck (US)" >pk</i><sub>_US</sub>), <i title="bushel" >bu</i> (or <i title="bushel (UK)" >bu</i><sub>_UK</sub>, <i title="bushel (US)" >bu</i><sub>_US</sub>); </li><li>Force: <i title="ounce-force" >ozf</i> (or <i title="ounce-force (alt)" >oz</i><sub>_f</sub>), <i title="pound-force" >lbf</i> (or <i title="pound-force (alt)" >lb</i><sub>_f</sub>), <i title="kilopound" >kip</i> (or <i title="kilopound-force" >kipf</i>, <i title="kilopound-force (alt)" >kip</i><sub>_f</sub>), <i title="ton-force" >tonf</i> (or <i title="ton-force" >ton</i><sub>_f</sub>), <i title="poundal" >pdl</i>; </li><li>Pressure: <i title="ounce-force per sq. inch" >osi</i>, <i title="ounce-force per sq. foot" >osf</i>, <i title="pound-force per sq. inch" >psi</i>, <i title="pound-force per sq. foot" >psf</i>, <i title="kilopound-force per sq. inch" >ksi</i>, <i title="kilopound-force per sq. foot" >ksf</i>, <i title="ton-force per sq. inch" >tsi</i>, <i title="ton-force per sq. foot" >tsf</i>, <i title="inches of mercury (conventional)">inHg</i>; </li><li>Energy/work: <i title="British Thermal Unit" >BTU</i>, <i title="therm" >therm</i> (or <i title="therm (UK)" >therm</i><sub>_UK</sub>, <i title="therm (US)" >therm</i><sub>_US</sub>), <i title="quad" >quad</i>; </li><li>Power: <i title="horsepower" >hp</i>, <i title="horsepower (electrical)" >hpE</i>, <i title="horsepower (boiler)" >hpS</i>. </ul> <p>Angle units are accepted by trigonometric functions and they override all other settings. Inverse trigonometric functions return unitless values by default. If you want them to return the result in the current units, you have to define a variable: <var>ReturnAngleUnits</var> = 1.</p> <p>Literals that follow numbers immediately are parsed as units, e.g. "2 <i>m</i>". Standalone literals can be either units or variables, e.g. "<i>N</i>*<i>m</i>". The rules for parsing are as follows: If a literal has not been defined as a variable, it is parsed as a unit. Otherwise, it is parsed as a variable, even if a unit with the same name exists. If you put a dot before the literal, you will force it to be parsed as a unit, even if a variable with the same name exists, e.g. ".<i>N</i>*.<i>m</i>".</p> <h4>Custom units</h4> <p>You can define your own "custom" units and use them like any others in your code. Defining a unit is similar to defining a variable, but the name must be prefixed with a dot ".":</p> <p>  <code>.<i>Name</i> = expression</code></p> <p>Names can include somе currency symbols like: €, £, ₤, ¥, ¢, ₽, ₹, ₩, ₪. If you need to create a unit, that derive from others, you can write an expression with numbers and units on the right side. You can also define dimensionless units, like currency (USD, EUR, €, ₤) or information (bit, byte, KiB, etc), by specifying "= 1" for the first unit and setting the others as multiples. For example: <p><code>  .<i>bit</i> = 1<br />   .<i>byte</i> = 8*<i>bit</i><br />   .<i>KiB</i> = 1024*<i>byte</i><br />   ...</code></p> <p>Custom dimensionless units exist in a special (ninth) non-physical dimension. That is how they do not cancel or convert to other dimensionless units, like percents or angles, when mixed. However, if you have two types of dimensionless units in a single file, they will exist in the same dimension, so you should avoid mixing them.</p> <h2 id="TOC_500">Reporting</h2> <p>All calculations are automatically collected into professionally formatted calculation report. You can print it or open it with MS Word for editing. Besides math expressions, you can add headings, comments, tables and images.</p> <h3 id="TOC_501">Headings</h3> <p>A heading is a text, enclosed in double quotes (<b>"</b>). It is bold and larger than the main text.</p> <h3 id="TOC_502">Text/comments</h3> <p>Comments are enclosed in single quotes (<b>'</b>). You can skip the closing quote, if it is the last symbol in the line. Headings and comments can contain any symbols without restrictions. Everything outside them is assumed to be math expressions. However, if you put any formulas inside comments, they will not be calculated or formatted. Since the final output is rendered to an Html document, you can use Html and CSS in comments to provide your calculation report with additional formatting .</p> <h3 id="TOC_503">Units in comments</h3> <p>Alternatively to native units, you can enter all values to be unitless and then put the units in the comments. In this case, you will have to include all unit conversion factors in the equations. Also, there is an option to generate a selection box for length units - <b>m</b>, <b>cm</b> and <b>mm</b>. You only need to insert <b>%u</b> in comments wherever you want the units to appear. When the program generates the input form (see further) it checks whether <b>%u</b> exists somewhere in the code. If so, it automatically adds a unit selection combo box, at the top-right corner. When you change the units from the combo, they will be filled in all occurrences of <b>%u</b> in the code. You can try it bellow:</p> <table border="1" width="550"> <thead> <tr> <th> Code </th> <th> Output </th> </tr> </thead> <tbody> <tr> <td style="line-height:200%;"> <code>"Units in comments</code><br /> <code>'Length -'l = ?'%u</code><br /> <code>'Area -'l = ? %u<sup>2</sup></code><br /> <code>'Volume -'l = ?'%u<sup>3</sup></code><br /> <code>'Scale factor -'Units</code><br /> </td> <td style="line-height:200%;"> <select id="Units" name="Units"><option value="m"> m </option><option value="cm"> cm </option><option value="mm"> mm </option></select> <b>Units in comments</b><br /> Length - <var>l</var> = <input type="text" size="2" name="Variable" value = "1"> <span class="Units">m</span><br /> Area - <var>l</var> = <input type="text" size="2" name="Variable" value = "1"> <span class="Units">m</span><sup>2</sup><br /> Volume - <var>V</var> = <input type="text" size="2" name="Variable" value = "1"> <span class="Units">m</span><sup>3</sup><br /> Scale factor - <var id="UnitScale">Units</var> </td> </tr> </tbody> </table>` <p>When you run the calculations, the "Units" combo will disappear from the output. Only the units will remain as filled. The program will also create a variable <var>Units</var>, which will contain the conversion factor from the selected units to meters. Its value is 1, 100 and 1000 for m, mm and cm, respectively. You can use it for units conversion inside the calculations. For example, you can create a conditional block for displaying the selected units in the report:</p> <p>  <span class="cond">#if</span> <var>Units</var> ≡ 1<br />     'The selected units are meters<br />   <span class="cond">#else if</span> <var>Units</var> ≡ 100<br />     'The selected units are centimeters<br />   <span class="cond">#else if</span> <var>Units</var> ≡ 1000<br />     'The selected units are millimeters<br />   <span class="cond">#end if</span></p> <h3 id="TOC_504">Formatting with Html and CSS</h3> <p>Calcpad can be used as a development platform for professional engineering programs. If you are not going to do that, you can skip this chapter.</p> <p><b>Html</b> (Hyper Text Markup Language) is a markup language which is created for formatting web pages. You can change the font type, size and weight, the color of the text and to insert tables, images, etc. This is performed by adding special elements called "tags". Each tag is enclosed in angular brackets: "<tag>". Some tags are used in pairs - opening "<tag>" and closing "</tag>". The contents is going in between. For example, if you want to make some text bold, you can use the following tags: <b><b>Bold text</b></b>. Even if you are not a professional programmer, you can easily learn some basic Html, to use with Calcpad:</p> <table border="1"> <thead> <tr> <th> Html code </th> <th> Output </th> </tr> </thead> <tbody> <tr> <td> <code><b><b></b>Bold<b></b></b></code> </td> <td> <b style="color:black;">Bold</b> </td> </tr> <tr> <td> <code><b><i></b>Italic<b></i></b></code> </td> <td> <i style="color:black;">Italic</i> </td> </tr> <tr> <td> <code><b><u></b>Underline<b></u></b></code> </td> <td> <u style="background:none;">Underline</u> </td> </tr> <tr> <td> <code><b><span style="color:red;"></b>Red<b></span></b></code> </td> <td> <span style="color:red;">Red</span> </td> </tr> <tr> <td> <code>x<b><sup></b>superscript<b></sup></b></code> </td> <td> x<sup>superscript</sup> </td> </tr> <tr> <td> <code>x<b><sub></b>subscript<b></sub></b></code> </td> <td> <var>x</var><sub>subscript</sub> </td> </tr> <tr> <td> <code><b><span style="font:16pt Times-New-Roman;"></b><br /> Times New Roman, 16pt<br /><b></span></b></code> </td> <td> <span style="font:16pt Times-New-Roman;">Times New Roman, 16pt</span> </td> </tr> </tbody> </table> <p>You can put Html tags only in comments, but you can also make them to affect expressions. For example:</p> <p style="margin-left: 2em;"><code>'<span style="color:red;"> as simple as ' 2 + 2 '</span>'</code></p> <p>will give the following output:</p> <p style="margin-left: 2em;"><span style="color:red;"> as simple as 2 + 2 = 4 </span></p> <p>We simply enclosed the expression with two comments. The first comment contains the opening tag '<code><span style="color:red;"></code>' and the second - the closing tag <code>'</span>'</code>. Everything between the two tags is colored in red. Make sure not to forget the quotes. Otherwise, the program will try to parse the Html code as math expression and will return an error. The following code: style="color:red" is called "inline CSS" (Cascading Style Sheets). It is used to format the look of Html documents. You can learn more about Html and CSS from the following links:</p> <p><a href="http://www.w3schools.com/html/">http://www.w3schools.com/html/</a></p> <p><a href="http://www.w3schools.com/CSS/">http://www.w3schools.com/CSS/</a></p> <p>You can also use some of the many free WYSIWYG Html editors available on the Internet.</p> <h4>Content folding</h4> <p>If you have some long and detailed calculations, you can fold them optionally in the output. They will be hidden by default, except for the first line, which can be used for the section heading. All you need to do is to enclose the folding section into a Html "<b>div</b>" element with class "<b>fold</b>", as follows:</p> <p>  <code>'<div class="fold"></code><br/>   <code>'<b>Heading</b> (click to unfold)</code><br/>   <code>'Content to be folded</code><br/>   <code>'</div></code></p> <p>The result will look as follows:</p> <div class="fold"> <p style="margin-left: 2em;"><b>Heading</b> (click to unfold)</p> <p style="margin-left: 2em;">Content to be folded</p> </div> <h3 id="TOC_505">Images</h3> <p>Before inserting an image into Calcpad document, you need to have it already as a file. You can create it by some image editing software and save it to a *.png, *.gif or *.jpg file. You can use some freeware programs like Paint, Gimp, InkScape, DraftSight or others. Then you can insert it using Html. All you need to do is to put the following text at the required place, inside a comment:</p> <p style="margin-left: 2em;"><code>'<img style="float:right" src="c:/Users/Me/Pictures/Picture1.png" alt="Picture1.png"></code></p> <p>Of course, instead of "<b>c:/Users/Me/Pictures/Picture1.png</b>" you must specify the actual path to your image. The file can be local, network or on the Internet. Always use forward slashes "<b>/</b>", even if the file is local. If the image is located in the same folder as the current worksheet, you can specify a relative path as follows: "<b>./Picture1.png</b>". The text <b>style="float:right;"</b> aligns the image to the right allowing the text to float at left. Otherwise, the image will become part of the text flow and will make it split. Alternatively to <b>style="float:right"</b>, you can use <b>class="side"</b> for the same purpose.</p> <p>You can also insert an image using the <img alt="Image" height="24" src="Images/Image.png"> button from the toolbar. You will be prompted to select a file. When you click "<b>Open</b>", the required record will be inserted at the beginning of the code. When you run the calculations, the picture will appear in the output window.</p> <h2 id="TOC_600">Programming</h2> <h3 id="TOC_601">Input Forms</h3> <p>If you have long and complicated problem or you want to share your solution with others, it is a good idea to create an input form. It is very easy to do that with Calcpad. Just replace the values that need to be entered with question marks "<b>?</b>", e.g. "<var>a</var> = ?". Please note that after that, you will not be able to calculate the results directly by clicking <img alt="Play" height="24" src="Images/Play.png">. You must compile it first to an input form. For that purpose, click the <img alt="Form" height="24" src="Images/Form.png"> button or press <b>F4</b> from the keyboard.</p> <p>The code will hide and the form will be loaded into the "<b>Input</b>" box at the full width of the main window. All texts and formulas will be rendered in Html format, protected from modification. Input boxes will be generated at every occurrence of the "<b>?</b>" symbol except those in comments. The ready-to-use input form will look as follows:</p> <p><img alt="Sample3" width="700" src="Images/Sample3.png"></p> <p>Now you have to fill the input boxes and click <img alt="Play" height="24" src="Images/Play.png"> to calculate the results. They are displayed in the "<b>Output</b>" box.</p> <p><img alt="Sample4" width="700" src="Images/Sample4.png"></p> <p> In order to return to input mode, click again <img alt="Play" height="24" src="Images/Play.png"> to switch the button off. Input data will remain unchanged since the last input. If you need to modify the source code, you have to unlock it by clicking the <img alt="Form" height="24" src="Images/Form.png"> button. The "<b>Code</b>" box will show again at the left side of the main window. Input data will be attached to the question marks. If you hover the mouse over one of them, you will see the respective value. Click on the question mark to change it. When you finish editing the code, you can compile it back to input form. The input values will be filled in the respective fields. Finally, you can save the document as a "<b>*.cpd</b>" file. When you open such file, it will be displayed directly into input form mode. This format is more convenient to use than a simple text file due to the following advantages:</p> <ul> <li>The user can see clearly which parameters should be entered. You can also provide pictures and additional explanations. This is more comprehensible for the user, especially if the program is developed by someone else;</li> <li>The rest of the source code is protected from modification, unless you unlock it on purpose. This prevents an inexperienced user to accidentally damage the calculation formulas.</li> </ul> <p>If you save the document as a "<b>*.cpdz</b>" file, you will make the source code completely inaccessible. It will not be possible to unlock it inside Calcpad anymore. Also, no one could edit the file in external text editor, because it is encoded. That is how you can protect your source code from unauthorized coping, viewing and modification.</p> <p>You can put question marks "<b>?</b>" not only in variable definitions, but at any place in the code e.g.: <p style="margin-left: 2em;">2 + ?</p> <p style="margin-left: 2em;">2 + <input type="text" size="2"></p> <p>Then, you can enter a value and calculate the result. This approach is not recommended for complicated problems, because the program logic gets unclear and difficult to understand.</p> <h4>Advanced UI with Html and CSS</h4> <p>Besides simple input boxes, you can use some advanced UI elements like "<b>select</b>" (combo box), "<b>radio</b>" buttons and "<b>checkboxes</b>" in your worksheets. Since all the output from Calcpad is rendered as an Html document, you can use Html and CSS for that purpose. However, Calcpad accepts input only from text boxes. That is why, it is required to map every other UI element to some text box. This is performed by enclosing the text box into an outer html element (paragraph or div) with a certain <b>id</b>. The same id must be assigned as a <b>name</b> or <b>data-target</b> attribute of the source UI element. Then, the content of the source element's value attribute will be automatically filled in the target text box. You can use the following sample code:</p> <p><b>Selection box:</b></p> <p>Code:</p> <pre>   'Select an option: <select name="<b class="err">target1</b>">   '<option value="11;12">x1; y1</option>   '<option value="21;22">x2; y2</option>   '<option value="31;32">x3; y3</option>   '</select>   '...   '<p id="<b class="err">target1</b>"> Values:'x = ? {21}','y = ? {22}'</p> </pre> <p>Output:</p> <p>  Select an option: <select name="target1"> <option value="11;12" id="line-3">x1; y1</option> <option value="21;22" id="line-4">x2; y2</option> <option value="31;32" id="line-5">x3; y3</option> </select><br/>  ... </p> <p id="target1">  Values: <span class="eq"><var>x</var> = <input type="text" size="2" name="Var" value="21"> </span> , <span class="eq"><var>y</var> = <input type="text" size="2" name="Var" value="22"> </span> </p> <p><b>Radio buttons:</b></p> <p>Code:</p> <pre>   '<p>Select:   '<input name="<b class="err">target2</b>" type="radio" id="opt1" value="1"/>   '<label for="opt1">option 1</label>   '<input name="<b class="err">target2</b>" type="radio" id="opt2" value="2"/>   '<label for="opt2">option 2</label>   '...   '<p id="<b class="err">target2</b>">Value -'opt = ? {2}'</p> </pre> <p>Output:</p> <p>  Select: <input name="target2" type="radio" id="opt1" value="1"/> <label for="opt1">option 1</label> <input name="target2" type="radio" id="opt2" value="2"/> <label for="opt2">option 2</label><br/>  ... </p> <p id="target2">  <span class="eq"><var>opt</var> = <input type="text" size="2" name="Var" value="2"> </span> </p> <p><b>CheckBox:</b></p> <p>Code:</p> <pre>   '<p><input name="<b class="err">target3</b>" type="checkbox" id="chk1" value="3"/>   '<label for="chk1">Checkbox 1</label></p>   '...   '<p id="<b class="err">target3</b>">Value -'chk = ? {3}'</p> </pre> <p>Output:</p> <p>  <input name="target3" type="checkbox" id="chk1" value="3"/> <label for="chk1">Checkbox 1</label><br/>  ... </p> <p id="target3">  <span class="eq"><var>chk</var> = <input type="text" size="2" name="Var" value="3"> </span> </p> <p>As you can see from the first example, one "value" attribute can contain multiple values, separated by semicolons ";". In this case, you have to provide the respective number of text boxes in the target paragraph. You can copy the above code, add as many options as you like and write your own labels and values. You can also change names and ids, but make sure that all source names match exactly the target ids and no duplicate ids exist.</p> <h3 id="TOC_602">Output control</h3> <p>You can easily specify which parts of the code should be visible or hidden in the output. Unlike conditional execution, the hidden code is always calculated. It is just not displayed. The following keywords can be used for that purpose:</p> <ul style="list-style-type:none;"> <li><span class="cond">#Hide</span> - hides the contents after the current line;</li> <li><span class="cond">#Pre</span> - shows the contents in "input" mode only (see ""<a href="#TOC_601">Input forms</a>" bellow);</li> <li><span class="cond">#Post</span> - shows the contents in "output" mode and hides it in "input" mode;</li> <li><span class="cond">#Show</span> - always shows the contents (revoke all other keywords);</li> </ul> <p>Each of the above keywords affects the content after the current line and overrides the previous one. You can use them to hide long and repetitive calculations that should not be visible. You can use the <span class="cond">#Pre</span> command to add some directions about filling the input data and <span class="cond">#Post</span> to hide the calculation algorithm during data input.</p> <p>You can also modify the display of the equations as follows:</p> <ul style="list-style-type:none;"> <li><span class="cond">#Val</span> - shows only the final result as a single value;</li> <li><span class="cond">#Equ</span> - shows both the equation and the calculated result (default);</li> <li><span class="cond">#Noc</span> - shows only the equation, without results (no calculations).</li> </ul> <p>Each of the above keywords overrides the other. You can use <span class="cond">#Val</span> to create a table with values, but without the formulas, like in Excel.</p> <h3 id="TOC_603">Conditional execution</h3> <p>Sometimes the solution have to continue in different ways, depending on some intermediate values. Such feature is included in Calcpad, similarly to other programming languages. It is called "conditional execution block" and has the following general form:</p> <ul style="list-style-type:none;"> <li><code><span class="cond">#If</span> <b>condition1</b></code></li> <li style="margin-left: 2em;">contents if condition1 is satisfied</li> <li><code><span class="cond">#Else If</span> <b>condition2</b></code></li> <li style="margin-left: 2em;">contents if condition2 is satisfied</li> <li><code><span class="cond">#Else If</span> <b>condition3</b></code></li> <li style="margin-left: 2em;">contents if condition3 is satisfied</li> <li>. . .</li> <li><code><span class="cond">#Else</span></code></li> <li style="margin-left: 2em;">contents if none of the conditions is satisfied</li> <li><code><span class="cond">#end if</span></code></li> </ul> <p>Shorter forms are also possible:</p> <ul style="list-style-type:none;"> <li><code><span class="cond">#If</span> <b>condition</b></code></li> <li style="margin-left: 2em;">contents if the condition is satisfied</li> <li><code><span class="cond">#Else</span></code></li> <li style="margin-left: 2em;">contents if the condition is not satisfied</li> <li><code><span class="cond">#end if</span></code></li> </ul> <p>or:</p> <ul style="list-style-type:none;"> <li><code><span class="cond">#If</span> <b>condition</b></code></li> <li style="margin-left: 2em;">contents if the condition is satisfied</li> <li><code><span class="cond">#end if</span></code></li> </ul> <p>Condition blocks affect not only the calculation path but also the report content like text and images. The "#" symbol must be the first one in the line. At the place of "<b>condition</b>" you can put any valid expression. Normally, a comparison is used like "<span class="cond">#If</span> <var>a</var> < 0", but it is not obligatory. If it evaluates to any nonzero number, the condition is assumed to be satisfied. Otherwise, it is not satisfied. Any result which absolute value is ≤ 0.00000001 is assumed to be zero.</p> <p>Let us look again at the quadratic equation example that we used earlier. If we enter "<var>c</var> = 5", the discriminant will be negative and the result will be <span class="err">NaN</span>. This is not a very intelligent way to finish a program. What we need to do is to check if "<var>D</var> < 0" and if so, to provide a comprehensible message. Otherwise, we have to calculate the roots. We can do this, using conditional execution, as follows:</p> <p><img alt="Sample2" width="700" src="Images/Sample2.png"></p> <h3 id="TOC_604">Iteration blocks</h3> <p>You can have simple iterations inside a Calcpad program. For that purpose, you have to define a "<b>repeat-loop</b>" block:</p> <ul style="list-style-type:none;"> <li><span class="cond">#Repeat</span> <var>n</var></li> <li style="margin-left: 2em;">Code to be executed repeatedly</li> <li><span class="cond">#Loop</span></li> </ul> <p>The symbol <var>n</var> stands for the number of repetitions. Instead of <var>n</var>, you can put a number, variable or any valid expression. If the result of the expression is not integer, it is rounded to the nearest one. You can exit the repeat-loop cycle prematurely by putting <span class="cond">#Break</span> inside the block. It will make sense only if you combine it a conditional block. Otherwise, it will always break at the same line, without performing any loops. A typical "repeat-break-loop" will look like this:</p> <ul style="list-style-type:none;"> <li><code class="cond">#Repeat</code></li> <li style="margin-left: 2em;">Code to be executed repeatedly</li> <li style="margin-left: 2em;"><code class="cond">#If</code> condition</li> <li style="margin-left: 4em;"><code class="cond">#Break</code></li> <li style="margin-left: 2em;"><code class="cond">#End if</code></li> <li style="margin-left: 2em;">You can have more code here</li> <li><code class="cond">#Loop</code></li> </ul> <p>You can use <code class="cond">#Continue</code> instead of <code class="cond">#Break</code>. The program will skip the remaining lines, return to the top of the conditional block and continue with the next iteration. You can omit the number of repetitions <var>n</var> only if you are sure that the condition will be satisfied and the loop will brake sooner or later. Anyway, to avoid infinite loop, the number of iterations is limited to 100 000 if nothing else is specified.</p> <p>Besides repetitive calculations, you can use loops to generate repetitive report content (like table rows). If you want to hide the iteration details, you can use output control directives (see the previous section). For example, you can enclose the "repeat-loop" block with <span class="cond">#Hide</span> and <span class="cond">#Show</span> statements.</p> <h3 id="TOC_605">Interactive (step-by-step) execution</h3> <p>You can make a Calcpad worksheet to execute interactively (step-by-step) by defining "breakpoints" at certain lines. It will allow the user to review the intermediate results and enter some additional input data if needed. There are two special keywords, you can use for that purpose:</p> <ul style="list-style-type:none;"> <li><code class="cond">#Pause</code> - calculates down to the current line, displays the results and waits for the user to resume;</li> <li><code class="cond">#Input</code> - renders an input form to the current line and waits the user to enter data and resume.</li> </ul> <p>When the execution is paused, the program renders a message at the bottom of the report:</p> <p>  <span class="err">Paused!</span> Press <b>F5</b> to <a href="#0" data-text="continue">continue</a> or <b>Esc</b> to <a href="#0" data-text="cancel">cancel</a>.</p> <p>You can resume the execution by pressing <b>F5</b>, clicking the link or the <img alt="Play" height="24" src="Images/Play.png"> button again. You can have several breakpoints in a single worksheet. WHen you use the <code class="cond">#Input</code> keyword, the previous section is calculated before the current input form is displayed. In this way, the stages of calculation overlap as shown in the following example:</p> <p><img alt="Interactive" height="360" src="Images/Interactive.png"></p> <p>Additionally, the user can press "<b>Pause/Break</b>" or "<b>Ctrl + Alt + P</b>" any time from the keyboard to pause the execution. The execution will pause at the current line as if <code class="cond">#Pause</code> is detected.</p> <h3 id="TOC_606">Modules (include)</h3> <p>Calcpad allows you to include contents from external files in your worksheet. If you have pieces of code that is repeated in different worksheets, you can organize it in modules and reuse it multiple times. Also, if you have a longer worksheet, you can split it into modules that will be easier to maintain. Then, you can include them into the main file by using the following statement:</p> <p>  <span class="cond">#include</span> <em class="macro">filename</em></p> <p>The "<em class="macro">filename</em>" must contain the full path to a local file. If the file is the same folder as the current one, you can specify only the filename.</p> <p>By default, Calcpad will include the whole contents of the external module. However, you can prevent some parts from inclusion, by making them local. To start a "local" section in a module, add a new line, containing the <span class="cond">#local</span> keyword. To end a "local" section (or start a "global" one), add a new line with the <span class="cond">#global</span> keyword. Calcpad supports multiple levels of inclusions. That means that the included file, in its turn, can reference other files and so on.</p> <h3 id="TOC_607">Macros and string variables</h3> <p>Macros and string variables are convenient ways to organize your code inside a single file and prevent repetitions. They can be inline or multiline. Unlike string variables, macros can have parameters. You can define them, by using the following statements:</p> <p>Inline string variable:<br />   <span class="cond">#def</span> <em class="macro">variable_name$</em> <span class="o">=</span> <em>content</em> </p> <p>Multiline string variable:<br />   <span class="cond">#def</span> <em class="macro">variable_name$</em><br />     <em>content line 1</em><br />     <em>content line 2</em><br />     <em>...</em><br />   <span class="cond">#end def</span> </p> <p>Inline string macro:<br />  <span class="cond">#def</span> <em class="macro">macro_name$</em>(<em class="macro">param1$</em><span class="o">;</span> <em class="macro">param2$</em><span class="o">;</span>...) <span class="o">=</span> <em>content</em> </p> <p>Multiline string macro:<br />   <span class="cond">#def</span> <em class="macro">macro_name$</em>(<em class="macro">param1$</em><span class="o">;</span> <em class="macro">param2$</em><span class="o">;</span>...)<br />     <em>content line 1</em><br />     <em>content line 2</em><br />     <em>...</em><br />   <span class="cond">#end def</span> </p> <p>Names of string variables, macros, and their parameters can contain small and capital latin letters and underscore "_". They must b with the "$" symbol. The contents can be virtually any string. It is not necessary to be a valid Calcpad expression, since it is not processed by the parser at this stage. However, other macro/string variable definitions are not allowed inside. You can insert only references to previously defined ones. Also, input fields "?" are not supported in macros yet. This feature will be developed in the next versions. You can use <span class="cond">#include</span> inside macros, but only if the included file does not contain other macros.</p> <p>After a string variable is defined, you can use it anywhere in the code, by writing its name (with the ending "$"). The same is for macros, but you also need to specify values for parameters. Macros and string variables are preprocessed and rewritten before the actual parsing is performed. As a result, intermediate (unwrapped) code is generated. You can review it by checking the "<b>Unwrapped code</b>" checkbox bellow the "<b>Output</b>" window.</p> <p>If any errors occur during macro preprocessing, the unwrapped code is displayed, together with the errors. Line numbers in error descriptions refer to your initial code. If preprocessing is completed successfully, the unwrapped code is parsed and calculated as normal. If errors are detected at this stage, they are displayed in the output. Line numbers in error descriptions refer to the unwrapped code. You can go to the respective line, by clicking the link on the line number.</p> <h2 id="TOC_700">Results</h2> <p>You can run the solution by pressing <b>F5</b> or clicking the <img alt="Play" height="24" src="Images/Play.png"> button. The results will appear in the "<b>Output</b>" box. You cannot edit the output content, but you can select, copy and print it. For that purpose, you can use the toolbar over the "<b>Output</b>" box on the right. You can also use additional commands from the context menu, that is displayed If you right-click inside the "<b>Output</b>" box, you will see a pop-up menu with additional commands. Detailed description is provided further in this manual.</p> <p>Since version 6.5.3, you can use the "☑ <b>AutoRun</b>" mode. While it is checked, the results will refresh each time you change the code and move to another line. If you need to synchronize the results manually, you can press "<b>Ctrl + Enter</b>". Additionally, the output window will scroll to match the current position in the source code. You can do the same by double clicking into the input window.</p> <h3 id="TOC_701">Substitution</h3> <p>Calcpad can substitute the values of variables in all formulas in the output, just before the answer:</p> <p style="margin-left: 2em;"><var>x</var><sub>1</sub> = <span class="dvc"> -<var>b</var> – <span class="root">√</span><span class="ovr"><var>D</var></span><span class="dvl"></span>2·<var>a</var></span> = <span class="dvc"> -3 – <span class="root">√</span><span class="ovr">89</span><span class="dvl"></span>2·4</span> = -1.55</p> <p>For that purpose, you need to check the "<b>Substitution</b>" checkbox at the bottom of the program window. That makes the results easy to review and check. This is important when calculations have to be checked by supervisors, teachers etc. This is also an advantage over the spreadsheet software where the actual formulas are hidden in the cells.</p> <p>If you do not need the substitution, you can uncheck this option. Then the answers will follow directly the calculation formulas:</p> <p style="margin-left: 2em;"><var>x</var><sub>1</sub> = <span class="dvc"> -<var>b</var> – <span class="root">√</span><span class="ovr"><var>D</var></span><span class="dvl"></span>2·<var>a</var></span> = -1.55</p> <p>After that, if you position the mouse over any variable, you will see a tooltip with the respective value.</p> <p>There is also an option to control the variable substitution behavior inside worksheets. You can use the following switches for that purpose:<br />   <span class="cond">#nosub</span></a> - do not substitute variables (no substitution);<br />   <span class="cond">#novar</span></a> - show equations only with substituted values (no variables);<br />   <span class="cond">#varsub</span></a> - show equations with variables and substituted values (default).</p> <p>If an equation gets too long and does not fit on a single line, you can choose the way it looks in the output by using these two switches:<br />   <span class="cond">#split</span></a> - the equation is splitted after the "=" symbol;<br />   <span class="cond">#warp</span></a> - the equation is warpped at the end of the line (default).<br /> <h3 id="TOC_702">Rounding</h3> <p>Rounding is specified by the number of digits <var>n</var> after the decimal point. It is entered into the "<b>Rounding</b>" input box at the bottom of the program window. The value of <var>n</var> can be between "0" and "15". If you enter "0", all results will be rounded to integers. If the value is less than "0" or greater than "15", the respective limit will be taken.</p> <p>However, rounding can come across some potential problems. If the result is less than 10<sup>-<var>n</var></sup> and you round it to <var>n</var> digits after the decimal point, the result will contain only zeros. That is why, Calcpad incorporates some advanced rules: If the output contains less than <var>n</var> significant digits after rounding, it is expanded up to <var>n</var> significant digits. Even then, if the number is too small, it will be difficult to count the zeros after the decimal point. So, in such cases, the output is converted to floating point format with <var>n</var> digits. When the total number of digits becomes greater than 2<var>n</var>, the factional part is being truncated. In this way, the output becomes easier to read, still providing at least 2<var>n</var> significant digits. You can see several examples bellow, obtained for (<var>n</var> = 3).</p> <ul style="list-style-type:none;"> <li>0.000001∙<var>π</var> = 3.14E-06</li> <li>0.001∙<var>π</var> = 0.00314</li> <li>0.1∙<var>π</var> = 0.314</li> <li>1∙<var>π</var> = 3.142</li> <li>1000∙<var>π</var> = 3141.59</li> <li>1000000∙<var>π</var> = 3141593</li> </ul> <p>Rounding affects only the way in which numbers are displayed in the output. Internally, all numbers are stored with the maximum possible precision. That is why, if you print the output and try to repeat the calculations with the numbers from the report, you probably will get some little differences. This is because you use the rounded values instead of the actual ones.</p> <p>You can override the global rounding inside a worksheet by using the <code class="cond">#Round</code> <var>n</var> keyword, where <var>n</var> is the number of digits after the decimal point (from "0" to "15").</p> <h3 id="TOC_703">Formatting</h3> <p>Calcpad does not simply calculate formulas. It also builds a professional looking report out of your source code. It uses Html to format the output. It is widely recognized and allows you to publish your calculations in the web. You can select between two different styles for equation formatting: "<b>professional</b>" and "<b>inline</b>". The professional style uses division bar, large and small brackets, radical, etc. Numerator and denominator are displayed one above the other. The inline style uses slash for displaying division and all symbols are arranged into a single line. The following formatting rules are applied:</p> <ul> <li>Intervals are maintained automatically.</li> <li>Variables are formatted as <var>italic</var>.</li> <li>Multiplication operator "*" is replaced with "∙".</li> <li>Exponentiation operator "^" is formatted as superscript.</li> <li>Underscore "_" is formatted as subscript.</li> <li>Square root function is replaced with radical "<span class="root">√</span><span class="ovr"> </span>".</li> </ul> <p>Several examples of formatting in different cases are provided in the table bellow:</p> <table style="margin-left:24px; max-width: 300px;" border="1"> <thead> <tr> <th style="width:50%">Text</th> <th>Html</th> </tr> </thead> <tbody> <tr> <td><code>x + 3</code></td> <td><var>x</var> + 3</td> </tr> <tr> <td><code>x-3</code></td> <td><var>x</var> – 3</td> </tr> <tr> <td><code>3*x</code></td> <td>3∙<var>x</var></td> </tr> <tr> <td><code>(x + 1)/3</code></td> <td>(<var>x</var> + 1)/3 or <span class="dvc"><var>x</var> + 1<span class="dvl"></span>3</span></td> </tr> <tr> <td><code>x+3 * y</code></td> <td><var>x</var> + 3∙<var>y</var></td> </tr> <tr> <td><code>sqr(x+3)</code></td> <td><span class="root">√</span><span class="ovr"><var>x</var> + 3</span></td> </tr> <tr> <td><code>x_1^3</code></td> <td><var>x</var><sub>1</sub><sup>3</sup></td> </tr> <tr> <td><code>sin(x)</code></td> <td><b>sin</b>(<var>x</var>)</td> </tr> </tbody> </table> <p> Html formatting makes the report easier to read and check than the respective plain text. You can also insert additional Html code inside the comments that will affect the final appearance. In this way, you can use Calcpad code to build professional Web applications. You will also need the cloud version of Calcpad for that purpose.</p> <h3 id="TOC_704">Scaling</h3> <p>You can scale up and down the text size in the output window. Hold the "<b>Ctrl</b>" button and rotate the mouse wheel. The forward rotation will scale up and the backward will scale down.</p> <h3 id="TOC_705">Saving the output</h3> <p>You can save the output to an <b>Html</b> file . Unlike the input file, it cannot be modified with Calcpad. On the other side, everyone will be able to view and print your calculations without Calcpad. Html files can be opened on any computer using web browser or office program like Word.</p> <p>You can save the file by clicking the <img alt="Save" height="24" src="Images/Save.png"> button over the output box. Then select a file name and click "<b>Save</b>".</p> <h3 id="TOC_706">Printing</h3> <p>You can print the output by clicking the <img alt="PrintPreview" height="24" src="Images/PrintPreview.png"> button. Normally, printing is performed after calculations. When you click the button, the print preview dialog will be displayed:</p> <p><img alt="Sample5" height="360" src="Images/Sample5.png"></p> <p>It allows you to set the printing layout and margins. Click the <img alt="Page Setup" height="24" src="Images/PageSetup.png"> button to change the paper size and type. Finally, press the <img alt="Print" height="24" src="Images/Print.png"> button. A printer selection dialog will appear. Choose the preferred printer and click "<b>Print</b>".</p> <p><img alt="PrintDialog" height="360" src="Images/PrintDialog.png"></p> <p>Printing in Calcpad uses the built-in functionality of Windows and Edge. The above screenshots may look differently on your computer, depending on the versions you use. Alternatively, you can right click in the output window and select "<b>Print preview…</b>" from the context menu. If you select "<b>Print</b>", you will skip the preview and proceed directly to printing.</p> <h3 id="TOC_707">Coping</h3> <p>You can copy the entire output at once by clicking the <img alt="Copy" height="24" src="Images/Copy.png"> button over the output window. Then, you can paste it in any other program. If the target program supports Html, like Word, the formatting will be preserved. Otherwise, the content will be pasted as plain text.</p> <h3 id="TOC_708">Export to Word</h3> <p>You can open the results directly with <b>MS Word</b> by clicking <img alt="Word" height="24" src="Images/Word.png">. It must be installed on the computer, but it is not necessary to be preliminary opened. This approach is easier than copy-paste and provides some additional benefits. If the output is obtained with the professional equation formatting option, Calcpad will use the "<b>*.docx</b>" file format for the export. This is the native format for the latest versions of <b>MS Word</b> and will open automatically. If you have <b>Open Office</b> or <b>Libre office</b>, the respective program will be used instead. If you do not have any text editor currently installed, the file will be saved to the disk, but not opened. You can go to the respective folder later and open it manually. Formulas are exported as <b>MathType</b> objects and can be modified inside Word. However, it is possible to loose part of the Html formatting. Images, tables and most common tags are supported. If you have selected inline equation formatting, Calcpad will use an <b>Html</b> file for the export. It will preserve most of the formatting, but formulas will be part of the document text.</p> <h3 id="TOC_709">Export to PDF</h3> <p>A good alternative to <b>Html</b> is to save the report as <b>pdf</b> file. It is another way to make a hard copy of your calculations. Click the <img alt="PDF" height="24" src="Images/Pdf.png"> button and select the name and the location of the file. The program will save the output to the specified file and open it with the default viewer. The pdf is always generated in A4 page size.</p> <p>Alternatively, you can use a pdf printer. There are a lot of free pdf printers over the Internet. Just download and install one. After that, the process of printing is not much different than any other printer. Detailed description of printing from Calcpad is provided above.</p> <h2 id="TOC_800">Working with files</h2> <p>Input data in Calcpad can be saved to disk and reused multiple times. The supported file formats are "<b>*.txt</b>", "<b>*.cpd</b>" and "<b>*.cpdz</b>". Input forms have to be saved to "<b>*.cpd</b>" and "<b>*.cpdz</b>" files and text scripts to "<b>*.txt</b>" files. Both "<b>*.cpd</b>" and "<b>*.cpdz</b>" file types are associated with Calcpad and can be opened with double click. The main difference between the two formats is that "<b>*.cpd</b>" is a text file and can be edited while "*<b>.cpdz</b>" is binary and can be only executed. The source code inside is protected from viewing, coping and modification.</p> <h3 id="TOC_801">New</h3> <p>You can start a new file by clicking the <img alt="New" height="24" src="Images/New.png"> button. This will clear the file name and the source code. If the current file is not saved, you will be prompted to do that.</p> <p><img alt="PromptSave" height="160" src="Images/PromptSave.png"></p> <p>If you answer "<b>Yes</b>", the "<b>File Save</b>" dialog will appear. Enter file name and click "<b>Save</b>". Thus, you will preserve your data before being cleared. If you select "<b>Cancel</b>" you will interrupt the command and everything will remain unchanged.</p> <h3 id="TOC_802">Open</h3> <p>You can open an existing file with the <img alt="Open" height="24" src="Images/Open.png"> button. A file selection dialog will appear. The active file extension is "*.cpd", by default. If you search for "*.txt" or "*.cpdz" files, select the corresponding type at the bottom of the dialog. Then find the required file and press "<b>Open</b>" or double click on the file. It will be loaded into Calcpad and the file name will be displayed in the title bar.</p> <h3 id="TOC_803">Save</h3> <p>You can save the current file by clicking the <img alt="Save" height="24" src="Images/Save.png"> button. If the file has not been saved so far, you will be prompted to select path and name. Otherwise, it will be rewritten at the current location.</p> <h3 id="TOC_804">Save As…</h3> <p>If you need to save the current file with a different name, select the "<b>File/Save As…</b>" menu command. A file selection dialog will be displayed. Select file path and name and click "<b>Save</b>"</p> <hr /> <p>Last edited on 27.08.2023 by eng. Nedelcho Ganchovski.</p> </div> <script src="jquery-3.6.3.min.js"></script> <script> if(window.jQuery){ function getTargetId(element) { var id = $(element).attr("name"); if (id != null && id.length > 0) return id; return $(element).data("target"); } function getValue(id, source) { var value = ""; var target = $("#" + id + " input"); var domObj = target.get(0); if (domObj == null || domObj.Length == 0) { target = $("#" + id + " .eq u"); target.each(function() { value += $(this).text() + ";"; }); $(source).prop('disabled', true); } else { target.each(function() { value += $(this).val() + ";"; }); } if (value.length > 1) { value = value.slice(0, -1); } return value; } function Toggle(button) { var list = $("#list" + button.attr("id").substring(6)); if (list.css("display") == "none") { list.css("display", "list-item"); button.html("−"); } else { list.css("display","none"); button.html("+"); } } $(document).ready(function(){ $("#Units").change(function(){ $(".Units").text($(this).val()); }); $(".exp").click(function(){ Toggle($(this)); }); $(".fold > :first-child").click(function() { if ($(this).parent().hasClass("fold")) { $(this).parent().removeClass("fold").addClass("unfold"); } else { $(this).parent().removeClass("unfold").addClass("fold"); } }); $("select").each(function(index) { if ($(this).prop("id") != "Units") { var id = getTargetId(this); if (id != null && id.length > 0){ var value = getValue(id, this); $(this).val(value); } } }); $("select").change(function(){ var id = getTargetId(this); if (id != null && id.length > 0){ var target = $("#" + id + " input"); if (target != null){ var values = $(this).val().split(";"); target.each(function(index) { $(this).val(values[index]); }); } } }); $("input:radio, input:checkbox").each(function(index) { var id = getTargetId(this); if (id != null && id.length > 0){ var value = getValue(id, this); $(this).prop("checked", $(this).val() == value); } }); $("input:radio, input:checkbox").change(function(){ var id = getTargetId(this); if (id != null && id.length > 0){ var target = $("#" + id + " input"); if (target != null){ if ($(this).prop("checked")){ var values = $(this).val().split(";"); target.each(function(index) { $(this).val(values[index]); }); } else if($(this).prop("type") == "checkbox"){ target.each(function() { $(this).val("0"); }); } } } }); $(".money").each(function(){$(this).text(Number(($(this).text())).toFixed(2));}); $(window).scroll(function() { if ($(".menu").is(":visible")){ var scrollTop = $(window).scrollTop(); var id; var min = 1e20; $("h2, h3").each(function() { var d = scrollTop - $(this).offset().top + 50; if (d > 0 && Math.abs(d) < min) { console.log(d); min = d; id = $(this).attr("id"); } }); $(".active").removeClass("active"); var element = $("a[href$='#" + id + "']") if (!element.is(":visible")) { $(".exp").html("+"); $(".menu li ul").css("display", "none"); var b = "#button" + id.substring(4, id.length - 2); Toggle($(b)); } element.addClass("active"); } }); }); } </script> </body> </html>