Power series for the exponential function: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 12: | Line 12: | ||
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.exp(t); }, "t", -10, 10],{strokeColor: "#cccccc"}); | board1.createElement('curve', | ||
[function(t){ return t; }, function(t){ return Math.exp(t); }, "t", -10, 10], | |||
{strokeColor: "#cccccc"}); | |||
// | // | ||
var s = board1.createElement('slider', [0.75,-2.0,5,0,12,0], {name:'S'}); | var s = board1.createElement('slider', [0.75,-2.0,5,0,12,0], {name:'S'}); | ||
Line 22: | Line 24: | ||
return 'e~'+board1.round(val,10); | return 'e~'+board1.round(val,10); | ||
}, | }, | ||
]); | ]); | ||
// | // | ||
board1.createElement('curve', [ | board1.createElement('curve', [ | ||
Line 45: | Line 47: | ||
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.exp(t); }, "t", -10, 10],{strokeColor: "#cccccc"}); | board1.createElement('curve', | ||
[function(t){ return t; }, function(t){ return Math.exp(t); }, "t", -10, 10], | |||
{strokeColor: "#cccccc"}); | |||
var s = board1.createElement('slider', [0.75,-2.0,5,0,12,0], {name:'S'}); | var s = board1.createElement('slider', [0.75,-2.0,5,0,12,0], {name:'S'}); | ||
var t = board1.createElement('text',[-4,8, function() { | var t = board1.createElement('text',[-4,8, function() { | ||
Line 56: | Line 59: | ||
}, | }, | ||
]); | ]); | ||
board1.createElement('curve', [ | board1.createElement('curve', [ | ||
't', | 't', |
Revision as of 09:12, 11 December 2008
// Board
board1 = JXG.JSXGraph.initBoard('jxgbox1', {originX: 300, originY: 250, unitX: 50, unitY: 10});
board1.suspendUpdate();
// Axes and Properties
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.exp(t); }, "t", -10, 10],
{strokeColor: "#cccccc"});
var s = board1.createElement('slider', [0.75,-2.0,5,0,12,0], {name:'S'});
var t = board1.createElement('text',[-4,8, function() {
var val = 0;
for(var i=0;i<= Math.floor(s.X()); i++) {
val+= 1.0/board1.factorial(i);
}
return 'e~'+board1.round(val,10);
},
]);
board1.createElement('curve', [
't',
function(t) {
var val = 0;
for(var i=0;i<= Math.floor(s.X()); i++) {
val+= Math.pow(t,i)/board1.factorial(i);
}
return val;
},
"t", -10, 10], {strokeColor: "#bb0000", curveType:'plot'});
board1.unsuspendUpdate();