Examples of RLSCF usage.

Fernando Gómez Lanza1998

To execute this notebook you need to download the package RLSCF.m  into  ExtraPackages folder, or another readed by Mathematica 3.0 .

<< RLSCF.m

Principal package functions.

LSFun[f[x], {x, xmin, xmax}]

Find all possible discontinuities between  xmin  and  xmax. Not use with functions defined with Which.

PlotFR[f[x], {x, xmin, xmax}, options]

Plots f[x] avoiding discontinuities. Options are of Plot type.

Object and limitations

The object of the package is to represent those real functions of one variable that present discontinuity points or complex roots that Plot cannot plot correctly. PlotFR plots correctly real 2D functions avoiding discontinuities and complex-roots, as,  logarithms, exponentials, trigonometric and hiperbolic functions, roots, fractions and functions defined with Which. Errors can appear when the functions contain iterations of these functions, because appear trascendental equations,  see last point.

Finding discontinuities

f[x_] := Tan[x/2] + 1;

The possible discontinuidades of f[x] contained in [-10,10] are obtained by

LSFun[f[x], {x, -10, 10}]

Plots

Functions p[x]/q[x]

f[x_] := 
      (4)/(x^5 - 13  x^4 + 50  x^3 - 50  x^2 - 51  x + 63)

Plot[f[x], {x, -5, 10}, PlotRange -> {{-5, 10}, {-5, 5}}]

PlotFR[f[x], {x, -5, 10}, PlotRange -> {{-5, 10}, {-5, 5}}]

Trigonometric functions

f[x_] := Tan[x/2] + 1;

Plot[f[x], {x, -10, 10}]

PlotFR   obtain the correct plot,

PlotFR[f[x], {x, -10, 10}]

g[x_] := 1/(2*Cos[x] - 1)

Plot[g[x], {x, -10, 10}, PlotRange -> {{-10, 10}, {-5, 5}}]

PlotFR[g[x], {x, -10, 10}, 
      PlotRange -> {{-10, 10}, {-5, 5}}]

The following function has an infinite number of discontinuities near 2.

h[x_] := Tan[1/(x - 2)];

Plot[h[x], {x, 0, 4}, PlotRange -> {{0, 4}, {-5, 5}}]

To see more than 10 discontinuities we need to increase the value of    vlkmax .
vlkmax=10    default.

PlotFR[h[x], {x, 0, 4}, PlotRange -> {{0, 4}, {-5, 5}}]

Zoom this plot to see more discontinuities.

Exponential functions, a^(f[x])

g[x_] := 1/(x - 1) + 2^(1/(x - 5))

Plot[g[x], {x, -10, 10}, PlotRange -> {{-10, 10}, {-5, 5}}]

PlotFR[g[x], {x, -10, 10}, 
      PlotRange -> {{-10, 10}, {-5, 5}}]

Logarithms

f[x_] := 3/Log[(x - 1)]

Plot[f[x], {x, -10, 10}]

PlotFR[f[x], {x, -10, 10}]

Functions with complex-roots, x^(1/3)

Problem suggested by Teodoro Morimoto.

g[x_] := (x - 3)^(2/5);

In this type of functions, complex roots that Plot cannot represent appear. In our example this happens when x <3.

Plot[g[x], {x, -10, 10}, PlotRange -> {{-10, 10}, {-3, 3}}]

PlotFR transforms the function so that Mathematica it only considers the real roots.

PlotFR[g[x], {x, -10, 10}, 
      PlotRange -> {{-10, 10}, {-3, 3}}]

Functions defined by intervals

Let us take a function defined by intervals and with presence of discontinuous functions in the same ones,

h[x_] := 
      Which[x < -3, -5, -3 < x < 3, 
        15/((x - 2)*(x + 1)), 3 < x <= 7, Cot[x - 4], x > 7, 
        2  x - 5];

Plot[h[x], {x, -10, 10}]

This version of PlotFR can analyze functions correctly with one Which, such as we can see when representing h[x]

PlotFR[h[x], {x, -10, 10}]

Confirmation of limitations:

LSFun[h[x], {x, -10, 10}]

it presents more discontinuities of those than really exist in functions defined by intervals. Also, those functions (trigonométriccas, hyperbolic) whose argument contains them again, can produce errors in the representation,

Plot[Tan[Tan[x] + 1], {x, -1, 1}]

PlotFR[Tan[Tan[x] + 1], {x, -1, 1}]

and although occasionally PlotFR can avoid some discontinuity it usually works bad in a bigger interval,

PlotFR[Tan[Tan[x] + 1], {x, -5, 5}]