# Inequalities

From JSXGraph Wiki

Revision as of 10:57, 8 June 2017 by A WASSERMANN (talk | contribs)

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
```