Tag Info

Hot answers tagged code

Accepted

Writing a program that will filter the integer solutions

You can use Solve. Your equation: ...
• 131k

Help understand a line of code

let's use curry one by one. Flatten[Module[{x}, x = #; Join[x[[1]], #] & /@ x[[2 ;; -1]]] & /@ igraph, 1] // Select[Length@# > 1 &]; ...
• 9,978
Accepted

Writing a program that divide numbers until I hit a one digit number

One way might be ...
• 146k
Accepted

Why is my version of Euler's Method not working?

You have to define the recursive increment. (I assume in your code S[w + 1, t] == w + h*S[w, t] is related to that.) ...
• 37.9k

Help understand a line of code

Mathematica's FullForm writes an expression without any abbreviations, not even ones you wish it would use: ...
• 238k

A system of nonlinear ODEs

There are two main problems in your code: A typo in your differential equations: phi -> psi Using the exact DSolve for such ...
• 27.2k
Accepted

Finding a subset in the set of the digits of Pi

Let's set up our parameters: digitCount = 1000; piDigits = First@RealDigits[N[Pi, digitCount]]; testSequence = {7, 9, 3}; You can now use SequencePosition: ...
• 30.2k
Accepted

Hiding code in presentations programmatically

Try with this: ...
• 8,458

Writing a program that will filter the integer solutions

You might try IntegerQ ...
• 54.5k
Accepted

Strange bug in LUP Decomposition

The problem is in these two lines: max = Max[U[[k ;;, k]]]; index = Flatten[Position[U[[k ;;, k]], max]][[1]]; You are looking for the pivoting row, so you have ...

Writing a program that divide numbers until I hit a one digit number

You can also use FixedPointList ...
• 398k
Accepted

How to programmatically modify a function definition

To operate on notebooks Let nb be the notebook you want to alter obtained with NotebookGet[]. For instance, it could be ...
• 238k

How to programmatically modify a function definition

This is my first time wading into metaprogramming in Mathematica, so take this with a pinch of salt. I can get the DownValues of ...
• 25.5k
Accepted

Strange effect in the SphericalPlot3D

We can compare the two cases in Cartesian coordinate. r1[θ_, φ_] = Sin[θ] Cos[φ]; r2[θ_, φ_] = Sin[φ] Cos[θ]; ...
• 76.6k

Graphic manipulation - Psychrometric chart

Add a white domain erasePlot to the plot. ...
• 76.6k
Accepted

...
• 55.6k

Graphic manipulation - Psychrometric chart

You can use RegionFunction option with your boundary function Y[1,T] Note that you don't need to plot each contour separately. ...
• 42.4k

Stepped Infinite Square Well

Having solved the problem with writing the potential, you may use "Eigensystem" to solve this problem (with arbitrary numerical values): ...
• 53.1k

Order of Terms in Algebraic Expression

Let us introduce the following function: ...
• 39.6k

Saving formatted code

You can save the code in the comments of the file. I use ExportByteArray and ImportByteArray to demonstrate but you can convert ...
• 42.4k

How to programmatically modify a function definition

That's not a real answer... But I failed to format it as a comment. Again. You're opening a deep can of worms now, called "metaprogramming". Please search for "metaprogramming" and ...
• 1,345

How to unprotect/see the code of a command in Mathematica

Unprotect[] is there to remove the Protected attribute. This allows the definition of a command to be modified, but doesn't ...
• 10.1k
Accepted

Solving a big system of equations using certain conditions

One way I prefer to go about such problems is using 0-1 programming. So each of the 9 variables gets split into 15 component sub-variables. The components are all 0 except for one which is 1. The all-...
• 59.3k
Accepted

Cantor type iterations in Mathematica

For labeling you can post-process the output to inject Texts: ...
• 398k
Accepted

Finding the 3D-model of a function that is rotated around the x-axis

Try RevolutionPlot3D with option RevolutionAxis -> "X": ...
• 398k

Could anyone please help with defining a vector function of tons of variables?

\$Version "13.0.0 for Mac OS X x86 (64-bit) (December 3, 2021)" Clear["Global`*"] For a variable number of arguments ...
• 160k
Accepted

...
• 160k

Can we solve the following integral by MATHEMATICA?

As mentioned in comment, it is GenerateConditions which sometimes makes it slow. To verify this, do the definite integration by hand and verify it is same as when ...
• 146k