Difference between revisions of "Power series for the exponential function"

From JSXGraph Wiki
Jump to navigationJump to search
 
(31 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<html>
+
<jsxgraph width="600" height="400" box="jxgbox1">
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
+
board1 = JXG.JSXGraph.initBoard('jxgbox1', {boundingbox: [-6, 25, 6, -15], axis: true});
<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:300px;"></div>
 
<script language="JavaScript">
 
// Board
 
board1 = JXG.JSXGraph.initBoard('jxgbox1', {originX: 300, originY: 200, unitX: 50, unitY: 50});
 
 
board1.suspendUpdate();
 
board1.suspendUpdate();
// Axes and Properties
+
 
board1.createElement('axis', [[0,0], [1,0]], {});
+
board1.create('functiongraph',  
board1.createElement('axis', [[0,0], [0,1]], {});
+
    [function(t){ return Math.exp(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.create('slider', [[0.75,-2],[5,-2.0],[0,0,15]], {name:'S',snapWidth:1});
var s = board1.createElement('slider', [0.75,-2.0,5,0,10,0], {name:'S'});
+
board1.create('text',[-4,10, function() {
//
+
return 'n='+s.Value();
board1.createElement('curve', [
+
}
't',
+
    ]);
 +
board1.create('text',[-4,8, function() {
 +
var val = 0, i, sv = s.Value()+1;
 +
for(i = 0; i < sv; i++) {
 +
  val+= 1.0/JXG.Math.factorial(i);
 +
}
 +
return 'e~'+(val).toFixed(10);
 +
}
 +
    ]);
 +
 
 +
board1.create('functiongraph', [
 
function(t) {
 
function(t) {
var val = 0;
+
var val = 0, i, sv = s.Value()+1;
for(var i=0;i<= Math.floor(s.X()); i++) {
+
for(i = 0; i < sv; i++) {
   val+= Math.pow(t,i)/board1.factorial(i);
+
   val+= Math.pow(t,i)/JXG.Math.factorial(i);
 
}
 
}
 
return val;
 
return val;
 
},
 
},
"t", -10, 10], {strokeColor: "#bb0000", curveType:'plot'});
+
-10, 10], {strokeColor: "#bb0000", curveType:'plot'});
 
board1.unsuspendUpdate();
 
board1.unsuspendUpdate();
/*
+
</jsxgraph>
*/
+
 
</script>
+
=== References ===
</html>
+
* [http://en.wikipedia.org/wiki/Exponential_function http://en.wikipedia.org/wiki/Exponential_function]
 +
 
 +
=== The underlying JavaScript code ===
 +
 
 
<source lang="javascript">
 
<source lang="javascript">
 +
board1 = JXG.JSXGraph.initBoard('jxgbox1', {boundingbox: [-6, 25, 6, -15], axis: true});
 +
board1.suspendUpdate();
 +
 +
board1.create('functiongraph',
 +
    [function(t){ return Math.exp(t); },-10, 10],
 +
    {strokeColor: "#cccccc"});
 +
 +
var s = board1.create('slider', [[0.75,-2],[5,-2.0],[0,0,15]], {name:'S',snapWidth:1});
 +
board1.create('text',[-4,10, function() {
 +
return 'n='+s.Value();
 +
}
 +
    ]);
 +
board1.create('text',[-4,8, function() {
 +
var val = 0, i, sv = s.Value()+1;
 +
for(i = 0; i < sv; i++) {
 +
  val+= 1.0/JXG.Math.factorial(i);
 +
}
 +
return 'e~'+(val).toFixed(10);
 +
}
 +
    ]);
 +
 +
board1.create('functiongraph', [
 +
function(t) {
 +
var val = 0, i, sv = s.Value()+1;
 +
for(i = 0; i < sv; i++) {
 +
  val+= Math.pow(t,i)/JXG.Math.factorial(i);
 +
}
 +
return val;
 +
},
 +
-10, 10], {strokeColor: "#bb0000", curveType:'plot'});
 +
board1.unsuspendUpdate();
 
</source>
 
</source>
  
  
 
[[Category:Examples]]
 
[[Category:Examples]]
 +
[[Category:Calculus]]

Latest revision as of 17:44, 20 February 2013

References

The underlying JavaScript code

board1 = JXG.JSXGraph.initBoard('jxgbox1', {boundingbox: [-6, 25, 6, -15], axis: true});
board1.suspendUpdate();

board1.create('functiongraph', 
    [function(t){ return Math.exp(t); },-10, 10],
    {strokeColor: "#cccccc"});

var s = board1.create('slider', [[0.75,-2],[5,-2.0],[0,0,15]], {name:'S',snapWidth:1});
board1.create('text',[-4,10, function() {
		return 'n='+s.Value();
	}
     ]);
board1.create('text',[-4,8, function() {
		var val = 0, i, sv = s.Value()+1;
		for(i = 0; i < sv; i++) {
   			val+= 1.0/JXG.Math.factorial(i);
		}
		return 'e~'+(val).toFixed(10);
	}
     ]);

board1.create('functiongraph', [
	function(t) {
		var val = 0, i, sv = s.Value()+1;
		for(i = 0; i < sv; i++) {
   			val+= Math.pow(t,i)/JXG.Math.factorial(i);
		}
		return val;
	},
-10, 10], {strokeColor: "#bb0000", curveType:'plot'});
board1.unsuspendUpdate();