Rational functions: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 17: | Line 17: | ||
<div id="box3" class="jxgbox" style="width:600px; height:400px;"></div> | <div id="box3" class="jxgbox" style="width:600px; height:400px;"></div> | ||
<script language="JavaScript"> | <script language="JavaScript"> | ||
board = JXG.JSXGraph.initBoard('box1', {originX: 300, originY: 100, unitX: 30, unitY: 25, axis:true}); | |||
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('functiongraph', [f,-10, 10]); | |||
function addPoint1() { | |||
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, axis:true}); | |||
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('functiongraph', [f2, -10, 10]); | |||
function addPoint2() { | |||
q.push(board2.createElement('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{style:6})); | |||
board2.update(); | |||
} | |||
board3 = JXG.JSXGraph.initBoard('box3', {originX: 300, originY: 200, unitX: 30, unitY: 25, axis:true}); | |||
graph3 = board3.createElement('functiongraph', [function(x){return f(x)/f2(x);}, -10, 10], {strokeColor:'#ff0000'}); | |||
board.addChild(board3); | |||
board2.addChild(board3); | board2.addChild(board3); | ||
Line 104: | Line 93: | ||
b1axisy3 = board3.createElement('axis', [[0,0], [0,1]], {}); | b1axisy3 = board3.createElement('axis', [[0,0], [0,1]], {}); | ||
graph3 = board3.createElement('functiongraph', [function(x){return f(x)/f2(x);}, -10, 10], {strokeColor:'#ff0000'}); | graph3 = board3.createElement('functiongraph', [function(x){return f(x)/f2(x);}, -10, 10], {strokeColor:'#ff0000'}); | ||
board.addChild(board3); | |||
board2.addChild(board3); | board2.addChild(board3); | ||
</source> | </source> |
Revision as of 13:37, 21 August 2009
Polynomial [math]\displaystyle{ f }[/math]:
Polynomial [math]\displaystyle{ g }[/math]:
Rational function [math]\displaystyle{ \frac{f}{g} }[/math]:
References
The underlying JavaScript source code
board = JXG.JSXGraph.initBoard('box1', {originX: 300, originY: 100, unitX: 30, unitY: 25});
// Axes
b1axisx = board.createElement('axis', [[0,0], [1,0]], {});
b1axisy = 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('functiongraph', [f,-10, 10]);
function addPoint1() {
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});
// Axes
b1axisx2 = board2.createElement('axis', [[0,0], [1,0]], {});
b1axisy2 = 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('functiongraph', [f2, -10, 10]);
function addPoint2() {
q.push(board2.createElement('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{style:6}));
board2.update();
}
board3 = JXG.JSXGraph.initBoard('box3', {originX: 300, originY: 200, unitX: 30, unitY: 25});
// Axes
b1axisx3 = board3.createElement('axis', [[0,0], [1,0]], {});
b1axisy3 = board3.createElement('axis', [[0,0], [0,1]], {});
graph3 = board3.createElement('functiongraph', [function(x){return f(x)/f2(x);}, -10, 10], {strokeColor:'#ff0000'});
board.addChild(board3);
board2.addChild(board3);