IMABS function
PRO
BASIC
In Jspreadsheet Formulas Pro, the IMABS function is utilized to calculate the absolute value or magnitude of a complex number. A complex number is a number that can be expressed in the form a + bi, where 'a' and 'b' are real numbers, and 'i' is an imaginary unit. When you input a complex number into the IMABS function, it will provide you with the number's absolute value, essentially its distance from the origin on a complex number plane. This function is particularly useful in mathematical and engineering calculations.
Documentation
The IMABS function is used to return the absolute value (magnitude) of a complex number.
Category
Engineering
Syntax
IMABS(inumber)
Parameter | Description |
---|---|
inumber |
The complex number for which to find the absolute value. |
Behavior
The IMABS
function takes a complex number in the format x + yi
or x + yj
and returns the absolute (modulus) value of the complex number. Here's how it handles different inputs:
- If the input cell is empty, the function will return a
#NUM!
error, as it expects a complex number as an argument. - If the input is not a valid complex number, the function will return a
#NUM!
error. - Text inputs that can't be interpreted as complex numbers will result in a
#NUM!
error. - Booleans are not valid inputs for the
IMABS
function and will result in a#NUM!
error. - If the referenced cell contains an error (such as
#REF!
,#DIV/0!
, or other calculation errors),IMABS
will return the same error without calculation.
Common Errors
Error | Description |
---|---|
#NUM! |
Occurs when the input cell is empty, the input is not a complex number, or if a boolean is used as input. |
#VALUE! |
If the function encounters this error in the input cell, it will propagate the same error. Other error types from input cells will also be propagated. |
Best Practices
- Ensure that the input to the
IMABS
function is a valid complex number in the formatx + yi
orx + yj
.- Avoid using the function with empty cells, booleans, and non-complex numbers to prevent a
#NUM!
error.- Be careful while referencing cells as the function will propagate any error from the input cell.
- Use error handling functions like
IFERROR
orISERROR
to handle possible errors before usingIMABS
.
Usage
A few examples using the IMABS function.
IMABS("2+3i") // Returns approximately 3.6056 (√(2² + 3²))
IMABS("-4-3i") // Returns exactly 5 (√(16 + 9))
IMABS("0+10i") // Returns exactly 10 (purely imaginary number)
IMABS("5+0i") // Returns exactly 5 (purely real number)
IMABS(A1) // Returns the modulus of the complex number stored in cell A1
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('OTRmMjY5ZWE0YzhhMGM3ZDM3NjUzYTUyY2RmYmFiNjI2OWQ5YTVjZTJkZTMxZDY0MjQwZTM2NjU4YTNjY2ZmNDMyODJmMDcxOThkNDNjZmY1ZmZjMmYzMjg1MWJjM2VjOTVkODdlODA2NjQ5MzgxY2I1MWIxNWY2Njc2NTJmY2EsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXdOakV5TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
worksheets: [{
data: [
[
"Complex Number",
"Absolute Value"
],
[
"3+4i",
"=IMABS(A2)"
],
[
"-5+12i",
"=IMABS(A3)"
],
[
"0-8i",
"=IMABS(A4)"
],
[
"6+0i",
"=IMABS(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('OTRmMjY5ZWE0YzhhMGM3ZDM3NjUzYTUyY2RmYmFiNjI2OWQ5YTVjZTJkZTMxZDY0MjQwZTM2NjU4YTNjY2ZmNDMyODJmMDcxOThkNDNjZmY1ZmZjMmYzMjg1MWJjM2VjOTVkODdlODA2NjQ5MzgxY2I1MWIxNWY2Njc2NTJmY2EsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXdOakV5TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default function App() {
// Spreadsheet array of worksheets
const spreadsheet = useRef();
// Worksheet data
const data = [
[
"Complex Number",
"Absolute Value"
],
[
"3+4i",
"=IMABS(A2)"
],
[
"-5+12i",
"=IMABS(A3)"
],
[
"0-8i",
"=IMABS(A4)"
],
[
"6+0i",
"=IMABS(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('OTRmMjY5ZWE0YzhhMGM3ZDM3NjUzYTUyY2RmYmFiNjI2OWQ5YTVjZTJkZTMxZDY0MjQwZTM2NjU4YTNjY2ZmNDMyODJmMDcxOThkNDNjZmY1ZmZjMmYzMjg1MWJjM2VjOTVkODdlODA2NjQ5MzgxY2I1MWIxNWY2Njc2NTJmY2EsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXdOakV5TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default {
components: {
Spreadsheet,
Worksheet,
},
data() {
// Worksheet data
const data = [
[
"Complex Number",
"Absolute Value"
],
[
"3+4i",
"=IMABS(A2)"
],
[
"-5+12i",
"=IMABS(A3)"
],
[
"0-8i",
"=IMABS(A4)"
],
[
"6+0i",
"=IMABS(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('OTRmMjY5ZWE0YzhhMGM3ZDM3NjUzYTUyY2RmYmFiNjI2OWQ5YTVjZTJkZTMxZDY0MjQwZTM2NjU4YTNjY2ZmNDMyODJmMDcxOThkNDNjZmY1ZmZjMmYzMjg1MWJjM2VjOTVkODdlODA2NjQ5MzgxY2I1MWIxNWY2Njc2NTJmY2EsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXdOakV5TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');
// 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",
"Absolute Value"
],
[
"3+4i",
"=IMABS(A2)"
],
[
"-5+12i",
"=IMABS(A3)"
],
[
"0-8i",
"=IMABS(A4)"
],
[
"6+0i",
"=IMABS(A5)"
]
]
}]
});
}
}