1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
<html>
<head>
<title>JSXGraph example</title>
<link rel="stylesheet" type="text/css" href="../distrib/jsxgraph.css" />
<script type="text/javascript" src="/javascript/prototype/prototype.js"></script>
<script type="text/javascript" src="../distrib/jsxgraphcore.js"></script>
</head>
<body>
<h2>Power Series for Sine</h2>
<div id="jxgbox1" class="jxgbox" style="width:600px; height:300px;"></div>
<br clear=all>
<div id="debug" style="display:block;"></div>
<script language="JavaScript">
// Board
board1 = JXG.JSXGraph.initBoard('jxgbox1', {originX: 200, originY: 150, unitX: 5, unitY: 5});
board1.suspendUpdate();
// Axes and Properties
board1.createElement('axis', [[0,0], [1,0]], {});
board1.createElement('axis', [[0,0], [0,1]], {});
board1.snapToGrid = true;
//
board1.createElement('functiongraph', [function(t){ return Math.sin(t); }, -10, 10],{strokeColor: "#cccccc"});
var s = board1.createElement('slider', [[2,-4],[7,-4],[0,1,10]], {name:'S',snapWidth:1});
board1.createElement('curve', [
function(t){ return t; },
function(t) {
var val = 0;
for(var i = 0; i < s.Value() + 1; i++) {
var f = JXG.Math.factorial(2*i+1); // sin
val += Math.pow(-1, i) * Math.pow(t, 2 * i + 1) / f;
}
return val;
},
-10, 10], {strokeColor: "#bb0000"});
board1.unsuspendUpdate();
</script>
<h2>Power Series for Cosine</h2>
<div id="jxgbox2" class="jxgbox" style="width:600px; height:300px;"></div>
<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', [[0,0], [1,0]], {});
board2.createElement('axis', [[0,0], [0,1]], {});
board2.snapToGrid = true;
//
board2.createElement('functiongraph', [function(t){ return Math.cos(t); }, -10, 10],{strokeColor: "#cccccc"});
var s2 = board2.createElement('slider', [[2,-4],[7,-4],[0,0,10]], {name:'S2',snapWidth:1});
board2.createElement('curve', [
function(t){ return t; },
function(t) {
var val = 0;
for(var i = 0; i < s2.Value() + 1; i++) {
//var f = 1;
//var n = 1;
//while (n <= 2 * i) { f = f * n++; }
var f = JXG.Math.factorial(2*i);
val += Math.pow(-1, i) * Math.pow(t, 2 * i) / f;
}
return val;
},
-10, 10],{strokeColor: "#009900"});
board2.unsuspendUpdate();
</script>
<h2>Binomial theorem</h2>
<div id="jxgbox3" class="jxgbox" style="width:600px; height:300px;"></div>
<script language="JavaScript">
board3 = JXG.JSXGraph.initBoard('jxgbox3', {originX: 300, originY: 150, unitX: 25, unitY: 25, axis:true, grid:true});
board3.suspendUpdate();
board3.snapToGrid = true;
//
var s3 = board3.createElement('slider', [[2,-4],[7,-4],[0,0,10]], {name:'S3',snapWidth:1});
board3.createElement('functiongraph', [function(t){ return Math.pow(1+t,s3.Value()); }, -10, 10],{strokeColor: "#cccccc"});
board3.createElement('functiongraph', [
function(x) {
var val = 0;
var n = Math.round(s3.Value());
var z = 1;
for(var k=0; k<=n; k++) {
var f = JXG.Math.binomial(n,k);
val += z*f;
z *= x;
}
return val;
},
-3, 3],{strokeColor: "#009900"});
board3.unsuspendUpdate();
</script>
</body>
</html>
|