EXPONENTIATION_12_JUNE_2023


To view hidden text inside of the preformatted text boxes below, scroll horizontally.

The content below this orange preformatted text box is a copy of all of the source code of the web page whose uniform resource locator was as follows: (https://karlinaobject.wordpress.com/exponentiation/).

The content below this orange preformatted text box is a was copied from the aforementioned web page on 12_JUNE_2023.

This web page (which includes this orange preformatted text box) was published on 12_JUNE_2023 by karbytes.

This web page (which includes this orange preformatted text box) is licensed by karbytes as PUBLIC_DOMAIN intellectual property.

EXPONENTIATION


The C++ program featured in this tutorial web page computes the approximate value of some real number base (which the program user inputs) raised to the power of some real number exponent (which the program user also inputs). Such a mathematical operation is referred to as exponentiation. The C++ program uses the natural logarithm and the base of the natural logarithm (which is Euler’s Number) to compute input base to the power of some non whole number input exponent.

To view hidden text inside of the preformatted text boxes below, scroll horizontally.

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 reciprical 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.

SOFTWARE_APPLICATION_COMPONENTS


C++_source_file: https://raw.githubusercontent.com/karlinarayberinger/karlina_object_evolution_0_pack/main/power.cpp

plain-text_file: https://raw.githubusercontent.com/karlinarayberinger/karlina_object_evolution_0_pack/main/power_output.txt


PROGRAM_COMPILATION_AND_EXECUTION


STEP_0: Copy and paste the C++ source code into a new text editor document and save that document as the following file name:

power.cpp

STEP_1: Open a Unix command line terminal application and set the current directory to wherever the C++ is located on the local machine (e.g. Desktop).

cd Desktop

STEP_2: Compile the C++ file into machine-executable instructions (i.e. object file) and then into an executable piece of software named app using the following command:

g++ power.cpp -o app

STEP_3: If the program compilation command does not work, then use the following command to install the C++ compiler:

sudo apt install build-essential

STEP_4: After running the g++ command, run the executable file using the following command:

./app

STEP_5: Once the application is running, the following prompt will appear:

Enter a real number value for base which is no larger than 10 and no smaller than -10:

STEP_6: Enter a value for base using the using the keyboard.

STEP_7: After a value for base is entered, the following prompt will appear:

Enter a real number value for exponent which is no larger than 10 and no smaller than -10:

STEP_8: Enter a value for exponent using the using the keyboard.

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:

Would you like to continue inputting program values? (Enter 1 if YES. Enter 0 if NO):

STEP_10: Enter a value according to your preference until you decide to close the program (and save your program data to the output text file).


PROGRAM_SOURCE_CODE


When copy-pasting the source code from the preformatted text box below into a text editor document, remove the spaces between the angle brackets and the library names in the preprocessing directives code block. (The spaces were inserted between the library names and angle brackets in the preformatted text box below in order to prevent the WordPress server from misinterpreting those C++ library references as HTML tags in the source code of this web page).

C++_source_file: https://raw.githubusercontent.com/karlinarayberinger/karlina_object_evolution_0_pack/main/power.cpp


/**
 * file: power.cpp
 * type: C++ (source file)
 * date: 11_JUNE_2023
 * 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 10 // constant which represents maximum absolute value for base
#define MAXIMUM_ABSOLUTE_VALUE_EXPONENT 10 // constant which represents maximum absolute value for exponent

/* function prototypes */
bool is_whole_number(double x);
double absolute_value(double 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. // ideal equivalence";

    // Print some program-related data to the file output stream.
    file << "\n\npower(base, exponent) = base ^ exponent. // ideal equivalence";

    // 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--------------------------------";

    // The following lines of code compare the cmath library pow() function and the power function defined in this program (and prints data to the command line terminal).
    std::cout << "\n\n0.5 ^ -0.5 = 0.70710678118. // mathematically correct equation (according to chatGPT 3.0)";
    std::cout << "\n\n0.5 ^ -0.5 = 1.41421356237. // mathematically correct equation (according to Google)";
    std::cout << "\n\npow(0.5, -0.5) = " << pow(0.5, -0.5) << ".";
    std::cout << "\n\npower(0.5, -0.5) = " << power(0.5, -0.5) << ".";

    // The following lines of code compare the cmath library pow() function and the power function defined in this program (and prints data to the file output stream).
    file << "\n\n0.5 ^ -0.5 = 0.70710678118. // mathematically correct equation (according to chatGPT 3.0)";
    file << "\n\n0.5 ^ -0.5 = 1.41421356237. // mathematically correct equation (according to Google)";
    file << "\n\npow(0.5, -0.5) = " << pow(0.5, -0.5) << ".";
    file << "\n\npower(0.5, -0.5) = " << power(0.5, -0.5) << ".";

    // 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--------------------------------";

    // The following lines of code compare the cmath library pow() function and the power function defined in this program (and prints data to the command line terminal).
    std::cout << "\n\n0.5 ^ 0.5 = 0.70710678118. // mathematically correct equation (according to chatGPT 3.0)";
    std::cout << "\n\n0.5 ^ 0.5 = 0.70710678118. // mathematically correct equation (according to Google)";
    std::cout << "\n\npow(0.5, 0.5) = " << pow(0.5, 0.5) << ".";
    std::cout << "\n\npower(0.5, 0.5) = " << power(0.5, 0.5) << ".";

    // The following lines of code compare the cmath library pow() function and the power function defined in this program (and prints data to the file output stream).
    file << "\n\n0.5 ^ 0.5 = 0.70710678118. // mathematically correct equation (according to chatGPT 3.0)";
    file << "\n\n0.5 ^ 0.5 = 0.70710678118. // mathematically correct equation (according to Google)";
    file << "\n\npow(0.5, 0.5) = " << pow(0.5, 0.5) << ".";
    file << "\n\npower(0.5, 0.5) = " << power(0.5, 0.5) << ".";

    // 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--------------------------------";

    // The following lines of code compare the cmath library pow() function and the power function defined in this program (and prints data to the command line terminal).
    std::cout << "\n\n-0.25 ^ 0.25 = -0.84370052602. // mathematically correct equation (according to chatGPT 3.0)"; 
    std::cout << "\n\n-0.25 ^ 0.25 = -0.70710678118. // mathematically correct equation (according to Google)"; 
    std::cout << "\n\npow(-0.25, 0.25) = " << pow(-0.25, 0.25) << ".";
    std::cout << "\n\npower(-0.25, 0.25) = " << power(-0.25, 0.25) << ".";

    // The following lines of code compare the cmath library pow() function and the power function defined in this program (and prints data to the file output stream).
    file << "\n\n-0.25 ^ 0.25 = -0.84370052602. // mathematically correct equation (according to chatGPT 3.0)"; 
    file << "\n\n-0.25 ^ 0.25 = -0.70710678118. // mathematically correct equation (according to Google)"; 
    file << "\n\npow(-0.25, 0.25) = " << pow(-0.25, 0.25) << ".";
    file << "\n\npower(-0.25, 0.25) = " << power(-0.25, 0.25) << ".";

    // 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--------------------------------";

    // The following lines of code compare the cmath library pow() function and the power function defined in this program (and prints data to the command line terminal).
    std::cout << "\n\n0.25 ^ 0.25 = 0.92016449499. // mathematically correct equation (according to chatGPT 3.0)"; 
    std::cout << "\n\n0.25 ^ 0.25 = 0.70710678118. // mathematically correct equation (according to Google)"; 
    std::cout << "\n\npow(0.25, 0.25) = " << pow(0.25, 0.25) << ".";
    std::cout << "\n\npower(0.25, 0.25) = " << power(0.25, 0.25) << ".";

    // The following lines of code compare the cmath library pow() function and the power function defined in this program (and prints data to the file output stream).
    file << "\n\n0.25 ^ 0.25 = 0.92016449499. // mathematically correct equation (according to chatGPT 3.0)"; 
    file << "\n\n0.25 ^ 0.25 = 0.70710678118. // mathematically correct equation (according to Google)"; 
    file << "\n\npow(0.25, 0.25) = " << pow(0.25, 0.25) << ".";
    file << "\n\npower(0.25, 0.25) = " << power(0.25, 0.25) << ".";

    // 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--------------------------------";

    // The following lines of code compare the cmath library pow() function and the power function defined in this program (and prints data to the command line terminal).
    std::cout << "\n\n0.5 ^ -1 = 0.5. // mathematically correct equation (according to chatGPT 3.0)"; 
    std::cout << "\n\n0.5 ^ -1 = 2. // mathematically correct equation (according to Google)"; 
    std::cout << "\n\npow(0.5, -1) = " << pow(0.5, -1) << ".";
    std::cout << "\n\npower(0.5, -1) = " << power(0.5, -1) << ".";

    // The following lines of code compare the cmath library pow() function and the power function defined in this program (and prints data to the file output stream).
    file << "\n\n0.5 ^ -1 = 0.5. // mathematically correct equation (according to chatGPT 3.0)"; 
    file << "\n\n0.5 ^ -1 = 2. // mathematically correct equation (according to Google)"; 
    file << "\n\npow(0.5, -1) = " << pow(0.5, -1) << ".";
    file << "\n\npower(0.5, -1) = " << power(0.5, -1) << ".";

    // Print one newline character to the command line terminal.
    std::cout << "\n\n";

    // Print one newline character to the file output stream
    file << "\n\n";

    while (input_additional_values != 0)
    {
        // Print a divider line to the command line terminal.
        std::cout << "--------------------------------";

        // Print a divider line to the file output stream.
        file << "--------------------------------";

        // 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 user input entered via keyboard to store in the variable named base.
        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 user input entered via keyboard to store in the variable named exponent.
        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 inputing program values? (Enter 1 if YES. Enter 0 if NO): ";

        // Scan the command line terminal for the most recent user input entered via keyboard to store in the variable named input_additional_values.
        std::cin >> input_additional_values;

        // Print one newline character to the command line terminal.
        std::cout << "\n";

        // Print one newline character to the file output stream
        file << "\n";
    }

    // 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--------------------------------";
    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;
}

/**
 * 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.
 * 
 * A potentially useful property of logarithms in general 
 * is the following:
 * 
 * For a log of any positive number base, b,
 * log(x) = ln(x) / ln(b).
 * 
 * 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 approcimately 
 * 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 real 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 real number, x, 
 * raised to the power of a negative exponent, y, 
 * is 1 / (x ^ -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 exp(log(base) * exponent); // Return e ^ (ln(base) * exponent). 
    return exp(exp(log(base) * absolute_value(exponent))); // Return e ^ (e ^ (ln(base) * absolute_value(exponent))).
}

SAMPLE_PROGRAM_OUTPUT


The text in the preformatted text box below was generated by one use case of the C++ program featured in this computer programming tutorial web page.

Note that when karbytes entered the value 3.14 to store in the double type variable named base, the program represented that value as 3.140000000000000124344978758017532527446746826171875 (which is evident in the last line of the corresponding output file displayed below).

plain-text_file: https://raw.githubusercontent.com/karlinarayberinger/karlina_object_evolution_0_pack/main/power_output.txt


--------------------------------
START OF PROGRAM
--------------------------------

power(base, exponent) = base ^ exponent. // ideal equivalence

--------------------------------

0.5 ^ -0.5 = 0.70710678118. // mathematically correct equation (according to chatGPT 3.0)

0.5 ^ -0.5 = 1.41421356237. // mathematically correct equation (according to Google)

pow(0.5, -0.5) = 1.4142135623730951454746218587388284504413604736328125.

power(0.5, -0.5) = 2.028114981647472614412208713474683463573455810546875.

--------------------------------

0.5 ^ 0.5 = 0.70710678118. // mathematically correct equation (according to chatGPT 3.0)

0.5 ^ 0.5 = 0.70710678118. // mathematically correct equation (according to Google)

pow(0.5, 0.5) = 0.70710678118654757273731092936941422522068023681640625.

power(0.5, 0.5) = 0.70710678118654757273731092936941422522068023681640625.

--------------------------------

-0.25 ^ 0.25 = -0.84370052602. // mathematically correct equation (according to chatGPT 3.0)

-0.25 ^ 0.25 = -0.70710678118. // mathematically correct equation (according to Google)

pow(-0.25, 0.25) = -nan.

power(-0.25, 0.25) = -nan.

--------------------------------

0.25 ^ 0.25 = 0.92016449499. // mathematically correct equation (according to chatGPT 3.0)

0.25 ^ 0.25 = 0.70710678118. // mathematically correct equation (according to Google)

pow(0.25, 0.25) = 0.70710678118654757273731092936941422522068023681640625.

power(0.25, 0.25) = 0.70710678118654757273731092936941422522068023681640625.

--------------------------------

0.5 ^ -1 = 0.5. // mathematically correct equation (according to chatGPT 3.0)

0.5 ^ -1 = 2. // mathematically correct equation (according to Google)

pow(0.5, -1) = 2.

power(0.5, -1) = 2.

--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: 2

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: 3

result = power(base,exponent) = power(2, 3) = 2 ^ 3 = 8.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: 2

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: -3

result = power(base,exponent) = power(2, -3) = 2 ^ -3 = 0.125.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: -2

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: 3

result = power(base,exponent) = power(-2, 3) = -2 ^ 3 = -8.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: -3

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: -2

result = power(base,exponent) = power(-3, -2) = -3 ^ -2 = 0.111111111111111104943205418749130330979824066162109375.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: -2

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: -3

result = power(base,exponent) = power(-2, -3) = -2 ^ -3 = -0.125.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: 9

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: 0.5

result = power(base,exponent) = power(9, 0.5) = 9 ^ 0.5 = 3.000000000000000444089209850062616169452667236328125.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: -2

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: 4

result = power(base,exponent) = power(-2, 4) = -2 ^ 4 = 16.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: 0.5

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: 0.25

result = power(base,exponent) = power(0.5, 0.25) = 0.5 ^ 0.25 = 0.84089641525371450203607537332572974264621734619140625.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: -0.5

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: 0.25

result = power(base,exponent) = power(-0.5, 0.25) = -0.5 ^ 0.25 = -nan.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: -0.5

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: -2

result = power(base,exponent) = power(-0.5, -2) = -0.5 ^ -2 = 4.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: 0.5

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: 2

result = power(base,exponent) = power(0.5, 2) = 0.5 ^ 2 = 0.25.
--------------------------------

Enter a real number value for base which is no larger than 10 and no smaller than -10: -0.5

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: -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 10 and no smaller than -10: 3.140000000000000124344978758017532527446746826171875

Enter a real number value for exponent which is no larger than 10 and no smaller than -10: -0.5

result = power(base,exponent) = power(3.140000000000000124344978758017532527446746826171875, -0.5) = 3.140000000000000124344978758017532527446746826171875 ^ -0.5 = 5.88263337571425015681825243518687784671783447265625.

--------------------------------
END OF PROGRAM
--------------------------------

This web page was last updated on 11_JUNE_2023. The content displayed on this web page is licensed as PUBLIC_DOMAIN intellectual property.