Difference between revisions of "Rational functions"

From JSXGraph Wiki
Jump to: navigation, search
Line 3: Line 3:
 
</html>
 
</html>
 
<jsxgraph width="600" height="200" box="box1">
 
<jsxgraph width="600" height="200" box="box1">
var board = JXG.JSXGraph.initBoard('box1', {originX: 300, originY: 100, unitX: 30, unitY: 25, axis:true});
+
var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-10, 4, 10, -4], axis:true});
 
var p = [];
 
var p = [];
 
var q = [];
 
var q = [];
p[0] = board.create('point', [-1,2], {style:6});
+
p[0] = board.create('point', [-1,2], {size:4});
p[1] = board.create('point', [3,-1], {style:6});
+
p[1] = board.create('point', [3,-1], {size:4});
 
var f = board.lagrangePolynomial(p);
 
var f = board.lagrangePolynomial(p);
 
var graph = board.create('functiongraph', [f,-10, 10]);
 
var graph = board.create('functiongraph', [f,-10, 10]);
  
 
function addPoint1() {
 
function addPoint1() {
   p.push(board.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{style:6}));
+
   p.push(board.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4}));
 
   board.update();
 
   board.update();
 
}
 
}
Line 22: Line 22:
 
</html>
 
</html>
 
<jsxgraph width="600" height="200" box="box2">
 
<jsxgraph width="600" height="200" box="box2">
var board2 = JXG.JSXGraph.initBoard('box2', {originX: 300, originY: 100, unitX: 30, unitY: 25, axis:true});
+
var board2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-10, 4, 10, -4], axis:true});
q[0] = board2.create('point', [-1,2], {style:6});
+
q[0] = board2.create('point', [-1,2], {size:4});
q[1] = board2.create('point', [3,-1], {style:6});
+
q[1] = board2.create('point', [3,-1], {size:4});
 
var f2 = board2.lagrangePolynomial(q);
 
var f2 = board2.lagrangePolynomial(q);
 
var graph2 = board2.create('functiongraph', [f2, -10, 10]);
 
var graph2 = board2.create('functiongraph', [f2, -10, 10]);
  
 
function addPoint2() {
 
function addPoint2() {
   q.push(board2.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{style:6}));
+
   q.push(board2.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4}));
 
   board2.update();
 
   board2.update();
 
}
 
}
 
</jsxgraph>
 
</jsxgraph>
 
Rational function <math>\frac{f}{g}</math>:  
 
Rational function <math>\frac{f}{g}</math>:  
</html>
+
 
 
<jsxgraph width="600" height="400" box="box3">
 
<jsxgraph width="600" height="400" box="box3">
var board3 = JXG.JSXGraph.initBoard('box3', {originX: 300, originY: 200, unitX: 30, unitY: 25, axis:true});
+
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'});
 
var graph3 = board3.create('functiongraph', [function(x){return f(x)/f2(x);}, -10, 10], {strokeColor:'#ff0000'});
 
board.addChild(board3);
 
board.addChild(board3);
Line 48: Line 48:
  
 
<source lang="javascript">
 
<source lang="javascript">
var board = JXG.JSXGraph.initBoard('box1', {originX: 300, originY: 100, unitX: 30, unitY: 25, axis:true});
+
var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-10, 4, 10, -4], axis:true});
 
var p = [];
 
var p = [];
 
var q = [];
 
var q = [];
p[0] = board.create('point', [-1,2], {style:6});
+
p[0] = board.create('point', [-1,2], {size:4});
p[1] = board.create('point', [3,-1], {style:6});
+
p[1] = board.create('point', [3,-1], {size:4});
 
var f = board.lagrangePolynomial(p);
 
var f = board.lagrangePolynomial(p);
 
var graph = board.create('functiongraph', [f,-10, 10]);
 
var graph = board.create('functiongraph', [f,-10, 10]);
  
 
function addPoint1() {
 
function addPoint1() {
   p.push(board.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{style:6}));
+
   p.push(board.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4}));
 
   board.update();
 
   board.update();
 
}
 
}
  
var board2 = JXG.JSXGraph.initBoard('box2', {originX: 300, originY: 100, unitX: 30, unitY: 25, axis:true});
+
var board2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-10, 4, 10, -4], axis:true});
q[0] = board2.create('point', [-1,2], {style:6});
+
q[0] = board2.create('point', [-1,2], {size:4});
q[1] = board2.create('point', [3,-1], {style:6});
+
q[1] = board2.create('point', [3,-1], {size:4});
 
var f2 = board2.lagrangePolynomial(q);
 
var f2 = board2.lagrangePolynomial(q);
 
var graph2 = board2.create('functiongraph', [f2, -10, 10]);
 
var graph2 = board2.create('functiongraph', [f2, -10, 10]);
  
 
function addPoint2() {
 
function addPoint2() {
   q.push(board2.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{style:6}));
+
   q.push(board2.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4}));
 
   board2.update();
 
   board2.update();
 
}
 
}
  
var board3 = JXG.JSXGraph.initBoard('box3', {originX: 300, originY: 200, unitX: 30, unitY: 25, axis:true});
+
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'});
 
var graph3 = board3.create('functiongraph', [function(x){return f(x)/f2(x);}, -10, 10], {strokeColor:'#ff0000'});
  

Revision as of 14:26, 8 June 2011

Polynomial [math]f[/math]:

Polynomial [math]g[/math]:
Rational function [math]\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 = board.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 = board2.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);