Given that I have the following code:

points = N@Solve[{x^2 + 3 x - 1 + y - 1 == 0, 3 x - y^2 + 1 - 1 == 0}, Reals];
{x, y} /. points

Which gives me the output:

{{0.93389, -1.67382}, {0.311843, 0.967227}}

In this case, how can I remove the first curly brackets in order to obtain:

{0.93389, -1.67382}, {0.311843, 0.967227}

I tried with

Row[{x, y} /. points]

but I am missing the commas. I need this because I am trying to make a grid, that is why I need the comma.

I do not know if it is allowed to ask two questions on the same post, but, is it possible in the above case to switch automatically between NSolve and Solve?

  • 1
    $\begingroup$ Sequence @@ ({x, y} /. points)? At first, it might not look as if it was what you are looking for, but it becomes clearer when you evaluate bla[Sequence @@ ({x, y} /. points)]... You may look up Apply in order to learn why it works. $\endgroup$ – Henrik Schumacher Jan 29 '18 at 23:53
  • $\begingroup$ With respect to the second question: What do you mean by switching automatically? When would you prefer NSolve and when Solve? $\endgroup$ – Henrik Schumacher Jan 29 '18 at 23:56
  • $\begingroup$ @HenrikSchumacher I am sorry I did not specify. When the solution involves Root or when it is very complicated, I would prefer NSolve, instead when the solution is simple and can be expressed in "closed form" I would prefer Solve. $\endgroup$ – DMH16 Jan 29 '18 at 23:59
  • $\begingroup$ @HenrikSchumacher How would I access the elements inside bla? After the evaluation I obtain bla[{0.93389, -1.67382}, {0.311843, 0.967227}] $\endgroup$ – DMH16 Jan 30 '18 at 0:03
  • 1
    $\begingroup$ Maybe Row[{x, y} /. points, ","]? $\endgroup$ – user1066 Jan 30 '18 at 0:44

With respect to the second question: Here is something to start with. Use it in the same way as you would use Solve.

MySolve[args___] := Module[{sol, threashold, b = True},
  threashold = 100;
  sol = Solve[args];
   ! MissingQ[FirstPosition[sol, _Root]],
   Print["NSolve used because of Root expressions."];
   sol = N[sol];
   LeafCount[sol] > threashold,
   Print["NSolve used because expression was too complicated."];
   sol = NSolve[args];
   Head[sol] === Solve,
   Print["NSolve used because Solve returned unevaluated expression."];
   sol = NSolve[args];
  • $\begingroup$ If sol contains a Root object you don't need to solve again with NSolve, just use sol = sol//N $\endgroup$ – Bob Hanlon Jan 30 '18 at 0:28
  • $\begingroup$ @BobHanlon Good point. $\endgroup$ – Henrik Schumacher Jan 30 '18 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.