This repository has been archived by the owner on Sep 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
EXPONENTIATION.html
499 lines (399 loc) · 26.9 KB
/
EXPONENTIATION.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
<hr>
<p><strong>EXPONENTIATION</strong></p>
<hr>
<p><span style="background:#ffff00">The <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/C%2B%2B" target="_blank" rel="noopener">C++</a> program featured in this tutorial web page computes the approximate value of some <a style="background:#000000;color:#ff9000" href="https://karlinaobject.wordpress.com/numbers/" target="_blank" rel="noopener">real number</a> <strong>base</strong> (which the program user inputs) raised to the <strong>power</strong> of some real number <strong>exponent</strong> (which the program user also inputs). Such a mathematical operation is referred to as <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/Exponentiation" target="_blank" rel="noopener">exponentiation</a>. The C++ program featured in this web page uses the <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/Natural_logarithm" target="_blank" rel="noopener">natural logarithm</a> and the base of the natural logarithm (which is <a style="background:#000000;color:#00ff00" href="https://karlinaobject.wordpress.com/eulers_number_approximation/" target="_blank" rel="noopener">Euler’s Number</a>) raised to the power of some number to approximate base to the power of exponent. (Note that the C++ program featured in this web page does not include either cmath of math.h (which are each C++ libraries)).</span></p>
<p><em>To view hidden text inside each of the preformatted text boxes below, scroll horizontally.</em></p>
<pre>Let base be a real number.
Let exponent be a real number.
Let power(base,exponent) return a real number equivalent to base raised to the power of exponent (i.e. base ^ exponent) using the following procedure:
procedure power(base, exponent):
Let e be approximately equal to Euler's Number.
Let exp(x) be e raised to the power of some real number x.
Let log(x) be the base-e logarithm of some real number x.
If exponent is zero: return one.
If exponent is one: return base.
If exponent is a whole number:
If exponent is a positive number:
return base multiplied by base exponent times.
End if.
If exponent is a negative number:
return the reciprocal of the number represented by base multiplied by base exponent times.
End if.
End if.
If exponent is not a whole number:
If exponent is a negative number:
return exp(log(base) * exponent).
End if.
If exponent is a positive number:
return exp(exp(log(base) * absolute_value(exponent))).
End if.
End if.
End procedure.
</pre>
<hr>
<p><strong>SOFTWARE_APPLICATION_COMPONENTS</strong></p>
<hr>
<p>C++_source_file: <a style="background:#000000;color:#00ff00" href="https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power.cpp" target="_blank" rel="noopener">https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power.cpp</a></p>
<p>plain-text_file: <a style="background:#000000;color:#ff9000" href="https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power_output.txt" target="_blank" rel="noopener">https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power_output.txt</a></p>
<hr>
<p><strong>PROGRAM_COMPILATION_AND_EXECUTION</strong></p>
<hr>
<p>STEP_0: Copy and paste the C++ <a style="background:#000000;color:#00ff00" href="https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power.cpp" target="_blank" rel="noopener">source code</a> into a new text editor document and save that document as the following file name:</p>
<pre>power.cpp</pre>
<p>STEP_1: Open a <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/Unix" target="_blank" rel="noopener">Unix</a> command line terminal application and set the current directory to wherever the C++ is located on the local machine (e.g. Desktop).</p>
<pre>cd Desktop</pre>
<p>STEP_2: Compile the C++ file into machine-executable instructions (i.e. object file) and then into an executable piece of software named <strong>app</strong> using the following command:</p>
<pre>g++ power.cpp -o app</pre>
<p>STEP_3: If the program compilation command does not work, then use the following commands (in top-down order) to install the C/C++ compiler (which is part of the <a style="background: #ff9000;color: #000000" href="https://en.wikipedia.org/wiki/GNU_Compiler_Collection" target="_blank" rel="noopener">GNU Compiler Collection (GCC)</a>):</p>
<pre>sudo apt install build-essential</pre>
<pre>sudo apt-get install g++</pre>
<p>STEP_4: After running the <strong>g++</strong> command, run the executable file using the following command:</p>
<pre>./app</pre>
<p>STEP_5: Once the application is running, the following prompt will appear:</p>
<pre>Enter a real number value for base which is no larger than 100 and no smaller than -100:</pre>
<p>STEP_6: Enter a value for base using the using the keyboard.</p>
<p>STEP_7: After a value for base is entered, the following prompt will appear:</p>
<pre>Enter a real number value for exponent which is no larger than 100 and no smaller than -100:</pre>
<p>STEP_8: Enter a value for exponent using the keyboard.</p>
<p>STEP_9: A statement showing the value returned by the power function which computes the approximate value of base raised to the power of exponent will be printed to the command line terminal and then the following prompt will appear:</p>
<pre>Would you like to continue inputting program values? (Enter 1 if YES. Enter 0 if NO):</pre>
<p>STEP_10: Enter a value according to your preference until you decide to close the program (and save your program data to the <a style="background:#000000;color:#ff9000" href="https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power_output.txt" target="_blank" rel="noopener">output text file</a>).</p>
<hr>
<p><strong>PROGRAM_SOURCE_CODE</strong></p>
<hr>
<p>The text in the preformatted text box below appears on this web page (while rendered correctly by the <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/HTML" target="_blank" rel="noopener">web browser</a>) to be identical to the content of the <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/C%2B%2B" target="_blank" rel="noopener">C++</a> source code file whose <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/URL" target="_blank" rel="noopener">Uniform Resource Locator</a> is displayed in the green <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/Hyperlink" target="_blank" rel="noopener">hyperlink</a> below. A <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/Computer" target="_blank" rel="noopener">computer</a> interprets that C++ source code as a series of programmatic instructions (i.e. <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/Software" target="_blank" rel="noopener">software</a>) which govern how the <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/Computer_hardware" target="_blank" rel="noopener">hardware</a> of that computer behaves.</p>
<p><em>(Note that angle brackets which resemble <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/HTML" target="_blank" rel="noopener">HTML</a> tags (i.e. an “is less than” symbol (i.e. ‘<‘) followed by an “is greater than” symbol (i.e. ‘>’) displayed in the aforementioned text box have been replaced (at the source code level of this web page) with Unicode symbols <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/Less-than_sign" target="_blank" rel="noopener">U+003C</a> (which is rendered by the web browser as ‘<‘) and <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/Greater-than_sign" target="_blank" rel="noopener">U+003E</a> (which is rendered by the web browser as ‘>’). That is because the <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/WordPress.com" target="_blank" rel="noopener">WordPress</a> web page editor interprets a plain-text versions of an “is less than” symbol followed by an “is greater than” symbol as being an opening HTML tag (which means that the WordPress web page editor deletes the content between those (plain-text) inequality symbols)).</em></p>
<p>C++_source_file: <a style="background:#000000;color:#00ff00" href="https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power.cpp" target="_blank" rel="noopener">https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power.cpp</a></p>
<hr>
<pre>
/**
* file: power.cpp
* type: C++ (source file)
* date: 16_SEPTEMBER_2024
* author: karbytes
* license: PUBLIC_DOMAIN
*/
/* preprocessing directives */
#include <iostream> // standard input (std::cin), standard output (std::cout)
#include <fstream> // file input, file output
// #include <cmath> // exp() and log() functions
#define MAXIMUM_ABSOLUTE_VALUE_BASE 100 // constant which represents maximum absolute value for base
#define MAXIMUM_ABSOLUTE_VALUE_EXPONENT 100 // constant which represents maximum absolute value for exponent
/* function prototypes */
bool is_whole_number(double x);
double absolute_value(double x);
double power_of_e_to_x(double x);
float ln(float x);
double power(double base, double exponent);
/* program entry point */
int main()
{
// Declare a file output stream object named file.
std::ofstream file;
// Declare three variables for storing floating-point number values.
double base = 0.0, exponent = 0.0, result = 0.0;
// Declare a variable for storing the program user's answer of whether or not to continue inputting values.
int input_additional_values = 1;
// Set the number of digits of floating-point numbers which are printed to the command line terminal to 100 digits.
std::cout.precision(100);
// Set the number of digits of floating-point numbers which are printed to the file output stream to 100 digits.
file.precision(100);
/**
* If the file named power_output.txt does not already exist
* inside of the same file directory as the file named power.cpp,
* create a new file named power_output.txt in that directory.
*
* Open the plain-text file named power_output.txt
* and set that file to be overwritten with program data.
*/
file.open("power_output.txt");
// Print an opening message to the command line terminal.
std::cout << "\n\n--------------------------------";
std::cout << "\nSTART OF PROGRAM";
std::cout << "\n--------------------------------";
// Print an opening message to the file output stream.
file << "--------------------------------";
file << "\nSTART OF PROGRAM";
file << "\n--------------------------------";
// Print some program-related data to the command line terminal.
std::cout << "\n\npower(base, exponent) = base ^ exponent.";
// Print some program-related data to the file output stream.
file << "\n\npower(base, exponent) = base ^ exponent.";
while (input_additional_values != 0)
{
// Print a divider line to the command line terminal.
std::cout << "\n\n--------------------------------";
// Print a divider line to the file output stream.
file << "\n\n--------------------------------";
// Prompt the user to enter a value to store in the variable named base (to the command line terminal).
std::cout << "\n\nEnter a real number value for base which is no larger than ";
std::cout << MAXIMUM_ABSOLUTE_VALUE_BASE;
std::cout << " and no smaller than ";
std::cout << (-1 * MAXIMUM_ABSOLUTE_VALUE_BASE) << ": ";
// Print the prompt for entering a base value to the file output stream.
file << "\n\nEnter a real number value for base which is no larger than ";
file << MAXIMUM_ABSOLUTE_VALUE_BASE;
file << " and no smaller than ";
file << (-1 * MAXIMUM_ABSOLUTE_VALUE_BASE) << ": ";
// Scan the command line terminal for the most recent keyboard input value.
std::cin >> base;
// Print the most recently input keyboard value to the command line terminal.
std::cout << base;
// Print the most recently input keyboard value to the file output stream.
file << base;
// Prompt the user to enter a value to store in the variable named exponent (to the command line terminal).
std::cout << "\n\nEnter a real number value for exponent which is no larger than ";
std::cout << MAXIMUM_ABSOLUTE_VALUE_EXPONENT;
std::cout << " and no smaller than ";
std::cout << (-1 * MAXIMUM_ABSOLUTE_VALUE_EXPONENT) << ": ";
// Print the prompt for entering an exponent value to the output file.
file << "\n\nEnter a real number value for exponent which is no larger than ";
file << MAXIMUM_ABSOLUTE_VALUE_EXPONENT;
file << " and no smaller than ";
file << (-1 * MAXIMUM_ABSOLUTE_VALUE_EXPONENT) << ": ";
// Scan the command line terminal for the most recent keyboard input value.
std::cin >> exponent;
// Print the most recently input keyboard value to the command line terminal.
std::cout << exponent;
// Print the most recently input keyboard value to the file output stream.
file << exponent;
// If base is not within the range of accepted values, set base to 1.
if ((base < (-1 * MAXIMUM_ABSOLUTE_VALUE_BASE)) || (base > MAXIMUM_ABSOLUTE_VALUE_BASE))
{
base = 1;
std::cout << "\n\nBecause the input value for base was not within the range of accepted values, base was set to the default value of 1.";
file << "\n\nBecause the input value for base was not within the range of accepted values, base was set to the default value of 1.";
}
// If exponent is not within the range of accepted values, set exponent to 0.
if ((exponent < (-1 * MAXIMUM_ABSOLUTE_VALUE_EXPONENT)) || (exponent > MAXIMUM_ABSOLUTE_VALUE_EXPONENT))
{
exponent = 0;
std::cout << "\n\nBecause the input value for exponent was not within the range of accepted values, exponent was set to the default value of 0.";
file << "\n\nBecause the input value for exponent was not within the range of accepted values, exponent was set to the default value of 0.";
}
// Compute base to the power of exponent.
result = power(base, exponent);
// Print the result returned by the power function defined in this program to the command line terminal.
std::cout << "\n\nresult = power(base,exponent) = power(" << base << ", " << exponent << ") = " << base << " ^ " << exponent << " = " << result << ".";
// Print the result returned by the power function defined in this program to the file output stream.
file << "\n\nresult = power(base,exponent) = power(" << base << ", " << exponent << ") = " << base << " ^ " << exponent << " = " << result << ".";
// Ask the user whether or not to continue inputing values.
std::cout << "\n\nWould you like to continue inputting program values? (Enter 1 if YES. Enter 0 if NO): ";
// Scan the command line terminal for the most recent keyboard input value.
std::cin >> input_additional_values;
}
// Print a closing message to the command line terminal.
std::cout << "\n--------------------------------";
std::cout << "\nEND OF PROGRAM";
std::cout << "\n--------------------------------\n\n";
// Print a closing message to the file output stream.
file << "\n\n--------------------------------";
file << "\nEND OF PROGRAM";
file << "\n--------------------------------";
// Close the file output stream.
file.close();
// Exit the program.
return 0;
}
/**
* If x is determined to be a whole number, return true.
* Otherwise, return false.
*/
bool is_whole_number(double x)
{
return (x == (long int) x);
}
/**
* Return the absolute value of a real number input, x.
*/
double absolute_value(double x)
{
if (x < 0) return -1 * x;
return x;
}
/**
* Return the approximate value of Euler's Number to the power of some real number x.
*
* This function is essentially identical to the C++ library math.h function exp().
*/
double power_of_e_to_x(double x) {
double a = 1.0, e = a;
int n = 1;
int invert = x < 0;
x = absolute_value(x);
for (n = 1; e != e + a; n += 1) {
a = a * x / n;
e += a;
}
return invert ? (1 / e) : e;
}
//-----------------------------------------------------------------------------------------------
// The following function and associated comments were not written by karbytes.
//
// The following function is essentially identical to the C++ library math.h function log().
//-----------------------------------------------------------------------------------------------
// ln.c
//
// simple, fast, accurate natural log approximation
// when without
// featuring * floating point bit level hacking,
// * x=m*2^p => ln(x)=ln(m)+ln(2)p,
// * Remez algorithm
// by Lingdong Huang, 2020. Public domain.
// ============================================
float ln(float x) {
unsigned int bx = * (unsigned int *) (&x);
unsigned int ex = bx >> 23;
signed int t = (signed int)ex-(signed int)127;
unsigned int s = (t < 0) ? (-t) : t;
bx = 1065353216 | (bx & 8388607);
x = * (float *) (&bx);
return -1.49278+(2.11263+(-0.729104+0.10969*x)*x)*x+0.6931471806*t;
}
// done.
//-----------------------------------------------------------------------------------------------
// End of code which was not written by karbytes.
//-----------------------------------------------------------------------------------------------
/**
* Reverse engineer the cmath pow() function
* using the following properties of natural logarithms:
*
* ln(x ^ y) = y * ln(x).
*
* ln(e ^ x) = x. // e is approximately Euler's Number.
*
* Note that the base of the logarithmic function
* used by the cmath log() function is e.
*
* Hence, log(x) is approximately the
* natural log of x (i.e. ln(x)).
*
* Note that the base of the exponential function
* used by the cmath exp() function is
* (approximately) Euler's Number.
*
* Hence, exp(x) is approximately
* x ^ e (where e is approximately Euler's Number).
*
* Note that any number, x, raised to the power of 0 is 1.
* In more succinct terms, x ^ 0 = 1.
*
* Note that any number, x, raised to the power of 1 is x.
* In more succinct terms, x ^ 1 = x.
*
* Note that any whole number, x,
* raised to the power of a positive whole number exponent, y,
* is x multiplied by itself y times.
* For example, if x is 2 and y is 3,
* 2 ^ 3 = power(2, 3) = 2 * 2 * 2 = 8.
*
* Note that any whole number, x,
* raised to the power of a negative exponent, y,
* is 1 / (x ^ (-1 * y)).
* For example, if x is 2 and y is -3,
* 2 ^ -3 = power(2, -3) = 1 / (2 * 2 * 2) = 1 / 8 = 0.125.
*/
double power(double base, double exponent)
{
double output = 1.0;
if (exponent == 0) return 1;
if (exponent == 1) return base;
// if ((base == 0) && (exponent < 0)) return -666; // Technically 0 raised to the power of some negative exponent is undefined (i.e. not a number).
if (is_whole_number(exponent))
{
if (exponent > 0)
{
while (exponent > 0)
{
output *= base;
exponent -= 1;
}
return output;
}
else
{
exponent = absolute_value(exponent);
while (exponent > 0)
{
output *= base;
exponent -= 1;
}
return 1 / output;
}
}
if (exponent > 0) return power_of_e_to_x(ln(base) * exponent); // Return e ^ (ln(base) * exponent).
return power_of_e_to_x(power_of_e_to_x(ln(base) * absolute_value(exponent))); // Return e ^ (e ^ (ln(base) * absolute_value(exponent))).
}
</pre>
<hr>
<p><strong>SAMPLE_PROGRAM_OUTPUT</strong></p>
<hr>
<p><em>Note that the value returned by the function call pow(-1, 0.5) (and pow() is a function encapsulated by the C++ libraries cmath and math.h) returned the value -nan.</em></p>
<p><em>By contrast, the value returned by the function call power(-1, 0.5) (and power() is a function defined in <a style="background:#000000;color:#00ff00" href="https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power.cpp" target="_blank" rel="noopener">power.cpp</a>) returned the value 340357746532624088885911455895174250496.</em></p>
<p><em>That is because -1 to the power of 0.5 is an <a style="background:#000000;color:#ff9000" href="https://karlinaobject.wordpress.com/numbers/" target="_blank" rel="noopener">imaginary number</a> instead of a real number.</em></p>
<hr>
<p>The text in the preformatted text box below was generated by one use case of the C++ program featured in this <a style="background:#ff9000;color:#000000" href="https://en.wikipedia.org/wiki/Computer_programming" target="_blank" rel="noopener">computer programming</a> tutorial web page.</p>
<p>plain-text_file: <a style="background:#000000;color:#ff9000" href="https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power_output.txt" target="_blank" rel="noopener">https://raw.githubusercontent.com/karlinarayberinger/KARLINA_OBJECT_extension_pack_20/main/power_output.txt</a></p>
<hr>
<pre>--------------------------------
START OF PROGRAM
--------------------------------
power(base, exponent) = base ^ exponent.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: 0
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: 0
result = power(base,exponent) = power(0, 0) = 0 ^ 0 = 1.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: 2
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: 3
result = power(base,exponent) = power(2, 3) = 2 ^ 3 = 8.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: -2
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: 3
result = power(base,exponent) = power(-2, 3) = -2 ^ 3 = -8.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: -2
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: -3
result = power(base,exponent) = power(-2, -3) = -2 ^ -3 = -0.125.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: 2
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: 0.5
result = power(base,exponent) = power(2, 0.5) = 2 ^ 0.5 = 1.41452190152525414390538571751676499843597412109375.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: 2
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: -2
result = power(base,exponent) = power(2, -2) = 2 ^ -2 = 0.25.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: 2
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: -1
result = power(base,exponent) = power(2, -1) = 2 ^ -1 = 0.5.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: 0.5
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: -1
result = power(base,exponent) = power(0.5, -1) = 0.5 ^ -1 = 2.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: 0.5
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: 0.5
result = power(base,exponent) = power(0.5, 0.5) = 0.5 ^ 0.5 = 0.7072609494155397413805985706858336925506591796875.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: 100
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: 0.5
result = power(base,exponent) = power(100, 0.5) = 100 ^ 0.5 = 10.0015620834400120742202489054761826992034912109375.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: -100
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: 0.5
result = power(base,exponent) = power(-100, 0.5) = -100 ^ 0.5 = 3403358482654129315574312994291840974848.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: 16
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: -2
result = power(base,exponent) = power(16, -2) = 16 ^ -2 = 0.00390625.
--------------------------------
Enter a real number value for base which is no larger than 100 and no smaller than -100: 16
Enter a real number value for exponent which is no larger than 100 and no smaller than -100: 0.5
result = power(base,exponent) = power(16, 0.5) = 16 ^ 0.5 = 4.0008722454872884810583855141885578632354736328125.
--------------------------------
END OF PROGRAM
--------------------------------</pre>
<hr>
<p>This web page was last updated on 16_SEPTEMBER_2024. The content displayed on this web page is licensed as <a style="background:#000000;color:#ff9000" href="https://karlinaobject.wordpress.com/public_domain/" target="_blank" rel="noopener">PUBLIC_DOMAIN</a> intellectual property.</p>
<hr>