Analogies to Help New Users
Clash Royale CLAN TAG#URR8PPP
up vote
27
down vote
favorite
In many of the classes that I teach, I require students to learn the basics of Mathematica which we use throughout the semester to do computations and to submit homeworks (in notebook form). Some students really like this and some... not so much.
Since I teach in an engineering department, almost everyone already knows some programming language: Matlab, python, java, or C are the most common, though there is quite a variety. One thing that I have found pretty effective is to try and relate Mathematica formalisms, structures, and ideas to those that students already know. For example:
$-$ When talking about using the Listable
Attribute of functions, I compare this to Matlab's vectorization
$-$ When talking about alternatives for loops, Mathematica's Table
function is analogous to python's List Comprehensions, for example, observe the similarity between
squares = [x**2 for x in range(10)]
and
squares = Table[x^2, x, Range[10]]
$-$ Mathematica's Notebook format is analogous to Jupyter notebooks which merge word processing, computation, and interactive presentations.
My question is this: What are some other analogies between Mathematica functions, expressions, and structures that might be helpful to new users in understanding "what Mathematica is thinking" or "why it works that way"?
Update: It seems that we have some very good answers for Matlab and for python. How about other languages? Any nice analogies for/with other popular languages?
programming functional-style education
 |Â
show 4 more comments
up vote
27
down vote
favorite
In many of the classes that I teach, I require students to learn the basics of Mathematica which we use throughout the semester to do computations and to submit homeworks (in notebook form). Some students really like this and some... not so much.
Since I teach in an engineering department, almost everyone already knows some programming language: Matlab, python, java, or C are the most common, though there is quite a variety. One thing that I have found pretty effective is to try and relate Mathematica formalisms, structures, and ideas to those that students already know. For example:
$-$ When talking about using the Listable
Attribute of functions, I compare this to Matlab's vectorization
$-$ When talking about alternatives for loops, Mathematica's Table
function is analogous to python's List Comprehensions, for example, observe the similarity between
squares = [x**2 for x in range(10)]
and
squares = Table[x^2, x, Range[10]]
$-$ Mathematica's Notebook format is analogous to Jupyter notebooks which merge word processing, computation, and interactive presentations.
My question is this: What are some other analogies between Mathematica functions, expressions, and structures that might be helpful to new users in understanding "what Mathematica is thinking" or "why it works that way"?
Update: It seems that we have some very good answers for Matlab and for python. How about other languages? Any nice analogies for/with other popular languages?
programming functional-style education
Do you have materials from your courses that you could make available? Much obliged.
â Rabbit
Sep 8 at 15:20
9
It is the other way around: Jupyter notebooks are (still poor) analogs of Mathematica notebooks.
â Anton Antonov
Sep 8 at 15:47
1
@bills I was half-joking, referring to the historical time-line of notion and implementation of "computational notebook". You are referring to the exposure time-lines of individuals/students.
â Anton Antonov
Sep 8 at 16:00
4
@sunt05 some percentage of the students in my class feel the same way. But the class is not about learning Mathematica or learning python, but about image processing. One thing python lacks is the easy interactivity of Mathematica, which is really key when examining many different variations on parameters, filters, and processing methods. I'd be happy to see an answer from you with more python-esque analogies
â bill s
Sep 10 at 21:17
7
Perhaps analogies are more harmful than helpful beyond a certain point. They might encourage students to think in Python and try to translate their Python solution directly to Mathematica. That often results in a hideously complex and inefficient solution. An alternative approach would be to show how certain basic tasks are accomplished. Describe those basic tasks in English, not in Python. The tasks should be chosen based on what is taught in your course, and what mistakes student most commonly made in past years.
â Szabolcs
Sep 11 at 13:51
 |Â
show 4 more comments
up vote
27
down vote
favorite
up vote
27
down vote
favorite
In many of the classes that I teach, I require students to learn the basics of Mathematica which we use throughout the semester to do computations and to submit homeworks (in notebook form). Some students really like this and some... not so much.
Since I teach in an engineering department, almost everyone already knows some programming language: Matlab, python, java, or C are the most common, though there is quite a variety. One thing that I have found pretty effective is to try and relate Mathematica formalisms, structures, and ideas to those that students already know. For example:
$-$ When talking about using the Listable
Attribute of functions, I compare this to Matlab's vectorization
$-$ When talking about alternatives for loops, Mathematica's Table
function is analogous to python's List Comprehensions, for example, observe the similarity between
squares = [x**2 for x in range(10)]
and
squares = Table[x^2, x, Range[10]]
$-$ Mathematica's Notebook format is analogous to Jupyter notebooks which merge word processing, computation, and interactive presentations.
My question is this: What are some other analogies between Mathematica functions, expressions, and structures that might be helpful to new users in understanding "what Mathematica is thinking" or "why it works that way"?
Update: It seems that we have some very good answers for Matlab and for python. How about other languages? Any nice analogies for/with other popular languages?
programming functional-style education
In many of the classes that I teach, I require students to learn the basics of Mathematica which we use throughout the semester to do computations and to submit homeworks (in notebook form). Some students really like this and some... not so much.
Since I teach in an engineering department, almost everyone already knows some programming language: Matlab, python, java, or C are the most common, though there is quite a variety. One thing that I have found pretty effective is to try and relate Mathematica formalisms, structures, and ideas to those that students already know. For example:
$-$ When talking about using the Listable
Attribute of functions, I compare this to Matlab's vectorization
$-$ When talking about alternatives for loops, Mathematica's Table
function is analogous to python's List Comprehensions, for example, observe the similarity between
squares = [x**2 for x in range(10)]
and
squares = Table[x^2, x, Range[10]]
$-$ Mathematica's Notebook format is analogous to Jupyter notebooks which merge word processing, computation, and interactive presentations.
My question is this: What are some other analogies between Mathematica functions, expressions, and structures that might be helpful to new users in understanding "what Mathematica is thinking" or "why it works that way"?
Update: It seems that we have some very good answers for Matlab and for python. How about other languages? Any nice analogies for/with other popular languages?
programming functional-style education
programming functional-style education
edited yesterday
asked Sep 8 at 14:34
bill s
51.3k375146
51.3k375146
Do you have materials from your courses that you could make available? Much obliged.
â Rabbit
Sep 8 at 15:20
9
It is the other way around: Jupyter notebooks are (still poor) analogs of Mathematica notebooks.
â Anton Antonov
Sep 8 at 15:47
1
@bills I was half-joking, referring to the historical time-line of notion and implementation of "computational notebook". You are referring to the exposure time-lines of individuals/students.
â Anton Antonov
Sep 8 at 16:00
4
@sunt05 some percentage of the students in my class feel the same way. But the class is not about learning Mathematica or learning python, but about image processing. One thing python lacks is the easy interactivity of Mathematica, which is really key when examining many different variations on parameters, filters, and processing methods. I'd be happy to see an answer from you with more python-esque analogies
â bill s
Sep 10 at 21:17
7
Perhaps analogies are more harmful than helpful beyond a certain point. They might encourage students to think in Python and try to translate their Python solution directly to Mathematica. That often results in a hideously complex and inefficient solution. An alternative approach would be to show how certain basic tasks are accomplished. Describe those basic tasks in English, not in Python. The tasks should be chosen based on what is taught in your course, and what mistakes student most commonly made in past years.
â Szabolcs
Sep 11 at 13:51
 |Â
show 4 more comments
Do you have materials from your courses that you could make available? Much obliged.
â Rabbit
Sep 8 at 15:20
9
It is the other way around: Jupyter notebooks are (still poor) analogs of Mathematica notebooks.
â Anton Antonov
Sep 8 at 15:47
1
@bills I was half-joking, referring to the historical time-line of notion and implementation of "computational notebook". You are referring to the exposure time-lines of individuals/students.
â Anton Antonov
Sep 8 at 16:00
4
@sunt05 some percentage of the students in my class feel the same way. But the class is not about learning Mathematica or learning python, but about image processing. One thing python lacks is the easy interactivity of Mathematica, which is really key when examining many different variations on parameters, filters, and processing methods. I'd be happy to see an answer from you with more python-esque analogies
â bill s
Sep 10 at 21:17
7
Perhaps analogies are more harmful than helpful beyond a certain point. They might encourage students to think in Python and try to translate their Python solution directly to Mathematica. That often results in a hideously complex and inefficient solution. An alternative approach would be to show how certain basic tasks are accomplished. Describe those basic tasks in English, not in Python. The tasks should be chosen based on what is taught in your course, and what mistakes student most commonly made in past years.
â Szabolcs
Sep 11 at 13:51
Do you have materials from your courses that you could make available? Much obliged.
â Rabbit
Sep 8 at 15:20
Do you have materials from your courses that you could make available? Much obliged.
â Rabbit
Sep 8 at 15:20
9
9
It is the other way around: Jupyter notebooks are (still poor) analogs of Mathematica notebooks.
â Anton Antonov
Sep 8 at 15:47
It is the other way around: Jupyter notebooks are (still poor) analogs of Mathematica notebooks.
â Anton Antonov
Sep 8 at 15:47
1
1
@bills I was half-joking, referring to the historical time-line of notion and implementation of "computational notebook". You are referring to the exposure time-lines of individuals/students.
â Anton Antonov
Sep 8 at 16:00
@bills I was half-joking, referring to the historical time-line of notion and implementation of "computational notebook". You are referring to the exposure time-lines of individuals/students.
â Anton Antonov
Sep 8 at 16:00
4
4
@sunt05 some percentage of the students in my class feel the same way. But the class is not about learning Mathematica or learning python, but about image processing. One thing python lacks is the easy interactivity of Mathematica, which is really key when examining many different variations on parameters, filters, and processing methods. I'd be happy to see an answer from you with more python-esque analogies
â bill s
Sep 10 at 21:17
@sunt05 some percentage of the students in my class feel the same way. But the class is not about learning Mathematica or learning python, but about image processing. One thing python lacks is the easy interactivity of Mathematica, which is really key when examining many different variations on parameters, filters, and processing methods. I'd be happy to see an answer from you with more python-esque analogies
â bill s
Sep 10 at 21:17
7
7
Perhaps analogies are more harmful than helpful beyond a certain point. They might encourage students to think in Python and try to translate their Python solution directly to Mathematica. That often results in a hideously complex and inefficient solution. An alternative approach would be to show how certain basic tasks are accomplished. Describe those basic tasks in English, not in Python. The tasks should be chosen based on what is taught in your course, and what mistakes student most commonly made in past years.
â Szabolcs
Sep 11 at 13:51
Perhaps analogies are more harmful than helpful beyond a certain point. They might encourage students to think in Python and try to translate their Python solution directly to Mathematica. That often results in a hideously complex and inefficient solution. An alternative approach would be to show how certain basic tasks are accomplished. Describe those basic tasks in English, not in Python. The tasks should be chosen based on what is taught in your course, and what mistakes student most commonly made in past years.
â Szabolcs
Sep 11 at 13:51
 |Â
show 4 more comments
3 Answers
3
active
oldest
votes
up vote
24
down vote
Imho some important things to translate between Matlab and Mathematica:
"everything is a matrix (or inefficient)" vs. "everything is an expression"
indexing into arrays:
:
vs.All
indexing into arrays:
j:i:k
vs.j;;k;;i
constructing ranges:
j:i:k
vs.Range[j,k,i]
column-major vs. row-major!:
mat(:)
vs.Flatten[Transpose[mat]]
or(mat')(:)
vs.Flatten
combining tensors:
cat
vs.Join
andArrayFlatten
anonymous functions:
@(x) x^2
vs.#^2&
orx [Function] x^2
building simple tensors:
zeroes
,ones
vs.ConstantArray
more tensors:
eye
andspeye
vs.IdentityMatrix
andIdentityMatrix[#,SparseArray]&
diag
andspdiags
vs.DiagonalMatrix
andDiagonalMatrix[SparseArray[#]] &
/SparseArray
together withBand
(but alsodiag
vs.Diagonal
btw.)even more tensors:
rand
vs.RandomReal
loops:
for
vs.Do
,Table
,Array
, andMap
(and notFor
!!11eleven)arrayfun
andcellfun
vs.Map
(with level spec-1
) (special thanks to mikado for pointing this one out)while
andrepeat
vs.While
, but alsoNestWhile
,NestWhileList
,FixedPoint
, andFixedPointList
if ... else ... end
vs.If
if ... elseif... elseif... end
vs.Which
piecewise
vs., well,Piecewise
solving linear systems:
and
/
vs.LinearSolve
andLinearSolve[#1][#2, "T"] &
more linear systems:
pinv
vs.LeastSquares
andPseudoInverse
struct
vs.Association
cell
vs.List
Certainly less important
kron
vs.KroneckerProduct
meshgrid
vs.Tuples
(Due to the intuitive plotting in Mathematica,Tuples
within Mathematica has not nearly the same importance asmeshgrid
has within Matlab.)class vs. tags (
TagSet
andTagSetDelayed
) (though each Matlab programmer I've ever met refused to use classes...)isa
vs.Head
and patternsmex
vs.Compile
(and LibraryLink for the pro users)
One could also mentionPiecewise
in the context ofIf
andWhich
...
â kirma
Sep 14 at 10:36
1
@kirma Good point. I added it, but compared it topiecewise
rather than toif
. ;)
â Henrik Schumacher
Sep 14 at 12:03
IsIdentityMatrix[@,SparseArray]&
intended to beIdentityMatrix[#,SparseArray]&
? Might also be worthwhile to point outDiagonalMatrix
, though I don't recall if there's a clear Matlab analog.
â eyorble
Sep 14 at 12:31
@eyorble Good point. Corrected it. There are alsdiag
andspdiags
in Matlab.
â Henrik Schumacher
Sep 14 at 12:38
@HenrikSchumacher Ah. I've never used Matlab. ;)
â kirma
Sep 14 at 13:06
 |Â
show 2 more comments
up vote
9
down vote
When a language, e.g., Python, not emphasizing but has to talk about "functional programming", usually it speaks about three functions: map
, filter
and reduce
. I always think comparison a good approach to learn things, so below I share the comparison I made before.
Besides, Function (&)
vs lambda
, Array, Table
vs "list comprehensions" (Table
has been mentioned but Range
is redundant.).
I think if you want to talk correspondence, the entirety of itertools is big. It provides a slew of utilities that Mathematica has, but does so in a more efficient lazy fashion.
â b3m2a1
12 hours ago
add a comment |Â
up vote
6
down vote
For those with experience in python, WRI has already provided a nice introductory tutorial along with many analogies.
However, for the class intended for image processing as mentioned by the OP, pure python is for certain not enough: numpy
, pandas
, scipy
and pillow
are some of the essential packages to go with.
As someone who has used pillow a fair amount, I do tend to think it is less-intuitive and certainly less-powerful than Mathematica. It is nice to know that it exists and get some sense for how to use it for when you lose that academic Mathematica license and the cost is prohibitive, but as they say, "use the right tool for the job" and for maybe the first time ever, the right tool is Mathematica. I do enjoy numpy, though, as a stand in for Mathematica arrays. It is often much more efficient.
â b3m2a1
12 hours ago
@b3m2a1 Actually I was really reluctant to write up this post days ago as I love Mathematica to death. However, I feel helpless now and then if I want to communicate my research outcome with others in Mathematica. As long as WRI stays with their current business model, it is hopeless to see new blood flowing into the Mathematica usership, not to mention discipline-specific python packages are moving really fast : I personally interact with atmospheric models a lot and feel Mathematica lacks essential tools to deal with those tools.
â sunt05
11 hours ago
I won't deny any of that. Modern research is done is python (and some R and MATLAB) and Mathematica has decidedly abdicated its once considerable position in that. My sole argument was about image processing with Mathematica vs. pillow. In that specific case, Mathematica still outperforms python in usability and performance.
â b3m2a1
11 hours ago
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
24
down vote
Imho some important things to translate between Matlab and Mathematica:
"everything is a matrix (or inefficient)" vs. "everything is an expression"
indexing into arrays:
:
vs.All
indexing into arrays:
j:i:k
vs.j;;k;;i
constructing ranges:
j:i:k
vs.Range[j,k,i]
column-major vs. row-major!:
mat(:)
vs.Flatten[Transpose[mat]]
or(mat')(:)
vs.Flatten
combining tensors:
cat
vs.Join
andArrayFlatten
anonymous functions:
@(x) x^2
vs.#^2&
orx [Function] x^2
building simple tensors:
zeroes
,ones
vs.ConstantArray
more tensors:
eye
andspeye
vs.IdentityMatrix
andIdentityMatrix[#,SparseArray]&
diag
andspdiags
vs.DiagonalMatrix
andDiagonalMatrix[SparseArray[#]] &
/SparseArray
together withBand
(but alsodiag
vs.Diagonal
btw.)even more tensors:
rand
vs.RandomReal
loops:
for
vs.Do
,Table
,Array
, andMap
(and notFor
!!11eleven)arrayfun
andcellfun
vs.Map
(with level spec-1
) (special thanks to mikado for pointing this one out)while
andrepeat
vs.While
, but alsoNestWhile
,NestWhileList
,FixedPoint
, andFixedPointList
if ... else ... end
vs.If
if ... elseif... elseif... end
vs.Which
piecewise
vs., well,Piecewise
solving linear systems:
and
/
vs.LinearSolve
andLinearSolve[#1][#2, "T"] &
more linear systems:
pinv
vs.LeastSquares
andPseudoInverse
struct
vs.Association
cell
vs.List
Certainly less important
kron
vs.KroneckerProduct
meshgrid
vs.Tuples
(Due to the intuitive plotting in Mathematica,Tuples
within Mathematica has not nearly the same importance asmeshgrid
has within Matlab.)class vs. tags (
TagSet
andTagSetDelayed
) (though each Matlab programmer I've ever met refused to use classes...)isa
vs.Head
and patternsmex
vs.Compile
(and LibraryLink for the pro users)
One could also mentionPiecewise
in the context ofIf
andWhich
...
â kirma
Sep 14 at 10:36
1
@kirma Good point. I added it, but compared it topiecewise
rather than toif
. ;)
â Henrik Schumacher
Sep 14 at 12:03
IsIdentityMatrix[@,SparseArray]&
intended to beIdentityMatrix[#,SparseArray]&
? Might also be worthwhile to point outDiagonalMatrix
, though I don't recall if there's a clear Matlab analog.
â eyorble
Sep 14 at 12:31
@eyorble Good point. Corrected it. There are alsdiag
andspdiags
in Matlab.
â Henrik Schumacher
Sep 14 at 12:38
@HenrikSchumacher Ah. I've never used Matlab. ;)
â kirma
Sep 14 at 13:06
 |Â
show 2 more comments
up vote
24
down vote
Imho some important things to translate between Matlab and Mathematica:
"everything is a matrix (or inefficient)" vs. "everything is an expression"
indexing into arrays:
:
vs.All
indexing into arrays:
j:i:k
vs.j;;k;;i
constructing ranges:
j:i:k
vs.Range[j,k,i]
column-major vs. row-major!:
mat(:)
vs.Flatten[Transpose[mat]]
or(mat')(:)
vs.Flatten
combining tensors:
cat
vs.Join
andArrayFlatten
anonymous functions:
@(x) x^2
vs.#^2&
orx [Function] x^2
building simple tensors:
zeroes
,ones
vs.ConstantArray
more tensors:
eye
andspeye
vs.IdentityMatrix
andIdentityMatrix[#,SparseArray]&
diag
andspdiags
vs.DiagonalMatrix
andDiagonalMatrix[SparseArray[#]] &
/SparseArray
together withBand
(but alsodiag
vs.Diagonal
btw.)even more tensors:
rand
vs.RandomReal
loops:
for
vs.Do
,Table
,Array
, andMap
(and notFor
!!11eleven)arrayfun
andcellfun
vs.Map
(with level spec-1
) (special thanks to mikado for pointing this one out)while
andrepeat
vs.While
, but alsoNestWhile
,NestWhileList
,FixedPoint
, andFixedPointList
if ... else ... end
vs.If
if ... elseif... elseif... end
vs.Which
piecewise
vs., well,Piecewise
solving linear systems:
and
/
vs.LinearSolve
andLinearSolve[#1][#2, "T"] &
more linear systems:
pinv
vs.LeastSquares
andPseudoInverse
struct
vs.Association
cell
vs.List
Certainly less important
kron
vs.KroneckerProduct
meshgrid
vs.Tuples
(Due to the intuitive plotting in Mathematica,Tuples
within Mathematica has not nearly the same importance asmeshgrid
has within Matlab.)class vs. tags (
TagSet
andTagSetDelayed
) (though each Matlab programmer I've ever met refused to use classes...)isa
vs.Head
and patternsmex
vs.Compile
(and LibraryLink for the pro users)
One could also mentionPiecewise
in the context ofIf
andWhich
...
â kirma
Sep 14 at 10:36
1
@kirma Good point. I added it, but compared it topiecewise
rather than toif
. ;)
â Henrik Schumacher
Sep 14 at 12:03
IsIdentityMatrix[@,SparseArray]&
intended to beIdentityMatrix[#,SparseArray]&
? Might also be worthwhile to point outDiagonalMatrix
, though I don't recall if there's a clear Matlab analog.
â eyorble
Sep 14 at 12:31
@eyorble Good point. Corrected it. There are alsdiag
andspdiags
in Matlab.
â Henrik Schumacher
Sep 14 at 12:38
@HenrikSchumacher Ah. I've never used Matlab. ;)
â kirma
Sep 14 at 13:06
 |Â
show 2 more comments
up vote
24
down vote
up vote
24
down vote
Imho some important things to translate between Matlab and Mathematica:
"everything is a matrix (or inefficient)" vs. "everything is an expression"
indexing into arrays:
:
vs.All
indexing into arrays:
j:i:k
vs.j;;k;;i
constructing ranges:
j:i:k
vs.Range[j,k,i]
column-major vs. row-major!:
mat(:)
vs.Flatten[Transpose[mat]]
or(mat')(:)
vs.Flatten
combining tensors:
cat
vs.Join
andArrayFlatten
anonymous functions:
@(x) x^2
vs.#^2&
orx [Function] x^2
building simple tensors:
zeroes
,ones
vs.ConstantArray
more tensors:
eye
andspeye
vs.IdentityMatrix
andIdentityMatrix[#,SparseArray]&
diag
andspdiags
vs.DiagonalMatrix
andDiagonalMatrix[SparseArray[#]] &
/SparseArray
together withBand
(but alsodiag
vs.Diagonal
btw.)even more tensors:
rand
vs.RandomReal
loops:
for
vs.Do
,Table
,Array
, andMap
(and notFor
!!11eleven)arrayfun
andcellfun
vs.Map
(with level spec-1
) (special thanks to mikado for pointing this one out)while
andrepeat
vs.While
, but alsoNestWhile
,NestWhileList
,FixedPoint
, andFixedPointList
if ... else ... end
vs.If
if ... elseif... elseif... end
vs.Which
piecewise
vs., well,Piecewise
solving linear systems:
and
/
vs.LinearSolve
andLinearSolve[#1][#2, "T"] &
more linear systems:
pinv
vs.LeastSquares
andPseudoInverse
struct
vs.Association
cell
vs.List
Certainly less important
kron
vs.KroneckerProduct
meshgrid
vs.Tuples
(Due to the intuitive plotting in Mathematica,Tuples
within Mathematica has not nearly the same importance asmeshgrid
has within Matlab.)class vs. tags (
TagSet
andTagSetDelayed
) (though each Matlab programmer I've ever met refused to use classes...)isa
vs.Head
and patternsmex
vs.Compile
(and LibraryLink for the pro users)
Imho some important things to translate between Matlab and Mathematica:
"everything is a matrix (or inefficient)" vs. "everything is an expression"
indexing into arrays:
:
vs.All
indexing into arrays:
j:i:k
vs.j;;k;;i
constructing ranges:
j:i:k
vs.Range[j,k,i]
column-major vs. row-major!:
mat(:)
vs.Flatten[Transpose[mat]]
or(mat')(:)
vs.Flatten
combining tensors:
cat
vs.Join
andArrayFlatten
anonymous functions:
@(x) x^2
vs.#^2&
orx [Function] x^2
building simple tensors:
zeroes
,ones
vs.ConstantArray
more tensors:
eye
andspeye
vs.IdentityMatrix
andIdentityMatrix[#,SparseArray]&
diag
andspdiags
vs.DiagonalMatrix
andDiagonalMatrix[SparseArray[#]] &
/SparseArray
together withBand
(but alsodiag
vs.Diagonal
btw.)even more tensors:
rand
vs.RandomReal
loops:
for
vs.Do
,Table
,Array
, andMap
(and notFor
!!11eleven)arrayfun
andcellfun
vs.Map
(with level spec-1
) (special thanks to mikado for pointing this one out)while
andrepeat
vs.While
, but alsoNestWhile
,NestWhileList
,FixedPoint
, andFixedPointList
if ... else ... end
vs.If
if ... elseif... elseif... end
vs.Which
piecewise
vs., well,Piecewise
solving linear systems:
and
/
vs.LinearSolve
andLinearSolve[#1][#2, "T"] &
more linear systems:
pinv
vs.LeastSquares
andPseudoInverse
struct
vs.Association
cell
vs.List
Certainly less important
kron
vs.KroneckerProduct
meshgrid
vs.Tuples
(Due to the intuitive plotting in Mathematica,Tuples
within Mathematica has not nearly the same importance asmeshgrid
has within Matlab.)class vs. tags (
TagSet
andTagSetDelayed
) (though each Matlab programmer I've ever met refused to use classes...)isa
vs.Head
and patternsmex
vs.Compile
(and LibraryLink for the pro users)
edited yesterday
answered Sep 8 at 15:01
Henrik Schumacher
40k255120
40k255120
One could also mentionPiecewise
in the context ofIf
andWhich
...
â kirma
Sep 14 at 10:36
1
@kirma Good point. I added it, but compared it topiecewise
rather than toif
. ;)
â Henrik Schumacher
Sep 14 at 12:03
IsIdentityMatrix[@,SparseArray]&
intended to beIdentityMatrix[#,SparseArray]&
? Might also be worthwhile to point outDiagonalMatrix
, though I don't recall if there's a clear Matlab analog.
â eyorble
Sep 14 at 12:31
@eyorble Good point. Corrected it. There are alsdiag
andspdiags
in Matlab.
â Henrik Schumacher
Sep 14 at 12:38
@HenrikSchumacher Ah. I've never used Matlab. ;)
â kirma
Sep 14 at 13:06
 |Â
show 2 more comments
One could also mentionPiecewise
in the context ofIf
andWhich
...
â kirma
Sep 14 at 10:36
1
@kirma Good point. I added it, but compared it topiecewise
rather than toif
. ;)
â Henrik Schumacher
Sep 14 at 12:03
IsIdentityMatrix[@,SparseArray]&
intended to beIdentityMatrix[#,SparseArray]&
? Might also be worthwhile to point outDiagonalMatrix
, though I don't recall if there's a clear Matlab analog.
â eyorble
Sep 14 at 12:31
@eyorble Good point. Corrected it. There are alsdiag
andspdiags
in Matlab.
â Henrik Schumacher
Sep 14 at 12:38
@HenrikSchumacher Ah. I've never used Matlab. ;)
â kirma
Sep 14 at 13:06
One could also mention
Piecewise
in the context of If
and Which
...â kirma
Sep 14 at 10:36
One could also mention
Piecewise
in the context of If
and Which
...â kirma
Sep 14 at 10:36
1
1
@kirma Good point. I added it, but compared it to
piecewise
rather than to if
. ;)â Henrik Schumacher
Sep 14 at 12:03
@kirma Good point. I added it, but compared it to
piecewise
rather than to if
. ;)â Henrik Schumacher
Sep 14 at 12:03
Is
IdentityMatrix[@,SparseArray]&
intended to be IdentityMatrix[#,SparseArray]&
? Might also be worthwhile to point out DiagonalMatrix
, though I don't recall if there's a clear Matlab analog.â eyorble
Sep 14 at 12:31
Is
IdentityMatrix[@,SparseArray]&
intended to be IdentityMatrix[#,SparseArray]&
? Might also be worthwhile to point out DiagonalMatrix
, though I don't recall if there's a clear Matlab analog.â eyorble
Sep 14 at 12:31
@eyorble Good point. Corrected it. There are als
diag
and spdiags
in Matlab.â Henrik Schumacher
Sep 14 at 12:38
@eyorble Good point. Corrected it. There are als
diag
and spdiags
in Matlab.â Henrik Schumacher
Sep 14 at 12:38
@HenrikSchumacher Ah. I've never used Matlab. ;)
â kirma
Sep 14 at 13:06
@HenrikSchumacher Ah. I've never used Matlab. ;)
â kirma
Sep 14 at 13:06
 |Â
show 2 more comments
up vote
9
down vote
When a language, e.g., Python, not emphasizing but has to talk about "functional programming", usually it speaks about three functions: map
, filter
and reduce
. I always think comparison a good approach to learn things, so below I share the comparison I made before.
Besides, Function (&)
vs lambda
, Array, Table
vs "list comprehensions" (Table
has been mentioned but Range
is redundant.).
I think if you want to talk correspondence, the entirety of itertools is big. It provides a slew of utilities that Mathematica has, but does so in a more efficient lazy fashion.
â b3m2a1
12 hours ago
add a comment |Â
up vote
9
down vote
When a language, e.g., Python, not emphasizing but has to talk about "functional programming", usually it speaks about three functions: map
, filter
and reduce
. I always think comparison a good approach to learn things, so below I share the comparison I made before.
Besides, Function (&)
vs lambda
, Array, Table
vs "list comprehensions" (Table
has been mentioned but Range
is redundant.).
I think if you want to talk correspondence, the entirety of itertools is big. It provides a slew of utilities that Mathematica has, but does so in a more efficient lazy fashion.
â b3m2a1
12 hours ago
add a comment |Â
up vote
9
down vote
up vote
9
down vote
When a language, e.g., Python, not emphasizing but has to talk about "functional programming", usually it speaks about three functions: map
, filter
and reduce
. I always think comparison a good approach to learn things, so below I share the comparison I made before.
Besides, Function (&)
vs lambda
, Array, Table
vs "list comprehensions" (Table
has been mentioned but Range
is redundant.).
When a language, e.g., Python, not emphasizing but has to talk about "functional programming", usually it speaks about three functions: map
, filter
and reduce
. I always think comparison a good approach to learn things, so below I share the comparison I made before.
Besides, Function (&)
vs lambda
, Array, Table
vs "list comprehensions" (Table
has been mentioned but Range
is redundant.).
edited Sep 14 at 11:09
answered Sep 14 at 9:18
ÃÂûÃÂþñýôÃÂÿàÃÂõóó
2,264725
2,264725
I think if you want to talk correspondence, the entirety of itertools is big. It provides a slew of utilities that Mathematica has, but does so in a more efficient lazy fashion.
â b3m2a1
12 hours ago
add a comment |Â
I think if you want to talk correspondence, the entirety of itertools is big. It provides a slew of utilities that Mathematica has, but does so in a more efficient lazy fashion.
â b3m2a1
12 hours ago
I think if you want to talk correspondence, the entirety of itertools is big. It provides a slew of utilities that Mathematica has, but does so in a more efficient lazy fashion.
â b3m2a1
12 hours ago
I think if you want to talk correspondence, the entirety of itertools is big. It provides a slew of utilities that Mathematica has, but does so in a more efficient lazy fashion.
â b3m2a1
12 hours ago
add a comment |Â
up vote
6
down vote
For those with experience in python, WRI has already provided a nice introductory tutorial along with many analogies.
However, for the class intended for image processing as mentioned by the OP, pure python is for certain not enough: numpy
, pandas
, scipy
and pillow
are some of the essential packages to go with.
As someone who has used pillow a fair amount, I do tend to think it is less-intuitive and certainly less-powerful than Mathematica. It is nice to know that it exists and get some sense for how to use it for when you lose that academic Mathematica license and the cost is prohibitive, but as they say, "use the right tool for the job" and for maybe the first time ever, the right tool is Mathematica. I do enjoy numpy, though, as a stand in for Mathematica arrays. It is often much more efficient.
â b3m2a1
12 hours ago
@b3m2a1 Actually I was really reluctant to write up this post days ago as I love Mathematica to death. However, I feel helpless now and then if I want to communicate my research outcome with others in Mathematica. As long as WRI stays with their current business model, it is hopeless to see new blood flowing into the Mathematica usership, not to mention discipline-specific python packages are moving really fast : I personally interact with atmospheric models a lot and feel Mathematica lacks essential tools to deal with those tools.
â sunt05
11 hours ago
I won't deny any of that. Modern research is done is python (and some R and MATLAB) and Mathematica has decidedly abdicated its once considerable position in that. My sole argument was about image processing with Mathematica vs. pillow. In that specific case, Mathematica still outperforms python in usability and performance.
â b3m2a1
11 hours ago
add a comment |Â
up vote
6
down vote
For those with experience in python, WRI has already provided a nice introductory tutorial along with many analogies.
However, for the class intended for image processing as mentioned by the OP, pure python is for certain not enough: numpy
, pandas
, scipy
and pillow
are some of the essential packages to go with.
As someone who has used pillow a fair amount, I do tend to think it is less-intuitive and certainly less-powerful than Mathematica. It is nice to know that it exists and get some sense for how to use it for when you lose that academic Mathematica license and the cost is prohibitive, but as they say, "use the right tool for the job" and for maybe the first time ever, the right tool is Mathematica. I do enjoy numpy, though, as a stand in for Mathematica arrays. It is often much more efficient.
â b3m2a1
12 hours ago
@b3m2a1 Actually I was really reluctant to write up this post days ago as I love Mathematica to death. However, I feel helpless now and then if I want to communicate my research outcome with others in Mathematica. As long as WRI stays with their current business model, it is hopeless to see new blood flowing into the Mathematica usership, not to mention discipline-specific python packages are moving really fast : I personally interact with atmospheric models a lot and feel Mathematica lacks essential tools to deal with those tools.
â sunt05
11 hours ago
I won't deny any of that. Modern research is done is python (and some R and MATLAB) and Mathematica has decidedly abdicated its once considerable position in that. My sole argument was about image processing with Mathematica vs. pillow. In that specific case, Mathematica still outperforms python in usability and performance.
â b3m2a1
11 hours ago
add a comment |Â
up vote
6
down vote
up vote
6
down vote
For those with experience in python, WRI has already provided a nice introductory tutorial along with many analogies.
However, for the class intended for image processing as mentioned by the OP, pure python is for certain not enough: numpy
, pandas
, scipy
and pillow
are some of the essential packages to go with.
For those with experience in python, WRI has already provided a nice introductory tutorial along with many analogies.
However, for the class intended for image processing as mentioned by the OP, pure python is for certain not enough: numpy
, pandas
, scipy
and pillow
are some of the essential packages to go with.
answered Sep 11 at 19:08
sunt05
1,4551019
1,4551019
As someone who has used pillow a fair amount, I do tend to think it is less-intuitive and certainly less-powerful than Mathematica. It is nice to know that it exists and get some sense for how to use it for when you lose that academic Mathematica license and the cost is prohibitive, but as they say, "use the right tool for the job" and for maybe the first time ever, the right tool is Mathematica. I do enjoy numpy, though, as a stand in for Mathematica arrays. It is often much more efficient.
â b3m2a1
12 hours ago
@b3m2a1 Actually I was really reluctant to write up this post days ago as I love Mathematica to death. However, I feel helpless now and then if I want to communicate my research outcome with others in Mathematica. As long as WRI stays with their current business model, it is hopeless to see new blood flowing into the Mathematica usership, not to mention discipline-specific python packages are moving really fast : I personally interact with atmospheric models a lot and feel Mathematica lacks essential tools to deal with those tools.
â sunt05
11 hours ago
I won't deny any of that. Modern research is done is python (and some R and MATLAB) and Mathematica has decidedly abdicated its once considerable position in that. My sole argument was about image processing with Mathematica vs. pillow. In that specific case, Mathematica still outperforms python in usability and performance.
â b3m2a1
11 hours ago
add a comment |Â
As someone who has used pillow a fair amount, I do tend to think it is less-intuitive and certainly less-powerful than Mathematica. It is nice to know that it exists and get some sense for how to use it for when you lose that academic Mathematica license and the cost is prohibitive, but as they say, "use the right tool for the job" and for maybe the first time ever, the right tool is Mathematica. I do enjoy numpy, though, as a stand in for Mathematica arrays. It is often much more efficient.
â b3m2a1
12 hours ago
@b3m2a1 Actually I was really reluctant to write up this post days ago as I love Mathematica to death. However, I feel helpless now and then if I want to communicate my research outcome with others in Mathematica. As long as WRI stays with their current business model, it is hopeless to see new blood flowing into the Mathematica usership, not to mention discipline-specific python packages are moving really fast : I personally interact with atmospheric models a lot and feel Mathematica lacks essential tools to deal with those tools.
â sunt05
11 hours ago
I won't deny any of that. Modern research is done is python (and some R and MATLAB) and Mathematica has decidedly abdicated its once considerable position in that. My sole argument was about image processing with Mathematica vs. pillow. In that specific case, Mathematica still outperforms python in usability and performance.
â b3m2a1
11 hours ago
As someone who has used pillow a fair amount, I do tend to think it is less-intuitive and certainly less-powerful than Mathematica. It is nice to know that it exists and get some sense for how to use it for when you lose that academic Mathematica license and the cost is prohibitive, but as they say, "use the right tool for the job" and for maybe the first time ever, the right tool is Mathematica. I do enjoy numpy, though, as a stand in for Mathematica arrays. It is often much more efficient.
â b3m2a1
12 hours ago
As someone who has used pillow a fair amount, I do tend to think it is less-intuitive and certainly less-powerful than Mathematica. It is nice to know that it exists and get some sense for how to use it for when you lose that academic Mathematica license and the cost is prohibitive, but as they say, "use the right tool for the job" and for maybe the first time ever, the right tool is Mathematica. I do enjoy numpy, though, as a stand in for Mathematica arrays. It is often much more efficient.
â b3m2a1
12 hours ago
@b3m2a1 Actually I was really reluctant to write up this post days ago as I love Mathematica to death. However, I feel helpless now and then if I want to communicate my research outcome with others in Mathematica. As long as WRI stays with their current business model, it is hopeless to see new blood flowing into the Mathematica usership, not to mention discipline-specific python packages are moving really fast : I personally interact with atmospheric models a lot and feel Mathematica lacks essential tools to deal with those tools.
â sunt05
11 hours ago
@b3m2a1 Actually I was really reluctant to write up this post days ago as I love Mathematica to death. However, I feel helpless now and then if I want to communicate my research outcome with others in Mathematica. As long as WRI stays with their current business model, it is hopeless to see new blood flowing into the Mathematica usership, not to mention discipline-specific python packages are moving really fast : I personally interact with atmospheric models a lot and feel Mathematica lacks essential tools to deal with those tools.
â sunt05
11 hours ago
I won't deny any of that. Modern research is done is python (and some R and MATLAB) and Mathematica has decidedly abdicated its once considerable position in that. My sole argument was about image processing with Mathematica vs. pillow. In that specific case, Mathematica still outperforms python in usability and performance.
â b3m2a1
11 hours ago
I won't deny any of that. Modern research is done is python (and some R and MATLAB) and Mathematica has decidedly abdicated its once considerable position in that. My sole argument was about image processing with Mathematica vs. pillow. In that specific case, Mathematica still outperforms python in usability and performance.
â b3m2a1
11 hours ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181499%2fanalogies-to-help-new-users%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Do you have materials from your courses that you could make available? Much obliged.
â Rabbit
Sep 8 at 15:20
9
It is the other way around: Jupyter notebooks are (still poor) analogs of Mathematica notebooks.
â Anton Antonov
Sep 8 at 15:47
1
@bills I was half-joking, referring to the historical time-line of notion and implementation of "computational notebook". You are referring to the exposure time-lines of individuals/students.
â Anton Antonov
Sep 8 at 16:00
4
@sunt05 some percentage of the students in my class feel the same way. But the class is not about learning Mathematica or learning python, but about image processing. One thing python lacks is the easy interactivity of Mathematica, which is really key when examining many different variations on parameters, filters, and processing methods. I'd be happy to see an answer from you with more python-esque analogies
â bill s
Sep 10 at 21:17
7
Perhaps analogies are more harmful than helpful beyond a certain point. They might encourage students to think in Python and try to translate their Python solution directly to Mathematica. That often results in a hideously complex and inefficient solution. An alternative approach would be to show how certain basic tasks are accomplished. Describe those basic tasks in English, not in Python. The tasks should be chosen based on what is taught in your course, and what mistakes student most commonly made in past years.
â Szabolcs
Sep 11 at 13:51