Computers

Octave Power Operator

Octave Power Operator

In this tutorial, we will learn about Octave Power Operator with Examples. We have two operators in Octave that compute the power.

x ^ y
x ** y

The result of the computation depends on the values of the operands x and y.

If both x and y are scalars, then x ^ y returns the result x raised to the power of y.

If x is scalar and y is a square matrix, the result would be eigenvalue expansion.

Examples

^ Operator

Let’s look at a simple example.

>> x = 2;
>> y = 3;
>> result = x ^ y;
>> result

result = 8

The result is 2*2*2 = 8

 

Octave Power Operator

** Operator

We can also use the ** operator.

>> x = 4;
>> y = 4;
>> result = x ** y;
>> result

result =  256

 

GNU Octave Power Operator Dobule Star

Element wise Power

To compute element-wise matrix power calculation, we can use the following operator.

x.^y

>> x = 2 ;
>> y = [2, 3; 3 , 5];
>> result = x.^ y

result =

  4    8
  8   32

 

 

Octave Tutorials

GNU Octave Tutorials on this website can be found at: