Skip to main content

Questions tagged [conditional]

Questions about programming or mathematical constructs that enable verification, selection, or branching behavior when one or more criteria are determined to be True.

Filter by
Sorted by
Tagged with
0 votes
1 answer
42 views

Generate a three-dimensional table with data that satisfy a certain relation between them

I need to generate a 3 dimensional table of two variables x1 and x2 such that for any point x1, x2 must be smaller than x1^2+a^2, where a is some given constant. Something like the following ...
MZP_user's user avatar
2 votes
0 answers
46 views

LaTeX symbols inside Expectation [duplicate]

I use LaTeX in my Mathematica code (using "^+4"), and was surprised that the first line in the code below evaluates correctly, but the second (essentially identical) line does not: ...
Dejan Evisal's user avatar
1 vote
1 answer
63 views

All possible tuples satisfying conditions

Let $\beta = (\beta_1, \beta_2, \ldots)$ be any given sequence of non-negative integers with all but finitely many $\beta_i$ zero. I want to collect all possible tuples $\beta^{\prime}= (\beta_1^{\...
Anantadulal paul's user avatar
0 votes
2 answers
82 views

NExpectation with complex condition

When I run a computation for NExpectation with a condition of the following form -- T>R>P -- the computation runs fine. But when I add another inequality -- T>R>P>S -- it gives me an '...
Paul Studtmann's user avatar
5 votes
3 answers
155 views

Evaluation control of nested With, If and Integrate

Can you explain the behaviour of the following? The first With outputs unevaluated If. So in the second ...
three777's user avatar
  • 188
5 votes
1 answer
213 views

Which NDSolve method is most effective for the given chaotic system?

Note: This question is for those chaotic systems where the order of maximal Lyapunov exponent is around $10^{-3}$. So it's different from normal chaotic systems like Hénon–Heiles system, Yang-Mills-...
codebpr's user avatar
  • 2,423
0 votes
1 answer
59 views

Which of the given codes $p1,p2,p3,p4$ is the correct one for imposing assumption in ContourPlot3D using RegionFunction?

I am using ContourPlot3D for the condition f[x_, y_, z_] ==0 assuming that the assumption ...
PhysFan's user avatar
  • 63
0 votes
1 answer
73 views

Using conditionals for a given function in Mathematica [closed]

I have two versions of a function (A and B) When A fails, I get ...
tommy J's user avatar
  • 21
5 votes
3 answers
218 views

How to highlight top N elements in each table column?

I have tables with column and row headings, similar to this one: table = {{"",0.1,0.01}, {{1,0},1,3}, {{1,1},2,4}} I want to highlight top N elements in ...
homocomputeris's user avatar
0 votes
1 answer
80 views

How to plot the given functions $g$ and $h$ with the assumption $f=0$?

I have a constraint f[a_, b_, c_] ==0 with three parameters $0<a,b,c<3$ where ...
math2021's user avatar
  • 749
0 votes
1 answer
110 views

Problem with If statement

It is a very simple problem but I am confused. A comment is required. I have the following list ...
Tanmoy Pati's user avatar
0 votes
0 answers
40 views

Trouble implementing switching hybrid system with NDSolve

I'm trying to use NDSolve to simulate a hybrid nonlinear system that switches between different linear behaviors based on states and inputs (i.e. switching from one linear behavior to another) which ...
Cameron Alred's user avatar
3 votes
1 answer
141 views

Pattern matching vs. condition in a function

I'm trying to learn stuff from pattern matching but I found sometimes pattern matching does not work as I expected. Could anyone explain why the below outputs are not same? Thank you. And could anyone ...
Josh's user avatar
  • 31
0 votes
0 answers
32 views

How to find clear solution for iterative problem by condition $<v_k ,v_n>=0$ If $k!=n$

I want to find x[n] by v[n] values without x[n] in solution by iterative below problem: <...
user68119's user avatar
0 votes
1 answer
74 views

A simpler way of identifying which elements of Tuples[{0,1,2,3},6] multiply with each of my codewords to give zero?

So I have a list of codewords. The codewords have length 64, so there are 64 codewords in my code. My code is over an alphabet of 4 (the code can be thought of as having four elements $0,1,2,3$ and ...
am567's user avatar
  • 617
0 votes
1 answer
57 views

Creating an If function for the probabilities of the classes of images after using NetTrain

So I have 3 Classes the model can output after veiwing an image, at the moment it has a 70% accuracy, however this is not an issue as the plan is unless it's 85%+ sure on the Probability of the class ...
Lewis Ryan MH's user avatar
4 votes
4 answers
160 views

How to check if at least one ordering of the given row matches one of the rows of a table?

Consider some list of elements ...
John Taylor's user avatar
  • 5,863
3 votes
5 answers
238 views

How to check if the given row matches one of the rows of a table?

Consider some table tabb = RandomInteger[{0, 4}, {5, 4}] and a row row = RandomInteger[{0, 4}, 4] How to check if ...
John Taylor's user avatar
  • 5,863
1 vote
2 answers
100 views

Can you recover the original vectors that, when summed together, achieved a particular criteria

I am wondering if it is possible to take the binary strings of length $3$ (tuples) whose sums have weight $2$ (i.e they have $2$ non-zero entries)(binary case, meaning they have two $1$'s entries) $$u ...
am567's user avatar
  • 617
0 votes
0 answers
51 views

Identify a condition among variables that satisfy an inequality

I have a symbolic function that produces the output a = (1 - e - mu/n) Log[(1 - e - mu/n)/(1 - mu/n)] + (e + mu/n) Log[((e + mu/n) n)/mu] If I substitute ...
Dotman's user avatar
  • 476
4 votes
1 answer
323 views

Confused about If statement [closed]

I have this simple test code: n1 = 0; n2 = 0; m = 0; If[n1 == 0, n2 == 1] which evaluates as False, as it should. However, if I do: ...
Silviu's user avatar
  • 145
2 votes
3 answers
109 views

SetDelayed assignment not producing expected result when using ReplaceAll

In Mathematica, I am surprised that the following code does not do what I expect (what I expect is in comments after each evaluation). The problem seems to be due to the fact that when I define test ...
tyogi's user avatar
  • 297
3 votes
1 answer
81 views

Adapt elements in the list, condition by condition

Could you give me some advice? Suppose I have the following list. box[1,1]={{4.4, {1,1}, {a}}, {1.5, {1,1}, {a}}, {10.8, {2,1}, {3a}}, {10, {1, 3}, {3a}}} I want ...
hare's user avatar
  • 436
1 vote
1 answer
57 views

Redundant cases from Sum

I am new to Mathematica. I would like to understand why Mathematica returns redundant cases, and whether it is possible to simplify them to the generic case $(n>1)$ that covers everything $(n\ge0)$....
Andras Vanyolos's user avatar
3 votes
6 answers
701 views

Make a list of the first 100 primes, keeping only ones whose last digit is less than 3 [closed]

This is a question from an "Elementary Introduction to the Wolfram Language" Section 28: Tests and Conditionals. We are asked to "Make a list of the first 100 primes, keeping only ones ...
am567's user avatar
  • 617
5 votes
1 answer
118 views

Condition inside pure function

Why condition /; not work inside pure function? Suppose we have: ...
lesobrod's user avatar
  • 1,769
3 votes
1 answer
106 views

Compute the area of the union of the intersections of two conditions

I have four conditions over the two-dimensional domain $x,y\in[a,b]$. I want to use NIntegrate to compute the area of the union of the intersection of the two ...
Martha97's user avatar
  • 349
0 votes
0 answers
41 views

Optimization of conditions applying

Let we have some data generator, e.g. lazy tuples or permutations. I need to select data by some conditions cond1, cond2, …, up to 5-6 conditions. All of them need ...
lesobrod's user avatar
  • 1,769
1 vote
2 answers
379 views

Parallelize a "For" cycle

I'm trying to parallelize a simple routine inside a "for" loop. Essentially, I need to compute the roots of a function $f(x)$ that depends on the discrete parameters $d$ and $R_0$. However, ...
Albus Black's user avatar
1 vote
2 answers
59 views

Weird behavior of Which with lists [closed]

To demonstrate my problem, let's create a little function: ...
user16320's user avatar
  • 2,396
6 votes
1 answer
140 views

Convert list of conditional expressions to list

I have a long list of items of the form ...
rogerl's user avatar
  • 4,219
0 votes
3 answers
62 views

Efficient and compact replacement for Association in the following case

Consider the following association: ...
John Taylor's user avatar
  • 5,863
0 votes
2 answers
76 views

How to minimize computational time in an if condition?

I have a code as below: ...
Kazim Ahmet Hasim's user avatar
4 votes
2 answers
335 views

Why does Select not work here?

Why does this not work? It returns empty while I expect the first two elements are selected. ...
internet's user avatar
  • 681
6 votes
2 answers
172 views

Generate all adjacency matrices of size $n=4$ s.t. $a_{ij}\neq a_{ij}$ and $a_{ii}==0$

I want to generate a list of adjacency matrices of size $n=4$ s.t. The diagonal is zero: $a_{ii}=0$ for all $i\in\lbrace 1,2,...,n\rbrace$ There are no 2-cyles, i.e. if $a_{ij}==1$, then $a_{ji}==0$ ...
Adriana LE's user avatar
4 votes
2 answers
118 views

How to discard the repeating elements of a list [closed]

Lets say there is a random list of expressions : a={Sin[x], Sin[3 x], Sin[4 x], Sin[x], Sin[4 x], Sin[x], Sin [5 x], Sin[3 x], Sin[5 x]} Plot[{a}, {x, 0, 2 Pi}] ...
a019's user avatar
  • 867
1 vote
0 answers
90 views

Selecting only one out of many: Differential equation

I have the following code: ...
a019's user avatar
  • 867
0 votes
2 answers
123 views

Selecting the specific values from a table and saving in a table:

I have the following code: ...
a019's user avatar
  • 867
0 votes
0 answers
48 views

Preventing Evaluation of Body of Manipulate

Overall, I am looking for a way to prevent the evaluation of the body of Manipulate until the controls meet a certain condition. For example, consider the following....
Just Some Old Man's user avatar
2 votes
0 answers
129 views

The fastest and most scalable way to write a nested loop

The problem is to find the weights {w1,w2,w3,w4} that satisfy the condition. Which is the fastest and most scalable way (e.g. for 10000 weights) to write this ...
John Matis's user avatar
6 votes
7 answers
353 views

How to select elements from a list of pairs based on first element belonging to a different list?

This is my very first question and I really appreciate this ability and thankful the community. I have two lists and need to select only those pairs from the first list, first element of which is ...
Igor Binder's user avatar
0 votes
1 answer
100 views

Is there any alternative for conditional plot that gives a more precise result in a shorter time?

I have the given function $Func$ and want to have a plot of those domains where $-3\leq Func\leq 3$ in precise details. I am using ...
Phys96's user avatar
  • 361
1 vote
1 answer
147 views

How to plot multiple functions with conditions that assign values of some of them to be greater than the others?

i am trying to plot multiple functions in mathematica but i would like to do this in such a way that the values of two of my functions are always greater than the other two. my functions are: ...
Hamed Kazerouni's user avatar
2 votes
2 answers
86 views

How to speedup comparison in the following example?

I have the following problem: I would like to generate random values of some variable $z$ obeying some distribution, but simultaneously within the interval zmin<...
John Taylor's user avatar
  • 5,863
4 votes
4 answers
189 views

Creating a cycle with conditions

I would like to arrange a gift exchange between 5 people, Alice, Bob, Carl, Danny, and Ellen, and I would like the gifts to be passed in a randomly created cycle (B->C->A->D->E->B), for ...
Wombles's user avatar
  • 792
2 votes
2 answers
187 views

Removing "spikes" in data

Imagine I have a data set which gives me the following ListLinePlot Is it possible to define a function over the data set that removes the "spikes" ...
sam wolfe's user avatar
  • 4,873
0 votes
1 answer
133 views

Check the existence of roots based on parameters

I have a function which has one variable $r$ and two parameters $M,\lambda$. Whether or not the function has roots, depend on the parameters $M,\lambda$. I want to obtain a parameter space such that ...
newtothis's user avatar
0 votes
1 answer
83 views

Remove conditional for ThreeJSymbol [closed]

When I evaluate: Assuming[3 > jj >= 1 && jj \[Element] Integers, ThreeJSymbol[{jj, 0}, {1, 0}, {2, 0}]] it outputs an expression saying that if $3 &...
esches's user avatar
  • 147
0 votes
2 answers
74 views

Is there an alternative way to obtain the given plot directly from the equation $f(a,b,x)=0$? [duplicate]

I have the equation $f(a,b,x)=0$ where the function $f(a,b,x)$ is as follows f[a_, b_, x_] := (x^2 + 2) (Sin[5 a] + Sin[3 b]) - 3 (x^2 + 1) Sin[x] I want to plot ...
charmin's user avatar
  • 1,159
7 votes
3 answers
387 views

How to write a condition for FindMinimum correctly

I would like that, when finding the minimum, the FindMinimum analyzes the variables (x and y) each time and finds q, depending on the current values of x and y. Can I somehow write this condition into ...
Mam Mam's user avatar
  • 1,883

1
2 3 4 5
11