eps2

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.1, Creation date: 2017-08-14, Last change: 2025-08-18

returns the rounding limit for triangular or quadratic problems

Description

While function eps returns the minimal distance between zero and a floting points number,
eps 2 returns the root of this number. Therefor eps is a candidate to round functions such as acos, cross, etc.

See Also: , rounddiv

Example Illustration

 missing image of eps2

Syntax

to=eps2

Output Parameter

to: rounding limit for square problems

Examples


eps2
VL=rand(100,3); VL=normr(VL); dp=bsxfun(@dot,VL',VL')'; a=real(acos(dp)); [a roundz(a,eps2)]
dp-1




Copyright 2017-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, named eps2, is designed to return a specific rounding limit for triangular or quadratic problems. It is part of the SolidGeometry library and was introduced in version 4.1. The function is authored by Tim Lueth and is classified under auxiliary procedures.

Input Parameters

The function eps2 does not take any input parameters. It is called without arguments.

Output

The function returns a single output:

Algorithm Explanation

The function uses a persistent variable t to store the calculated rounding limit. The persistent variable ensures that the value of t is retained between function calls, avoiding recalculation.

  1. The function checks if t is empty. If it is, the function calculates t using the formula: t = 10^-(floor((log10(1/sqrt(eps))))).
  2. The calculation involves the following steps:
    • eps is the machine epsilon, representing the smallest difference between 1 and the next larger floating-point number.
    • sqrt(eps) computes the square root of the machine epsilon.
    • 1/sqrt(eps) calculates the reciprocal of the square root of the machine epsilon.
    • log10(1/sqrt(eps)) computes the base-10 logarithm of the reciprocal value.
    • floor(log10(1/sqrt(eps))) rounds down the logarithm to the nearest integer.
    • 10^-(floor(log10(1/sqrt(eps)))) raises 10 to the power of the negative rounded-down logarithm, resulting in the desired rounding limit.
  3. The calculated value of t is then assigned to the output variable to.

Example Usage

An example provided in the comments demonstrates the use of eps2 in conjunction with other functions:

VL = rand(100,3); 
VL = normr(VL); 
dp = bsxfun(@dot, VL', VL')'; 
a = real(acos(dp)); 
[a roundz(a, eps2)]
dp - 1

This example generates random vectors, normalizes them, computes dot products, and uses eps2 to round the results of the acos function.

Algorithm explaination created using ChatGPT on 2025-08-18 23:08. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21