Difference between revisions of "Power Series for sine and cosine"

From JSXGraph Wiki
Jump to: navigation, search
Line 12: Line 12:
 
board1.createElement('axis', [[0,0], [1,0]], {});
 
board1.createElement('axis', [[0,0], [1,0]], {});
 
board1.createElement('axis', [[0,0], [0,1]], {});
 
board1.createElement('axis', [[0,0], [0,1]], {});
board1.createElement('curve', [function(t){ return t; }, function(t){ return Math.sin(t); }, "t", -10, 10],{strokeColor: "#cccccc"});
+
board1.createElement('functiongraph', [function(t){ return Math.sin(t); },-10, 10],{strokeColor: "#cccccc"});
 
var s = board1.createElement('slider', [[0.75,-2.5],[5.75,-2.5],[0,0,10]], {name:'S'});
 
var s = board1.createElement('slider', [[0.75,-2.5],[5.75,-2.5],[0,0,10]], {name:'S'});
board1.createElement('curve', [
+
board1.createElement('functiongraph', [
  't',
 
 
   function(t) {
 
   function(t) {
 
     var val = 0;
 
     var val = 0;
Line 22: Line 21:
 
     }
 
     }
 
     return val;
 
     return val;
   }, "t", -10, 10], {strokeColor: "#bb0000", curveType:'plot'});
+
   }, -10, 10], {strokeColor: "#bb0000", curveType:'plot'});
 
board1.unsuspendUpdate();
 
board1.unsuspendUpdate();
 
</source>
 
</source>
Line 39: Line 38:
 
board1.createElement('axis', [[0,0], [0,1]], {});
 
board1.createElement('axis', [[0,0], [0,1]], {});
 
//
 
//
board1.createElement('curve', [function(t){ return t; }, function(t){ return Math.sin(t); }, "t", -10, 10],{strokeColor: "#cccccc"});
+
board1.createElement('functiongraph', [function(t){ return Math.sin(t); },-10, 10],{strokeColor: "#cccccc"});
 
//
 
//
 
var s = board1.createElement('slider', [[0.75,-2.5],[5.75,-2.5],[0,0,10]], {name:'S'});
 
var s = board1.createElement('slider', [[0.75,-2.5],[5.75,-2.5],[0,0,10]], {name:'S'});
 
//
 
//
board1.createElement('curve', [
+
board1.createElement('functiongraph', [
't',
 
 
function(t) {
 
function(t) {
 
var val = 0;
 
var val = 0;
Line 52: Line 50:
 
return val;
 
return val;
 
},
 
},
"t", -10, 10], {strokeColor: "#bb0000", curveType:'plot'});
+
-10, 10], {strokeColor: "#bb0000", curveType:'plot'});
 
board1.unsuspendUpdate();
 
board1.unsuspendUpdate();
 
/*
 
/*
Line 65: Line 63:
 
board2.createElement('axis', [[0,0], [1,0]], {});
 
board2.createElement('axis', [[0,0], [1,0]], {});
 
board2.createElement('axis', [[0,0], [0,1]], {});
 
board2.createElement('axis', [[0,0], [0,1]], {});
board2.createElement('curve', [function(t){ return t; }, function(t){ return Math.cos(t); }, "t", -10, 10],{strokeColor: "#cccccc"});
+
board2.createElement('functiongraph', [function(t){ return Math.cos(t); }, -10, 10],{strokeColor: "#cccccc"});
 
var s2 = board2.createElement('slider', [[0.75,-2.5],[5.75,-2.5],[0,0,10]], {name:'T'});
 
var s2 = board2.createElement('slider', [[0.75,-2.5],[5.75,-2.5],[0,0,10]], {name:'T'});
board2.createElement('curve', [
+
board2.createElement('functiongraph', [
  't',
 
 
   function(t) {
 
   function(t) {
 
     var val = 0;
 
     var val = 0;
Line 75: Line 72:
 
     }
 
     }
 
     return val;
 
     return val;
   }, "t", -10, 10],{strokeColor: "#009900", curveType:'plot'});
+
   }, -10, 10],{strokeColor: "#009900", curveType:'plot'});
 
board2.unsuspendUpdate();
 
board2.unsuspendUpdate();
 
</source>
 
</source>
Line 88: Line 85:
 
board2.createElement('axis', [[0,0], [0,1]], {});
 
board2.createElement('axis', [[0,0], [0,1]], {});
 
//
 
//
board2.createElement('curve', [function(t){ return t; }, function(t){ return Math.cos(t); }, "t", -10, 10],{strokeColor: "#cccccc"});
+
board2.createElement('functiongraph', [function(t){ return t; }, function(t){ return Math.cos(t); }, -10, 10],{strokeColor: "#cccccc"});
 
//
 
//
 
var s2 = board2.createElement('slider', [[0.75,-2.5],[5.75,-2.5],[0,0,10]], {name:'T'});
 
var s2 = board2.createElement('slider', [[0.75,-2.5],[5.75,-2.5],[0,0,10]], {name:'T'});
 
//
 
//
board2.createElement('curve', [
+
board2.createElement('functiongraph', [
't',
 
 
function(t) {
 
function(t) {
 
var val = 0;
 
var val = 0;
Line 101: Line 97:
 
return val;
 
return val;
 
},
 
},
"t", -10, 10],{strokeColor: "#009900", curveType:'plot'});
+
-10, 10],{strokeColor: "#009900", curveType:'plot'});
 
board2.unsuspendUpdate();
 
board2.unsuspendUpdate();
 
</script>
 
</script>

Revision as of 13:04, 10 March 2009

Power Series for Sine

<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>
<div id="jxgbox1" class="jxgbox" style="width:600px; height:600px;"></div>
board1 = JXG.JSXGraph.initBoard('jxgbox1', {originX: 300, originY: 150, unitX: 50, unitY: 50});
board1.suspendUpdate();
board1.createElement('axis', [[0,0], [1,0]], {});
board1.createElement('axis', [[0,0], [0,1]], {});
board1.createElement('functiongraph', [function(t){ return Math.sin(t); },-10, 10],{strokeColor: "#cccccc"});
var s = board1.createElement('slider', [[0.75,-2.5],[5.75,-2.5],[0,0,10]], {name:'S'});
board1.createElement('functiongraph', [
  function(t) {
    var val = 0;
    for(var i = 0; i < Math.floor(s.X()) + 1; i++) {
      val = val + Math.pow(-1, i) * Math.pow(t, 2 * i + 1) / board1.factorial(2*i+1);
    }
    return val;
  }, -10, 10], {strokeColor: "#bb0000", curveType:'plot'});
board1.unsuspendUpdate();

Power Series for Cosine

board2 = JXG.JSXGraph.initBoard('jxgbox2', {originX: 300, originY: 150, unitX: 50, unitY: 50});
board2.suspendUpdate();
board2.createElement('axis', [[0,0], [1,0]], {});
board2.createElement('axis', [[0,0], [0,1]], {});
board2.createElement('functiongraph', [function(t){ return Math.cos(t); }, -10, 10],{strokeColor: "#cccccc"});
var s2 = board2.createElement('slider', [[0.75,-2.5],[5.75,-2.5],[0,0,10]], {name:'T'});
board2.createElement('functiongraph', [
  function(t) {
    var val = 0;
    for(var i = 0; i < Math.floor(s2.X()) + 1; i++) {
      val = val + Math.pow(-1, i) * Math.pow(t, 2 * i) / board2.factorial(2*i);
    }
    return val;
  }, -10, 10],{strokeColor: "#009900", curveType:'plot'});						
board2.unsuspendUpdate();

References