Arithmetics of complex numbers: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
===Addition of complex numbers===
===Addition of complex numbers===
<html>
<jsxgraph box="box" width="600" height="400">
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
board = JXG.JSXGraph.initBoard('box', {boundingbox: [-6, 6, 8, -4], 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="box" class="jxgbox" style="width:600px; height:400px;"></div>
<script language="JavaScript">
        board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 40, unitY: 40});
        // Axes
        b1axisx = board.createElement('axis', [[0,0], [1,0]], {});
        b1axisy = board.createElement('axis', [[0,0], [0,1]], {});
          
          
        var org = board.createElement('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
var org = board.create('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
        var x = board.createElement('point', [2,2], {style:5,fillColor:'blue',name:'x'});
var x = board.create('point', [2,2], {style:5,color:'blue',name:'x'});
        var y = board.createElement('point', [-1,-3], {style:5,fillColor:'blue',name:'y'});
var y = board.create('point', [-1,-3], {style:5,color:'blue',name:'y'});
        var xy = board.createElement('point',  
var xy = board.create('point',  
              ["X(x)+X(y)","Y(x)+Y(y)"], {style:7,fillColor:'blue',name:'x+y'});
    ["X(x) + X(y)", "Y(x) + Y(y)"], {style:7,color:'green',name:'x+y'});
        var ax =board.createElement('line', [org,x], {straightFirst:false,straightLast:false,lastArrow:true,strokeColor:'blue'});
var ax =board.create('arrow', [org, x], {strokeColor:'blue'});
        var ay =board.createElement('line', [org,y], {straightFirst:false,straightLast:false,lastArrow:true,strokeColor:'blue'});
var ay =board.create('arrow', [org, y], {strokeColor:'blue'});
        var axy =board.createElement('line', [org,xy], {straightFirst:false,straightLast:false,lastArrow:true,strokeColor:'red'});
var axy =board.create('arrow', [org, xy], {strokeColor:'red'});
        var ax2 =board.createElement('line', [x,xy], {straightFirst:false,straightLast:false,lastArrow:true,strokeColor:'blue',strokeWidth:1,dash:1});
var ax2 =board.create('arrow', [x, xy], {strokeColor:'blue',strokeWidth:1,dash:1});
        var ay2 =board.createElement('line', [y,xy], {straightFirst:false,straightLast:false,lastArrow:true,strokeColor:'blue',strokeWidth:1,dash:1});
var ay2 =board.create('arrow', [y, xy], {strokeColor:'blue',strokeWidth:1,dash:1});
</jsxgraph>
 
===Multiplication of complex numbers===
<jsxgraph box="box2" width="600" height="400">
brd2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-6, 6, 8, -4], axis: true});
          
          
</script>
var org2 = brd2.create('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
</html>
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});       
</jsxgraph>


=== References ===
* [http://en.wikipedia.org/wiki/Complex_numbers http://en.wikipedia.org/wiki/Complex_numbers]


=== The underlying JavaScript code ===
=== The underlying JavaScript code ===


Addition:
<source lang="javascript">
<source lang="javascript">
        board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 40, unitY: 40});
board = JXG.JSXGraph.initBoard('box', {boundingbox: [-6, 6, 8, -4], axis: true});
        // Axes
        b1axisx = board.createElement('axis', [[0,0], [1,0]], {});
        b1axisy = board.createElement('axis', [[0,0], [0,1]], {});
          
          
        var org = board.createElement('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
var org = board.create('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
        var x = board.createElement('point', [2,2], {style:5,fillColor:'blue',name:'x'});
var x = board.create('point', [2,2], {style:5,color:'blue',name:'x'});
        var y = board.createElement('point', [-1,-3], {style:5,fillColor:'blue',name:'y'});
var y = board.create('point', [-1,-3], {style:5,color:'blue',name:'y'});
        var xy = board.createElement('point',  
var xy = board.create('point',  
              ["X(x)+X(y)","Y(x)+Y(y)"], {style:7,fillColor:'blue',name:'x+y'});
    ["X(x) + X(y)", "Y(x) + Y(y)"], {style:7,color:'green',name:'x+y'});
        var ax =board.createElement('line', [org,x], {straightFirst:false,straightLast:false,lastArrow:true,strokeColor:'blue'});
var ax =board.create('arrow', [org, x], {strokeColor:'blue'});
        var ay =board.createElement('line', [org,y], {straightFirst:false,straightLast:false,lastArrow:true,strokeColor:'blue'});
var ay =board.create('arrow', [org, y], {strokeColor:'blue'});
        var axy =board.createElement('line', [org,xy], {straightFirst:false,straightLast:false,lastArrow:true,strokeColor:'red'});
var axy =board.create('arrow', [org, xy], {strokeColor:'red'});
        var ax2 =board.createElement('line', [x,xy], {straightFirst:false,straightLast:false,lastArrow:true,strokeColor:'blue',strokeWidth:1,dash:1});
var ax2 =board.create('arrow', [x, xy], {strokeColor:'blue',strokeWidth:1,dash:1});
        var ay2 =board.createElement('line', [y,xy], {straightFirst:false,straightLast:false,lastArrow:true,strokeColor:'blue',strokeWidth:1,dash:1});
var ay2 =board.create('arrow', [y, xy], {strokeColor:'blue',strokeWidth:1,dash:1});
</source>
</source>


===Multiplication of complex numbers===
Multiplication:
<html>
<div id="box2" class="jxgbox" style="width:600px; height:400px;"></div>
<script language="JavaScript">
        brd2 = JXG.JSXGraph.initBoard('box2', {originX: 250, originY: 250, unitX: 40, unitY: 40});
        // Axes
        b1axisx = brd2.createElement('axis', [[0,0], [1,0]], {});
        b1axisy = brd2.createElement('axis', [[0,0], [0,1]], {});
       
        var org2 = brd2.createElement('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
        var x = brd2.createElement('point', [1,0], {style:4,fillColor:'blue',name:'x'});
        var y = brd2.createElement('point', [0,2], {style:4,fillColor:'red',strokeColor:'red',name:'y'});
        var xy = brd2.createElement('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.createElement('circle',[org2,1],{strokeWidth:1,dash:1});       
</script>
</html>


<source lang="javascript">
<source lang="javascript">
        brd2 = JXG.JSXGraph.initBoard('box2', {originX: 250, originY: 250, unitX: 40, unitY: 40});
brd2 = JXG.JSXGraph.initBoard('box2', {boundingbox: [-6, 6, 8, -4], axis: true});
        // Axes
        b1axisx = brd2.createElement('axis', [[0,0], [1,0]], {});
        b1axisy = brd2.createElement('axis', [[0,0], [0,1]], {});
          
          
        var org2 = brd2.createElement('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
var org2 = brd2.create('point', [0,0], {style:10,visible:true,fixed:true,name:' '});
        var x = brd2.createElement('point', [1,0], {style:5,fillColor:'blue',name:'x',trace:true});
var x = brd2.create('point', [1,0], {style:4,color:'blue',name:'x'});
        var y = brd2.createElement('point', [0,2], {style:5,fillColor:'red',strokeColor:'red',name:'y',trace:true});
var y = brd2.create('point', [0,2], {style:4,color:'red',strokeColor:'red',name:'y'});
        var xy = brd2.createElement('point',  
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',trace:true});
    ["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.createElement('circle',[org2,1],{strokeWidth:1,dash:1});         
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 09:51, 18 January 2021

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