Questions tagged [code]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
3 answers
318 views

Saving formatted code [closed]

I am writing some ODE notes with lots of pictures generated using Mathematica, and I'd like to include the code used to generate them. Currently I have a notebook where all the pictures are generated. ...
Mariano Suárez-Álvarez's user avatar
3 votes
1 answer
72 views

Hiding code in presentations programmatically

A number of discussions is dedicated to hiding the code/input in presentations or notebooks. It is very simple to hide the input by hand. I could not find, if it is possible to hide input by the code ...
Konstantin's user avatar
0 votes
0 answers
45 views

Matrix subtraction not working [duplicate]

I am using Mathematica to solve a hw question. I have the following code: ...
zaza sea's user avatar
1 vote
0 answers
91 views

Solve system of ODE by fractional finite difference method

I am trying to solve the following system using fractional finite difference method: where e=0.1, a=1.3, m=0.3, p=10, g=3, k=1 and s1, s2, s3 it was mentioned in this paper that it is calculated ...
ahmed's user avatar
  • 75
0 votes
0 answers
44 views

How to solve this Third Order PDE using NDSolve; Showing some missing variable error

I just confuse why ***u[0,t]==Sin[\omega t] cannot be used as a variable error was showing ...
FDMEM's user avatar
  • 19
0 votes
0 answers
53 views

Part specification error

I am doing a solved exercise shared here. However, while running the code, I encountered an error on page-8, under the Dynamics section. with error : I think this error is due to the absence of ...
user444's user avatar
  • 2,126
-2 votes
1 answer
66 views

How can I calculate the negativity?

I tried to calculate the negativity that is defined as follows: $eq(1): N = Tr(Sqrt(A.A\dagger))-1$ The result should be ~0.41 in for example r~0.01 (when r is close to 0) and it decreases versus r. ...
reza's user avatar
  • 103
0 votes
1 answer
53 views

How to find a conditional solution of inequalities?

Im trying to find the conditions of: a>0,b>0,c>1,d>0 (a + (2 a - b/c) d + (a + b - b/c) d^2 + (-b + (2 b)/c) d^3 + (b d^4)/ c - (b d^5)/c) > 0 I ...
Adel 's user avatar
1 vote
2 answers
228 views

Order of Terms in Algebraic Expression

When I write an algebraic expression of the following form, B*OverBar[A]*C^3 + A*OverBar[C]*B B C^3 Overscript[A, _]+A B Overscript[C, _] the order of the ...
SciJewel's user avatar
  • 369
0 votes
1 answer
93 views

Why can't the denominator be rationalized for such a result?

The root formula of the output is rational for denominator, and the result of FullSimplify output is the same. ...
csn899's user avatar
  • 3,625
1 vote
1 answer
263 views

Stepped Infinite Square Well [closed]

Here is the link for making the above graph for the Stepped infinite square well. The problem here is, all the eigenfunctions and energy eigenvalues are previously defined. Whereas, I want to use this ...
user444's user avatar
  • 2,126
1 vote
2 answers
76 views

Defining and executing large matrix operators on vectors efficiently

For an $N$-qubit system, I am interested in coding, in an efficient way, the following set of Kraus operators $\{A_c\}_c$ defined in the computational basis as \begin{align} \hat{A}_c := \sum_{m=...
John Doe's user avatar
  • 329
3 votes
2 answers
239 views

Finding a subset in the set of the digits of Pi

Well, I want to find the first position where the digits of Pi are {a,b,c,...,z}. So to find the first n digits of Pi and put them in listform I used: ...
Jan Eerland's user avatar
  • 1,941
3 votes
3 answers
268 views

Graphic manipulation - Psychrometric chart

I'm working on a psychrometric chart on Mathematica. The code is as follows: ...
Julio Araujo Dos Santos's user avatar
1 vote
2 answers
234 views

Can we solve the following integral by MATHEMATICA?

I am trying to solve the integral using the following Mathematica code. f1 = (t[m + 1] - t)^(\[Alpha] - 1)*(t - t[m - 1])*(t - t[m - 2]); ...
user avatar
-1 votes
1 answer
50 views

Swap Composite Command Components

Let's take a composite Mathematica command: A[B[]] where A and B - two arbitrary ...
dtn's user avatar
  • 2,394
-1 votes
1 answer
41 views

Using barchart on outputs [closed]

I want to use barchart to make a plot with a series of outputs from the given command max1={max, arg} = NMaximize[{solutionI[t], 0 < t < 100}, t] here it is ...
Vangsnes's user avatar
  • 571
0 votes
0 answers
74 views

How do we define the function near the end of my post?

Suppose I have two sets $F_{1,n}$ and $F_{2,n}$ written as: ...
Arbuja's user avatar
  • 39
7 votes
2 answers
584 views

Help understand a line of code

this is a weird question, but I read the following line of code: ...
diegor's user avatar
  • 93
0 votes
0 answers
39 views

Problem with ToExpression and TexForm changing two variables multiplied together into one multi-lettered variable

I have a problem where if I multiply two variables a c in Mathematica, then copy as LaTeX (or just use the Mathematica output) to get a c, then put it in ToExpression["a c",TeXForm], I get ...
Tom00496's user avatar
1 vote
1 answer
113 views

How do we find the limit of my code?

Suppose we have the following: ...
Arbuja's user avatar
  • 39
2 votes
1 answer
95 views

Strange effect in the SphericalPlot3D [closed]

I found something odd in Mathematica when using the SphericalPlot3D command. Ranges for $x,y∈[0,2 \pi]$ are the same. All I do is swap sine and cosine. But when I ...
dtn's user avatar
  • 2,394
1 vote
1 answer
89 views

Separating terms in an expression with many variables by their "nature"

I have an expression like this: $f=t_1(\sin(\alpha),\cos(\beta),\cos(\gamma)^2) \cdot r_1(x,y,z)+t_n(\sin(\alpha),\cos(\beta),\cos(\gamma)^2) \cdot r_n(x,y,z)$ Where $t_i$ and $r_i$ - functions of ...
dtn's user avatar
  • 2,394
0 votes
1 answer
42 views

Updating the association with answers from the TrigProperties Function

I have created a list of rules I would like to update with values. My goal here is to be able to write the following: ...
Brandon Evans's user avatar
2 votes
2 answers
97 views

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

Could anyone please help with effectively defining a vector-valued function of tons of variables so that ...
mathlive1's user avatar
1 vote
0 answers
48 views

Help me understand a part of this code (using Clock) [closed]

I'm a begginer in Mathematica and I need help understanding a part of some code that I took and adapt from another question in this forum. The code is to animate one by one a list of points (with x,y ...
Alberto Sierraalta's user avatar
1 vote
0 answers
107 views

How to solve ODEs using deep learning in Mathematica [closed]

I have a number of ODEs (58) with 16 parameters and 9 variables. I want to solve the ODEs to obtain the analytical relationship between the parameters and variables. It is obviously that the ODEs ...
Miaoxiao Wang's user avatar
0 votes
1 answer
51 views

FoldList type evaluation for multivariable function

In the example code which follows I define a two variable conditional function h[_i, _v], one variable denotes the integer index i, and the other is an N-dimensional vector v (I denote dimension 'N' ...
John Doe's user avatar
  • 329
1 vote
0 answers
73 views

How can I access Mathematica on a more powerful machine remotely? [closed]

I have Mathematica installed on my machine. My code is taking a long time. It could be owing to my machine strength. Is there a way to run my code remotely on a cloud?
F. A. Mala's user avatar
0 votes
1 answer
164 views

The list of coefficients of the "polynomial", which has the order of derivatives instead of degrees

I have some equation eqn = (A + B).x''[t] + Transpose[x'[t]].(2 A - 3 B + 1).x'[t] +(СС - 5).y'[t]+ Sin[x[t]+y[t]] I need to collect all the coefficients at ...
dtn's user avatar
  • 2,394
0 votes
1 answer
33 views

How to resolve problem during summation of functions?

I am trying to find out the output of this basic problem but getting an error. If anyone can resolve this will be helpful. ...
vini's user avatar
  • 83
4 votes
1 answer
166 views

A system of nonlinear ODEs

I am working with Mathematica to plot a system of Nonlinear ODEs, I did a program but it doesn't work. I don't know exactly where is the problem? If someone kindly can help with a remark or a ...
Kamal Khalil's user avatar
0 votes
0 answers
299 views

How to convert a Python code to a Mathematica code?

I've written the following code in Python. I want to write this code in Mathematica but I don't know Mathematica. How can I convert this code to a code in Mathematica? Thanks in advance. ...
M.Ramana's user avatar
  • 101
1 vote
0 answers
55 views

Show Code Assist

I want to cancel the Auto Popup in the options menu. It turns to False but when I come back to the code it turns to true again. I clicked in Apply. I need to turn it off because it sometimes does not ...
Hadi's user avatar
  • 11
1 vote
0 answers
73 views

Need help understanding a chunk of code [closed]

...
Ma. Fernanda Robles Hernández's user avatar
2 votes
1 answer
63 views

Counting the number of elements

I have the following output: {{{0, 1}}, {{1, 1}, {1, 2}}, {{2, 1}, {2, 3}}, {{3, 1}, {3, 2}, {3, 3}, {3, 4}}} Using Length[] on ...
Jan Eerland's user avatar
  • 1,941
1 vote
2 answers
77 views

To write mathematica code for summation using a given data

I am given a set like some terms from the partition of $20$: $\{\{17, 3\}, \{13, 7\}, \{11, 3, 3, 3\}, \{7, 7, 3, 3\}, \{7, 5, 5, 3\}, \{5, 5, 5, 5\}\}$. From the above data, $20= \underline{1}*17+\...
user75105's user avatar
5 votes
3 answers
422 views

How to programmatically modify a function definition

I would like to know an efficient method (without converting Mathematica Code to strings and string processing) of modifying a function definition programmatically. For example, I would like to tidy ...
Iconoclast's user avatar
1 vote
2 answers
67 views

Filtering solutions in PowerRepresentations

I have the following code: PowersRepresentations[10400, 7, 2] This produces Length[PowersRepresentations[10400, 7, 2]]=433789 ...
Jan Eerland's user avatar
  • 1,941
2 votes
1 answer
110 views

Getting two different results for the same computation

I have the following two codes: ...
Jan Eerland's user avatar
  • 1,941
2 votes
0 answers
65 views

Microcontrollerkit No longer compiles code after update

I recently restarted a project where I used MicrocontrollerKit to generate code for me into the Wiring language to be then imported into arduino IDE for editing and ...
DrMrstheMonarch's user avatar
0 votes
0 answers
52 views

How to deal with unknown variables in NSolve?

I am trying to solve these equations by using NSolve and want to plot $p1^{2}+p2^{2}$ v/s P0. But there is some problem, it is showing running... but not showing any error. I don't know where I am ...
vidya's user avatar
  • 35
1 vote
1 answer
117 views

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

How do you see the code form of a command in Mathematica? I know there is a command in Mathematica, "Unprotect[]", but how do you actually use this?
Krishiv SURESH's user avatar
1 vote
1 answer
54 views

Formatted/modified Mathematica command

I know there is a way of making your own commands that outputs your desired information but I'm not sure how to do this. How do you format/modify/make your own command that outputs what you want. E.g. ...
Krishiv SURESH's user avatar
2 votes
1 answer
116 views

Implementing binomial expansion of (non-commuting) matrices in Mathematica

Given two matrices $A$ and $B$, their Binomial expansion is, in general, given by (see this page) $(A+B)^n = \sum\limits_{k=0, k=n[2]}^n \Bigg( \sum\limits_{r=0}^k \binom{k}{r} A^r B^{k-r} \Bigg) \...
Rob's user avatar
  • 423
0 votes
0 answers
77 views

Alternative to Coefficient List

I was using CoeffientList to get the probabilities of this generating function... ...
PiE's user avatar
  • 437
5 votes
3 answers
756 views

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

Well, I have the following question: How can I write a program such that an input number $n$ is divided by the number $k$ as long as the resulting number does not have one digit, if the resulting ...
Jan Eerland's user avatar
  • 1,941
2 votes
0 answers
351 views

How to use Mathematica code in LaTeX files?

How can you use Mathematica code in LaTeX files? any similar to A random number is RNUMBER and the square of RNUMBER is RNUMBER^2 appearing numbers instead the capital letters (or Mathematica code) ...
Mika Ike's user avatar
  • 3,201
0 votes
0 answers
86 views

How can I wirte Mathematica code in microsoft word

What I am trying to do is write Mathematica code in Microsoft word because I am doing like tutorial, so how can I insert code with the form in the picture. As an alternative what I am doing is to ...
Las Des's user avatar
  • 807
0 votes
1 answer
84 views

How to plot the roots of two complex equations?

I have these two equations as two variables '$a1$' and '$b1$', mentioned below and I want to plot the roots of $a1^{\dagger}*a1$ with respect to P0, which will give me bistable plot with three values. ...
vini's user avatar
  • 83