Power Series for sine and cosine: Difference between revisions
From JSXGraph Wiki
No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 3: | Line 3: | ||
board1 = JXG.JSXGraph.initBoard('jxgbox1', {originX: 300, originY: 150, unitX: 50, unitY: 50}); | board1 = JXG.JSXGraph.initBoard('jxgbox1', {originX: 300, originY: 150, unitX: 50, unitY: 50}); | ||
board1.suspendUpdate(); | board1.suspendUpdate(); | ||
board1.createElement('axis', [[ | board1.createElement('axis', [[0,0], [1,0]], {}); | ||
board1.createElement('axis', [[0, | 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('curve', [function(t){ return t; }, function(t){ return Math.sin(t); }, "t", -10, 10],{strokeColor: "#cccccc"}); | ||
var s = board1.createElement('slider', [0.75,-2.5,5,0,10,0], {name:'S'}); | var s = board1.createElement('slider', [0.75,-2.5,5,0,10,0], {name:'S'}); | ||
Line 29: | Line 29: | ||
board1.suspendUpdate(); | board1.suspendUpdate(); | ||
// Axes and Properties | // Axes and Properties | ||
board1.createElement('axis', [[ | board1.createElement('axis', [[0,0], [1,0]], {}); | ||
board1.createElement('axis', [[0, | 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('curve', [function(t){ return t; }, function(t){ return Math.sin(t); }, "t", -10, 10],{strokeColor: "#cccccc"}); | ||
Line 56: | Line 56: | ||
board2 = JXG.JSXGraph.initBoard('jxgbox2', {originX: 300, originY: 150, unitX: 50, unitY: 50}); | board2 = JXG.JSXGraph.initBoard('jxgbox2', {originX: 300, originY: 150, unitX: 50, unitY: 50}); | ||
board2.suspendUpdate(); | board2.suspendUpdate(); | ||
board2.createElement('axis', [[ | board2.createElement('axis', [[0,0], [1,0]], {}); | ||
board2.createElement('axis', [[0, | 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('curve', [function(t){ return t; }, function(t){ return Math.cos(t); }, "t", -10, 10],{strokeColor: "#cccccc"}); | ||
var s2 = board2.createElement('slider', [0.75,-2.5,5,0,10,0], {name:'T'}); | var s2 = board2.createElement('slider', [0.75,-2.5,5,0,10,0], {name:'T'}); | ||
Line 78: | Line 78: | ||
board2.suspendUpdate(); | board2.suspendUpdate(); | ||
// Axes and Properties | // Axes and Properties | ||
board2.createElement('axis', [[ | board2.createElement('axis', [[0,0], [1,0]], {}); | ||
board2.createElement('axis', [[0, | 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('curve', [function(t){ return t; }, function(t){ return Math.cos(t); }, "t", -10, 10],{strokeColor: "#cccccc"}); |
Revision as of 15:18, 28 November 2008
Power Series for Sine
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('curve', [function(t){ return t; }, function(t){ return Math.sin(t); }, "t", -10, 10],{strokeColor: "#cccccc"});
var s = board1.createElement('slider', [0.75,-2.5,5,0,10,0], {name:'S'});
board1.createElement('curve', [
't',
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;
}, "t", -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('curve', [function(t){ return t; }, function(t){ return Math.cos(t); }, "t", -10, 10],{strokeColor: "#cccccc"});
var s2 = board2.createElement('slider', [0.75,-2.5,5,0,10,0], {name:'T'});
board2.createElement('curve', [
't',
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;
}, "t", -10, 10],{strokeColor: "#009900", curveType:'plot'});
board2.unsuspendUpdate();