Skip to main content

Questions tagged [coding-style]

Questions on how to write code in a better or different style, using Mathematica's capabilities for coding in multiple styles.

Filter by
Sorted by
Tagged with
5 votes
1 answer
447 views

Recently, I have been struggling with the task of writing a Mathematica programming tutorial for my graduate students. My goal is to teach my students how to use Mathematica for complex scientific ...
Sophia Thary's user avatar
-1 votes
2 answers
119 views

data = Range[10]^2 Table[Style[data[[n]], FontSize->data[[n]]], {n, Length[data]}] I understand that the above can also be coded in one line. But I could do so ...
Splendid Digital Solutions's user avatar
2 votes
1 answer
257 views

I have a problem of finding the shape of a current. please see the details here NDSolve does not accept the boundary condition I wrote a code but it gives the "ndnum" error. I tested the ...
AWer's user avatar
  • 35
0 votes
0 answers
107 views

I am new at Mathematica and trying to solve a nonlinear PDE with the help of NDSolve. H, the height of the current is a function of x and t. Based on the context I know the current has a parabolic ...
AWer's user avatar
  • 35
1 vote
1 answer
156 views

I don't know how to make the code editor in Mathematica present the code in a real 'monospace' font, with a dark, customisable theme (syntax highlighting and so on). This is something that keeps me ...
Vicent's user avatar
  • 1,141
0 votes
1 answer
156 views

I am trying to make graphs given by using this code but I failed. Please correct this code. ...
riaz iram's user avatar
1 vote
3 answers
148 views

Question: How do we label point coordinates in Pathgraph using VertexLabels. Suppose we have a list of points ...
Arbuja's user avatar
  • 81
1 vote
3 answers
396 views

Suppose we want an interactive plot for the code: ...
Arbuja's user avatar
  • 81
7 votes
4 answers
943 views

I wrote some Mathematica code that defines a function I want to use repeatedly (f) inside another function (finit) that pre-...
jjoIV's user avatar
  • 303
0 votes
0 answers
144 views

I looked up the Wolfram Language on Codewars as the site is great to improve coding. WL is not among the listed languages (I checked the beta versions as well). I assume this is because the language ...
ExpressionCoder's user avatar
9 votes
1 answer
206 views

I was wondering if there were any important differences or stylistic considerations for deciding between different ways to define functions of multiple variables, e.g. ...
Diffycue's user avatar
  • 1,973
2 votes
2 answers
412 views

For example like so. x = 10; xi = 11; xv = 15; Is there an automated way to spit these numbers out maybe 1-1000.
William's user avatar
  • 7,675
8 votes
6 answers
909 views

I would like to know if there is a direct way to remove the rules from a list of rules. I know that, simply, this can be done with: ...
Joshua Salazar's user avatar
8 votes
4 answers
590 views

Recently I have met with with this interesting question:How can I efficiently define functions with different names but doing the same stuff? Somebody may want to ask me why I want to do things like ...
AlbertLew's user avatar
  • 493
1 vote
2 answers
169 views

I have lots of definitions of (usually numeric) quantities that depend on parameters; they're mostly matrices (in the actual code, there are many more definitions): ...
Deniz's user avatar
  • 329
-1 votes
1 answer
141 views

I am trying to find the $n$-th derivative of $\csc(m\pi)$, so I took few cases: for simplicity let $x=\cot(m\pi)$ and $y=\csc(m\pi)$, $$\frac{d^0}{dm^0}\csc(m\pi)=\pi^0(\color{red}{1}x^0y^1)$$ $$\frac{...
Ali Olaikhan's user avatar
0 votes
1 answer
138 views

We know that the Euler numbers $(E_r)$ has many integral and series representations but I am wondering if there is a simpler Mathematica command.
Ali Olaikhan's user avatar
3 votes
4 answers
450 views

Is there a nice way in Mathematica to express the equivalent of Switch where statements (not cases) fall through? Here is a toy example in C: ...
Bob Werner's user avatar
2 votes
0 answers
214 views

I wondered whether there is a known formatting guide that Wolfram employees (have to) use when writing Mathematica code? As stated in Mathematica style guide? there are many different formatting ...
Gert's user avatar
  • 1,783
5 votes
0 answers
261 views

What does "Analyze Notebook" and "Analyze Cells" do? They seem to, at least, point out some coding errors that are already highlighted in a notebook. Do they do anything else? Is ...
Just Some Old Man's user avatar
0 votes
0 answers
253 views

At first, I was surprised that Mathematica doesn't have a built-in function for this, e.g. JordanMatrixQ. Anyway, we all know that a Jordan matrix is consisted of ...
polfosol's user avatar
  • 964
0 votes
1 answer
75 views

I have the following: ClearAll["Global`*"] n= 3; T = Transpose[Table[{t^i}, {i, 0, n}]]; B = DiagonalMatrix[Range[n], 1, n + 1]; Print[ T, B] I want ...
user62716's user avatar
  • 807
3 votes
0 answers
297 views

I've parsed (almost verbatim) Python RPCA implementation to WM. Can it be rewritten using a better WM style? In particular, I'm not happy with ...
I.M.'s user avatar
  • 3,516
2 votes
1 answer
234 views

I am trying to see if Mathematica can calculate: $$\int_0^1\frac{\ln(x)\ln(1-x)\ln(1+x)}{x}dx,$$ which has a closed form found here. So I tried ...
Ali Olaikhan's user avatar
0 votes
1 answer
618 views

I have an equation for the effective potential for a neutral particle (non-spinning), i.e. VeffNonSPIN[r_, θ_] := (1 - 2/r)*(1 + LL^2/(r^2 Sin[θ]^2)); If I take ...
MMS's user avatar
  • 171
6 votes
1 answer
252 views

With respect to code readability I like the possibility to use keyword (named) arguments. I would like to have this under Mathematica, but AFAIK there is no native support for that. By example, to ...
Picaud Vincent's user avatar
0 votes
1 answer
109 views

Question: I need to move the point Fun1 to 10 positions in the interval [-3,0), and have the drawing updated each time (including the tangent and intersection points). I don't know how to add Fun2-...
Qy Ln's user avatar
  • 69
2 votes
1 answer
175 views

Here is a link to my previous question Question about plotting a curve and tangent lines I want to know how can the area be found between the curve and tangent line for between Point Fun1 and Fun2....
Qy Ln's user avatar
  • 69
4 votes
3 answers
751 views

This is a Mathematica question. I have a function $y=x^3$. “Fun1” is any point on the curve. At the point Fun1, draw a tangent line at that point to the curve. At another point where the curve and the ...
Qy Ln's user avatar
  • 69
0 votes
1 answer
100 views

...
Aran's user avatar
  • 373
0 votes
1 answer
109 views

How can I find the tangent at the point $(2,8)$ to the curve $y=x^2+4$ on Mathematica? How can I show the tangent of the curve at the point and I need to mark the point where they meet with the word &...
Aran's user avatar
  • 373
3 votes
0 answers
167 views

I'm reading the book Mathematica® programming: an advanced introduction by Leonid Shifrin and there is a very nice evaluation. Here is: This, plus a large number of quite generic and efficient ...
Nam Nguyen's user avatar
  • 1,811
4 votes
0 answers
184 views

The problem of Mathematica is there are too many ways to perform one task. That leads to confusion for new users because the performances of these methods are so different. I'm learning the best ...
Nam Nguyen's user avatar
  • 1,811
5 votes
2 answers
210 views

I'm looking to see if there's a more idiomatic/concise/neat solution than what I have for this. I have a list of boxes with heights and I want to stack them; that is, add to each box the distance to ...
Matt Murphy's user avatar
1 vote
2 answers
110 views

...
Aran's user avatar
  • 373
2 votes
0 answers
70 views

Consider 3 functions f, g and k Suppose we want to know for 3. functions from P={(x, y )|x=-1,-0.9,-0.8,-0.7....,1 and y=-1,-0.9,-0.8,-0.7....1 this is what i have so far ...
Aran's user avatar
  • 373
4 votes
1 answer
269 views

I am a novice so imagine my confusion with Mathematica's very poor error and trace messages. Debugging should be an easy thing to do even for beginning programmers but not with Mathematica. What are ...
Jules Manson's user avatar
  • 2,507
2 votes
1 answer
161 views

Is it possible to shorten the length of a (delayed) rule (i.e. lhs :> rhs) when there are expressions which repeat several times? Those expressions involve ...
abcd's user avatar
  • 483
6 votes
0 answers
114 views

Apologies for a less than ideal question, but if I could have asked a good question the answer would probably have been revealed in the process... In answer to this question @LeonidShifrin gave some -...
Julian Moore's user avatar
  • 2,570
7 votes
1 answer
208 views

I find the old stylesheet UI clunky and hard to use: FrontEndExecute @ FrontEndToken @ "EditStyleDefinitions" There's also the clunky style previewer as well: ...
M.R.'s user avatar
  • 31.9k
2 votes
1 answer
107 views

So I want to be able to put axes labels simultaneously as the numerical labels. I can achieve that with the following, but is there a better/cleaner way? I can't use callout, because I am using ...
ions me's user avatar
  • 1,145
5 votes
1 answer
170 views

So lets say I have a list of spending transactions tlist = {{john,23},{bob,2},{john,7}...} and I want to have a list of the total expenses per person. I can do ...
ions me's user avatar
  • 1,145
2 votes
1 answer
317 views

I am trying to compare two functions on the end points of an interval. For instance, $f_1(t)=t^3$ and $f_2(t)=t^4$. From my code below I check whether $f_1(t)\leq f_2(t)$ when $t=50$ on $[50, 51]$ ...
primefinder's user avatar
5 votes
1 answer
255 views

I have been using Mathematica now for a little over a year...this started off in maybe a modern 'classic' way of having to solve symbolic mathematics and related plus the want to learn a CAS (and more)...
DrMrstheMonarch's user avatar
9 votes
2 answers
446 views

There're two ways to generate a random tree as 1 and 2 below. Both work fine here. So what's the reason to use vtx[] instead of ...
emnha's user avatar
  • 2,151
0 votes
0 answers
40 views

I am creating a code that calculates or approximates $$D(S\cap[a,b])=\lim_{n\to\infty}\frac{\left|S\cap{F_n\cap[a,b]}\right|}{\left|F_n\cap[a,b]\right|}$$ where $D$ is the density of $S\cap[a,b]$ (...
Arbuja's user avatar
  • 81
4 votes
1 answer
160 views

I am creating Euler's method for $\frac{dw}{dt}=(3-w)(w+1)$ for $\Delta t=0.5$ from $0\le t \le 3$. I tried the following. ...
Arbuja's user avatar
  • 81
2 votes
0 answers
115 views

I am working on becoming more and more familiar with MMA and on a scale from one to ten, I would rate myself as a four or a five. I understand vectorization and that loops-are-very-bad. I have ...
Fixed Point's user avatar
3 votes
2 answers
406 views

How can I convert my multiple outputs of a while loop in a table form and save it for later use. Here is a sample code: ...
primefinder's user avatar