Questions tagged [sequence]
Questions on specifying order in and splicing of lists, including use of Mathematica Sequence objects.
178
questions
2
votes
1
answer
77
views
Limit of Taylor coefficients
I want to calculate the following limit:
b[n_] := (D[1/(1 - t), {t, n}] /. {t -> 0})/Factorial[n]
Limit[b[n], n -> ∞]
(* Indeterminate *)
where ...
0
votes
1
answer
79
views
When running code to compute a sequence, loop variable gets set to a constant
I would like to write Mathematica code to read in a list of sequences, and print the sequence definition ($a_n$), along with the sequence evaluated at a few values of $n$.
...
4
votes
0
answers
52
views
How to use Shortest[___] with Sequence pattern matching?
Shortest[] doesn't appear to work with Sequence s. Is this a bug or a feature? What can I do to force the following ...
0
votes
1
answer
22
views
Confusing result when pattern matching a BlankSequence (__) to a list, then calling unary function on the list [duplicate]
The following makes sense to me:
In[1] = f[a, b] /. f[x__] -> x
Out[1] = Sequence[a, b]
In[2] = f[a, b] /. f[x__] -> {x}
Out[2] = {a, b}
However, the ...
0
votes
0
answers
16
views
Difference Equation with Upper Boundary Condition, Lower Terms Not correct
I am struggling to understand the solution Mathematica is providing for the following recurrence relation
As I have written a[i] I expected the following behavior
<...
10
votes
7
answers
637
views
Select data from a structured list
Let's suppose we have the following structure of data
...
1
vote
2
answers
97
views
we want to get all possible values with $a_1$
I would appreciate it if somebody could help me with the following problem:
Given
$$a_{n+1}=\begin{cases} \dfrac{a_n}{2}& (a_n \: \text{even})\\
n{a_n}& (a_n \: \text{odd})\end{cases},\:a_8= ...
0
votes
1
answer
62
views
Problem with For Loop when evaluating a recursive function at multiple points
I am running into problems with my For loop when trying to evaluate my expression. Fix some parameter values :
...
1
vote
3
answers
86
views
Rewrite the list without certain elements in the sequence
I have a list1:
...
4
votes
4
answers
196
views
One-to-multiple values relation from two excel columns
I have excel file with two columns:
After data import I have the following list:
...
2
votes
5
answers
255
views
Subsequences with distinct values
(this question was modified after initial answers)
For a sequence
x = {6,4,2,4,2,4,6}
y = Subsequences[x]
gives the list of ...
3
votes
2
answers
116
views
Determining the run length of elements in a list that satisfy a pattern
Is there a simple way to determine the run length of elements in a list that satisfy a pattern?
For example, consider the following list:
...
3
votes
2
answers
187
views
How to insert a list in the second argument of Table?
I wrote the following table:
k = 4;
T = Table[{a[n], 0, 1}, {n, 1, k}]
Which generates:
...
5
votes
1
answer
77
views
Isolating sequences from a list based on a formula
SeedRandom[4];
alist = RandomInteger[{-4, 4}, 100]
From this list, I can isolate similar neighbors of length two:
...
5
votes
3
answers
226
views
Selective deletions from a list
i have two lists of strings with unequal numbers of subelements in each.
i would like to remove from lis2 all instances where a pattern in lis1 appears in lis2:
...
2
votes
2
answers
173
views
Trouble understanding function composition?
I made the following code:
Cs = {{0, 1}};
f[x_] := (Clear[s]; s = (x[[2]] - x[[1]])/3; Splice[{{x[[1]], x[[1]] + s}, {x[[1]] + 2 s, x[[2]]}}])
Observe that we can ...
0
votes
0
answers
46
views
How to find the sequence function $f(n,x)$ of the three given functions?
I have the three functions $f(2,x)$, $f(3,x)$ and $f(4,x)$ where $x>0$
...
2
votes
2
answers
153
views
While loop not working problem [closed]
I am new to Mathematica ,and I am trying to implement this while loop which adds all odd Fibonacci numbers less than or equal to 2 million but it keeps outputting 0 for sum.
Any solutions for that?
...
0
votes
0
answers
40
views
Problem with FindGeneratingFunction
I have a lengthy function of a real parameter $n$ that generates values $val$ for each $n$ {$n$, $val$}:
...
6
votes
2
answers
173
views
Longest common subset sequence with gaps
I would like to find the longest common subset (including a gap of x) within two lists.
Example:
A = AAABBBBCCCCC
B = CCCBBBAAABABA
We can use
...
1
vote
1
answer
108
views
RSolve unable to solve the equation
I gave the following code as input:
RSolve[x[n + 1] == 1/2 x[n] + 2 Log[x[n]], x[n], n]
Mathematica gave the same output:
...
0
votes
0
answers
59
views
Is there a concise way to generate a continuous less-than relationship?
Actually, I have a ton of variables, Let me simplify it to 4 in this post.
vars = {a, b, c, d};
0 < Less @@ vars < 10
0 < (a < b < c < d) < ...
0
votes
1
answer
80
views
How to solve this RecurrenceTable in Mathematica
I would appreciate if somebody could help me with the following problem:
Q: How to define this in Mathematica.
...
0
votes
1
answer
131
views
Variable dimension tables with variable ranges
I need to construct a table that has variable dimension and variable ranges (see for tables with variable dimensions and constant ranges, e.g., this question).
Suppose there is a list ...
3
votes
1
answer
86
views
A possible issue in combination of the Infix operator ~ with Sequence [closed]
There are other similar questions on this site about using the Infix operator for more than two arguments, which I have read. But there is one thing that I wasn't able to understand and couldn't ...
0
votes
0
answers
66
views
FindSequenceFunction with very small numbers
I need some help with FindSequenceFunction because at the moment it seems like a black box to me. For example, it deals with
...
5
votes
1
answer
100
views
Patterns are not Sequences are not Lists, or: Global Function Argument Reversal
H[z_] := z /. {F[p__] -> F[Reverse[p]]}
F[{x, y}] + F[{x, z}] + F[{}] // H
Almost. It gives an annoying "Nonatomic Reverse" error message at the ...
2
votes
1
answer
79
views
Defining function with arguments in a specific pattern similar to Graphics[]
I'm trying to define a function that is of this form:
...
2
votes
0
answers
99
views
Finding recurrence relation from an inexact numerical sequence
Consider the recurrence relationship
d[0] = 0;
d[i_] := (1 + Sqrt[1 + 4 d[i - 1]^2])/2 /; i >= 1
which generates the following sequence (generated by using <...
1
vote
0
answers
32
views
What subsequences does SequenceReplace consider
Consider SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e].
What subsequences does SequenceReplace consider?
The ...
0
votes
1
answer
64
views
Using :> vs -> in SequenceReplace
The first example on the page for SequenceReplace is the following:
SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e]
...
1
vote
1
answer
144
views
Extract function argument sequence
Is it somehow possible to access and reference the sequence of arguments of a non-pure function?
For example if I want to take the derivative with respect to the n'th argument, a pseudocode example ...
4
votes
1
answer
172
views
Find the longest sequence of "1" in a SubList
I'm trying to return the sublist(s) with the longest sequence of 1, although my code is working in a majority of cases, there are exceptions that I don't understand .
Example:
...
7
votes
4
answers
398
views
Find the longest sequence of "1" in a matrix row, and its position
I would like to find the longest sequence of "1" (consecutive ones) in rows of a matrix; moreover, I would like to know the position of this sequence in the matrix .
Example:
Input :
...
3
votes
1
answer
74
views
How to Map over a BlankSequence? [closed]
I would like to replace any function f[x, y, ...] in a certain expression with the same function with all its arguments squared, i.e. ...
4
votes
1
answer
80
views
SequenceSplit around empty sequences is inconsistent
Bug introduced in 11.3 and persisting through 12.3
Only the first one recognizes a zero-length sequence between non-X's.
...
4
votes
1
answer
64
views
Conditionally add an element to a list by using Apply to delay the Sequence until evaluation
Could you explain the details for the following code?
foo[x_, y_] := {a, If[x === y, b, Sequence @@ {}]}
foo[s, s]
foo[s, t]
Output:
...
2
votes
2
answers
148
views
Calculating Average Price and P&L Efficiently Without Loops
A very common task is stock portfolio evaluation is to calculate the average price of stock holdings for a sequence of trades and from there to calculate the (realized) profit or loss. Obviously one ...
1
vote
1
answer
197
views
check a sequence in Pi
I read that the string 36541622473 occurs in π(pi) at position 36541622473, counting from ...
2
votes
1
answer
36
views
ordered set inclusion
Suppose I have a ordered set $A=\{2,3\}$ and $B=\{2,3,4\}$ and $C=\{2,4,3\}$.
Is there any mathematica command whether $A\subset B$ gives true(or 1) but $A$ which is not a subset of $C$ gives false(or ...
0
votes
1
answer
80
views
Why won't Sequence work when wrapping a list of arguments for deletion with Remove?
I wrote a quick and dirty little function freshStart which does a variety of things meant to give me a nearly fresh Kernel without having to ...
2
votes
1
answer
198
views
How can I get an element of a sequence?
How can I get an element of a sequence?
For example Sequence[a,b,c,d]
How can get c?
1
vote
0
answers
92
views
Alternatives not working with Sequence[]?
In the following piece of code I've specified two possibilities to match via Alternatives, but only one of them seems to be considered:
...
1
vote
2
answers
111
views
Recursive sequence with RecurenceTable
I want to compute elements of a recursive sequence and use them as coefficients of a power series. However, the (i+1)-th element depends on all previous elements. Writing this as a sum in ...
1
vote
1
answer
44
views
Using For to generate a sequence
I want to find the smallest positive integer $k$ such that the finite list s[k*m] contains no odd numbers, for $m=1,2 \dots$. Unfortunately ...
2
votes
2
answers
110
views
Use Mathematica to split a sequence according to other two sequences
I want to use Mathematica to solve the following problem:
For example I have a sequence 101. I want to compare it with $1101$ and $0101$. The comparison has the following procedure:
Check the first ...
1
vote
0
answers
62
views
Avoiding the memory requirements of an accumulation of returned Nulls (etc)
There is an extensive but relatively old answer to a similar question here, and there are many Qs and As about avoiding using Table where possible.
My problem is a mixture of the two: I have been ...
4
votes
2
answers
151
views
Generate a sequence of sequences
Imagine I have a sequence of M integers each of which is either zero or one. How do I generate a sequence of all such 2^M sequences?
1
vote
2
answers
127
views
How to use a general method to solve this problem
Suppose $a_{n}>0(n=1,2,\cdots)$. The series $ \sum_{n=1}^{\infty} a_{n}$ converges and the constant $ \lambda \in\left(0, \frac{\pi}{2}\right)$. Now I need to judge whether the series $\sum_{n=1}^{\...
2
votes
2
answers
186
views
How to judge whether the series is absolutely convergent?
I need to judge whether the series $\sum_{n=1}^{\infty}(-1)^{n}\left(1-\cos \frac{\alpha}{n}\right)$ (α>0) is absolutely convergent.
...