# Tag Info

4

A zero-order interpolation is a good way to in effect invert the function from positive integers to values in sortedlist. Timing[ table = Table[N[n^2 + m^2], {n, 1, 3000}, {m, 1, 3000}]; sortedlist = Sort[Apply[Join, table[[1 ;; 50]]]]; lastpairs = SplitBy[Join[{{0, 0}}, Transpose[{sortedlist, Range[Length[sortedlist]]}]], First][...

3

Here are some suggestions for simpler methods to find the counts, and to make a plot. Instead of Array[table[[#]]&, 50]] use table[[;; 50]]. Check the documentation for Part. An easy way to count the number of values that are less or equal to $x$, is to count the values with Tally, and then total the tallies with Accumulate. table = Table[N[n^2 + m^2], {...

16

Workaround: This issue seems to be related to caching of previous numerical values. If we clear the cache during each iteration we get a result back: Table[ ClearSystemCache["Numeric"]; N[Log[Im[ZetaZero[n + 1]]/Im[ZetaZero[n]]]], {n, 1, 128} ]; // AbsoluteTiming {6.8104, Null} What to do Report this to WRI. It's strange that N[ZetaZero[...

3

If expr is your expression with the Inactivate, and you're looking for a complex (Wirtinger) derivative, then we can use ResourceFunction["ComplexD"] and simplify assuming t is real valued: FullSimplify[ ResourceFunction["ComplexD"][expr, t] , t ∈ Reals] Which gives us: (-0.92 sqr Cosh[(sqr t)/2] + (0.8448 + 0.25 sqr^2) Sinh[(sqr t)/2])...

2

If the plot is the main goal, then this is simplest: xsol = NDSolveValue[eqns, x, {t, t0, tfin}] (* N.B. x, not x[s] *) ListLinePlot@xsol See also Easy way to plot ODE solutions from NDSolve?

1

You can use a Table: With[{x0 = {1, 3, 6}, t0 = 0,tfin = 5}, solx[s_] = Table[NDSolveValue[{x'[t] == -x[t], x[0] == x0[[i]]}, x[s], {t, t0, tfin}], {i, 1, Length[x0]}]; Plot[Evaluate[solx[t]], {t, 0, 5}]]

3

You can use Indexed: Plot[Evaluate @ Table[Indexed[xsol[t], i], {i, 3}], {t, t0, tfin}]

2

Perhaps this is what you want: x0 = {1, 3, 6}; eqns = {x'[t] == -x[t], x[0] == #} &; t0 = 0; tfin = 5; xsol[s_] = NDSolveValue[eqns@#, x[s], {t, t0, tfin}] & /@ x0 Plot[Evaluate@xsol[t], {t, t0, tfin}]

10

Root Cause The root cause of the error is that we are attempting to join tensors of incompatible shapes. Namely, a 1x2 array... Dimensions[{{0,0}}] (* {1, 2} *) ... with a zero-length one-dimensional array: Dimensions[ConstantArray[{0, 0}, 0]] (* {0} *) Dimensions[{}] (* {0} *) While this is permitted by the main evaluator, the compiler applies stricter ...

11

I think it's a bug that DeleteCases does not work; more specifically, it is not permitted to return an empty tensor when deleting elements from an tensor of rank > 1. Compile can return an empty tensor, but certain internal functions cannot. In particular Table in this case, but also Part. It seems a complicated situation, would take a long time to ...

2

You can also hold then release: Hold[rvec[[2]]] /. rvec -> {x, y} // ReleaseHold y Pattern replacement works through hold.

3

Using exact math works: subst = SetPrecision[{μ -> 1.0649627263045793 mχ, mχ -> m0, μF -> 0.126881598, σ0 -> 5.137783801543852*^-18, nn -> 0.0022767242753033053, B0 -> 0.5801875039070804, mn -> 0.939}, ...

4

It's instructive to look at the output of TracePrint. Length[Unevaluated[1 + 1 + 1 + 1]] // TracePrint (* Out: *) Length[Unevaluated[1+1+1+1]] Length Length[1+1+1+1] 4 Whereas f[Unevaluated[1 + 1 + 1 + 1]] // TracePrint (* Out: *) f[Unevaluated[1+1+1+1]] f f[1+1+1+1] Length[1+1+1+1] Length 1+1+1+1 Plus 1 1 1 1 4 Length[4] ...

0

Try this (which works in 0.1 second): Clear[numNeeded, dimension, thevecs, thevertices, theWeights, numConstraints]; numNeeded = 50; dimension = 15; numConstraints = 1000; thevecs = Normalize /@ RandomReal[{-1, 1}, {numConstraints, dimension}]; thevertices = Flatten[Table[Drop[thevecs, {i}], {i, Length[thevecs]}], 1]; theWeights = Normalize /@ ...

Top 50 recent answers are included