0

Here is the code:

syms G1 G2 G3 M1 M2 M3 P1 P2 P3 D1 D2 D3
S = solve(0 == 0.9 * (20 - G1) - 0.012 * D3 * G1, ...
      0 == 0.9 * (20 - G2) - 0.012 * D1 * G2, ...
      0 == 0.9 * (20 - G3) - 0.012 * D2 * G3, ...
      0 == -0.0033 * M1 + 0.002 * G1, ...
      0 == -0.0033 * M2 + 0.002 * G2, ...
      0 == -0.0033 * M3 + 0.002 * G3, ...
      0 == 0.1 * M1 - 0.0033 * P1 + 2 * 0.5 * D1 - 2 * 0.025 * (P1 ^ 2), ...
      0 == 0.1 * M2 - 0.0033 * P2 + 2 * 0.5 * D2 - 2 * 0.025 * (P2 ^ 2), ...
      0 == 0.1 * M3 - 0.0033 * P3 + 2 * 0.5 * D3 - 2 * 0.025 * (P3 ^ 2), ...
      0 == -0.5 * D1 + 0.025 * (P1 ^ 2) + 0.9 * (20 - G2) - 0.012 * D1 * G2, ...
      0 == -0.5 * D2 + 0.025 * (P2 ^ 2) + 0.9 * (20 - G3) - 0.012 * D2 * G3, ...
      0 == -0.5 * D3 + 0.025 * (P3 ^ 2) + 0.9 * (20 - G1) - 0.012 * D3 * G1)

The problem is that I need real solution, but I have got answers with roots. How can I get real answers?

uNxe
  • 33
  • 4

1 Answers1

0

Assuming by "real solution" you mean a numeric value instead of the exact root-of-polynomial form, there are two options depending on how you intend on using the results:

  1. double: this will evaluate the RootOf expressions, assuming there are no free parameters, and return a numeric output of class double. While the output is now limited to double-precision, if your goal is to use the roots in computation and care about performance, this is the fastest option.

  2. vpa: this will evaluate the RootOf expressions, assuming there are no free parameters, and return a Symbolic output of class sym. While the output is now able to be approximated to varying degrees of accuracy at evaluation by calling digits beforehand, there may be a large computational overhead in subsequent calculations due to its Symbolic nature.

TroyHaskin
  • 8,361
  • 3
  • 22
  • 22