Benutzer:MovGP0/Mathematica
Zur Navigation springen
Zur Suche springen
Mathematica
[Bearbeiten | Quelltext bearbeiten]- Lists
Calculate the probability that a 6-sided dice gets a number less than 4:
ClearAll["Global`*"]
possible = {1, 2, 3, 4, 5, 6}
good = Select[possible, # < 4 &]
prob = Length[good] / Length[possible]
- Apply and deconstruct
ClearAll["Global`*"]
circumfence = 12π
{radius} = r /. Solve[circumfence == 2*r*π, r]
- Solve system of linear equations
ClearAll["Global`*"];
M = {{3, 0, 0},
{1, 2, 0},
{0, 1, 4}}
(* {{3, 0, 0}, {1, 2, 0}, {0, 1, 4}} *)
system = M.{cat, head, feet} == {30, 20, 9}
(* {3 cat, cat + 2 head, 4 feet + head} == {30, 20, 9} *)
result = Solve[system, {cat, head, feet}]
(* {{cat -> 10, head -> 5, feet -> 1}} *)
{cat, head, feet} = {cat, head, feet} /. result[[1]]
(* {10, 5, 1} *)
head + feet * cat
(* 15 *)
Cheatsheet[1]
[Bearbeiten | Quelltext bearbeiten]a = 3; |
assignment |
a := 3; |
delayed assignment |
a == 3; |
equality |
a =.; |
Clear[a]
|
a === true; |
boolean test |
f[x_] := f[x] = ...; |
store computed value |
Ctrl+T | Exponent |
Ctrl+, | Square Root |
Ctrl+/ | Horizontal Fraction |
Ctrl+f | Form input |
Ctrl+ü | Underscript |
Ctrl+q | Overscript |
Ctrl+- | Index |
Quellen
[Bearbeiten | Quelltext bearbeiten]- ↑ Hugo Touchette: Mathematica commands summary (cheat sheet). National Institute for Theoretical Physics, Stellenbosch, South Africa, 18. Mai 2016, abgerufen am 6. April 2017.