Skip to main content
93 votes

General strategies to write big code in Mathematica?

Preamble I had a talk devoted specifically to this topic, on Second Russian WTC in 2014. Unfortunately, it is in Russian. But I will try to summarize it here. Since this post is becoming too long, I ...
Leonid Shifrin's user avatar
78 votes
Accepted

General strategies to write big code in Mathematica?

Managing the complexity, II: controlling complexity on the smaller scale There are a few things you can do to control and reduce the complexity of your code, even on the small scale - long before you ...
Leonid Shifrin's user avatar
47 votes

What are some common issues with fitting functions to data?

First, let's enumerate some of the functions: Fit[] is the simplest of fitting functions. It has been introduced in v5, and hasn't been updated since v6 (as of v11)...
Feyre's user avatar
  • 8,597
44 votes

General strategies to write big code in Mathematica?

Here are some advices from my experience. Explore new ideas with the Mathematica frontend. Don't hesitate to use sections and subsections in the frontend to structure your work and experiment various ...
faysou's user avatar
  • 11k
40 votes

Is manual adjustment of AccuracyGoal and PrecisionGoal useless?

Introduction The first section below can be found in standard numerical analysis textbooks. Most current textbooks seem to assume a working environment such as MATLAB or a programming language such C,...
Michael E2's user avatar
  • 237k
39 votes

General strategies to write big code in Mathematica?

Managing the complexity III: using powerful abstractions In this section I will list a few techniques which allow one to write more modular code and better separate the concerns, by using certain ...
Leonid Shifrin's user avatar
37 votes

Q&A Mathematica v.11 Neural Networks: A comprehensive look at Layers, Net Functions, and pioneering into this [[experimental]] code

Thank you for your summary. I would like to clarify and correct a few of your points. however, Mathematica - being proprietary - does not make it clear as to which algorithms they choose to use to ...
Sebastian's user avatar
  • 3,479
26 votes

General strategies to write big code in Mathematica?

This answer is based on the original poster's statement that he has been using Mathematica for six months, and is now trying to build something a bit more complex. I do not take this to mean a large ...
C. E.'s user avatar
  • 70.7k
21 votes

What are the most common pitfalls awaiting new users?

Fourier transforms do not return the expected result Many users know a particular definition of the Fourier transform. When Mathematica returns an unexpected result and users cannot comprehend what ...
21 votes
Accepted

Package organization

The key point is not to set the usage message between BeginPackage and Begin["`Private`"], but just to mention the symbol. A ...
Szabolcs's user avatar
  • 235k
21 votes
Accepted

Custom atomic expressions - modern tutorial

I have a new package for speeding up the construction of things like these which I discuss at the end Atomic vs Valid These are two related but distinct concepts. The former indicates that we can't ...
b3m2a1's user avatar
  • 46.9k
19 votes

General strategies to write big code in Mathematica?

As Leonid mentions in one of his answers one of the methods of managing complexity is using Domain Specific Languages (DSLs). In this answer I will provide links to documents, packages, blog posts, ...
Anton Antonov's user avatar
19 votes

Q&A Mathematica v.11 Neural Networks: A comprehensive look at Layers, Net Functions, and pioneering into this [[experimental]] code

Layers BatchNormalizationLayer There are several layers introduced in v.11 that can not be used uninitialized, this is one of them. Input must be either a rank 1 or rank 3 tensor. To be honest, I do ...
SumNeuron's user avatar
  • 5,422
18 votes

Package organization

It is possible, your code works. I don't see any downsides which aren't a matter of taste. I like to keep usages next to definitions too. But I hate using full names, you can just mention symbols in ...
Kuba's user avatar
  • 137k
18 votes

Unexpected behaviors in built-in functions

...Q functions that can return something else than True or False TL;DR; Those exceptions ...
17 votes

General strategies to write big code in Mathematica?

Use an IDE like Workbench and remember good software development practices Take a look at workbench which is a branded version of Eclipse, a very common Integrated Development Platfom (IDE). On the ...
gwr's user avatar
  • 13.5k
17 votes
Accepted

Working with DynamicModule: SetDelayed + OwnValues

J. Fultz' answer indicates that it is not a bug but a feature which needs better documentation. Get a habit of defining your procedures with [], e.g. ...
Kuba's user avatar
  • 137k
15 votes

General strategies to write big code in Mathematica?

(This answer is complementary to those of faysou, C. E., and Leonid Shifrin. It corresponds to one of the methods mentioned but not covered in the answer of Leonid Shifrin.) For large development ...
Anton Antonov's user avatar
15 votes

What are the most common pitfalls awaiting new users?

Understand the difference between Set (or =) and Equal (or ...
15 votes

How to use the Testing Notebook to test a package without shadowing?

What R.M. answer means is that Get as a part of the test will not help. The reason is that the content is parsed before Get is ...
Kuba's user avatar
  • 137k
15 votes
Accepted

Internal DynamicModule steals scope of external DynamicModule

This answer builds on @AlbertRetey's answer where, in the comments, you wanted some guidance as to how Wolfram creates robust controls. Think very carefully about the division of labor between the FE ...
John Fultz's user avatar
  • 12.6k
14 votes

General techniques for creating complex animations

If you have recurring requirements, such as stringing together multiple animation segments in sequence, it makes sense to write some helper code to deal with things like timekeeping. You can decide ...
Simon Woods's user avatar
14 votes

Q&A Mathematica v.11 Neural Networks: A comprehensive look at Layers, Net Functions, and pioneering into this [[experimental]] code

Thank you for the extensive summary on layers. There are some points I would like to fix, in addition to @Sebastian 's response. In CatenateLayer It is the Net ...
JungHwan Min's user avatar
  • 4,674
13 votes

What are the most common pitfalls awaiting new users?

Association/<||> objects are Atomic and thus unmatchable before 10.4 ...
13 votes

What are the most common pitfalls awaiting new users?

How to work always in WYSIWYG mode? How to get in PDF format exactly what I see in my Notebook? It is counterintuitive and undocumented, but Mathematica by default prints to PostScript printers and ...
13 votes
Accepted

Good clearing practices

I'd like to summarize the discussion that took place in comments, since I think this is an important question, and a common source of frustration when lingering definitions cause weird behavior that ...
MarcoB's user avatar
  • 67.3k
13 votes

Q&A Mathematica v.11 Neural Networks: A comprehensive look at Layers, Net Functions, and pioneering into this [[experimental]] code

Useful functions NetExtract This is probably one of the more important functions. I mean, your weights are the nuts and bolts of your network. It has two arguments, net and then layers you want. You ...
SumNeuron's user avatar
  • 5,422
13 votes

What are some common issues with fitting functions to data?

@Feyre's answer is excellent. I would add the following two items: 1. Overparameterizing a model. When a model has parameters that are not estimable, errors and convergence problems arise. For ...
JimB's user avatar
  • 41.9k
12 votes

Guidelines for planning custom GUI in Mathematica

Things to keep in mind when developing complex GUI in Mathematica: Wolfram System general issues: Styles management/inheritance system (StyleSheets and friend) It is complicated, full of exceptions ...
12 votes

What are the most common pitfalls awaiting new users?

Omitting ; can cause unexpected results in functions A missing ; somewhere inside a function is my number one reason for time-consuming debugging because there are no error messages indicating that ...

Only top scored, non community-wiki answers of a minimum length are eligible