Hi
I f I try to solve these equations
Solve[{2 x + 3 y == 8 + I 7,
3 x + y == 5 + 7 I, -2 I x + (1 + 3 I) y == 3 + 5 I}]
the result is
{{x -> 1 + 2*I, y -> 2 + I}}
but if I have
Solve[{2 x + 3 y == 8 + I 7,
3 x + y == 4.99999999999999 + 7 I, -2 I x + (1 + 3 I) y == 3 + 5 I}]
gives
\!\(\*FormBox[
RowBox[{\(RowReduce::"luc"\), \(\(:\)\(\ \)\), "\<\"Result for \
\\!\\(TraditionalForm\\`RowReduce\\) of badly conditioned matrix \
\\!\\(TraditionalForm\\`\\((\[NoBreak] \\(\[LeftSkeleton] 1 \
\[RightSkeleton]\\) \[NoBreak])\\)\\) may contain significant numerical \
errors. \\!\\(\\*ButtonBox[\\\"More\\\",
ButtonStyle->\\\"RefGuideLinkText\\\
\", ButtonFrame->None, ButtonData:>\\\"General::luc\\\"]\\)\"\>"}], \
TraditionalForm]\)
{}
I need only an aproximate result, say 5 digits of precission, how can I
override the NSolve behavior?
Thanks in advance
you have 3 equations and two unknowns ?? This can
only
have a solution, when one of the 3 equations is
linear
depend on one of the others.
For exact numbers Mathematica can find the linear
depend equation
for inexact numbers you will get problems with the
precision.
In your case it may be the best to remove one of
the
equations
Solve[{2 x + 3 y == 8 + I 7.,
-2 I x + (1 + 3 I) y == 3 + 5 I}, {x, y}]
Regards
Jens
"Enrique Zeleny" <eze...@fcfm.buap.mx> schrieb im
Newsbeitrag news:dcsc67$q0k$1...@smc.vnet.net...
Solve[SetPrecision[{2*x + 3*y == 8 + I*7,
3*x + y == 4.99999999999999 + 7*I,
-2*I*x + (1 + 3*I)*y == 3 + 5*I}, 50]]
{}
There are a number of ways to deal with your problem. The most
obvious one is to just use Solve with exact input and only afterwards
apply N
N[Solve[{2*x + 3*y == 8 + I*7, 3*x + y == 5 + 7*I,
-2*I*x + (1 + 3*I)*y == 3 + 5*I}],5]
{{x -> 1.0000 + 2.0000 I, y -> 2.0000 + 1.0000 I}}
Another approach is to simply drop one of the equations:
NSolve[Drop[{2*x + 3*y == 8 + I*7,
3*x + y == 4.99999999999999 + 7*I,
-2*I*x + (1 + 3*I)*y == 3 + 5*I}, -1]]
{{x -> 0.9999999999999958 + 2.*I,
y -> 2.0000000000000027 + 1.*I}}
(Note that I used NSolve this time).
Another possibility, which you could use with a larger number of
variables and equations is to first find a GroebnerBasis for your
system and then solve the resulting new system:
NSolve[GroebnerBasis[{2*x + 3*y == 8 + I*7,
3*x + y == 5 + 7*I, -2*I*x + (1 + 3*I)*y ==
3 + 5*I} /. Equal -> Subtract, {x, y}] == 0,
{x, y}]
{{x -> 1. + 2.*I, y -> 2. + 1.*I}}
Also, note that N[Solve[eqns]] and NSolve[eqns] use different
algorithms and will not always return the same answer.
Also, if you really want 5 digits of precision you have to request it
as above or as in:
N[Solve[GroebnerBasis[{2*x + 3*y == 8 + I*7,
3*x + y == 5 + 7*I, -2*I*x + (1 + 3*I)*y ==
3 + 5*I} /. Equal -> Subtract, {x, y}] == 0,
{x, y}], 5]
{{y -> 2.0000 + 1.0000 I, x -> 1.0000 + 2.0000 I}}
Andrzej Kozlowski
eqn = {2*x + 3*y == 8 + I*7, 3*x + y ==
4.99999999999999 + 7*I, -2*I*x + (1 + 3*I)*y ==
3 + 5*I}
{2 x + 3 y == 8 + 7 I, 3 x + y == 5. + 7 I,
(1 + 3 I) y - 2 I x == 3 + 5 I}
This system is inconsistent even if you use high precision arithmetic:
Solve[SetPrecision[eqn,50],{x,y}]
{}
In this particular case just rationalising the equations will give
you the answer:
In[3]:=
N[Solve[Rationalize[eqn],{x,y}],5]
Out[3]=
{{x -> 1.0000 + 2.0000 I, y -> 2.0000 + 1.0000 I}}
However, you may have an inconsistent system like this:
eq1 = {2*x + 3*y == 8 + I*7, 3*x + y == 4.9 + 7*I, -2*I*
x + (1 + 3*I)*y == 3 + 5*I};
for which rationalising will still return an empty set:
Solve[Rationalize[eqn1],{x,y}]
{}
You might however want to find a set of "solutions" for a nearby
system and treat them as solutions to your inconsistent system. This
is a more complex problem, but it can be sometimes solved by several
methods. One of them consists of peturbing slighly one of the
equations by a parameter and solving the new system:
eq2 = {2*x + 3*y == 8 + I*7, 3*x + y ==
4.9 + 7*I + epsilon, -2*I*x + (1 + 3*I)*y ==
3 + 5*I};
Solve[Rationalize[eqn1], {x, y, epsilon}]
1
{{x -> 1 + 2 I, y -> 2 + I, epsilon -> --}}
10
This shows that with one ho to find a "nearby" system which has a
solution. Of course there are going to be lots of other such systems.
Andrzej Kozlowski
{{x -> 1 + 2*I, y -> 2 + I}}
Bob Hanlon
Your system of equations has more equations than unkowns (I believe the
term for such a system is over-determined). In such a situation it is
rare for a solution to exist at all. If a solution does exist then one
of the equations is a linear combination of some of the others and so
is reduntant.
In your case the final equation -2 I x + (1 + 3 I) y == 3 + 5 I is a
linear combination of the other two and so you can discard it.
Solve[{2 x + 3 y == 8 + I 7, 3 x + y == 5 + 7 I}]
gives the same solution you had before
{{x -> 1 + 2*I, y -> 2 + I}}
Solve[{2 x + 3 y == 8 + I 7, 3 x + y == 4.9999 + 7 I}]
gives
{{x -> 0.999957142857143 + 2.*I, y -> 2.000028571428571 +
1.0000000000000002*I}}
HTH
Mike
The set of equations is composed of three equations of two unknowns.
Therefore it is basically a linearly dependent set of equations. You
can see that (3/7 + 11/7*I) * (1st equation) + (-2/7 -12/7*I) * (2nd
equation) = (3rd equation). It means solving three equations is
equivalent to solving first two equations.
If you change the RHS of second equation as you did 5 --> 4.999999, you
can't generate the 3rd equation with a combination of 1st and 2nd
equation any more, so Mathematica gives no solution.
If you want only approximate solutions, the best way is to use N[expr,
n], where 'n' means 'n-digit precision.'
Try the following:
N[Solve[{2 x + 3 y == 8 + I 7,
3 x + y == 5 + 7 I, -2 I x + (1 + 3 I) y == 3 + 5 I}], 5]
--
Wonseok Shin
wss...@gmail.com
> I f I try to solve these equations
>
> Solve[{2 x + 3 y == 8 + I 7,
> 3 x + y == 5 + 7 I, -2 I x + (1 + 3 I) y == 3 + 5 I}]
>
> the result is
>
> {{x -> 1 + 2*I, y -> 2 + I}}
>
> but if I have
>
> Solve[{2 x + 3 y == 8 + I 7,
> 3 x + y == 4.99999999999999 + 7 I, -2 I x + (1 + 3 I) y == 3 + 5 I}]
Others have explained the answer returned by Mathematica. Here is
another approach, suitable since you have linear equations.
[1] Load the LinearAlgebra stubs:
<< LinearAlgebra`
[2] Determine the matrix A, and right-hand side b:
{A, b} = LinearEquationsToMatrices[
{2*x + 3*y == 8 + I*7,
3*x + y == 4.99999999999999 + 7*I,
(1 + 3*I)*y - 2*I*x == 3 + 5*I}, {x, y}]
[3] Solve using LinearSolve:
LinearSolve[A,b]
Cheers,
Paul
--
Paul Abbott Phone: +61 8 6488 2734
School of Physics, M013 Fax: +61 8 6488 1014
The University of Western Australia (CRICOS Provider No 00126G)
AUSTRALIA http://physics.uwa.edu.au/~paul
http://InternationalMathematicaSymposium.org/IMS2005/
> I f I try to solve these equations
>
> Solve[{2 x + 3 y == 8 + I 7,
> 3 x + y == 5 + 7 I, -2 I x + (1 + 3 I) y == 3 + 5 I}]
>
> the result is
>
> {{x -> 1 + 2*I, y -> 2 + I}}
>
> but if I have
>
> Solve[{2 x + 3 y == 8 + I 7,
> 3 x + y == 4.99999999999999 + 7 I, -2 I x + (1 + 3 I) y == 3 + 5 I}]
Further to my previous posting, here is another approach:
pinv = PseudoInverse[{{2, 3}, {3, 1}, {-2 I, 1 + 3 I}}]
pinv . {8 + 7 I, 4.99999999999999 + 7 I, 3 + 5 I}