# N-th root

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This example shows the various possibilities to plot the graph of the function

$\displaystyle{ \mathbb{R} \to \mathbb{R}, x \mapsto x^{1/3} }$

also for negative values of $\displaystyle{ x }$.

There are the following choices:

• "Math.pow(x, 1/3)": this built-in JavaScript function is restricted to positive values of $\displaystyle{ x }$.
• "JXG.Math.cbrt(x)": cube root function which is able to compute the real cube root of $\displaystyle{ x }$. It is available in most browsers as built-in "Math.cbrt()". The JSXGraph makes cbrt available also on old browsers.
• "JXG.Math.nthroot(x, 3)": general method in JSXGraph to compute the real $\displaystyle{ n }$-th root of a real number.

### The underlying JavaScript code

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

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