Square root - MATLAB sqrt - MathWorks France (2024)

Square root

collapse all in page

Syntax

B = sqrt(X)

Description

example

B = sqrt(X) returnsthe square root of each element of the array X.For the elements of X that are negative or complex, sqrt(X) producescomplex results.

The sqrt function’s domain includesnegative and complex numbers, which can lead to unexpected resultsif used unintentionally. For negative and complex numbers z= u + i*w, the complex square root sqrt(z) returns

sqrt(r)*(cos(phi/2) + 1i*sin(phi/2))

where r = abs(z) is the radius and phi= angle(z) is the phase angle on the closed interval -pi<= phi <= pi.

If you want negative and complex numbers to return error messagesrather than return complex results, use realsqrt instead.

Examples

collapse all

Square Root of Vector Elements

Create a row vector containing both negative and positive values.

X = -2:2
X = 1×5 -2 -1 0 1 2

Compute the square root of each element of X.

Y = sqrt(X)
Y = 1×5 complex 0.0000 + 1.4142i 0.0000 + 1.0000i 0.0000 + 0.0000i 1.0000 + 0.0000i 1.4142 + 0.0000i

Input Arguments

collapse all

XInput array
scalar | vector | matrix | multidimensional array | table | timetable

Input array, specified as a numeric scalar, vector, matrix, multidimensional array, table, or timetable.

Data Types: single | double | table | timetable
Complex Number Support: Yes

More About

collapse all

IEEE Compliance

For real inputs, sqrt has a few behaviors that differ from those recommended in the IEEE®-754 Standard. In particular, negative inputs produce complex results instead of NaN.

MATLAB® IEEE

sqrt(-0)

-0

sqrt(X) for X < 0

0+sqrt(-X)*i

NaN

Tips

  • See sqrtm for the matrix square root.

Extended Capabilities

This function fully supports tall arrays. Formore information, see Tall Arrays.

Version History

Introduced before R2006a

expand all

The sqrt function can calculate on all variables within a table or timetable without indexing to access those variables. All variables must have data types that support the calculation. For more information, see Direct Calculations on Tables and Timetables.

See Also

nthroot | sqrtm | realsqrt

Commande MATLAB

Vous avez cliqué sur un lien qui correspond à cette commande MATLAB:

 

Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.

Square root - MATLAB sqrt- MathWorks France (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

Contact your local office

Square root - MATLAB sqrt
- MathWorks France (2024)
Top Articles
Latest Posts
Article information

Author: Clemencia Bogisich Ret

Last Updated:

Views: 6005

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Clemencia Bogisich Ret

Birthday: 2001-07-17

Address: Suite 794 53887 Geri Spring, West Cristentown, KY 54855

Phone: +5934435460663

Job: Central Hospitality Director

Hobby: Yoga, Electronics, Rafting, Lockpicking, Inline skating, Puzzles, scrapbook

Introduction: My name is Clemencia Bogisich Ret, I am a super, outstanding, graceful, friendly, vast, comfortable, agreeable person who loves writing and wants to share my knowledge and understanding with you.