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

371 questions
Filter by
Sorted by
Tagged with
43 views

### How to carry out a different function based on weighted probabilities

I am looking to carry out a function based on weighted probabilities I have looked at using If[] and random numbers but ...
2k views

### How to define conditional function with Mathematica?

How to define conditional function $f(x,y)$ with the following result. If $x=1$ and $y=0$ then $f=77$, if $x=0$ and $y=1$, then $f=66$, if $x$ and $y$ are all other integer values then $f=0$. How to ...
89 views

### Why does conditional NExpectation fail for a multivariate distribution?

To give an example for a multiparametric distribution let us take a binormal distribution: ...
49 views

### behavior of functions with parameters inside arguments

I don't understand this behavior: why does Limit[z/(z - a), z -> 0] give zero and not a condition depending on a, provided it ...
38 views

### Reduce: number of available solutions changes and I want to pick the lowest

I have an equation that has no analytical solution and can have multiple roots. I am focusing on Real roots that are in the (0,1) interval. For example: ...
89 views

### Cases with condition vs Select inside Manipulate

I tried to plot integer points that fall into a 2D region that's dynamically changed. So I resort to Cases and Select, but ...
83 views

### Conditional Programming

I need help creating a function that takes 5 integer inputs and does the following: If exactly 2 or 3 of the first four inputs are not divisible by the last input I want the output to read “...
123 views

### Problems with If condition when Pochhammer symbols are zero

There is a formula for the hypergeometric ($_2F_1$) that expresses it as a sum of Pochhammer symbols, times something that reads _2F_1(a,b,c;x) = \sum_{i=0}^{\infty} \frac{(a)_i (b)_i}{(c)_i} \frac{...
93 views

### Using If condition to replace columns of a matrix

I have two matrices: ...
1k views

### Define a function with a condition

I defined a function u[y]. ...
1k views

### Using “If” statement to change a list values

I have a question that would be pretty trivial in almost any other language but is giving me a massive headache in Mathematica. I am trying to construct an If statement check on one variable that I ...
406 views

### Can For loop be used with multiple conditions?

I am wondering if For could be used with multiple conditions (tests). For the simple example ...
3k views

### How to restrict the domain of a function

I realize this question has been asked many times, but I am fairly new at Mathematica and the other answers are very complex, and certainly too complicated for this simple code I am trying to write. ...
46 views

### How to pass var to Select[(#colunm == value) &] construct [duplicate]

I'm using a construct (more complex in fact as the value_ should take a list) to select some entries from an association with criteria: ...
161 views

### A simple code for conditional double summation?

I wrote a code as follows ...
145 views

### PlotStyle based on If condition

So in the If[evecs==Re[evecs], I want to then change the colour in PlotStyle of the ...
143 views

159 views

### Finding the largest palindrome which is the product of two 2-digit numbers

My goal is to find the largest palindrome which is the product of two 2-digit numbers using the following program. I want the program to add each palindrome it finds, to the list H. I also want it to ...
103 views

### Condition syntax: “when equal to any of”

I am trying to write a condition clause for a certain expression. I need to pick out the following cases: Mod[x*y, 10] == 8, or Mod[x*y, 10] == 3, or Mod[x*y, 10] == 7. I need to repeat ...
337 views

### How to use If statement inside DynamicModule?

I believe I am missing an important piece of information. I am trying to execute a simple If statement inside a DynamicModule. The variable tested in the If statement is a Dynamic variable, in this ...
110 views

### Making ConditionalExpression as a Function to use

i have these functions: savA[k_, s_, a_] := s*a*k^0.5; savB[k_, s_, b_, c_] := s*b*k^(0.5) - c; depr[k_, n_, d_] := (n + d)*k; ...
614 views

### Find Array Elements That Meet a Condition

I have an array of 5 numbers (say m). I want the following operation m=[-1,-3,-2,-5,-4] For (j=1,j==5,j++) if ...
98 views

### Why this expression doesn't work?

I am trying to choose a function and then the parameters using Manipulate, but isn't working... ...
57 views

### Incorporating additional conditions on FindInstance or Solve for a cubic map

I have the cubic map: f[a_, x_] := (a - 1) x - a x^3 To determine the values of a for which this cubic map is bounded to the closed interval -1 and +1, I tried: <...
139 views

### Adding extra lines to the If[condition,t,f] command [duplicate]

I wish that the Mathematica documentation for the If command showed examples that have more than one statement for the t and f responses. All three of these work: No parentheses or braces: ...
I have the code below, which simulates a particle of mass $m$ in a fourth order polynomial potential given an initial conditions $q_0,p_0$. That is to say, I am simulating Hamilton's equations using <...
I have a piecewise map of the form $M\left ( x \right )=\left\{\begin{matrix} 2x & x<0.5 \\ 2-2x& x>0.5 \end{matrix}\right.$ The domain is the closed interval from 0 to 1. I would ...