21 votes
Accepted

Can we explain why using `Nothing` twice on a list does not operate twice?

Take a look at Definition[b]. ...
Domen's user avatar
  • 21.9k
20 votes
Accepted

What is a function?

A function is really a mathematical idea. In Mathematica, we can represent, or denote, a function in a few ways. But Mathematica is really working with expressions. ...
lericr's user avatar
  • 26.4k
12 votes

C++' "do ... while" loop equivalent in Mathematica

Version 13.1 introduced the function Until Until[test,body] evaluates body and then test, repetitively, until test first gives True.
Jason B.'s user avatar
  • 67.9k
12 votes

select elements from a list by 0 or 1

Use Pick Pick[{a,b,c},{0,1,0},1]
AsukaMinato's user avatar
  • 9,318
11 votes

Can we explain why using `Nothing` twice on a list does not operate twice?

[Based on the timestamp, it looks like Domen's answer has priority. I'm leaving my answer, because I think it adds some extra flavor, but I don't think there is sufficient reason for these answers to ...
lericr's user avatar
  • 26.4k
11 votes

What is a function?

Clear["Global`*"] Map[#[{2, b}] &, {Reverse}] (* {{b, 2}} *) Or equivalently, ...
Bob Hanlon's user avatar
  • 155k
11 votes
Accepted

How does this code work?

+## stays for Plus[##] and 1 ## for Times[##]. So it ...
azerbajdzan's user avatar
  • 13.4k
10 votes
Accepted

How to find the analytical expression of function f [x] for such a composite function?

...
Bob Hanlon's user avatar
  • 155k
10 votes
Accepted

To Chop or not to Chop

Look at the output of Maximize: Maximize[{x*y + 2*y*z + 6*x, x^2 + y^2 + z^2 == 36}, {x, y, z}] //InputForm {6Root[{-108 - 72#...
Carl Woll's user avatar
  • 130k
9 votes
Accepted

How to use Slater Type Orbitals as a basis functions in matrix method correctly?

Your orbitals are not orthogonal to each other: here I've normalized them with an explicit formula (using FindSequenceFunction to discover it): ...
Roman's user avatar
  • 46.9k
9 votes
Accepted

Why `AsymptoticSolve` doesn't work for a multivariate implicit function?

General remarks It takes manual work sometimes when the starting value for the series cannot be easily determined. Also, for an exact solver like AsymptoticSolve (...
Michael E2's user avatar
  • 234k
8 votes

Floor function returning unexpected value

Machine-precision numbers are stored internally by a 64-bit pattern encoding the IEEE 754 format. Each bit pattern describes a rational number of the form $\pm m\times 2^{e}$ where $m$ is the mantissa ...
Roman's user avatar
  • 46.9k
8 votes
Accepted

Test whether an expression contains a particular pattern

This is a bit more direct: ContainsPlus = Not@*FreeQ[Plus] Examples: ...
lericr's user avatar
  • 26.4k
8 votes
Accepted

Slope-demarcated PlotStyle implementation

...
Syed's user avatar
  • 48.6k
8 votes
Accepted

How to handle the calculation of piecewise functions?

Use g[f[x]] // PiecewiseExpand How to make the definition field display as: x>=0? I do not know offhand without writing special code to post-process it. But ...
Nasser's user avatar
  • 142k
8 votes
Accepted

How to get a Table of pairs (a/b, c/d) where GCD[a,b]==1 and GCD[c,d]==1?

sol = Solve[{GCD[a, b] == 1, GCD[c, d] == 1, 1 <= a <= 6, 1 <= b <= 6, 1 <= c <= 6, 1 <= d <= 4}, Integers]; {a/b, c/d} /. sol
cvgmt's user avatar
  • 69.2k
8 votes

Stopping mathematica from rearranging elements in a list

You can use DeleteElements which came with V 13.1: ...
eldo's user avatar
  • 60.7k
8 votes
Accepted

How to draw an image similar to a periodic function (f [x+1]=2 f [x])?

Edit For x<0,we rewrite f[x+1]=2f[x] to `f[x]=f[x+1]/2; ...
cvgmt's user avatar
  • 69.2k
8 votes
Accepted

How to use the symmetry of a function to find the analytical expression of a function on a certain interval?

f[-x] == -f[x] means that the graph is point reflection respect to {0,0}. f[1-x]+f[1+x]==2 ...
cvgmt's user avatar
  • 69.2k
7 votes
Accepted

How to keep lines on boundary or inside a region?

...
kirma's user avatar
  • 19k
7 votes
Accepted

Sorting a List Based on a Given Order

If order is not a very large list: ...
Domen's user avatar
  • 21.9k
7 votes
Accepted

ConjugateTranspose[#] vs Conjugate[Transpose[#]] for lists

Hm. This might also be version dependent. I recall that some time ago it caused an error to call Transpose on a vector. With Mathematica 13.2, all the results of ...
Henrik Schumacher's user avatar
7 votes

Adding Edge and Vertices to already made graph?

You can add new vertices/edges using EdgeAdd, and use GraphEmbedding[hc] to compute the desired vertex coordinates for new ...
kglr's user avatar
  • 392k
7 votes

How to visualize point movements across multiple plots using Manipulate or something similar?

fx = Table[{t, Sin[t]}, {t, 0, 2 Pi, 2 Pi/64}]; fy = Table[{t, Sin[2 t]}, {t, 0, 2 Pi, 2 Pi/64}]; fxy = Transpose[#[[All, 2]] & /@ {fx, fy}]; Transform the ...
kglr's user avatar
  • 392k
7 votes

Applies f to all locations other than the specified location

1. ClearAll[mapWithExceptions] mapWithExceptions[a_, f_, e_] := MapAt[f, a, Map[List] @ Keys @ KeyDrop[e] @ a] Examples: ...
kglr's user avatar
  • 392k
7 votes
Accepted

How to invert this function when the argument e is small?

As @userrandrand suggests, series-expand the function in $\epsilon$ and then invert the series: ...
Roman's user avatar
  • 46.9k
7 votes

How to draw an image similar to a periodic function (f [x+1]=2 f [x])?

Plot[With[{qr = QuotientRemainder[x, 1]}, 2^First[qr] Last[qr] (Last[qr] - 1)], {x, 0, 3}]
Goofy's user avatar
  • 2,572
7 votes
Accepted

How to fit function with data?

Provide initial estimates for a and b ...
Bob Hanlon's user avatar
  • 155k
7 votes

How to fit function with data?

NonlinearModelFit default settings work ok with simpler model and thena and b can be derived,...
ubpdqn's user avatar
  • 60k
7 votes

Finding Saddle Points

...
MarcoB's user avatar
  • 66.6k

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