# Rational functions: Difference between revisions

Polynomial $\displaystyle{ f }$:

Polynomial $\displaystyle{ g }$:

Rational function $\displaystyle{ \frac{f}{g} }$:

### The underlying JavaScript source code

        board = JXG.JSXGraph.initBoard('box1', {originX: 300, originY: 100, unitX: 30, unitY: 25});
board.createElement('axis', [[0,0], [1,0]]);
board.createElement('axis', [[0,0], [0,1]]);

var p = [];
var q = [];
p[0] = board.createElement('point', [-1,2], {style:6});
p[1] = board.createElement('point', [3,-1], {style:6});
var f = board.lagrangePolynomial(p);
graph = board.createElement('curve', ['x', f, 'x', -10, 10], {curveType:'graph'});

p.push(board.createElement('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{style:6}));
board.update();
}

board2 = JXG.JSXGraph.initBoard('box2', {originX: 300, originY: 100, unitX: 30, unitY: 25});
board2.createElement('axis', [[0,0], [1,0]]);
board2.createElement('axis', [[0,0], [0,1]]);

q[0] = board2.createElement('point', [-1,2], {style:6});
q[1] = board2.createElement('point', [3,-1], {style:6});
var f2 = board2.lagrangePolynomial(q);
graph2 = board2.createElement('curve', ['x', f2, 'x', -10, 10], {curveType:'graph'});