This file is indexed.

/usr/share/genius/gel/calculus/limits.gel is in genius-common 1.0.23-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
# Limits of functions
# this function is a general limit function and allows (for instance) one to
# take limits of functions, derivatives, integrals, etc.
#FIXME: I need a way to truncate the return value to disregard epsilon < tolerance (so 1/x -> 0 ;-).

# documentation:
# this detect the existence of a limit by a function being almost constant over
# a long enough interval.
# Because of the existence of continuous (even of smooth) function with compact
# support (i.e., that vanish outside of some finite interval [a,b]),
# it is impossible to determine the limit of an arbitrary continuous/smooth
# function as it goes to infinity
# in a finite number of steps, since it is always possible that a function will
# become constant (or close to it), and then suddenly have a step or bulge at
# 10^43 (for instance).
# Thus, this function is necessarily imperfect.
# If you have more information about a function (for instance, it is a
# rational function), then there are other ways of computing its limits.
# 
# 

# Limits:
SetHelp ("NumericalLimitAtInfinity", "calculus", "Attempt to calculate the limit of f(step_fun(i)) as i goes from 1 to N")
function NumericalLimitAtInfinity(f,step_fun,tolerance,successive_for_success,N) =
# this evaluates f(step_fun(i)) as i goes from 1 to N.
# If s_f_s of the pairwise successive differences are less than tolerance, then
# it returns the last value; if this doesn't happen, it returns Null.
# INPUT: N had better be at least 1
#FIXME: should have a way of dealing with +infinity, -infinity, and
# bounded oscillation (like sin(x))
(
    local *;
    current_limit = f(step_fun(1));
    number_of_consecutive_differences_within_tolerance = 0;
    for i = 2 to N do (
        new_limit = f(step_fun(i));
        if (|new_limit-current_limit| < tolerance) then (
            increment number_of_consecutive_differences_within_tolerance
        ) else (
            number_of_consecutive_differences_within_tolerance = 0
        );
        current_limit = new_limit;
        if (number_of_consecutive_differences_within_tolerance >= successive_for_success) then
            return current_limit
    );
    null
)


# The following are simple functions to find
# lim_{x -> x_0} f(x)
# ...from the left
# ...from the right
# ...two-sided

SetHelp ("ContinuousTolerance", "parameters", "Tolerance for continuity of functions and for calculating the limit")
parameter ContinuousTolerance=10.0^(-5);
SetHelp ("ContinuousSFS", "parameters", "How many successive steps to be within tolerance for calculation of continuity")
parameter ContinuousSFS=20;
SetHelp ("ContinuousNumberOfTries", "parameters", "How many iterations to try to find the limit for continuity and limits")
parameter ContinuousNumberOfTries=100;

SetHelp ("LeftLimit", "calculus", "Calculate the left limit of a real-valued function at x0")
function LeftLimit(f,x0) =
(
	local *;
	NumericalLimitAtInfinity (f,
				  `(n)[x0]=(x0-2.0^(-n)),
				  ContinuousTolerance,
				  ContinuousSFS,
				  ContinuousNumberOfTries)
)

SetHelp ("RightLimit", "calculus", "Calculate the right limit of a real-valued function at x0")
function RightLimit(f,x0) =
(
	local *;
	NumericalLimitAtInfinity (f,
				  `(n)[x0]=(x0+2.0^(-n)),
				  ContinuousTolerance,
				  ContinuousSFS,
				  ContinuousNumberOfTries)
)

SetHelp ("Limit", "calculus", "Calculate the limit of a real-valued function at x0.  Tries to calculate both left and right limits.")
function Limit(f,x0) =
(
	local *;
	LeftLim = LeftLimit(f,x0);
	RightLim = RightLimit(f,x0);
	if ( not IsNull(LeftLim) and
	     not IsNull(RightLim) and
	     |LeftLim-RightLim| < 2*ContinuousTolerance ) then
		(LeftLim+RightLim)/2
)

SetHelp ("IsContinuous", "calculus", "Try and see if a real-valued function is continuous at x0 by calculating the limit there")
function IsContinuous(f,x0) =
(
    local *;
    l = Limit(f,x0);
    not IsNull(l) and |l-f(x0)| < ContinuousTolerance
)