# Difference between revisions of "Mathematical functions"

From JSXGraph Wiki

Jump to navigationJump to searchA WASSERMANN (talk | contribs) |
A WASSERMANN (talk | contribs) |
||

Line 1: | Line 1: | ||

==Functions of the JavaScript Object Math== | ==Functions of the JavaScript Object Math== | ||

The following functions are part of every JavaScript virtual machine: | The following functions are part of every JavaScript virtual machine: | ||

− | * Math.abs; | + | * ''Math.abs''; |

− | * Math.acos; | + | * ''Math.acos''; |

− | * Math.asin; | + | * ''Math.asin''; |

− | * Math.atan; | + | * ''Math.atan''; |

− | * Math.ceil; | + | * ''Math.ceil''; |

− | * Math.cos; | + | * ''Math.cos''; |

− | * Math.exp; | + | * ''Math.exp''; |

− | * Math.floor; | + | * ''Math.floor''; |

− | * Math.log; | + | * ''Math.log''; |

− | * Math.max; | + | * ''Math.max''; |

− | * Math.min; | + | * ''Math.min''; |

− | * Math.random; | + | * ''Math.random''; |

− | * Math.sin; | + | * ''Math.sin''; |

− | * Math.sqrt; | + | * ''Math.sqrt''; |

− | * Math.tan; | + | * ''Math.tan''; |

JSXGraph expands the set of available mathematical functions. To keep the JavaScript implementations clean, the new mathematical functions are part of the JSXGraph board. | JSXGraph expands the set of available mathematical functions. To keep the JavaScript implementations clean, the new mathematical functions are part of the JSXGraph board. | ||

Line 23: | Line 23: | ||

</source> | </source> | ||

Then, the object ''board'' contains the following additional mathematical functions: | Then, the object ''board'' contains the following additional mathematical functions: | ||

− | * board.angle(A, B, C): for Point objects A, B, C. (A: name string, id string or object pointer) | + | * ''board.angle(A, B, C)'': for Point objects A, B, C. (A: name string, id string or object pointer) |

− | * board.rad(A, B, C) | + | * ''board.rad(A, B, C)'' |

− | * board.distance(arr1, arr2): Euclidean distane between two vectors | + | * ''board.distance(arr1, arr2)'': Euclidean distane between two vectors |

− | * board.pow(a, b): <math>a^b</math> for floating point value of ''b''. Math.pow is defined for integer values of b, only. | + | * ''board.pow(a, b)'': <math>a^b</math> for floating point value of ''b''. Math.pow is defined for integer values of ''b', only. |

− | * board.round(x, n): returns string with fixed point representation of ''x''. | + | * ''board.round(x, n)'': returns string with fixed point representation of ''x''. |

May be replaced by string.tofixed(n). | May be replaced by string.tofixed(n). | ||

− | * board.cosh(x) | + | * ''board.cosh(x)'' |

− | * board.sinh(x) | + | * ''board.sinh(x)'' |

− | * board.D(f): Numerically computed derivative of the function ''f'', returns a function. | + | * ''board.D(f)'': Numerically computed derivative of the function ''f'', returns a function. |

− | * board.I(interval,f): Numerically computed v alue integral of the function ''f'' in the given interval. | + | * ''board.I(interval,f)'': Numerically computed v alue integral of the function ''f'' in the given interval. |

− | * board.root(f,x): root of the function f. Uses Newton methon with start value ''x'. | + | * ''board.root(f,x)'': root of the function f. Uses Newton methon with start value ''x''. |

## Revision as of 14:13, 25 January 2009

## Functions of the JavaScript Object Math

The following functions are part of every JavaScript virtual machine:

*Math.abs*;*Math.acos*;*Math.asin*;*Math.atan*;*Math.ceil*;*Math.cos*;*Math.exp*;*Math.floor*;*Math.log*;*Math.max*;*Math.min*;*Math.random*;*Math.sin*;*Math.sqrt*;*Math.tan*;

JSXGraph expands the set of available mathematical functions. To keep the JavaScript implementations clean, the new mathematical functions are part of the JSXGraph board. That means, initially a board has to be created, for example with the command

```
board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 250, unitX: 40, unitY: 40});
```

Then, the object *board* contains the following additional mathematical functions:

*board.angle(A, B, C)*: for Point objects A, B, C. (A: name string, id string or object pointer)*board.rad(A, B, C)**board.distance(arr1, arr2)*: Euclidean distane between two vectors*board.pow(a, b)*: [math]a^b[/math] for floating point value of*b*. Math.pow is defined for integer values of*b', only.**board.round(x, n)*: returns string with fixed point representation of*x*.

May be replaced by string.tofixed(n).

*board.cosh(x)**board.sinh(x)**board.D(f)*: Numerically computed derivative of the function*f*, returns a function.*board.I(interval,f)*: Numerically computed v alue integral of the function*f*in the given interval.*board.root(f,x)*: root of the function f. Uses Newton methon with start value*x*.