Skip to main content
deleted 291 characters in body
Source Link
Command Master
  • 10.9k
  • 1
  • 15
  • 79

05AB1E, 23 22 19 1212 8 bytes

LŽsÄO*Lż{.Δβd 

Try it online!Try it online!

Takes as an input a number \$n\$ and the coefficients list, from the highest power to the smallest one, and returns \$a_n\$.

Requires the leading coefficient to be positive. If that is invalid, we need +2 bytes to fix it by adding after β

If this is invalid because we may not assume \$\sin\$\$\tan\$ has infinite precision, then the following 13 bytes alternative could be used, which uses a spacing of \$\frac1 n\$ for the \$x\$s inside a bound:

*ÄO(D(Ÿ¹/.Δβd 

Explanation

Uses the fact that \$ \sum_{i=0}^m{|c_i|}\$ is a bound on polynomial roots (when \$|c_m| \geq 1\$, which is always the case for integer coefficients) to findFinds the non-negative value of \$p(x)\$ (\$p(x) \cdot c_m\$ in the version which doesn't require a positive leading coefficient) with the smallest \$x\$ among the values \$ x = bound \cdot \sin(i) \$\$ x = \tan(i) \$ for \$ 1 \leq i \leq n \$. This is correct since the sineThe \$\tan\$ of integers is dense in \$\mathbb{R}\$ (Since \$ n\mod \pi\$ is dense in the range \$[-1, 1]\$\$(0, \pi)\$ ), so we can get arbitrarily close to the target number, and since we always keep \$x\$s as \$n\$ increases the sequence is non-increasing. Additionally, uses the fact that base conversion is the same action as evaluating a polynomial at the base, and that 05AB1E's base conversion builtin works well with non-integers.

L Get the range [1, 2, 3, ..., n] Žż Calculate the sinetangent of each number in that range s Swap, so the polynomial is on top Ä Absolute value of each coefficient O Sum the absolute values * Multiply those sin(x)-s by the bound { And sort themthose .Δ Now find the first value such that β When converting the polynomial from that base d It is non-negative 

05AB1E, 23 22 19 12 bytes

LŽsÄO*{.Δβd 

Try it online!

Takes as an input a number \$n\$ and the coefficients list, from the highest power to the smallest one, and returns \$a_n\$.

Requires the leading coefficient to be positive. If that is invalid, we need +2 bytes to fix it by adding after β

If this is invalid because we may not assume \$\sin\$ has infinite precision, then the following 13 bytes alternative could be used, which uses a spacing of \$\frac1 n\$ for the \$x\$s:

*ÄO(D(Ÿ¹/.Δβd 

Explanation

Uses the fact that \$ \sum_{i=0}^m{|c_i|}\$ is a bound on polynomial roots (when \$|c_m| \geq 1\$, which is always the case for integer coefficients) to find the non-negative value of \$p(x)\$ (\$p(x) \cdot c_m\$ in the version which doesn't require a positive leading coefficient) with the smallest \$x\$ among the values \$ x = bound \cdot \sin(i) \$ for \$ 1 \leq i \leq n \$. This is correct since the sine of integers is dense in the range \$[-1, 1]\$, so we can get arbitrarily close to the target number, and since we always keep \$x\$s as \$n\$ increases the sequence is non-increasing. Additionally, uses the fact that base conversion is the same action as evaluating a polynomial at the base, and that 05AB1E's base conversion builtin works well with non-integers.

L Get the range [1, 2, 3, ..., n] Ž Calculate the sine of each number in that range s Swap, so the polynomial is on top Ä Absolute value of each coefficient O Sum the absolute values * Multiply those sin(x)-s by the bound { And sort them .Δ Now find the first value such that β When converting the polynomial from that base d It is non-negative 

05AB1E, 23 22 19 12 8 bytes

Lż{.Δβd 

Try it online!

Takes as an input a number \$n\$ and the coefficients list, from the highest power to the smallest one, and returns \$a_n\$.

Requires the leading coefficient to be positive. If that is invalid, we need +2 bytes to fix it by adding after β

If this is invalid because we may not assume \$\tan\$ has infinite precision, then the following 13 bytes alternative could be used, which uses a spacing of \$\frac1 n\$ for the \$x\$s inside a bound:

*ÄO(D(Ÿ¹/.Δβd 

Explanation

Finds the non-negative value of \$p(x)\$ (\$p(x) \cdot c_m\$ in the version which doesn't require a positive leading coefficient) with the smallest \$x\$ among the values \$ x = \tan(i) \$ for \$ 1 \leq i \leq n \$. The \$\tan\$ of integers is dense in \$\mathbb{R}\$ (Since \$ n\mod \pi\$ is dense in the range \$(0, \pi)\$ ), so we can get arbitrarily close to the target number, and since we always keep \$x\$s as \$n\$ increases the sequence is non-increasing. Additionally, uses the fact that base conversion is the same action as evaluating a polynomial at the base, and that 05AB1E's base conversion builtin works well with non-integers.

L Get the range [1, 2, 3, ..., n] ż Calculate the tangent of each number in that range { And sort those .Δ Now find the first value such that β When converting the polynomial from that base d It is non-negative 
added 1 character in body
Source Link
Command Master
  • 10.9k
  • 1
  • 15
  • 79

05AB1E, 23 22 19 12 bytes

LŽsÄO*{.Δβd 

Try it online!

Takes as an input a number \$n\$ and the coefficients list, from the highest power to the smallest one, and returns \$a_n\$.

Requires the leaderleading coefficient to be positive. If that is invalid, we need +2 bytes to fix it by adding after β

If this is invalid because we may not assume \$\sin\$ has infinite precision, then the following 13 bytes alternative could be used, which uses a spacing of \$\frac1 n\$ for the \$x\$s:

*ÄO(D(Ÿ¹/.Δβd 

Explanation

Uses the fact that \$ \sum_{i=0}^m{|c_i|}\$ is a bound on polynomial roots (when \$|c_m| \geq 1\$, which is always the case for integer coefficients) to find the non-negative value of \$p(x)\$ (\$p(x) \cdot c_m\$ in the version which doesn't require a positive leading coefficient) with the smallest \$x\$ among the values \$ x = bound \cdot \sin(i) \$ for \$ 1 \leq i \leq n \$. This is correct since the sine of integers is dense in the range \$[-1, 1]\$, so we can get arbitrarily close to the target number, and since we always keep \$x\$s as \$n\$ increases the sequence is non-increasing. Additionally, uses the fact that base conversion is the same action as evaluating a polynomial at the base, and that 05AB1E's base conversion builtin works well with non-integers.

L Get the range [1, 2, 3, ..., n] Ž Calculate the sine of each number in that range s Swap, so the polynomial is on top Ä Absolute value of each coefficient O Sum the absolute values * Multiply those sin(x)-s by the bound { And sort them .Δ Now find the first value such that β When converting the polynomial from that base d It is non-negative 

05AB1E, 23 22 19 12 bytes

LŽsÄO*{.Δβd 

Try it online!

Takes as an input a number \$n\$ and the coefficients list, from the highest power to the smallest one, and returns \$a_n\$.

Requires the leader coefficient to be positive. If that is invalid, we need +2 bytes to fix it by adding after β

If this is invalid because we may not assume \$\sin\$ has infinite precision, then the following 13 bytes alternative could be used, which uses a spacing of \$\frac1 n\$ for the \$x\$s:

*ÄO(D(Ÿ¹/.Δβd 

Explanation

Uses the fact that \$ \sum_{i=0}^m{|c_i|}\$ is a bound on polynomial roots (when \$|c_m| \geq 1\$, which is always the case for integer coefficients) to find the non-negative value of \$p(x)\$ (\$p(x) \cdot c_m\$ in the version which doesn't require a positive leading coefficient) with the smallest \$x\$ among the values \$ x = bound \cdot \sin(i) \$ for \$ 1 \leq i \leq n \$. This is correct since the sine of integers is dense in the range \$[-1, 1]\$, so we can get arbitrarily close to the target number, and since we always keep \$x\$s as \$n\$ increases the sequence is non-increasing. Additionally, uses the fact that base conversion is the same action as evaluating a polynomial at the base, and that 05AB1E's base conversion builtin works well with non-integers.

L Get the range [1, 2, 3, ..., n] Ž Calculate the sine of each number in that range s Swap, so the polynomial is on top Ä Absolute value of each coefficient O Sum the absolute values * Multiply those sin(x)-s by the bound { And sort them .Δ Now find the first value such that β When converting the polynomial from that base d It is non-negative 

05AB1E, 23 22 19 12 bytes

LŽsÄO*{.Δβd 

Try it online!

Takes as an input a number \$n\$ and the coefficients list, from the highest power to the smallest one, and returns \$a_n\$.

Requires the leading coefficient to be positive. If that is invalid, we need +2 bytes to fix it by adding after β

If this is invalid because we may not assume \$\sin\$ has infinite precision, then the following 13 bytes alternative could be used, which uses a spacing of \$\frac1 n\$ for the \$x\$s:

*ÄO(D(Ÿ¹/.Δβd 

Explanation

Uses the fact that \$ \sum_{i=0}^m{|c_i|}\$ is a bound on polynomial roots (when \$|c_m| \geq 1\$, which is always the case for integer coefficients) to find the non-negative value of \$p(x)\$ (\$p(x) \cdot c_m\$ in the version which doesn't require a positive leading coefficient) with the smallest \$x\$ among the values \$ x = bound \cdot \sin(i) \$ for \$ 1 \leq i \leq n \$. This is correct since the sine of integers is dense in the range \$[-1, 1]\$, so we can get arbitrarily close to the target number, and since we always keep \$x\$s as \$n\$ increases the sequence is non-increasing. Additionally, uses the fact that base conversion is the same action as evaluating a polynomial at the base, and that 05AB1E's base conversion builtin works well with non-integers.

L Get the range [1, 2, 3, ..., n] Ž Calculate the sine of each number in that range s Swap, so the polynomial is on top Ä Absolute value of each coefficient O Sum the absolute values * Multiply those sin(x)-s by the bound { And sort them .Δ Now find the first value such that β When converting the polynomial from that base d It is non-negative 
deleted 136 characters in body
Source Link
Command Master
  • 10.9k
  • 1
  • 15
  • 79

05AB1E, 23 22 1919 12 bytes

ÄOsLŽ*LŽsÄO*{.Δ∞<m¹¤**OdΔβd 

Try it online!Try it online!

Takes as an input a number \$n\$ and the coefficients list, from the lowesthighest power to the biggestsmallest one, and a number \$n\$, and returns \$a_n\$.

Requires the leader coefficient to be positive. If that is invalid, we need +2 bytes to fix it by adding after β

If this is invalid because we may not assume \$\sin\$ has infinite precision, then the following 2013 bytes alternative could be used, which uses a spacing of \$\frac1 n\$ for the \$x\$s:

ÄO**ÄO(D(Ÿ²Ÿ¹/.Δ∞<m¹¤**OdΔβd 

If we can require the leading term to be positive we can remove the ¤* (in both versions) for -2 bytes.

Uses the fact that \$ \sum_{i=0}^m{|c_i|}\$ is a bound on polynomial roots (when \$|c_m| \geq 1\$, which is always the case for integer coefficients) to find the non-negative value of \$p(x)\$ (\$p(x) \cdot c_m\$ in the version which doesn't require a positive leading coefficient) with the smallest \$x\$ among the values \$ x = bound \cdot \sin(i) \$ for \$ 1 \leq i \leq n \$. This is correct since the sine of integers is dense in the range \$[-1, 1]\$, so we can get arbitrarily close to the target number, and since we always keep \$x\$s as \$n\$ increases the sequence is non-increasing. Additionally, uses the fact that base conversion is the same action as evaluating a polynomial at the base, and that 05AB1E's base conversion builtin works well with non-integers.

Ä Absolute value of each coefficient O Sum the absolute values s Swap with, so now n is on top L Get the range [1, 2, 3, ..., n] Ž Calculate the sine of each number in that range * s Multiply those numbersSwap, byso the bound { polynomial Andis sorton themtop Ä Now find the firstAbsolute value suchof thateach coefficient O ∞< PushSum the infinite list [0, 1, 2, 3,absolute ...]values  m * Calculate x^n forMultiply eachthose nsin(x)-s inby the listbound  ¹ { Get theAnd polynomial'ssort coefficientsthem  ¤ Now Getfind the lastfirst coefficient,value withoutsuch poppingthat  * β Multiply it with allWhen ofconverting the coefficients *  And thenpolynomial multiplyfrom that with x^0, x^1, ... O  Calculate the sum of those productsbase d  And check if itIt is non-negative 

05AB1E, 23 22 19 bytes

ÄOsLŽ*{.Δ∞<m¹¤**Od 

Try it online!

Takes as an input the coefficients list, from the lowest power to the biggest one, and a number \$n\$, and returns \$a_n\$.

If this is invalid because we may not assume \$\sin\$ has infinite precision, then the following 20 bytes alternative could be used, which uses a spacing of \$\frac1 n\$ for the \$x\$s:

ÄO*(D(Ÿ²/.Δ∞<m¹¤**Od 

If we can require the leading term to be positive we can remove the ¤* (in both versions) for -2 bytes.

Uses the fact that \$ \sum_{i=0}^m{|c_i|}\$ is a bound on polynomial roots (when \$|c_m| \geq 1\$, which is always the case for integer coefficients) to find the non-negative value of \$p(x) \cdot c_m\$ with the smallest \$x\$ among the values \$ x = bound \cdot \sin(i) \$ for \$ 1 \leq i \leq n \$. This is correct since the sine of integers is dense in the range \$[-1, 1]\$, so we can get arbitrarily close to the target number, and since we always keep \$x\$s as \$n\$ increases the sequence is non-increasing.

Ä Absolute value of each coefficient O Sum the absolute values s Swap with, so now n is on top L Get the range [1, 2, 3, ..., n] Ž Calculate the sine of each number in that range *  Multiply those numbers by the bound {  And sort them  Now find the first value such that ∞< Push the infinite list [0, 1, 2, 3, ...]  m  Calculate x^n for each n in the list  ¹  Get the polynomial's coefficients  ¤ Get the last coefficient, without popping  * Multiply it with all of the coefficients *  And then multiply that with x^0, x^1, ... O  Calculate the sum of those products d  And check if it is non-negative 

05AB1E, 23 22 19 12 bytes

LŽsÄO*{.Δβd 

Try it online!

Takes as an input a number \$n\$ and the coefficients list, from the highest power to the smallest one, and returns \$a_n\$.

Requires the leader coefficient to be positive. If that is invalid, we need +2 bytes to fix it by adding after β

If this is invalid because we may not assume \$\sin\$ has infinite precision, then the following 13 bytes alternative could be used, which uses a spacing of \$\frac1 n\$ for the \$x\$s:

*ÄO(D(Ÿ¹/.Δβd 

Uses the fact that \$ \sum_{i=0}^m{|c_i|}\$ is a bound on polynomial roots (when \$|c_m| \geq 1\$, which is always the case for integer coefficients) to find the non-negative value of \$p(x)\$ (\$p(x) \cdot c_m\$ in the version which doesn't require a positive leading coefficient) with the smallest \$x\$ among the values \$ x = bound \cdot \sin(i) \$ for \$ 1 \leq i \leq n \$. This is correct since the sine of integers is dense in the range \$[-1, 1]\$, so we can get arbitrarily close to the target number, and since we always keep \$x\$s as \$n\$ increases the sequence is non-increasing. Additionally, uses the fact that base conversion is the same action as evaluating a polynomial at the base, and that 05AB1E's base conversion builtin works well with non-integers.

L Get the range [1, 2, 3, ..., n] Ž Calculate the sine of each number in that range s Swap, so the polynomial is on top Ä Absolute value of each coefficient O Sum the absolute values * Multiply those sin(x)-s by the bound { And sort them  Now find the first value such that β When converting the polynomial from that base d It is non-negative 
added 109 characters in body
Source Link
Command Master
  • 10.9k
  • 1
  • 15
  • 79
Loading
added 13 characters in body
Source Link
Command Master
  • 10.9k
  • 1
  • 15
  • 79
Loading
added 285 characters in body
Source Link
Command Master
  • 10.9k
  • 1
  • 15
  • 79
Loading
added 75 characters in body
Source Link
Command Master
  • 10.9k
  • 1
  • 15
  • 79
Loading
edited body
Source Link
Command Master
  • 10.9k
  • 1
  • 15
  • 79
Loading
added 1104 characters in body
Source Link
Command Master
  • 10.9k
  • 1
  • 15
  • 79
Loading
Source Link
Command Master
  • 10.9k
  • 1
  • 15
  • 79
Loading