Questions tagged [sequence]

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

Filter by
Sorted by
Tagged with
4 votes
1 answer
98 views

How can I find some first terms of a sequence?

I have a sequence knowing that $a_1=15$, $a_{n+1} = a_n + \sqrt{2a_{n+1}-a_n}$. I want to find some the first terms. I tried by my hand ...
Thuy Nguyen's user avatar
2 votes
1 answer
90 views

Why is there such a problem with finding a formula for the general term of a sequence?

FindSequenceFunction[{1, 2, 5, 14, 41}, n] 1/6 (3 + 3^n) You can directly calculate the general term formula above Why is it impossible to find the general term ...
csn899's user avatar
  • 2,905
0 votes
2 answers
92 views

Generating sequence from a number with Precision

This question was from the End-Semester question paper of the previous year of my Course on Wolfram Mathematica - Apparently when I try to code it, something is going wrong with respect to Precision - ...
Venkatakrishnan's user avatar
6 votes
4 answers
413 views

Subdivide a sequence

Yesterday I couldn't solve a problem which seemed to be rather simple. I tried RepleaceRepeated, SequenceReplace and similar ...
eldo's user avatar
  • 48.9k
20 votes
6 answers
826 views

Peaks, plateaus and ledges

I want to find the peaks, plateaus and ledges of an integer sequence, but all my attempts failed. 1. Example list ...
eldo's user avatar
  • 48.9k
5 votes
4 answers
181 views

Joining constant arrays determined by a subsequence of contiguous block of ones

I have the following: data = {15, 25, 35, 45, 55, 65, 75, 85, 95, 105}; selector = {0, 1, 1, 0, 1, 1, 1, 0, 0, 0}; I want to create the following list from ...
IntroductionToProbability's user avatar
9 votes
6 answers
1k views

How can I define a sequence of Integers which only contains the first k integers, then doesnt contain the next j integers, and so on

I need a list of integers to check if a variable has one of the values of the list. If[ MemberQ[List,x], Green, Red] The list contains integers and is characterized ...
100xln2's user avatar
  • 427
1 vote
1 answer
62 views

Why doesn't Sequence@@ work inside Manipulate[]?

I'm trying to use Manipulate[] and I need to have a non-fixed amount of sliders. I tried writing something like: ...
Nuno Catalão's user avatar
1 vote
0 answers
38 views

Sequence reconstruction from ordered subsamples

Given a sequence (we'll assume of integers) like seq = {1, 0, 0, 1, 2, 0, 1} I can take a random permutation ...
b3m2a1's user avatar
  • 46.6k
6 votes
3 answers
292 views

Split list into ascending sublists

I would like to split a list into non-overlapping, ascending (more precisely, non-descending with ≤) sublists. The function would be close to LongestOrderedSequence,...
SnzFor16Min's user avatar
  • 2,180
4 votes
3 answers
213 views

Find shortest subsequence

We will deal with arrays of chars, but not strings! Let we have the next three arrays: ...
lesobrod's user avatar
  • 1,197
0 votes
1 answer
41 views

Derivative with respect to a sequence

I want D[Subscript[a, k],Subscript[a,j]] to return something like the Kronecker delta. Is this possible?
Aakash Lakshmanan's user avatar
2 votes
1 answer
92 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 ...
SKS's user avatar
  • 23
0 votes
1 answer
88 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$. ...
mjw's user avatar
  • 2,096
5 votes
0 answers
61 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 ...
podge cassidy's user avatar
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 ...
xdavidliu's user avatar
  • 181
0 votes
0 answers
21 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 <...
abnowack's user avatar
  • 113
10 votes
7 answers
649 views

Select data from a structured list

Let's suppose we have the following structure of data ...
Vaggelis_Z's user avatar
  • 8,560
1 vote
2 answers
101 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= ...
Young's user avatar
  • 259
0 votes
1 answer
78 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 : ...
Anna MSJ's user avatar
1 vote
3 answers
108 views

Rewrite the list without certain elements in the sequence

I have a list1: ...
Mam Mam's user avatar
  • 1,753
4 votes
4 answers
208 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: ...
Филипп Цветков's user avatar
2 votes
5 answers
273 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 ...
Jamie M's user avatar
  • 493
3 votes
2 answers
134 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: ...
1689vantil's user avatar
3 votes
2 answers
191 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: ...
Red Banana's user avatar
  • 5,121
5 votes
1 answer
82 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: ...
Syed's user avatar
  • 42k
5 votes
3 answers
231 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: ...
Suite401's user avatar
  • 4,313
2 votes
2 answers
193 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 ...
Red Banana's user avatar
  • 5,121
0 votes
0 answers
48 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$ ...
math2021's user avatar
  • 689
2 votes
2 answers
265 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? ...
Brotos's user avatar
  • 31
0 votes
0 answers
43 views

Problem with FindGeneratingFunction

I have a lengthy function of a real parameter $n$ that generates values $val$ for each $n$ {$n$, $val$}: ...
Sid's user avatar
  • 977
6 votes
2 answers
198 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 ...
Teabelly's user avatar
  • 984
1 vote
1 answer
122 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: ...
coconut2000's user avatar
0 votes
0 answers
60 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) < ...
yode's user avatar
  • 26.4k
0 votes
1 answer
84 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. ...
Young's user avatar
  • 259
0 votes
1 answer
204 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 ...
Keyspire's user avatar
  • 359
3 votes
1 answer
90 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 ...
polfosol's user avatar
  • 952
0 votes
0 answers
67 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 ...
ThunderBiggi's user avatar
  • 1,195
5 votes
1 answer
102 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 ...
Hauke Reddmann's user avatar
2 votes
1 answer
80 views

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

I'm trying to define a function that is of this form: ...
Timevortex's user avatar
2 votes
0 answers
105 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 <...
TDH's user avatar
  • 429
1 vote
0 answers
34 views

What subsequences does SequenceReplace consider

Consider SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e]. What subsequences does SequenceReplace consider? The ...
user106860's user avatar
0 votes
1 answer
66 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] ...
user106860's user avatar
1 vote
1 answer
209 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 ...
jabberwocky's user avatar
4 votes
1 answer
174 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: ...
Yassin's user avatar
  • 199
7 votes
4 answers
424 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 : ...
Yassin's user avatar
  • 199
3 votes
1 answer
78 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. ...
CMB's user avatar
  • 117
4 votes
1 answer
82 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. ...
H.v.M.'s user avatar
  • 1,073
4 votes
1 answer
69 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: ...
Display Name's user avatar
  • 1,879
3 votes
2 answers
239 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 ...
Jonathan Kinlay's user avatar