# Tag Info

5

This is probably not going to be the best answer but offering it as an opener or as a guide to towards a better solution Setting your initial input as a function f[n_]:=Length[Select[IntegerPartitions[10],First[#]==n&]] then Map[f,Range[10]] {1, 5, 8, 9, 7, 5, 3, 2, 1, 1} No doubt regular contributors can improve on this

4

There are as usual several ways. The most convenient one is probably MemberQ, as already pointed out in the comments. MemberQ[{1, 2, 3, 4, 9}, 9] (* True *) If you have a complex structure and not only a flat list, then FreeQ can be of use. Note that you have to negate the result. MemberQ[{1, 2, {3}, {{4, 9}}}, 9] Not[FreeQ[{1, 2, {3}, {{4, 9}}}, 9]] (* ...

3

There is a nice combination of Prime and PrimePi: count3[n_] := Sum[1, {i, PrimePi[n]}, {j, i, PrimePi[n/Prime[i]]}, {k, j, PrimePi[n/Prime[i]/Prime[j]]}]; count3[100000.] // AbsoluteTiming {0.157486, 25556} It is ~30 times faster: Omega3Count[100000] // AbsoluteTiming {4.445524, 25556} Update A general solution (with Coolwater's ...

3

For clarity, I would write the expression as a symbolic expression and a bunch of numerical replacement rules. So igSymbolic = (a s)/((b + c s) (d + e s^2)) and replRules={a -> 3.25269*10^7, b -> 424000., c -> 923., d -> 142122., e -> 1}. You don't need ExpToTrig here, the inverse Laplace transform of your expression is a decaying ...

3

You can try this myFunc[q_, f_ + g_] := myFunc[q, f] + myFunc[q, g] myFunc[q_, a_ f_state] := a myFunc[q, f] /; FreeQ[a, state] So that myFunc[q, a state[c, d]] a myFunc[q, state[c,d] ] and myFunc[q, a state[c, d] + b state[e, h]] a myFunc[q, state[c, d]] + b myFunc[q, state[e, h]] You can still assign a specific definition to ...

2

Something like this? n = 5; xi = Array[x, n] f[x_, t_] := -Log[t] - Log[1 - x.x - t^2] {x[1], x[2], x[3], x[4], x[5]} D[f[x, t], t] D[f[xi, t], x[3]] D[f[xi, t], x[1], t] $\frac{2 t}{-t^2-x.x+1}-\frac{1}{t}$ $\frac{2 x(3)}{-t^2-x(1)^2-x(2)^2-x(3)^2-x(4)^2-x(5)^2+1}$ \$\frac{4 t ...

2

I found same answer as ybeltukov, but a little improvment using cubic root (i see now the difference is actually significant (130 times faster than omega3count)): co2[k_]:=Sum[1,{n,PrimePi[Power[k, (3)^-1]]}, {m,n,PrimePi[k/Prime[n]^2]},{l,m,PrimePi[k/(Prime[n]Prime[m])]}] Result: Timing[Omega3Count[310123]] {14.383000000000001`,78591} Versus ...

1

If your interval is from 1 to 80 then this defines your range (which is from min to max): r[q_] := 30 q - 0.3 q^2; Plot[r[q], {q, 1, 80}] For plotting you need a min and a max. Or didn't I understand your question?

1

EDIT Using Sow and Reap for general function. Mush less efficient than ybeltukov: cnt[k_, n_] := Last@Reap[Sow[1, PrimeOmega@#] & /@ Range[n], k, Total@#2 &] Timing: cnt[3, 100000] // AbsoluteTiming yields: {2.263500, {25556}} Reassuringly same result... ORIGINALANSWER You could use Pick: f[u_] := Pick[Range[u], PrimeOmega /@ Range[u], ...

1

You can also perform this without "netsted functions" issue. For example: Count[IntegerPartitions[10][[All, 1]], #] & /@ Range[10] It could be even faster but we have to assume that you know the output of IntegerPartitions (explained on the bottom): Reverse @ Tally[IntegerPartitions[10][[All, 1]]][[All, 2]] Description IntegerPartitions[10][[All, ...

Only top voted, non community-wiki answers of a minimum length are eligible