Rational functions: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
(40 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Polynomial <math>f</math>: | |||
<html><form><input type="button" value="Add point" onClick="addPoint1()"></form> | |||
</html> | |||
<jsxgraph width="600" height="200" box="box1"> | |||
var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-10, 4, 10, -4], axis:true}); | |||
var p = []; | |||
var q = []; | |||
p[0] = board.create('point', [-1,2], {size:4}); | |||
p[1] = board.create('point', [3,-1], {size:4}); | |||
var f = JXG.Math.Numerics.lagrangePolynomial(p); | |||
var graph = board.create('functiongraph', [f,-10, 10]); | |||
function addPoint1() { | |||
p.push(board.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4})); | |||
board.update(); | |||
} | |||
</jsxgraph> | |||
Polynomial <math>g</math>: | |||
<html> | <html> | ||
<form><input type="button" value="Add point" onClick="addPoint2()"></form> | <form><input type="button" value="Add point" onClick="addPoint2()"></form> | ||
< | </html> | ||
<jsxgraph width="600" height="200" box="box2"> | |||
var board2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-10, 4, 10, -4], axis:true}); | |||
q[0] = board2.create('point', [-1,2], {size:4}); | |||
q[1] = board2.create('point', [3,-1], {size:4}); | |||
var f2 = JXG.Math.Numerics.lagrangePolynomial(q); | |||
var graph2 = board2.create('functiongraph', [f2, -10, 10]); | |||
function addPoint2() { | |||
q.push(board2.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4})); | |||
board2.update(); | |||
} | |||
</jsxgraph> | |||
Rational function <math>\frac{f}{g}</math>: | |||
<jsxgraph width="600" height="400" box="box3"> | |||
var board3 = JXG.JSXGraph.initBoard('box3', {boundingbox: [-10, 8, 10, -8], axis:true}); | |||
var graph3 = board3.create('functiongraph', [function(x){return f(x)/f2(x);}, -10, 10], {strokeColor:'#ff0000'}); | |||
board.addChild(board3); | |||
board2.addChild(board3); | |||
</jsxgraph> | |||
=== References === | |||
* [http://en.wikipedia.org/wiki/Rational_function http://en.wikipedia.org/wiki/Rational_function] | |||
=== The underlying JavaScript source code === | |||
<source lang="javascript"> | |||
var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-10, 4, 10, -4], axis:true}); | |||
var p = []; | |||
var q = []; | |||
p[0] = board.create('point', [-1,2], {size:4}); | |||
p[1] = board.create('point', [3,-1], {size:4}); | |||
var f = JXG.Math.Numerics.lagrangePolynomial(p); | |||
var graph = board.create('functiongraph', [f,-10, 10]); | |||
function addPoint1() { | |||
p.push(board.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4})); | |||
board.update(); | |||
} | |||
var board2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-10, 4, 10, -4], axis:true}); | |||
q[0] = board2.create('point', [-1,2], {size:4}); | |||
q[1] = board2.create('point', [3,-1], {size:4}); | |||
var f2 = JXG.Math.Numerics.lagrangePolynomial(q); | |||
var graph2 = board2.create('functiongraph', [f2, -10, 10]); | |||
function addPoint2() { | |||
q.push(board2.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4})); | |||
board2.update(); | |||
} | |||
var board3 = JXG.JSXGraph.initBoard('box3', {boundingbox: [-10, 8, 10, -8], axis:true}); | |||
var graph3 = board3.create('functiongraph', [function(x){return f(x)/f2(x);}, -10, 10], {strokeColor:'#ff0000'}); | |||
board.addChild(board3); | |||
board2.addChild(board3); | |||
</ | </source> | ||
[[Category:Examples]] | |||
[[Category:Calculus]] |
Latest revision as of 15:47, 20 February 2013
Polynomial [math]\displaystyle{ f }[/math]:
Polynomial [math]\displaystyle{ g }[/math]:
Rational function [math]\displaystyle{ \frac{f}{g} }[/math]:
References
The underlying JavaScript source code
var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-10, 4, 10, -4], axis:true});
var p = [];
var q = [];
p[0] = board.create('point', [-1,2], {size:4});
p[1] = board.create('point', [3,-1], {size:4});
var f = JXG.Math.Numerics.lagrangePolynomial(p);
var graph = board.create('functiongraph', [f,-10, 10]);
function addPoint1() {
p.push(board.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4}));
board.update();
}
var board2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-10, 4, 10, -4], axis:true});
q[0] = board2.create('point', [-1,2], {size:4});
q[1] = board2.create('point', [3,-1], {size:4});
var f2 = JXG.Math.Numerics.lagrangePolynomial(q);
var graph2 = board2.create('functiongraph', [f2, -10, 10]);
function addPoint2() {
q.push(board2.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4}));
board2.update();
}
var board3 = JXG.JSXGraph.initBoard('box3', {boundingbox: [-10, 8, 10, -8], axis:true});
var graph3 = board3.create('functiongraph', [function(x){return f(x)/f2(x);}, -10, 10], {strokeColor:'#ff0000'});
board.addChild(board3);
board2.addChild(board3);