Hello Johann,
Another thing,
Your program seems to give wrong answers and becomes much slower than
mine when the degree of p is >> 4.
Try maxterm(x^100 + 4x^3 + 3x^2 + 2x + 1, 5)
or more dramatically maxterm(x^1000 + 4x^3 + 3x^2 + 2x + 1, 5),
versus maxterm1(...).
Cheers,
Valeriu
On 2/6/2007, "Valeriu ANISIU" <[log in to unmask]> wrote:
>Hello Johann,
>
>I was aware from the beginning that your program is much faster.
>But your program does not use Derive as a CAS;
>it manipulates lists instead of polynomials
>(except for a derivative, but this can be also
>avoided).
>In an ideal CAS (an world) the manipulation of polynomials
>should be very efficient. My program is waiting
>for that moment -:).
>
>Best reards,
>Valeriu
>
>
>
>
>On 2/6/2007, "Johann Wiesenbauer" <[log in to unmask]> wrote:
>
>>Hello Valeriu,
>>
>>Great! Yes, as for brevity and elegance, your program is hard to surpass.
>>In particular, it makes excellent use of some built-in Derive features.
>>Even though, I hate to say it, but it is considerably slower (by a factor
>>of about 100 on my machine) than my program.
>>
>>You know, I have been in the programming business for decades now, and
>>nowadays I'm no longer the merciless performance hunter I used to be. If a
>>program is so elegant and short like yours, I would certainly accept a
>>lower performance to some degree. But here, as for me, this sacrifice of
>>performance is too much though. (Just a hint: Try to increase the exponent
>>n in this example up to say n=1000 and compare!)
>>
>>Cheers,
>>Johann
>>
>>At 19:57 06.02.2007, you wrote:
>>>Hello Johann, hello everybody,
>>>
>>>My solution is slower but simpler:
>>>
>>>maxterm1(u,n,x,c_,v_):=PROG(
>>>v_:=TERMS(EXPAND(u^n),x),c_:=SUBST(v_,x,1),v_ SUB POSITION(MAX(c_),c_)
>>>)
>>>
>>>However, the result of
>>>maxterm1(4*x^3 + 3*x^2 + 2*x + 1,100)
>>>
>>>namely
>>>
>>>39824366720341062302484823668460396313761926035630933326602206546298515593960~
>>>4195463780443664821745*x^200
>>>
>>>is obtained in < 2 seconds.
>>>
>>>Best regards,
>>>Valeriu
>>>
>>>
>>>
>>>On 2/6/2007, "Johann Wiesenbauer" <[log in to unmask]> wrote:
>>>
>>> >Hi folks,
>>> >
>>> >Now that Josef Boehm is about to reissue the DNL #13, I had a look at R.
>>> >Schorn's problem on page 3, namely to compute the maximal coefficient of
>>> >the polynomial
>>> >
>>> >(4x^3+3x^2+2x+1)^20
>>> >
>>> >Well, that was almost 13 years ago and it took Derive 387.2s then to find
>>> >the answer 8842311087597693745, which turns out to be the coefficient of
>>> x^40.
>>> >
>>> >Just to take into account the advances of both Derive and computers since
>>> >then, I would like to increase the exponent to say 100, and pose this as a
>>> >new challenge. (As there are vacations at the universities right now, I
>>> >thought, you might feel like a challenge!) In other words, what is the
>>> >maximal coefficient in the expansion of
>>> >
>>> >(4x^3+3x^2+2x+1)^100
>>> >
>>> >and in which monomial does it occur?
>>> >
>>> >I for my part also got my teeth into this nice problem and just in case you
>>> >want to compare with my solution (in Derive 6.10), you will find it in the
>>> >attachment.
>>> >
>>> >Cheers,
>>> >Johann)
|