Questions tagged [sequence]

Questions on specifying order in and splicing of lists, including use of Mathematica Sequence objects.

Filter by
Sorted by
Tagged with
0 votes
0 answers
48 views

Limit of Sequence? [closed]

I have following sequence t1[n] whose convergence I want to check. I have taken f[n_] := 2^n and ...
user avatar
-1 votes
0 answers
38 views

How to use commands such as SequencePredict to find the next element of a sequence that is not easily guessable?

I used SequencePredict to exactly predict the sequences of very many standard sequences, such as even numbers, primes etc. But this example failed. ...
user avatar
0 votes
0 answers
28 views

Problem with FindGeneratingFunction

I have a lengthy function of a real parameter $n$ that generates values $val$ for each $n$ {$n$, $val$}: ...
user avatar
  • 883
6 votes
2 answers
145 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 ...
user avatar
  • 974
1 vote
1 answer
92 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: ...
user avatar
0 votes
0 answers
51 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) < ...
user avatar
  • 23.1k
0 votes
1 answer
68 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. ...
user avatar
  • 127
0 votes
1 answer
70 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 ...
user avatar
  • 317
3 votes
1 answer
84 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 ...
user avatar
  • 789
0 votes
0 answers
64 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 ...
user avatar
  • 1,185
5 votes
1 answer
98 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 ...
user avatar
2 votes
1 answer
73 views

Defining function with arguments in a specific pattern similar to Graphics[]

I'm trying to define a function that is of this form: ...
user avatar
2 votes
0 answers
85 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 <...
user avatar
  • 335
1 vote
0 answers
28 views

What subsequences does SequenceReplace consider

Consider SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e]. What subsequences does SequenceReplace consider? The ...
user avatar
0 votes
1 answer
61 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] ...
user avatar
1 vote
1 answer
85 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 ...
user avatar
4 votes
1 answer
167 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: ...
user avatar
  • 189
7 votes
4 answers
365 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 : ...
user avatar
  • 189
3 votes
1 answer
69 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. ...
user avatar
  • 107
4 votes
1 answer
78 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. ...
user avatar
  • 1,055
0 votes
0 answers
43 views

Calculating correlational dimension using Mathematica

I am modelling such a system: $T:(x,y)\rightarrow (d+C_2(x\cos\tau - y\sin\tau),C_2(x\sin\tau+y\cos\tau))$, $\tau = C_1-C_3/(1+x^2+y^2), C_1=0.4, C_2=0.9,C_3=0.6,d=0.6$. I am applying $T$ to point $(...
user avatar
  • 93
4 votes
1 answer
63 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: ...
user avatar
1 vote
2 answers
127 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 ...
user avatar
4 votes
0 answers
174 views

Numerical backward induction -- Solving sequential Cournot

I'd like to numerically solve a sequential Cournot competition in which supplier 1 moves before supplier 2, then the manufacturer sources from them, and finally sells the item at market clearing price....
user avatar
  • 313
1 vote
1 answer
138 views

check a sequence in Pi

I read that the string 36541622473 occurs in π(pi) at position 36541622473, counting from ...
user avatar
  • 2,147
2 votes
1 answer
33 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 ...
user avatar
  • 335
0 votes
1 answer
77 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 ...
user avatar
  • 1,787
1 vote
1 answer
97 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?
user avatar
  • 2,147
1 vote
0 answers
79 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: ...
user avatar
  • 483
1 vote
2 answers
90 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 ...
user avatar
  • 123
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 ...
user avatar
2 votes
2 answers
96 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 ...
user avatar
1 vote
0 answers
60 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 ...
user avatar
  • 186
4 votes
2 answers
130 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?
user avatar
1 vote
2 answers
125 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}^{\...
user avatar
2 votes
2 answers
180 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. ...
user avatar
0 votes
3 answers
154 views

How to find the limit of this recursive sequence

I want to find the limit of the following recursive sequence when n tends to : ...
user avatar
4 votes
1 answer
250 views

What does Sequence[2,4]^2 mean?

I am learning pattern matching. An example that confuse me is as follows. Foo[x__?EvenQ] := x^2; Foo[2, 4] which is equal to ...
user avatar
5 votes
1 answer
107 views

head of a sequence

Why does Head[Sequence[b, c]] return c[Symbol] and not Sequence? Why does ...
user avatar
  • 1,004
2 votes
1 answer
49 views

Splice matching function arguments

Mathematica 12.1 introduces Splice that replaces the old way of using Sequence@@ to "melt" a list of entries. However, the ...
user avatar
  • 777
1 vote
0 answers
38 views

Apply SequenceReplace with a fixed shift

How can I apply SequenceReplace with a fixed prespecified shift instead of a shift equal to the length of the pattern, on a given list? E.g. ...
user avatar
  • 1,548
6 votes
2 answers
286 views

Build general form of an infinite sequence

Please, I would like to build the general form of an infinite number sequence $$\dfrac{8}{35}, \dfrac{5}{21} ,\dfrac{8}{33} ,\dfrac{35}{143},\dfrac{16}{65} ,\dfrac{21}{85} ,\dfrac{80}{323},\...
user avatar
  • 449
0 votes
1 answer
46 views

Plot any parametrization (pure function, numbered variables)

I'd like to write a function plot[reg_,f_] that takes as input any product of intervals (list of pairs of reals) reg$\subseteq\!\...
user avatar
  • 1,095
2 votes
0 answers
66 views

FindSequenceFunction instantly throws an exception

FindSequenceFunction[{2, 4, 6, 7, 14, 29, 18, 5, 5, 2, 4}] SystemException["MemoryAllocationFailure"] $Version "12.0.0 ...
user avatar
1 vote
1 answer
93 views

How to write f[ t[i],...,t[i+r] ]=f [t[i+1],...,t[i+r] ]- f[ t[i] ,...,t[i+r-1] ] in Mathematica for 0 <= i <= n , 0<= r <= n [closed]

For[[[[[[[[[[[Do[]]]]]]]]]]]]]
user avatar
6 votes
0 answers
178 views

How can I prevent errors with ReplicateLayer[]?

I am trying to build a NetGraph[] that takes input of the form {{0.6},{0.6},...,{0.8},{0.8}} and multiplies the last sequence ...
user avatar
  • 1,397
2 votes
2 answers
74 views

Select subsets from a list based on a criterion?

Assume we have a set of numbers, for instance $A=\{2,3,4,5,6,7,8,9,10\}$ and we are looking for the sums of reciprocals such that they are less than one. I mean I am looking for all $S_B$'s $$ S_B=\...
user avatar
  • 798
12 votes
2 answers
216 views

The use of SlotSequence in If[#1 > #2, ##] &

The below function when applied to a list of two elements, will output the maximum between the two: If[#1 > #2, ##] & For example: ...
user avatar
4 votes
3 answers
463 views

Slow computation of recursive sequences

I want to investigate the asymptotic behavior of the following recursive system: ...
user avatar
0 votes
0 answers
82 views

How to convert a symbolic recursive formula to a non-recursive one

I am new to Mathematica. I want to convert a recursive formula to a non-recursive one using symbolic math. Specifically, I have a recursive formula similar to this: $a_n = f_a(c_{n-1}, x_{n-1})$ $...
user avatar
  • 101