In following applet a function f is defined by two random generated parameters. Additionally the function value of a random generated value is calculated. Clicking on a button racalculates all random numbers in a one-line script.
[list][*][b]random parameters[/b]: Define:[br]- [code]a = RandomDiscrete({-3, -2, -1, 0, 1, 2, 3}, {5, 5, 3, 1, 3, 5, 5})[/code] to define the parameter a. The command [code]RandomDiscrete()[/code] allows you to give each of the possible values a weight to differentiate the probabilities of them. Here [code]0[/code] is allowed but its probability is reduced.[br]- [code]b = RandomBetween(-3, 3)[/code]. Each number in the range has an equal probability.[br]- [code]c = RandomBetween(-20, 20).[/code][br][/*][*][code][/code][b]function[/b]: Define:[br][code]f = Polynomial ( a x + b)[/code] to create the fuction f.[br]The command Polynomial() prevents the equation to be shown as e.g. f(x) = 1 x + 2.[/*][*][b]texts[/b]: Create:[br]- a dynamic text to show the equation of f. Select f in the list of objects. [br]- a dynamic text to show the function value f(c). Select c in the list of available objects.[/*][*][b]button: [/b]Create a button to recalculate the random values used in the applet.[br]You can recalculate all random generated numbers by insering the definition of them in the command [i]SetValue()[/i], e.g. [code]SetValue(c, RandomBetween(-20,20))[/code]. [br]You might as well can recalculate all random generated values in the applet with one scripting command. Just type the command [code]UpdateConstruction()[/code] in the script of the button and all will be done.[br][br][/*][/list]