# 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.

501 questions
Filter by
Sorted by
Tagged with
74 views

### Condition inside pure function

Why condition /; not work inside pure function? Suppose we have: ...
98 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 ...
248 views

### How can I use WhenEvent with multiple conditions inside NDSolve?

I would like to use WhenEvent but I'm not getting what I want: I set the initial condition var\epsilon=0; I want var\epsilon to change continuously over time, from to 0.1 if s'[t]>=0 or to -0.1 if s'[...
288 views

### Join matrix based on conditions

Given the following matrix: ...
40 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 ...
1 vote
360 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, ...
68 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: ...
153 views

### Restrict the domain of a function (and plot) it) when it depends on the value of a parameter [closed]

I know similar questions have been asked, but I am very new at Mathematica and other questions/answers are quite complex and do not suit the code I want to write. I want to restrict the domain of the ...
1 vote
57 views

### Weird behavior of Which with lists [closed]

To demonstrate my problem, let's create a little function: ...
129 views

### Convert list of conditional expressions to list

I have a long list of items of the form ...
79 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 ...
1 vote
207 views

### Nested If question

Using the following code, I got the first two piecewise equations right but the third one returns -99. ...
55 views

### Efficient and compact replacement for Association in the following case

Consider the following association: ...
74 views

### How to minimize computational time in an if condition?

I have a code as below: ...
295 views

### Why does Select not work here?

Why does this not work? It returns empty while I expect the first two elements are selected. ...
137 views

### How to check if solution to NSolve exists?

I'm trying to created a table where the entries are values of x, either given by x/.NSolve[...][[1]] or a fixed value x0 if there is no numerical solution. Is there a way to find the truth value for ...
142 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$ ...
1 vote
89 views

### Selecting only one out of many: Differential equation

I have the following code: ...
112 views

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

I have the following code: ...
116 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}] ...
43 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....
96 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 ...
150 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 ...
81 views

1 vote
70 views

### Table mix with If function [closed]

Anyone could explain to me which problem is? after running the function "Table" combining with "If" as below, but the result is not a value instead. ...
99 views

### How to find that this be always real number

I don't know how to find out this is be real number for l[y]? ...
117 views

### Unexpected behaviour of Condition with Cases/MatchQ?

When using the unsorted version of Complement in this question I met the following unexpected result, ...
827 views

### How to generate a list of random numbers with conditional statements

I want to generate a list of numbers with certain conditions. Eg. First I generated 10 random numbers between 1 and 20. M1= RandomReal[{1,20},10] Now I want to ...
93 views

...
1 vote
122 views

...
1 vote
110 views

### Conditional mathematical expression [closed]

I want to produce A, B, C, D and E values between 0 and 2*pi with two conditions: A!=B!=C!=D!=E And (C,D,E)!=n*pi/2 n is an ...
89 views

### If or Piecewise dependent coefficients in NDSolveValue

This: but the following (placing the partials inside the If) does not. Any suggestions?
213 views

### Modify list elements if last two entries are equal

Suppose I have a list as follows {{1, 1, 1, 1, 1, 3}, {1, 1, 3, 4, 1, 1}} and I want to check the last two coordinates are equal or not. If that is the case then I ...
51 views

### Plotting a conditional expression

I'm trying to plot the feasible region of a maximization problem with PlotRegion3D. This region is the intersection of two constraints and I'd like to plot also the ...
76 views

### Select with simplification does not work

Given a list, I want to find all elements that have positive imaginary part. For example, if $y,z\in\mathbb R$ and $a>0$ and the list is $\{ ia+y, -ia+z\}$, then the result should be $\{ia+y\}$. ...