New answers tagged

2

Per my comment, observe: myGB[lst_, tst_] := With[{gb = GatherBy[lst, tst]}, If[Length@gb == 1, AssociationThread[{tst@gb[[1, 1]]} -> gb], AssociationThread[{tst@gb[[1, 1]], tst@gb[[2, 1]]} -> gb]]]; Then test with the following. The results will be the same. xxx = {1, 1, 1, 1, 1, 1}; seed = RandomInteger[500]; SeedRandom[seed]; GroupBy[xxx, # ...


13

The problem is that GroupBy uses the key function once to map over all of the elements, and then it uses it again for each distinct key. As an example, consider: SeedRandom[3]; f[x_] := x > RandomReal[2] TraceScan[ Identity, GroupBy[{1, 1, 1, 1, 1, 1}, f], _Map, Print @* Rule, TraceInternal -> True ]; f/@{1,1,1,1,1,1}->{True,...


12

It seems (clearly!) to be a bug in the preprocessing for the new convex optimizer. Use one of the other methods (e.g. "DifferentialEvolution"): Trace[ NMaximize[E^(-x^2) - 1, x], _Optimization`MinimizationProblem, TraceForward -> True, TraceInternal -> True ] Workaround: NMaximize[E^(-x^2) - 1, x, Method -> "...


2

If ImplicitRegion was working properly you would not get a plot. If you are trying to plot the equation: funcs = y /. Solve[x^2 + y^2 == -1, y]; ReImPlot[funcs, {x, -Pi, Pi}, PlotStyle -> {AbsoluteThickness[3], Automatic}, PlotLegends -> Automatic]


Top 50 recent answers are included