IMSQRT function
PRO BASIC
The IMSQRT function in Jspreadsheet Formulas Pro is a useful tool when dealing with complex numbers. It is designed to return the square root of a complex number that you provide. In other words, it calculates the number which when multiplied by itself gives the original complex number. This function is especially helpful in fields like engineering or physics where complex number calculations are common.
Documentation
Returns the square root of a complex number.
Category
Engineering
Syntax
IMSQRT(inumber)
| Parameter | Description | 
|---|---|
inumber | 
The complex number for which you want to calculate the square root. | 
Behavior
The IMSQRT function is used to calculate the square root of a complex number. Here's how it handles various inputs:
- Empty Cells: If the 
IMSQRTfunction is used with an empty cell, it returns a#VALUE!error because the input cannot be interpreted as a complex number. - Text: If the input is a pure text string that cannot be interpreted as a complex number, the 
IMSQRTfunction returns a#VALUE!error. - Booleans: The function doesn't support boolean values. If a boolean value is provided as the argument, the function will treat it as an integer (TRUE as 1 and FALSE as 0).
 - Errors: If the argument in the 
IMSQRTfunction is another function or formula that results in an error, thenIMSQRTwill also result in an error. - Complex Numbers: The 
IMSQRTfunction works best with complex numbers. The function calculates the square root of the given complex number. 
Common Errors
| Error | Description | 
|---|---|
| #NUM! | Occurs if the argument to IMSQRT function is either non-numeric or is an invalid numeric value. | 
| #VALUE! | Occurs if the input is a pure text string which cannot be interpreted as a complex number or if the argument is a boolean value. | 
| Error passed from argument | If the argument in the IMSQRT function is another function or formula that results in an error, then IMSQRT will result in the same error. | 
Best practices
- Always ensure that the input to the
 IMSQRTfunction is a valid complex number.- Handle errors properly to ensure that your spreadsheets remain clean and easy to read. Use error functions like
 IFERRORto handle errors and provide a default value if an error occurs.- Be careful about the cell references and ranges when using
 IMSQRTfunction to avoid unexpected#NUM!and#VALUE!errors.- Remember that
 IMSQRTfunction cannot be used with logical values or pure text strings which cannot be interpreted as complex numbers.
Usage
A few examples using the IMSQRT function.
IMSQRT("1+i") returns 1.09868411346781+0.455089860562227i
IMSQRT("4+0i") returns 2
IMSQRT("-1") returns 6.1257422745431E-17+i
IMSQRT(9) returns 3  // Treated as a real number
Interactive Spreadsheet Demo
<html>
<script src="https://jspreadsheet.com/v11/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://jspreadsheet.com/v11/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/formula-pro/dist/index.min.js"></script>
<div id="spreadsheet"></div>
<script>
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('YjBiMDdlMTA5NzA4YzU4YzE0NmE4ZTU2NzA5MDdiMjc4ZDRjZjc1ODhlMDJjMTg1ZGRmNWE2MTQwNGZjYTJhOGIwNzQ5MmQ2YmEzMWY0N2M3MmU0NzcyNzk3MTY3ZDA2NTMzYzRiN2RlMGU3ZTc4YjI3ODFlOTBkZmIwNzI3NmQsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU1qVTNNemswTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
  worksheets: [{
    data: [
    [
        "Complex Number",
        "Square Root"
    ],
    [
        "1+i",
        "=IMSQRT(A2)"
    ],
    [
        "4+3i",
        "=IMSQRT(A3)"
    ],
    [
        "2-2i",
        "=IMSQRT(A4)"
    ],
    [
        "-1+0i",
        "=IMSQRT(A5)"
    ]
]
  }]
});
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/react";
import formula from "@jspreadsheet/formula-pro";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
// Set license
jspreadsheet.setLicense('YjBiMDdlMTA5NzA4YzU4YzE0NmE4ZTU2NzA5MDdiMjc4ZDRjZjc1ODhlMDJjMTg1ZGRmNWE2MTQwNGZjYTJhOGIwNzQ5MmQ2YmEzMWY0N2M3MmU0NzcyNzk3MTY3ZDA2NTMzYzRiN2RlMGU3ZTc4YjI3ODFlOTBkZmIwNzI3NmQsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU1qVTNNemswTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default function App() {
    // Spreadsheet array of worksheets
    const spreadsheet = useRef();
    // Worksheet data
    const data = [
    [
        "Complex Number",
        "Square Root"
    ],
    [
        "1+i",
        "=IMSQRT(A2)"
    ],
    [
        "4+3i",
        "=IMSQRT(A3)"
    ],
    [
        "2-2i",
        "=IMSQRT(A4)"
    ],
    [
        "-1+0i",
        "=IMSQRT(A5)"
    ]
];
    // Render component
    return (
        <Spreadsheet ref={spreadsheet}>
            <Worksheet data={data} />
        </Spreadsheet>
    );
}
<template>
    <Spreadsheet ref="spreadsheet">
        <Worksheet :data="data" />
    </Spreadsheet>
</template>
<script>
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/vue";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
import formula from "@jspreadsheet/formula-pro";
// Set license
jspreadsheet.setLicense('YjBiMDdlMTA5NzA4YzU4YzE0NmE4ZTU2NzA5MDdiMjc4ZDRjZjc1ODhlMDJjMTg1ZGRmNWE2MTQwNGZjYTJhOGIwNzQ5MmQ2YmEzMWY0N2M3MmU0NzcyNzk3MTY3ZDA2NTMzYzRiN2RlMGU3ZTc4YjI3ODFlOTBkZmIwNzI3NmQsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU1qVTNNemswTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default {
    components: {
        Spreadsheet,
        Worksheet,
    },
    data() {
        // Worksheet data
        const data = [
    [
        "Complex Number",
        "Square Root"
    ],
    [
        "1+i",
        "=IMSQRT(A2)"
    ],
    [
        "4+3i",
        "=IMSQRT(A3)"
    ],
    [
        "2-2i",
        "=IMSQRT(A4)"
    ],
    [
        "-1+0i",
        "=IMSQRT(A5)"
    ]
]
        return {
            data
        };
    }
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import * as formula from "@jspreadsheet/formula-pro";
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('YjBiMDdlMTA5NzA4YzU4YzE0NmE4ZTU2NzA5MDdiMjc4ZDRjZjc1ODhlMDJjMTg1ZGRmNWE2MTQwNGZjYTJhOGIwNzQ5MmQ2YmEzMWY0N2M3MmU0NzcyNzk3MTY3ZDA2NTMzYzRiN2RlMGU3ZTc4YjI3ODFlOTBkZmIwNzI3NmQsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU1qVTNNemswTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
@Component({
    standalone: true,
    selector: "app-root",
    template: `<div #spreadsheet></div>`
})
export class AppComponent {
    @ViewChild("spreadsheet") spreadsheet: ElementRef;
    // Worksheets
    worksheets: jspreadsheet.worksheetInstance[];
    // Create a new data grid
    ngAfterViewInit() {
        // Create spreadsheet
        this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
            worksheets: [{
                data: [
    [
        "Complex Number",
        "Square Root"
    ],
    [
        "1+i",
        "=IMSQRT(A2)"
    ],
    [
        "4+3i",
        "=IMSQRT(A3)"
    ],
    [
        "2-2i",
        "=IMSQRT(A4)"
    ],
    [
        "-1+0i",
        "=IMSQRT(A5)"
    ]
]
            }]
        });
    }
}