Products

SEC function

PRO BASIC

The SEC function in Jspreadsheet Formulas Pro is a mathematical tool that gives you the secant of a given angle. The angle should be provided in radians, which is a type of angular measurement. You simply input the radian value into the SEC function, and it will calculate the secant for you. This can be particularly useful in trigonometry calculations and data analysis within your Jspreadsheet.

Documentation

Returns the secant of an angle specified in radians.

Category

Math and trigonometry

Syntax

SEC(x)

Parameter Description
x The angle in radians for which to calculate the secant.

Behavior

The SEC function is used to calculate the secant of a given angle. The angle should be provided in radians. Here's how it typically handles different values:

  • Numbers: The function works as expected with numerical values. It takes the numerical input as an angle in radians and returns the secant of the angle.
  • Empty cells: If the SEC function is applied to an empty cell, it will typically return an error, as it expects a numerical input.
  • Text: The SEC function does not work with text input and will return an error if applied to a cell containing text.
  • Booleans: Boolean values are treated as numbers 0 (for FALSE) and 1 (for TRUE) in numerical functions.
  • Errors: If the input cell contains an error, the SEC function will also return an error.

Common Errors

Error Description
#VALUE! This error is returned when the input to the SEC function is non-numeric, such as text or an empty cell.
#DIV/0! This error might occur when the SEC function attempts to divide by zero, which can occur when the cosine of the angle is zero.

Best practices

  • Always ensure the input to the SEC function is a numerical value representing an angle in radians.
  • Be aware that the SEC function can return very large values for certain angles (when the cosine of the angle is close to zero). Ensure your spreadsheet or subsequent calculations can handle these large values.
  • Remember that trigonometric functions typically work in radians, not degrees. If your input is in degrees, convert it to radians first using the RADIANS function.
  • Handle errors appropriately to maintain the integrity of your spreadsheet. Use error handling functions to catch and manage errors that may arise from non-numeric input or angles that result in division by zero.

Usage

A few examples using the SEC function.

SEC(0.5) returns 1.139493927
SEC(1) returns 1.850815718
SEC(2) returns -2.402997962

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('YWZjY2JlMzMwZjE4Y2VjNDE3NWY1N2Q0ZjYzYWE4ZjYzMDYyOWIyNGE4MmMyYjUxNjhhMDExNGIzYjJkYWRlNmQ5OThjOThiYzdhNzFhOThmNzVjZDM4OGJlNzQwNzQwYjUyNDI4MmRiMjM4NGQwMmRlMTM5ZGVhMWUzZTQ2OTYsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXdOVEU1TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');

// Set the extensions
jspreadsheet.setExtensions({ formula });

// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
  worksheets: [{
    data: [
    [
        "Angle (radians)",
        "Secant Value"
    ],
    [
        0,
        "=SEC(A2)"
    ],
    [
        0.5,
        "=SEC(A3)"
    ],
    [
        1,
        "=SEC(A4)"
    ],
    [
        1.57,
        "=SEC(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('YWZjY2JlMzMwZjE4Y2VjNDE3NWY1N2Q0ZjYzYWE4ZjYzMDYyOWIyNGE4MmMyYjUxNjhhMDExNGIzYjJkYWRlNmQ5OThjOThiYzdhNzFhOThmNzVjZDM4OGJlNzQwNzQwYjUyNDI4MmRiMjM4NGQwMmRlMTM5ZGVhMWUzZTQ2OTYsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXdOVEU1TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');

// Set the extensions
jspreadsheet.setExtensions({ formula });

export default function App() {
    // Spreadsheet array of worksheets
    const spreadsheet = useRef();

    // Worksheet data
    const data = [
    [
        "Angle (radians)",
        "Secant Value"
    ],
    [
        0,
        "=SEC(A2)"
    ],
    [
        0.5,
        "=SEC(A3)"
    ],
    [
        1,
        "=SEC(A4)"
    ],
    [
        1.57,
        "=SEC(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('YWZjY2JlMzMwZjE4Y2VjNDE3NWY1N2Q0ZjYzYWE4ZjYzMDYyOWIyNGE4MmMyYjUxNjhhMDExNGIzYjJkYWRlNmQ5OThjOThiYzdhNzFhOThmNzVjZDM4OGJlNzQwNzQwYjUyNDI4MmRiMjM4NGQwMmRlMTM5ZGVhMWUzZTQ2OTYsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXdOVEU1TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');

// Set the extensions
jspreadsheet.setExtensions({ formula });

export default {
    components: {
        Spreadsheet,
        Worksheet,
    },
    data() {
        // Worksheet data
        const data = [
    [
        "Angle (radians)",
        "Secant Value"
    ],
    [
        0,
        "=SEC(A2)"
    ],
    [
        0.5,
        "=SEC(A3)"
    ],
    [
        1,
        "=SEC(A4)"
    ],
    [
        1.57,
        "=SEC(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('YWZjY2JlMzMwZjE4Y2VjNDE3NWY1N2Q0ZjYzYWE4ZjYzMDYyOWIyNGE4MmMyYjUxNjhhMDExNGIzYjJkYWRlNmQ5OThjOThiYzdhNzFhOThmNzVjZDM4OGJlNzQwNzQwYjUyNDI4MmRiMjM4NGQwMmRlMTM5ZGVhMWUzZTQ2OTYsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpVM01ETXdOVEU1TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2lkMlZpSWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpOQ0lzSW5OamIzQmxJanBiSW5ZM0lpd2lkamdpTENKMk9TSXNJbll4TUNJc0luWXhNU0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklpd2lZMnhwWlc1MElpd2ljMlZ5ZG1WeUlpd2ljMmhoY0dWeklpd2labTl5YldGMElsMHNJbVJsYlc4aU9uUnlkV1Y5');

// 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: [
    [
        "Angle (radians)",
        "Secant Value"
    ],
    [
        0,
        "=SEC(A2)"
    ],
    [
        0.5,
        "=SEC(A3)"
    ],
    [
        1,
        "=SEC(A4)"
    ],
    [
        1.57,
        "=SEC(A5)"
    ]
]
            }]
        });
    }
}