0
$\begingroup$

The known equation is:

(1 + 62 x)^99 + (62 - x)^99 == a0 + a1  x + a2  x^2 + a3  x^3 + ... + 
 a99  x^99

And

a0, a1, a3, ..., a99 \[Element] Reals

When

ak < 0, k \[Element] Integers, 0 <= k <= 99

Find the maximum value of k that satisfies ak < 0, where k is an integer and k is between 0 and 99 inclusive.


The table function was used to list all the coefficients, but the maximum value of k that satisfies the condition was not determined.

Table["a" <> ToString[k] <> "=" <> 
  ToString[
   Coefficient[(1 + 62 x)^99 + (62 - x)^99 // Expand, x, k]], {k, 0, 
  99, 1}]

From the data generated above, only the maximum value of k that meets the condition can be viewed.

$\endgroup$
1

3 Answers 3

2
$\begingroup$

This finds positions of all negative coefficients. You want the last one. But since the position of coefficient's position is indexed from 1 to 100 and you want them 0 to 99 you need to subtract 1.

CoefficientList[(1 + 62 x)^99 + (62 - x)^99, x];
Position[%, x_ /; x < 0]
Last[%]-1

{{2},{4},{6},{8},{10},{12},{14},{16},{18},{20},{22},{24},{26},
{28},{30},{32},{34},{36},{38},{40},{42},{44},{46},{48},{50}}

{49}
$\endgroup$
2
$\begingroup$

You can use Sow and Reap:

p= (1 + 62 x)^99 + (62 - x)^99;
Reap[Table[Sow[j,Coefficient[p,x,j]],{j,0,99}],_?(#<0&),#2&][[2,-1]]

yields {49}

$\endgroup$
1
$\begingroup$

Use user-defined ZipWithIndexStartsFrom0 and DropWhile.

Clear["Global`*"];
ZipWithIndexStartsFrom1 = MapIndexed[Labeled, #] &;
ZipWithIndexStartsFrom0 = MapIndexed[Labeled[#1, #2 - 1] &, #] &;
DropWhile = Drop[#, LengthWhile[#, #2]] &;

Table[Coefficient[(1 + 62 x)^99 + (62 - x)^99 // Expand, x, k], {k, 0, 99, 1}] 
// ZipWithIndexStartsFrom0
// Reverse 
// DropWhile[#, #[[1]] >= 0 &] & 
// TableForm
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.