Wolfram Mathematica 8.0.4
Version of implementation Wolfram Mathematica of programming language Wolfram MathematicaA version of Wolfram Mathematica, released on October 26, 2011.
Main changes:
- support for CDF (Computable Data Format), meant for interactive data visualization.
- system is tested with Mac OS X Lion.
- performance improvement of KLM library and quotation functions.
-
memory usage improvement when using
Share
with large amounts of data. -
new syntax highlight warns about using
Module
variable inDynamic
. - improved saving of unnamed Notebook on Linux.
Examples:
Factorial - Wolfram Mathematica (441):
This example uses recursive factorial definition. The first line defines Fact
function. Note that the names of function arguments must have an underscore _
appended to them.
Fact[n_] := If[n == 0, 1, Fact[n - 1]*n];
For[i = 0, i <= 16, i++, Print[i, "! = ", Fact[i]]];
Quadratic equation - Wolfram Mathematica (443):
After accepting user input we define variable y
which is a quadratic equation with the given coefficients. Since x
is not defined yet, it stays a variable — for example, Print[y]
will output the notation of the equation c + b x + a x^2
(with c, b and a replaced with values entered by the user). Reduce
calculates the values of the variables which satisfy the condition “equation value equals zero”.
a = Input["Input a", 0];
b = Input["Input b", 0];
c = Input["Input c", 0];
y = a*x^2 + b*x + c;
Print[Reduce[y == 0]];
Hello, World! - Wolfram Mathematica (438):
Evaluation of this expression results in a string “Hello, World!” itself; since it is not followed by a semicolon, it will be printed as a separate Out
, which is not always convenient.
"Hello, World!"
Hello, World! - Wolfram Mathematica (439):
Print
function outputs its argument(s) to the main output stream. Streams can nest, so for convenience it’s recommended to to use a single stream for all output throughout the program.
Print["Hello, World!"];
Factorial - Wolfram Mathematica (440):
This example uses built-in factorial function !
.
Do
is one of the ways to run a loop — it evaluates its first argument for a sequence of numbers defined by the second argument. In this case it’s all values of i
from 0 to 16, inclusive, with step of 1.
Do[Print[i, "! = ", i!] , {i, 0, 16, 1}]
Fibonacci numbers - Wolfram Mathematica (442):
Print
always outputs a newline after the output, so to prints the numbers in a single line, one has to accumulate them into a string and print it. <>
is concatenation operator, it works only on strings, so the result of Fibonacci
call must be converted to string explicitly using ToString
function.
msg = "";
Do[msg = msg <> ToString[Fibonacci[i]] <> ", " , {i, 16} ];
Print[msg, "..."];
Comments
]]>blog comments powered by Disqus
]]>