Rational functions: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<html>
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/prototype.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
</html>
Polynomial <math>f</math>:  
Polynomial <math>f</math>:  
<html><form><input type="button" value="Add point" onClick="addPoint1()"></form>
<html><form><input type="button" value="Add point" onClick="addPoint1()"></form>
<div id="box1" class="jxgbox" style="width:600px; height:200px;"></div>
</html>
</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>:  
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>
<div id="box2" class="jxgbox" style="width:600px; height:200px;"></div>
</html>
</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>:  
Rational function <math>\frac{f}{g}</math>:  
<html>
<div id="box3" class="jxgbox" style="width:600px; height:400px;"></div>
<script language="JavaScript">
        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('curve', ['x', f, 'x', -10, 10], {curveType:'graph'});
        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('curve', ['x', f2, 'x', -10, 10], {curveType:'graph'});
        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('curve', ['x', function(x){return f(x)/f2(x);}, 'x', -10, 10], {curveType:'graph',strokeColor:'#ff0000'});
         
</script>
</html>


<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 ===
=== References ===
* [http://en.wikipedia.org/wiki/Rational_function http://en.wikipedia.org/wiki/Rational_function]
* [http://en.wikipedia.org/wiki/Rational_function http://en.wikipedia.org/wiki/Rational_function]
Line 64: Line 48:


<source lang="javascript">
<source lang="javascript">
        board = JXG.JSXGraph.initBoard('box1', {originX: 300, originY: 100, unitX: 30, unitY: 25});
var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-10, 4, 10, -4], axis:true});
        board.createElement('axis', [[0,0], [1,0]]);
var p = [];
        board.createElement('axis', [[0,0], [0,1]]);
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]);


        var p = [];
function addPoint1() {
        var q = [];
  p.push(board.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4}));
        p[0] = board.createElement('point', [-1,2], {style:6});
  board.update();
        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'});


        function addPoint1() {
var board2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-10, 4, 10, -4], axis:true});
          p.push(board.createElement('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{style:6}));
q[0] = board2.create('point', [-1,2], {size:4});
          board.update();
q[1] = board2.create('point', [3,-1], {size:4});
        }
var f2 = JXG.Math.Numerics.lagrangePolynomial(q);
var graph2 = board2.create('functiongraph', [f2, -10, 10]);


        board2 = JXG.JSXGraph.initBoard('box2', {originX: 300, originY: 100, unitX: 30, unitY: 25});
function addPoint2() {
        board2.createElement('axis', [[0,0], [1,0]]);
  q.push(board2.create('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{size:4}));
        board2.createElement('axis', [[0,0], [0,1]]);
  board2.update();
}


        q[0] = board2.createElement('point', [-1,2], {style:6});
var board3 = JXG.JSXGraph.initBoard('box3', {boundingbox: [-10, 8, 10, -8], axis:true});
        q[1] = board2.createElement('point', [3,-1], {style:6});
var graph3 = board3.create('functiongraph', [function(x){return f(x)/f2(x);}, -10, 10], {strokeColor:'#ff0000'});
        var f2 = board2.lagrangePolynomial(q);
        graph2 = board2.createElement('curve', ['x', f2, 'x', -10, 10], {curveType:'graph'});


        function addPoint2() {
board.addChild(board3);
          q.push(board2.createElement('point',[(Math.random()-0.5)*10,(Math.random()-0.5)*3],{style:6}));
board2.addChild(board3);
          board2.update();
         
        }
 
        board3 = JXG.JSXGraph.initBoard('box3', {originX: 300, originY: 200, unitX: 30, unitY: 25});
        board3.createElement('axis', [[0,0], [1,0]]);
        board3.createElement('axis', [[0,0], [0,1]]);
        board3.createElement('curve', ['x', function(x){return f(x)/f2(x);}, 'x', -10, 10], {curveType:'graph',strokeColor:'#ff0000'});
</source>
</source>


[[Category:Examples]]
[[Category:Examples]]
[[Category:Calculus]]
[[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);