The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
31 views

How to properly use conditionals inside NDSolve

Currently I am working with Mathematica to learn the program, and I'm confused what exactly is wrong with this code. ...
1
vote
1answer
71 views

Solving equations bounded by a region

Straight to the point I have a function ...
2
votes
1answer
51 views

Is there a shorthand for Optional with Condition?

I have a recursive function that does some work to an object for a repeatedamount of times. ...
2
votes
2answers
68 views

RSolve with conditional equation

I have the following conditional equation: $f(n) = 1+2 f(n/2)$ when n is even $f(n) = 1+f((n-1)/2)+f((n+1)/2)$ when n is odd I want to represent this as a conditional equation to be used in ...
2
votes
1answer
44 views

Define (conditional) substitution rule for sum/difference of radicals

I want to tell Mathematica to simplify some expressions applying the following substitutions, conditioned on the fact that $a\geq 0,b \geq 0, a^2-b\geq0 $ $$ \sqrt{a+\sqrt{a^2-b}} \pm ...
1
vote
1answer
43 views

Replacing Logic operator List and generate combination of variables

so I'm trying to do the following starting from a list of inequalities: ...
1
vote
2answers
63 views

Conditional Convolution

I was hoping to incorporate an If function into a Convolve operation, as in ...
1
vote
2answers
107 views

How to select elements from a list by condition?

Considering I have a list: F = {f1, f2, f3, f4} I want to perform exponent on the list F = Power[#, 2]& /@ F Now I ...
0
votes
0answers
33 views

Doing a repeated calculation on unique chunks of data based on a value in a column

First post ever on a forum, please bear with me if I don't get it right the first time :) I'm making a script for someone that imports a data file, generates some histograms, tables, and outputs them ...
0
votes
0answers
49 views

Evaluating an integral

Here is the input: Integrate[E^(2 I*t)/(2*Pi*(E^(I*t) - z)), {t, 0, 2 Pi}] and here the output: ...
1
vote
1answer
58 views

Minimize under constraint on an interval

I want find the minima of a (multivariable) function under a constraint which has to be fulfilled on a whole interval, let's say $$ \nabla f (\underline x) = 0 \ \\ \ c(\underline x,s)\geq0\ \forall ...
2
votes
1answer
77 views

Simplifying conditional expressions using assumptions does not work

I have a conditional expression f[x_] := x /; x ∈ Reals This works fine for normal numbers and symbols, e.g. ...
1
vote
2answers
120 views

Problems with Solve when constraining solutions to a range

I have the following code ...
1
vote
1answer
79 views

Compiling If statement

I have this code: ...
0
votes
2answers
36 views

Simplify integration result with conditions

Let's say I have integral Integrate[1/(1 + (f^2/B^2)), {f, 0, Infinity}] The result is $$\text{ConditionalExpression}\left[\frac{\pi }{2 ...
2
votes
1answer
152 views

Seeking simple function in interval

I am a bit rusty, and struggling to solve this problem. Looking for a simple, well behaved parametric function f[t], from [0,1] to [0,1] such that: f[0] = f0; f[1] = f1; f'[1] = ff1; where -1<= ...
2
votes
4answers
116 views

List Manipulation Via Conditionals

I'm trying to convert one list to another by applying a condition on the list's elements. But I can't figure out how to do this in mathematica's language. Python example below ...
0
votes
0answers
22 views

A question about conditional replacement [duplicate]

{g[x, y, z], h[x, y], f[]} /. (f_[t___] /; f != List) :> Plus[t] Why is the output of this expression ...
1
vote
1answer
69 views

Modifying a list of matrices with conditional statement

I have a list of around 100 matrices, that looks like this ...
4
votes
2answers
124 views

Weird behavior of conditions when using OptionsPattern and OptionValue

I'm trying to define a function that is evaluated differently depending on its options. This code ...
7
votes
2answers
123 views

using memoization with conditional statement

I would like some advice about the use of memoization in conjunction with conditional statements. Let me try to explain my problem: I am constructing a function depending on a number of parameters. ...
0
votes
2answers
69 views

Use conditional expression inside With

I want to assign a number to an internal variable, depending if a specific option has been given, but it seems to fail. Something like: ...
1
vote
1answer
132 views

Counting number of trues in If condition inside a For loop [closed]

I want to count number of trues in an If condition inside a For loop of some 10k iterations. I will be happy if you suggest me some command.
3
votes
1answer
67 views

How can I create a set (list) provide a kind of rule/algorithm?

Example: S = {r ∈ Q : r² < 2} Let S be the set of all rational numbers whose squares are less than 2. It follows that 1 ∈ S, 4/3 ∈ S, but 3/2 doesn't ∈ S because 9/4 ≥ 2. Thank you.
24
votes
5answers
2k views

2D random walk within a bounded area

I want to simulate a random walk on two dimension in a bounded area such as a square or circle. I am thinking of using If statement to define a boundary. Is there a ...
3
votes
5answers
251 views

Creating a conditional table

I'm trying to create a conditional table. Let's say I want to have such result: {1,2,3,4,5,0,0,0,0,0}. The idea is to create a table of n elements (10 in a given example), but when one element takes ...
1
vote
4answers
154 views

Minimum and maximum values under conditions

Let's create some sample data ...
0
votes
0answers
40 views

How to correctly use PatternTest (?) [duplicate]

This works fine: {3, -5, 2, 7, -6, 3} /. x_ /; x < 0 :> 0 (*{3, 0, 2, 7, 0, 3}*) and this works fine: ...
0
votes
2answers
47 views

Multiply value if it includes a period

I download data from an online source, now I have a problem: the source code doesn't allow to differ between values of 10 (which actually stands for 10) and 10.000 (which is 10'000, but Mathematica ...
4
votes
1answer
139 views

Multiple down-values with exactly the same lefthand side

I was working on an answer to this question, when I was sidetracked by what I bring up here. I wanted a function, which when given a string representing a binary number, would convert the string to a ...
0
votes
0answers
63 views

Making sense of output of Assuming/Refine

I have a conditional statement as output: ...
3
votes
1answer
119 views

Why does pattern test not work in this case to restrict the function parameters?

I was looking at this Q&A about using pattern test (pattern_?test) vs pattern condition (pattern_/;cond) and came across ...
14
votes
1answer
392 views

Quick way to use conditioned patterns when defining multi-argument function?

I have a simple function that is supposed to only accept numeric values (i.e. complex/real numbers and constant symbols e.g. Pi, E). $$f(a,b,c)=a+b+c$$ Edit: I should have chosen a less simple ...
4
votes
4answers
584 views

Skip other If conditions

I'm trying to write a code to "random" move in a matrix but it can't go to a certain position if it has a certain value (in this case I'm using the number 2). How do I make it to skip all other If ...
5
votes
2answers
119 views

What is the syntax to conditionally suppress plotting in version 9?

In Mathematica 7 it is very easy to conditionally suppress plotting of individual lines using If: ...
0
votes
3answers
84 views

Half kth term if n is even and k=n/2?

I am trying to write a function which will perform the equation in the attached image. So far, I have: ...
0
votes
1answer
33 views

How to use more/less black textcolor in function of the value of numbers in a table?

A few weeks ago, I viewed in the Mathematica Documentation any page withmultiple examples using diferent styles dpending on the value of the number in position (i,j), but I can´t remember... and I ...
1
vote
3answers
127 views

Initialize table in a Module but Break if criteria not met

I am initializing a table inside a function as follows: f[a1_, a2_, a3_] := Module[{RM = Table[a1+a2+a3+i1, {i1, 1, 10}]}, Plus@@RM] I am calling the function ...
1
vote
3answers
128 views

Where Statement

Is there a "parallel" way to perform these operations? Indices = {} For[i = 1, i <= Length[w], i++, If[w[[i]] < 0, AppendTo[Indices, i]]] Which gives a ...
0
votes
1answer
60 views

Resolve a conditional expression including exists and forall

I don't know the Resolve function exactly, especially when involved with Exists and ForAll, ...
0
votes
2answers
184 views

Replace matrix with conditions

I want to replace the values of 1. in slot under the condition that the year and month in basevalue and ...
6
votes
2answers
290 views

Flow/graph-based programming in Mathematica?

Is it possible in Mathematica to write a program inside a graph? For example if you have a bunch of different If[] statements that you need to embed within one ...
2
votes
3answers
159 views

Join matrix based on conditions

Given the following matrix: ...
3
votes
1answer
52 views

Table doesn't replace inside conditionals (If, Which) [duplicate]

This: Table[If[cond, y], {y, 1, 3}] outputs this: {If[cond, y], If[cond, y], If[cond, y]} The ...
5
votes
2answers
217 views

How to “ReplaceAll” using a set of conditional expressions instead of a list of rules [closed]

Suppose that I have two linear functions f[x_] := f0 + f1 x g[x_] := g0 + g1 x and a (possibly rather complicated) set of conditional expressions, obtained ...