lettura facile

Complex Numbers in Scilab

Navigating the realm of complex numbers in Scilab can seem daunting, but with this tutorial, you'll be handling them like a pro in no time.

First things first, launch Scilab.

To represent the complex number 3+4i, simply input z1=complex(3,4)

z1=complex(3,4)

Alternatively, you can represent the complex number 3+4i using this syntax. The result is the same.

z1 = 3 + 4 * %i

Here, %i is the constant Scilab uses for the imaginary unit.

Next, for the complex number 2+3i, type z2=complex(2,3)

Once again, press 'Enter'.

z1=complex(2,3)

You've now initialized two complex variables.

These aren't just for show; you can employ them in a variety of mathematical operations.

For instance, if you're curious about the sum of these two complex numbers, input z1+z2

z1+z2

Scilab efficiently computes the interaction between the two complex numbers, presenting you with the result

It will promptly return the sum.

ans =
5.+7.i

Diving deeper, if you wish to access the real part of a complex number, the `real()` function is your go-to.

Given that z1 is assigned the value 2+3i, you can retrieve its real coefficient by typing:

real(z1)

The real() function returns the coefficient of the real part of the complex number, which is 2.

2

In a similar vein, the `imag()` function lets you tap into the imaginary part of the complex number. Try:

imag(z1)

And Scilab will display 3, indicating the coefficient of the imaginary part of the complex number 2+3i.

3

Consider a complex number, denoted as z = x + yi.

This isn't just a mathematical abstraction; it also represents a specific point (x,y) on the Gaussian plane.

Visualize it as a vector originating from the plane's origin and extending to the point (x,y).

a complex number in the Gauss plane

The vector's length, represented as |z|, is termed its magnitude or absolute value. The angle theta θ it forms with the positive x-axis provides the argument of the complex number.

With knowledge of the real and imaginary components of the complex number z = x + yi, the angle (or argument) can be deduced from:

$$ θ = \tan^{-1} \frac{y}{x} $$

In Scilab's mathematical notation, this formula translates to:

atan(imag(z1)/real(z1))

For instance, given the complex number z1 = 3 + 4i, the resulting angle is approximately 0.98 radians, or:

0.9827937

To ascertain the magnitude — essentially the distance from the origin to the complex number on the Gaussian plane — the absolute value function, abs(), comes in handy:

abs(z1)

For our example, z1 = 3 + 4i, the magnitude is approximately 3.6

3.6055513

 

We hope this guide by Nigiara proves invaluable in your Scilab endeavors. Stay tuned for more insights and tutorials.




Report a mistake or post a question




FacebookTwitterLinkedinLinkedin