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

51 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
148 views

### Reduce[Sin[x]==0,x] splitting odd and even multiples of Pi

as from Title, I'm wondering why Mathematica does not automatically give a single, simple solution for the problem Reduce[Sin[x] == 0, x] for which I obtain the ...
258 views

### Is it possible to do probabilistic programming by variable elimination with plain Mathematica 10 or later?

Using frameworks like Figaro it is possible to do probabilistic programming by variable elimination to build a probabilistic model and then run inferences against it in a very intuitive way. Example: ...
893 views

### When are If, Piecewise, Switch, and Which interchangeable and when are they not?

Experimenting with joint dependent distributions via the TransformedDistribution function, I used the following to derive a distribution where the second variate is ...
75 views

126 views

### Is Mathematica computing the conditional expectation correctly?

Given a simple case of say 2 independent trials each with probability of success 1/3. Consider a random variable that is gives the 3 times the total successes. We can define this random variable in ...
69 views

...
132 views

### How to set up Switch with variable number of conditionals?

I would like to use a Switch command with IntegerPartitions[n] of terms with n ranging from 3 to 12 and n chosen at run time. I have: ...
80 views

### If condition in differential equation

I need to plot the Integrate the Fire model of neuron. The differential equation is $\frac{dV}{dt} + \frac{V}{\tau} = \frac{I}{C}$. The initial condition is $V(0) = 0$. And there is this condition if ...
84 views

### "If" not working when solving piecewise differential equation

This is a part 2 to my previous question: Solving Piecewise Differential Equation I am embarking on a physics project and this is the simulation that I would like to do. More information is included ...
29 views

### How to avoid delayed evaluation in Condition used in a function definition

I would like to define a function (below, f) that evaluates only under the condition that some expression is True. The condition is to be specified now, and I don't want it to change for the purposes ...
34 views

### Are the conditions in ConditionalExpression necessary or sufficient?

I computed a limit and obtained it in the form of a ConditionalExpression (see below). Substituting the variables with numerical values in the resulting formula ...
28 views

### Finding the positions of minima for a function with algebraic constants

I have a function of several variables: inverse[Qx_, Qy_]:= T - 2 J + 4 J1 Cos[(Qx + Qy)/2 a] Cos[(Qx - Qy)/2 a] - 2 J2 Cos[(Qx - Qy) a] + 2 J3 Cos[(Qx + Qy) a] ...
194 views

### Is there a way to find the Region of Convergence along with the Laplace Transform?

This is what I've tried so far. Is the inequality of the conditional expression the Region of Convergence? Why doesn't LaplaceTransform Generate conditions here? ...
334 views

### Ternary diagram

I'd like to make a RegionPlot on a ternary diagram, meaning in a triangle where the axis are $x,y,z$, which are related by $x+y+z=1$. The RegionPlot would have as a condition $x^2+y^2<1$ for ...
62 views

### Determine n related elements with least sum from a matrix?

Consider defining a matrix such as mat: ...
308 views

### How to solve a system of six coupled PDE with step function

i'm trying to solve a coupled system of six partial differential equations with NDSolve. The system is as follows but i don't have idea how to use the conditionals. Here $H_{\sigma}$ is a continuous ...
104 views

78 views

### 3D-plot of a maximization of a definite integral

I'm applying the answer (If method) suggested by 'ThatGravityGuy' in this post in a more complicated case. Consider my objective function (pardon its formidable ...
62 views

### solving inside for loop and sorting x which are less than 3 and greater than -3 from the list

I give a simple function code here... Clear[a, x, t]; s = ParametricNDSolve[{x'[t] + a*x[t] == 0, x[0]==1}, x, {t, 0, 100}, {a}] y = x[1] /. s y[5] /. s I ...
66 views

### How can I better formulate a conditional statement?

To solve optimization problems I have seen this: Is there a more elegant way to do this with alternative conditional expressions? Is there something equivelant to ...
47 views

### How to use === with condition?

I have two expressions, and they are same when k is positive and x is non-zero real number. Below code gives me ...
61 views

### How can I select the true expansion?

I have a series expansion which gives two results. Series[-(1/ Sqrt[-1 + x + x z1^2 \[Chi]^2]) , {x, 0, 1}] /. y -> x I want only the series which is true. ...
53 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 ...
560 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 ...
35 views

...
83 views

### The conditions used in Sum or ParallelSum: Calling a function/variable

For some reason, I encounter a problem when doing the Sum and ParallelSum (or doing the Do or ParallelDo, e.g. such as the issue here), I figured that the potential cause of the problem can be ...
79 views

### How to put conditional for a iterator?

I have the next code: f = Table[ mtxt[[p[[i, j]] - wi ;; p[[i, j]] + we]], {i, n}, {j, m}] I want that wi and we have different values depend of the j value. For ...
83 views

### Solving a system of equations with conditional functions

With your help i am getting closer to the solution of my problem. I know that the code is long but most of it is boring definition. At the beginning i am just defining function, which works at the ...