Power Series for sine and cosine: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 3: Line 3:
<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/prototype.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<div id="jxgbox1" class="jxgbox" style="width:600px; height:300px;"></div>
<div id="jxgbox1" class="jxgbox" style="width:600px; height:400px;"></div>
<script language="JavaScript">
<script language="JavaScript">
// Board
// Board
Line 15: Line 15:
board1.createElement('curve', [function(t){ return t; }, function(t){ return Math.sin(t); }, "t", -10, 10],{strokeColor: "#cccccc"});
board1.createElement('curve', [function(t){ return t; }, function(t){ return Math.sin(t); }, "t", -10, 10],{strokeColor: "#cccccc"});
//
//
var s = board1.createElement('slider', [2,-4,5,0,10,0], {name:'S'});
var s = board1.createElement('slider', [1,-4,5,0,10,0], {name:'S'});
//
//
board1.createElement('curve', [
board1.createElement('curve', [

Revision as of 11:17, 17 September 2008

<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>

<script language="JavaScript"> // Board board1 = JXG.JSXGraph.initBoard('jxgbox1', {originX: 300, originY: 100, unitX: 50, unitY: 50}); board1.suspendUpdate(); // Axes and Properties board1.createElement('axis', [[1,0], [0,0]], {}); board1.createElement('axis', [[0,1], [0,0]], {}); board1.snapToGrid = true; // board1.createElement('curve', [function(t){ return t; }, function(t){ return Math.sin(t); }, "t", -10, 10],{strokeColor: "#cccccc"}); // var s = board1.createElement('slider', [1,-4,5,0,10,0], {name:'S'}); // board1.createElement('curve', [ function(t){ return t; }, function(t) { var val = 0; for(var i = 0; i < Math.floor(s.X()) + 1; i++) { var f = 1; var n = 1; while (n <= 2 * i + 1) { f = f * n++; }

  			val = val + Math.pow(-1, i) * Math.pow(t, 2 * i + 1) / f;

} return val; }, "t", -10, 10], {strokeColor: "#bb0000"}); board1.unsuspendUpdate(); /*

  • /

</script>

Power Series for Cosine

<script language="JavaScript"> // Board board2 = JXG.JSXGraph.initBoard('jxgbox2', {originX: 300, originY: 150, unitX: 25, unitY: 25}); board2.suspendUpdate(); // Axes and Properties board2.createElement('axis', [[1,0], [0,0]], {}); board2.createElement('axis', [[0,1], [0,0]], {}); board2.snapToGrid = true; // board2.createElement('curve', [function(t){ return t; }, function(t){ return Math.cos(t); }, "t", -10, 10],{strokeColor: "#cccccc"}); // var s2 = board2.createElement('slider', [2,-4,5,0,10,0], {name:'T'}); // board2.createElement('curve', [ function(t){ return t; }, function(t) { var val = 0; for(var i = 0; i < Math.floor(s2.X()) + 1; i++) { var f = 1; var n = 1; while (n <= 2 * i) { f = f * n++; }

  			val = val + Math.pow(-1, i) * Math.pow(t, 2 * i) / f;

} return val; }, "t", -10, 10],{strokeColor: "#009900"}); board2.unsuspendUpdate(); </script>