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

learn more… | top users | synonyms (1)

1
vote
1answer
38 views

Do double vertical bars in ConditionalExpression mean 'or'? [on hold]

I have a very simple interpretation question. I think that double vertical bars in a ConditionalExpression given by Mathematica as the result of an integration must mean 'or', but I am hoping to ...
1
vote
2answers
48 views

How to plot data with different colors (or symbols) depending on a condition [duplicate]

Let's consider a simple example. I want to plot a function on [0;2], depending on a condition: if x<1, I want to plot ...
-1
votes
1answer
105 views

Why this code gives different output for differents runs

Edit Here is my code to plot many constrained variables in (x,y) plan : the variables are : ...
1
vote
2answers
44 views

ListPlot function in 2D- plan in two varibles

Suppose a function f[s,k]. How to Listplot this function in 2D plot in (s,k) plan, such that ...
3
votes
2answers
194 views

Selection of points based on position

I have a series of points, for example: points = {{0, 0}, {1, 3}, {2.5, 2.5}, {4, 4}, {6, 6}}; I want to join all points successively unless, for example, the y-...
1
vote
2answers
73 views

Using solve on conditional functions

I know that the code is pretty long, but most of it is just defintion. Do you see why the Solve gives me "his system cannot be solved with the methods available to Solve" back? ...
0
votes
0answers
59 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 ...
0
votes
0answers
51 views

Use If condition with ListPlot

Here is my code to use If condition with PLot: ...
0
votes
1answer
47 views

Solving a polynomial where variables are constrained to take only some values

I want to find out which combinations of 1's and 0's would make this kind of equation be null: ...
0
votes
3answers
135 views

Do loop with If condition

I have the following formulas: 1- A cross section: sigma[beta_,alpha_,Y4_] := c^2/(256*Pi) * (1/2) ( Ytt[beta,alpha,Y4]/ m ) * Abs[A]^2 Where c is a strong ...
0
votes
2answers
38 views

Conditions on a product

I want to impose specific conditions on a product I am trying to take. I found this previous question asked here but when I use this I get zero. My expression is $$ \prod_{(i,j)=(-a+1,-b+1)}^{(a,b)}\...
5
votes
4answers
451 views

How to simplify block of multiple repetitive If statements?

I'm building a boardgame...game in Mathematica. I have the board state represented as a matrix. It's a two player game, and each player (let's call them A & B) only has one type of piece or '...
2
votes
1answer
70 views

Inconsistent Integrate behavior?

Evaluating the following integral with Mathematica Integrate[q0/(-1 + q0^2), {q0, 0, A}] gives a conditional expression ...
4
votes
1answer
90 views

double sum with condition

I was trying to compute the following sum: $$\phi(x,y)=\frac{1}{4\pi^2}\sum_{(n,m)\neq(0,0)}\frac{1}{n^2+m^2}\exp(i(nx+my))$$ where the range of indices is, say, $-10\leq n, \,m\leq 10$. But I don't ...
0
votes
0answers
27 views

Semi-infinite sheet and Spherical inversion

I'm trying to define a function that will give a semi-infinite sheet (i.e. a sheet which exists when z=0 and x>0 for all y). I've tried using ConditionalExpression and ForAll, but when plotted using ...
3
votes
2answers
79 views

Find most general 3-tensor under given constraint?

Consider A to be a general $2\times 2\times 2$ tensor: A = Table[ a[i,j,k], {i, 1, 2}, {j, 1, 2}, {k, 1, 2}]; pictorially one ...
0
votes
1answer
78 views

Conditional function plot in Manipulate

I'm looking into the stability of solution of a set of chemical rate equations. There is a set of rate constants {$k_i$} I which to manipulate, and I want to find the stable solutions where $\frac{\...
0
votes
1answer
58 views

Checkbox in manipulate not properly working

This question is related to another question of mine : How can I add a checkbox to a Manipulate expression?, but I'm still unable to make the checkbox to work properly. Here's a MWE code, from my ...
1
vote
1answer
40 views

This input is incomplete [closed]

I'm sorry if this is a totally simple question, but I'm new to Mathematica, and I've just spent 30mins looking through the documentation, but I can't seem to figure out why this code won't work: <...
1
vote
1answer
90 views

Solving trigonometric functions in Mathematica

I am new to Mathematica language and recently I had the need to solve the following equations with two variables, A and B: ...
5
votes
1answer
84 views

An unexpected match when using Condition, Optional and passing a Sequence

Mathematica is behaving in an expected way when passing a parameter with an Optional and a Sequence. Here is an example: ...
12
votes
3answers
399 views

Double Sum Involving Condition

I would like to compute the dimensions of some small free nilpotent Lie algebras. However, I am totally new to this and I could not figure out how to write the double sum which gives the dimension of ...
3
votes
1answer
93 views

Eliminating elements from sublists under a global condition

Consider the following list of 4215 sublists (note that the file as displayed at github is truncated, but there is a link to the full version). Each of the ...
0
votes
0answers
25 views
1
vote
1answer
64 views

Conditional probability syntax [closed]

What syntax do I use to compute this in Mathematica? Game of Yahtzee: 1. Suppose you get three 5’s on the first roll. What is the probability of rolling the other two dice and completing the Yahtzee ...
3
votes
2answers
78 views

Except[] with levelspec

I am trying to determine all the variables used in list. For This I use: DeleteDuplicates[Cases[l1,_Symbol,-1]] This is great except that ...
15
votes
3answers
486 views

Generating Tuples with restrictions

I am interested in a certain subset of all tuples. Generating all with Tuples and then filtering is wasteful, and will "blow up" very quickly. For a concrete ...
0
votes
1answer
65 views

If Statement in function does not evaluate

I've written a function that should try to simulate a "triangle-wave-signal", given a few parameters. It looks like this: ...
1
vote
1answer
92 views

Manipulating Some Lists in Compile

Consider a list of lists, such as: Z={{1,4,3},{2,1,3},{3,1,4}} Z is an $n \times n$ matrix (here $3 \times 3$) which ...
3
votes
3answers
83 views

How-to select an entry from a list of pairs that meets a condition depending the 2nd element of each pair

Processed data structure data = Transpose[{RandomInteger[{1, 20}, 100], RandomReal[{10^-8, 10^-1}, 100]}] You can download the actual raw data structure here. ...
1
vote
0answers
53 views

recursion and if-statements

So im trying to write a recursion module in mathematica (specifically for strassen multiplication but this doesn't matter). My issue is I don't really know how if statements work in mathematica and if ...
0
votes
2answers
198 views

Using 0 < x < 10 as a condition in an equation

How do I write 0 < x < 10 on the right side in the equation. If #1 + #2 is bigger than 0 and smaller than 10. And is it possible to require -10 < x < 10 with the additional condition x != ...
0
votes
2answers
73 views

If Which Piecewise-defined function [closed]

How would I write a function using If and/or Which command for following Piecewise-defined function then plot the function ...
5
votes
0answers
96 views

Find regions in which the roots of a third degree polynomial are real

I have to find the roots of a third degree polynomial in $\phi$ that depends from 3 parameters, namely $t,s,w\in \mathbb R$. In order to do that I've used the command ...
0
votes
1answer
51 views

If/Then Statement Evaluation [closed]

Really rudimentary question here...why is the following if/then statement always evaluating both "True" and "False" expressions and updating my CurCost and Temp variable values? ...
0
votes
0answers
40 views

Impose a condition on a function in a loop

I am trying to calculate something in the following code and I need to omit the final values which are going to be infinity.obviously I want to extract the answers of H2[s] which are zero. ...
0
votes
1answer
50 views

if-conditional tracing a half-sphere [closed]

I have a 2D discrete plane (x,y) and I would like to assign an amplitude to each point in the plane. Each dimension runs from -1 to 1. Say I want to assign an <...
2
votes
1answer
62 views

Change some elements at the second level of a list based on some conditions

I need to change some elements at the second level of a list based on some conditions. I have the following list of objects of the same type: ...
1
vote
1answer
171 views

Fall through multiple cases in switch to execute same function

In C++ / C#, one can fall through multiple cases to execute one function instead of calling that function after each case. For example, ...
10
votes
1answer
240 views

Question about Rules and Pattern (The operator patt/;test)

Maybe this question is so trivial but it has confused me. I'm studying the What the @#%^&*?! do all those funny signs mean? and in the Rules and patterns under ...
1
vote
1answer
62 views

How to make Which not connect its parts? [closed]

I've noticed that when "Mod" and "Which" are used to the same effect, they plot to slightly different results. Take the following example: ...
1
vote
1answer
53 views

Triangular inequality condition

I have to calculate the following table Table[ ThreeJSymbol[{j1, 0}, {j2, 0}, {j3, 0}], {j1, 1, j1max}, {j2, 1, j2max}, {j3, 1, j3max} ]; in such a way that $...
8
votes
1answer
163 views

Why does pattern test work only with pure functions?

Why is it that pattern test works only with pure functions? Cases[Range[0, 70], _?(Divisible[#, 7] &)] Cases[Range[0, 70], x_?(Divisible[x, 7])] I ...
1
vote
2answers
64 views

Creating a Table with a list of If statements given in a certain order

I am trying to create a conditional Table with If statements, where I move to the next condition only if the first one is satisfied, otherwise I "Break[]" and move to the next element of the table. ...
0
votes
1answer
122 views
2
votes
3answers
152 views

Join nested lists based on first and last elements within each list

I have a nested list like this: test1 = {{1, 3}, {1, 4}, {1, 7}, {2, 1}, {3, 5}, {4, 1}, {5, 2}, {6, 1}, {7, 6}} I want to join the lists together depending on ...
3
votes
1answer
131 views

How to use Compile to generate an $n\times n$ array using $n$ vectors

Let's consider the following: ...
0
votes
1answer
54 views

If statement for evaluating small values

I have a simple calculation which I am trying to use if condition to evaluate summation of some values, here's a code; ...