1
$\begingroup$

I am writing a public ResourceFunction and I need a good clever use case that should not appear to emulate any examples in the official documentation but will consider examples not commonly used. Definitely no Pause or deliberate time lags. Expression should be as short as possible while take close to 10 seconds to evaluate. I prefer expression NOT be Table, Do,For,While, or any other loops or iterators but I shall consider them.

So far I have one expression expr1 that uses a Do with no Pause which evaluates on my old laptop in just over 8 seconds.

expr1 = Timing[sum = 0; Do[sum += i, {i, 5000000}]; sum]

Here are a few examples of what I tried for expr2 but were too fast and even broke my Timing function. Quit and ClearSystemCache[] did not fix it. There were other things I tried but did not work.

(* results in {0.,3.68*10^(30102999)} *)
expr2=Timing[n=2.^1000000000;ScientificForm[n,3]]

(* results in {0.,9.58*10^(301029995663) *)
expr2=Timing[n=2.^1000000000;ScientificForm[n,3]]

In short expr2 should be:

  1. must use mathematics
  2. prefer not in docs (not a hard requirement)
  3. short as possible
  4. no Pause or other deliberate lags
  5. prefer no loops or iterators (not a hard requirement)
  6. timing close to 10 seconds

Thank you. I am looking forward to what you guys come up with.

$\endgroup$
13
  • 2
    $\begingroup$ You indicate that you want an expression that is "mathematical"; however, all of the examples that you give are "numeric". $\endgroup$
    – Bob Hanlon
    Commented Mar 11, 2022 at 17:41
  • 1
    $\begingroup$ How about PadeApproximant[MittagLefflerE[4, x], {x, 1, 6}] // AbsoluteTiming which results in {62.3867, large output}? $\endgroup$
    – user64494
    Commented Mar 11, 2022 at 17:59
  • 1
    $\begingroup$ Quite frankly I still don't get what the scope is. I mean the objective that defines what form the analytic function should have. Maybe I am being stupid and it's something well explained, but it's not obvious to me $\endgroup$
    – user49048
    Commented Mar 11, 2022 at 18:09
  • 1
    $\begingroup$ PadeApproximant[MittagLefflerE[4, x], {x, 1, 5}] // AbsoluteTiming is executed in 6.36297 s. $\endgroup$
    – user64494
    Commented Mar 11, 2022 at 18:13
  • 2
    $\begingroup$ Me too. What a question, such an answer. $\endgroup$
    – user64494
    Commented Mar 11, 2022 at 18:19

1 Answer 1

4
$\begingroup$

If I correctly understand the question, here is a possible one:

PadeApproximant[MittagLefflerE[4, x], {x, 1, 5}] // AbsoluteTiming

{6.36297 , large output}

$\endgroup$
5
  • 1
    $\begingroup$ (+1). Note worthy: it's much faster to do the {x,0,5} $\endgroup$
    – user49048
    Commented Mar 11, 2022 at 19:25
  • 1
    $\begingroup$ Sorry for the double comment, but along these lines this is also faster PadeApproximant[ HypergeometricPFQ[{1, 1}, {3, 3, 3}, x], {x, 0, 5}] // AbsoluteTiming yields {0.01508,stuff...}. And of course, the much humbler Series[HypergeometricPFQ[{1, 1}, {3, 3, 3}, x], {x, 0, 5}] // AbsoluteTiming gives {0.014726,stuff} $\endgroup$
    – user49048
    Commented Mar 11, 2022 at 19:28
  • $\begingroup$ @kcr can you modify Series[..]//AbsoluteTiming so that it goes for about 5 seconds? $\endgroup$ Commented Mar 11, 2022 at 20:44
  • $\begingroup$ @user64494 thank you answer was accepted. here is how i shall use it. i dont want to reveal my ResourceFunction yet so Beep will stand in for it: Timing[(beeg = Iconize[PadeApproximant[MittagLefflerE[4, x], {x, 1, 5}], "beeg output"]; Beep[]; beeg)]. $\endgroup$ Commented Mar 11, 2022 at 20:56
  • 1
    $\begingroup$ @JulesManson you can play a bit with it, sure. I guess for higher order in the expansion you will get the desired timeframe $\endgroup$
    – user49048
    Commented Mar 11, 2022 at 21:48