JSXGraph logo
JSXGraph
JSXGraph share

Share

N-th root
QR code
<iframe 
    src="http://jsxgraph.org/share/iframe/n-th-root" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: N-th root" 
    allowfullscreen
></iframe>
This code has to
<div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; ">
   <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div>
</div>

<script type = "text/javascript"> 
    /*
    This example is licensed under a 
    Creative Commons Attribution ShareAlike 4.0 International License.
    https://creativecommons.org/licenses/by-sa/4.0/
    
    Please note you have to mention 
    The Center of Mobile Learning with Digital Technology
    in the credits.
    */
    
    const BOARDID = 'board-0';

    var board = JXG.JSXGraph.initBoard(BOARDID, {
        axis: true,
        boundingbox: [-5, 5, 5, -5],
        showFullscreen: true,
        keepaspectratio: true
    });
    
    var plot1 = board.create('functiongraph', ["nthroot(x, 3)"], {
        withLabel: true,
        name: 'nthroot(x,3)',
        strokeWidth: 2,
        label: { position: '1 rt' }
    });
    var plot2 = board.create('functiongraph', ["cbrt(x) + 1"], {
        withLabel: true,
        name: 'cbrt(x)+1',
        strokeColor: 'black',
        strokeWidth: 2,
        label: { position: '1 rt' }
    });
    var plot3 = board.create('functiongraph', [(x) => Math.pow(x, 1 / 3) - 1], {
        withLabel: true,
        name: 'Math.pow(x, 1/3) - 1',
        strokeColor: 'red',
        strokeWidth: 2,
        label: { position: '1 rt', offset: [0, -20] }
    });
 </script> 
/*
This example is licensed under a 
Creative Commons Attribution ShareAlike 4.0 International License.
https://creativecommons.org/licenses/by-sa/4.0/

Please note you have to mention 
The Center of Mobile Learning with Digital Technology
in the credits.
*/

const BOARDID = 'your_div_id'; // Insert your id here!

var board = JXG.JSXGraph.initBoard(BOARDID, {
    axis: true,
    boundingbox: [-5, 5, 5, -5],
    showFullscreen: true,
    keepaspectratio: true
});

var plot1 = board.create('functiongraph', ["nthroot(x, 3)"], {
    withLabel: true,
    name: 'nthroot(x,3)',
    strokeWidth: 2,
    label: { position: '1 rt' }
});
var plot2 = board.create('functiongraph', ["cbrt(x) + 1"], {
    withLabel: true,
    name: 'cbrt(x)+1',
    strokeColor: 'black',
    strokeWidth: 2,
    label: { position: '1 rt' }
});
var plot3 = board.create('functiongraph', [(x) => Math.pow(x, 1 / 3) - 1], {
    withLabel: true,
    name: 'Math.pow(x, 1/3) - 1',
    strokeColor: 'red',
    strokeWidth: 2,
    label: { position: '1 rt', offset: [0, -20] }
});
<jsxgraph width="100%" aspect-ratio="1 / 1" title="N-th root" description="This construction was copied from JSXGraph examples database: BTW HERE SHOULD BE A GENERATED LINKuseGlobalJS="false">
   /*
   This example is licensed under a 
   Creative Commons Attribution ShareAlike 4.0 International License.
   https://creativecommons.org/licenses/by-sa/4.0/
   
   Please note you have to mention 
   The Center of Mobile Learning with Digital Technology
   in the credits.
   */
   
   var board = JXG.JSXGraph.initBoard(BOARDID, {
       axis: true,
       boundingbox: [-5, 5, 5, -5],
       showFullscreen: true,
       keepaspectratio: true
   });
   
   var plot1 = board.create('functiongraph', ["nthroot(x, 3)"], {
       withLabel: true,
       name: 'nthroot(x,3)',
       strokeWidth: 2,
       label: { position: '1 rt' }
   });
   var plot2 = board.create('functiongraph', ["cbrt(x) + 1"], {
       withLabel: true,
       name: 'cbrt(x)+1',
       strokeColor: 'black',
       strokeWidth: 2,
       label: { position: '1 rt' }
   });
   var plot3 = board.create('functiongraph', [(x) => Math.pow(x, 1 / 3) - 1], {
       withLabel: true,
       name: 'Math.pow(x, 1/3) - 1',
       strokeColor: 'red',
       strokeWidth: 2,
       label: { position: '1 rt', offset: [0, -20] }
   });
</jsxgraph>

N-th root

This example shows the various possibilities to plot the graph of the function $$\mathbb{R} \to \mathbb{R}, x \mapsto x^{1/3}.$$ They handle negative values of $x$ differently. There are the following choices: - `Math.pow(x, 1/3)`: this built-in JavaScript function is restricted to positive values of $x$. - `JXG.Math.cbrt(x)`: cube root function which is able to compute the real cube root of $x$. It is available in most browsers as built-in JavaScript's `Math.cbrt()`. JSXGraph makes cbrt available also on old browsers. - `JXG.Math.nthroot(x, 3)`: general method in JSXGraph to compute the real $n$-th root of a real number.
// Define the id of your board in BOARDID

var board = JXG.JSXGraph.initBoard(BOARDID, {
    axis: true,
    boundingbox: [-5, 5, 5, -5],
    showFullscreen: true,
    keepaspectratio: true
});

var plot1 = board.create('functiongraph', ["nthroot(x, 3)"], {
    withLabel: true,
    name: 'nthroot(x,3)',
    strokeWidth: 2,
    label: { position: '1 rt' }
});
var plot2 = board.create('functiongraph', ["cbrt(x) + 1"], {
    withLabel: true,
    name: 'cbrt(x)+1',
    strokeColor: 'black',
    strokeWidth: 2,
    label: { position: '1 rt' }
});
var plot3 = board.create('functiongraph', [(x) => Math.pow(x, 1 / 3) - 1], {
    withLabel: true,
    name: 'Math.pow(x, 1/3) - 1',
    strokeColor: 'red',
    strokeWidth: 2,
    label: { position: '1 rt', offset: [0, -20] }
});

license

This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License.
Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.