Inequalities: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
To graph inequalities of the form
''y <= b/a * x + c/a''
a line of the form
<source lang="javascript">
line = b.create('line', [c, b, a]);
ineq = b.create('inequality', [line]),
</source>
and an inequality of this line have to be created.
In case ''a = 0'', that is if the equation of the line is ''bx + c = 0'', the area of the inequality
''bx + c <= 0'' is shown.
If one wants to show "greater than", ''inverse:true'' has to be used:
<source lang="javascript">
line = b.create('line', [c, b, a]);
ineq = b.create('inequality', [line], {inverse:true}),
</source>
In the following example, two lines are shown.
The first, black line has the equation ''y = c'' or ''0 = -1y + 0x + c'',
the second, blue line has the equation ''y = 2/3 x + 1'' or ''0 = -3y + 2x +1''.
<jsxgraph width="400" height="400" box="box1">
(function() {
var b = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 5, 5, -5], axis:true});
var c = b.create('slider', [[-3,4], [2,4], [-5,1,5]]),
    line1 = b.create('line', [function() { return [c.Value(), 0, -1]; }], {strokeColor: 'black'}),
    ineq1 = b.create('inequality', [line1], {inverse: true}),
    line2 = b.create('line', [1, 2, -3]),  // Line y = 2/3 x + 1 or 0 = -3y + 2x +1
    ineq2 = b.create('inequality', [line2], {fillColor: 'yellow'});
})();
</jsxgraph>
===The JavaScript code===
<source lang="javascript">
var b = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 5, 5, -5], axis:true});
var c = b.create('slider', [[-3,4], [2,4], [-5,1,5]]),
    line1 = b.create('line', [function() { return [c.Value(), 0, -1]; }], {strokeColor: 'black'}),
    ineq1 = b.create('inequality', [line1], {inverse: true}),
    line2 = b.create('line', [1, 2, -3]), // Line y = 2/3 x + 1 or 0 = -3y + 2x +1
    ineq2 = b.create('inequality', [line2], {fillColor: 'yellow'});
</source>
To graph inequalities of the "less than" form
To graph inequalities of the "less than" form
"ax + by + c <= 0"
"ax + by + c <= 0"
<source lang="javascript">
<source lang="javascript">
var line = b.create('line', [c, b, a]),
var line = board.create('line', [c, b, a]),
ineq = b.create('inequality', [line]);
ineq = board.create('inequality', [line]);
</source>
</source>


If one wants to show "greater than" i.e.  "ax + by + c >= 0" , ''inverse:true'' has to be used:
If one wants to show "greater than" i.e.  "ax + by + c >= 0" , ''inverse:true'' has to be used:
<source lang="javascript">
<source lang="javascript">
var line = b.create('line', [c, b, a]),
var line = board.create('line', [c, b, a]),
ineq = b.create('inequality', [line], {inverse:true});
ineq = board.create('inequality', [line], {inverse:true});
</source>
</source>


Line 83: Line 35:
===The JavaScript code===
===The JavaScript code===
<source lang="javascript">
<source lang="javascript">
     var b = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 5, 5, -5], axis:true});
     var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 5, 5, -5], axis:true});
     var line1 = b.create('line', [3, 2, -1]), // Line y = 2x + 3 or 2x - 1y + 3 = 0
     var line1 = board.create('line', [3, 2, -1]), // Line y = 2x + 3 or 2x - 1y + 3 = 0
     ineq1 = b.create('inequality', [line1], {fillColor: 'yellow'});  //This would plot the inequality 2x - y + 3 <= 0
     ineq1 = board.create('inequality', [line1], {fillColor: 'yellow'});  //This would plot the inequality 2x - y + 3 <= 0


     var line2 = b.create('line', [-3, 1, 0], {strokeColor: 'black'}); // Line x = 3 or 1x + 0y - 3 = 0
     var line2 = board.create('line', [-3, 1, 0], {strokeColor: 'black'}); // Line x = 3 or 1x + 0y - 3 = 0
     var ineq2 = b.create('inequality', [line2], {inverse: true, fillColor: 'red'});  //This would plot the inequality 1x + 0y - 3 >= 0
     var ineq2 = board.create('inequality', [line2], {inverse: true, fillColor: 'red'});  //This would plot the inequality 1x + 0y - 3 >= 0
</source>
</source>


[[Category:Examples]]
[[Category:Examples]]
[[Category:Calculus]]
[[Category:Calculus]]

Latest revision as of 09:57, 8 June 2017

To graph inequalities of the "less than" form "ax + by + c <= 0"

var line = board.create('line', [c, b, a]),
ineq = board.create('inequality', [line]);

If one wants to show "greater than" i.e. "ax + by + c >= 0" , inverse:true has to be used:

var line = board.create('line', [c, b, a]),
ineq = board.create('inequality', [line], {inverse:true});

In the following example, two lines are shown. The first, blue line has the equation "y = 2x + 3" or "2x - 1y + 3 = 0", the second, black line has the equation "x = 3" or "1x + 0y - 3 = 0".

For these equations, the inequalities plotted are "2x - y + 3 <= 0" (less than form hence don't add "inverse: true") - yellow region and "1x + 0y - 3 >= 0" (greater than form hence do add "inverse: true") - red region.

The JavaScript code

    var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 5, 5, -5], axis:true});
    var line1 = board.create('line', [3, 2, -1]), // Line y = 2x + 3 or 2x - 1y + 3 = 0
    ineq1 = board.create('inequality', [line1], {fillColor: 'yellow'});  //This would plot the inequality 2x - y + 3 <= 0

    var line2 = board.create('line', [-3, 1, 0], {strokeColor: 'black'}); // Line x = 3 or 1x + 0y - 3 = 0
    var ineq2 = board.create('inequality', [line2], {inverse: true, fillColor: 'red'});  //This would plot the inequality 1x + 0y - 3 >= 0