Difference between revisions of "Arithmetics of complex numbers"

From JSXGraph Wiki
Jump to: navigation, search
(New page: <html> <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/pro...)
 
 
(24 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<html>
+
===Addition of complex numbers===
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
+
<jsxgraph box="box" width="600" height="400">
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/prototype.js"></script>
+
board = JXG.JSXGraph.initBoard('box', {boundingbox: [-6, 6, 8, -4], axis: true});
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
+
       
<form><textarea id="input" rows=7 cols=35 wrap="off" >
+
var org = board.create('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
function f(x) {
+
var x = board.create('point', [2,2], {style:5,color:'blue',name:'x'});
  return Math.cos(x)*p.Y();
+
var y = board.create('point', [-1,-3], {style:5,color:'blue',name:'y'});
}
+
var xy = board.create('point',
c = plot(f);
+
    ["X(x)+X(y)","Y(x)+Y(y)"], {style:7,color:'green',name:'x+y'});
// Derivative:
+
var ax =board.create('arrow', [org,x], {strokeColor:'blue'});
g = board.algebra.D(f);
+
var ay =board.create('arrow', [org,y], {strokeColor:'blue'});
plot(g,{strokecolor:'black', dash:1});
+
var axy =board.create('arrow', [org,xy], {strokeColor:'red'});
</textarea> <br>
+
var ax2 =board.create('arrow', [x,xy], {strokeColor:'blue',strokeWidth:1,dash:1});
<input type="button" value="plot" onClick="doIt()" style='margin:1em'>
+
var ay2 =board.create('arrow', [y,xy], {strokeColor:'blue',strokeWidth:1,dash:1});
<input type="button" value="clear all" onClick="board=clearAll(board)">
+
</jsxgraph>
</form>
+
 
<div id="box" class="jxgbox" style="width:600px; height:600px;"></div>
+
===Multiplication of complex numbers===
<script language="JavaScript">
+
<jsxgraph box="box2" width="600" height="400">
        board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 40, unitY: 40});
+
brd2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-6, 6, 8, -4], axis: true});
         // Axes
+
       
        b1axisx = board.createElement('axis', [[0,0], [1,0]], {});
+
var org2 = brd2.create('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
        b1axisy = board.createElement('axis', [[0,0], [0,1]], {});
+
var x = brd2.create('point', [1,0], {style:4,color:'blue',name:'x'});
</script>
+
var y = brd2.create('point', [0,2], {style:4,color:'red',strokeColor:'red',name:'y'});
</html>
+
var xy = brd2.create('point',
 +
    ["X(x)*X(y)-Y(x)*Y(y)","X(x)*Y(y)+X(y)*Y(x)"], {style:7,fillColor:'green',strokeColor:'green',name:'x*y'});
 +
var c = brd2.create('circle',[org2,1],{strokeWidth:1,dash:1});       
 +
</jsxgraph>
 +
 
 +
 
 +
=== The underlying JavaScript code ===
 +
 
 +
Addition:
 +
<source lang="javascript">
 +
board = JXG.JSXGraph.initBoard('box', {boundingbox: [-6, 6, 8, -4], axis: true});
 +
          
 +
var org = board.create('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
 +
var x = board.create('point', [2,2], {style:5,color:'blue',name:'x'});
 +
var y = board.create('point', [-1,-3], {style:5,color:'blue',name:'y'});
 +
var xy = board.create('point',
 +
    ["X(x)+X(y)","Y(x)+Y(y)"], {style:7,color:'green',name:'x+y'});
 +
var ax =board.create('arrow', [org,x], {strokeColor:'blue'});
 +
var ay =board.create('arrow', [org,y], {strokeColor:'blue'});
 +
var axy =board.create('arrow', [org,xy], {strokeColor:'red'});
 +
var ax2 =board.create('arrow', [x,xy], {strokeColor:'blue',strokeWidth:1,dash:1});
 +
var ay2 =board.create('arrow', [y,xy], {strokeColor:'blue',strokeWidth:1,dash:1});
 +
</source>
 +
 
 +
Multiplication:
  
 
<source lang="javascript">
 
<source lang="javascript">
 +
brd2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-6, 6, 8, -4], axis: true});
 +
       
 +
var org2 = brd2.create('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
 +
var x = brd2.create('point', [1,0], {style:4,color:'blue',name:'x'});
 +
var y = brd2.create('point', [0,2], {style:4,color:'red',strokeColor:'red',name:'y'});
 +
var xy = brd2.create('point',
 +
    ["X(x)*X(y)-Y(x)*Y(y)","X(x)*Y(y)+X(y)*Y(x)"], {style:7,fillColor:'green',strokeColor:'green',name:'x*y'});
 +
var c = brd2.create('circle',[org2,1],{strokeWidth:1,dash:1});       
 
</source>
 
</source>
 +
 +
=== References ===
 +
* [http://en.wikipedia.org/wiki/Complex_numbers http://en.wikipedia.org/wiki/Complex_numbers]
  
  
 
[[Category:Examples]]
 
[[Category:Examples]]

Latest revision as of 17:43, 14 January 2012

Addition of complex numbers

Multiplication of complex numbers


The underlying JavaScript code

Addition:

board = JXG.JSXGraph.initBoard('box', {boundingbox: [-6, 6, 8, -4], axis: true});
        
var org = board.create('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
var x = board.create('point', [2,2], {style:5,color:'blue',name:'x'});
var y = board.create('point', [-1,-3], {style:5,color:'blue',name:'y'});
var xy = board.create('point', 
    ["X(x)+X(y)","Y(x)+Y(y)"], {style:7,color:'green',name:'x+y'});
var ax =board.create('arrow', [org,x], {strokeColor:'blue'});
var ay =board.create('arrow', [org,y], {strokeColor:'blue'});
var axy =board.create('arrow', [org,xy], {strokeColor:'red'});
var ax2 =board.create('arrow', [x,xy], {strokeColor:'blue',strokeWidth:1,dash:1});
var ay2 =board.create('arrow', [y,xy], {strokeColor:'blue',strokeWidth:1,dash:1});

Multiplication:

brd2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-6, 6, 8, -4], axis: true});
        
var org2 = brd2.create('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
var x = brd2.create('point', [1,0], {style:4,color:'blue',name:'x'});
var y = brd2.create('point', [0,2], {style:4,color:'red',strokeColor:'red',name:'y'});
var xy = brd2.create('point', 
    ["X(x)*X(y)-Y(x)*Y(y)","X(x)*Y(y)+X(y)*Y(x)"], {style:7,fillColor:'green',strokeColor:'green',name:'x*y'});
var c = brd2.create('circle',[org2,1],{strokeWidth:1,dash:1});

References