问题描述:

I have a task to solve equation system with FindRoot:

a*x+b*y^2-c*x^2=a-b, a*x^2+b*y^2+b*x-cy=b+c , where a = 10, b = 10, c = 6;

I'm very(!) new to Mathematica and have one day to get to know it.

Any comments on how to solve that equation will be much appreciated!

Thanks!

网友答案:

This starts searching for root at x = 0 and y = 0

eq = {a*x + b*y^2 - c*x^2 == a - b, a*x^2 + b*y^2 + b*x - c*y == b + c}
param = {a -> 10, b -> 10, c -> 6}
result = FindRoot[eq /. param, {x, 0}, {y, 0}]

This only gives you 1 of the two Real solutions. Solve will give you both (and even some solutions with Complex numbers). To test it:

eq /. param /. result

This returns (True, True) so you know you've found the correct root.

To find the solution graphically, use ContourPlot:

ContourPlot[Evaluate[eq /. param], {x, -5, 5}, {y, -5, 5}]
网友答案:

Here is the version with Solve/NSolve

NSolve[{a*x + b*y^2 - c*x^2 == a - b, 
        a*x^2 + b*y^2 + b*x - c*y == b + c} /.  {a -> 10, b -> 10, c -> 6},
       {x, y}]

It will give the 4 solutions. If you use Solve instead of NSolve you will have a (large) closed form of each component of each solution.

If you need more digits for the solution, add at the end of the NSolve command the option WorkingPrecision->30 (or any other number of digits. These are quadratics, they can computed to any precision necessary).

相关阅读:
Top