Share JSXGraph: example "Discontinuous derivative"

JSXGraph
Share JSXGraph: example "Discontinuous derivative"
This website is a beta version. The official release will be in **2023**.

Discontinuous derivative

Examples of continuous, differentiable functions with discontinuous derivative. #### First example Consider the function (blue curve) $$f: \mathbb{R} \to \mathbb{R}, x \mapsto \cases{ x^2\sin(1/x),& $x\neq 0$\cr 0,& $x=0$. } $$ $f$ is a continuous and differentiable function. The derivative of $f$ is the function (red curve) $$ f': \mathbb{R} \to \mathbb{R}, x \mapsto \cases{ 2x\sin(1/x) - \cos(1/x), & $x \neq 0$\cr 0,& $x=0$. } $$ We observe that $f'(0) = 0$, but $\lim_{x\to0}f'(x)$ does not exist. Therefore, $f'$ is an example of a derivative which is not continuous. #### Second example $$ g: \mathbb{R} \to \mathbb{R}, x \mapsto \cases{ x^2(1-x)^2\sin( \frac{1}{\pi x(1-x)}),& $0 < x < 1$\cr 0,& otherwise }\,. $$ Here, the derivative is not continuous for $x=0$ and $x=1$.
// Define the ids of your boards in BOARDID0, BOARDID1,...

(function() {
    const board = JXG.JSXGraph.initBoard(BOARDID0, {axis:true, boundingbox:[-1/2, 1/2, 1/2, -1/2]});

    var g = board.create('functiongraph', ["2*x*sin(1/x) - cos(1/x)"], {strokeColor: 'red'});
    var f = board.create('functiongraph', ["x^2*sin(1/x)"], {strokeWidth:2});
})();

(function() {
    const board = JXG.JSXGraph.initBoard(BOARDID1, {axis:true, boundingbox:[-1/2, 0.08, 1.5, -0.02]});

    var g_der = board.create('functiongraph', [
        "(0 < x && x < 1) ? ((sin((1 / ((PI * x) * (1 - x)))) * ((2 * (x * ((1 - x)^2))) - (2 * ((x^2) * (1 - x))))) - (((x^2) * ((1 - x)^2)) * (cos((1 / ((PI * x) * (1 - x)))) * (((PI * (1 - x)) - (PI * x)) / (((PI * x) * (1 - x))^2))))) : 0"], 
        {strokeColor: 'red'});
    var g = board.create('functiongraph', ["(0 < x && x < 1) ? x^2*(1-x)^2*sin(1/(PI* x*(1-x))) : 0"],  
        {strokeWidth:2});
})();