Home > equation solving > How to solve an overdetermined system in Mathematica

How to solve an overdetermined system in Mathematica

May 30Hits:4
Advertisement

I would like to understand the reasons and find a way to avoid such behaviour of the Solve function in Mathematica 8.

Solve[x + y + z == 5 && y == 3 , {x, y}] (* Out[1]= {{x -> 2 - z, y -> 3}} *)  Solve[x + y + z == 5 && y == 3 , {x}] (* Out[2]= {} (why empty?) *) 

I need to get an answer in the second case. Any suggestions on how to persuade the program to calculate an answer that is even simpler than the first?

Answers

In general, when the system of equations is overdetermined, you have an optimization problem and would therefore not expect Solve or Reduce to be the right tools because the equations are likely not solvable "exactly" but only in some "best possible" way.

You would then instead formulate the optimization problem in terms of a merit function that you attempt to extremize. For example, in a system of linear equations you would want to minimize the sum of squares of the error for each equation.

A simple implementation of this would be to use Minimize, and for more specialized solutions one can use PseudoInverse or SingularValueDecomposition. Since your example is very simple, I'll just try to illustrate how to treat it with Minimize:

[email protected][{(x + y + z - 5)^2, y == 3}, {x}]

Here the y == 3 is entered as a constraint whereas the other equation is converted to a squared "merit function" that has to be minimized. That last function would in general be a sum of several squares if you have more equations.

The result is a Piecewise expression of which we only need the part that actually satisfies y == 3:

$ \left\{ x\to\begin{cases} 2-z & y=3\\ \text{Indeterminate} & \text{True} \end{cases}\right\} $

An alternative would be:

[email protected][{(x + y + z - 5)^2 + (y - 3)^2}, {x}]

$ \{x \to 5 - y - z\}$

You could use Reduce in this case:

Reduce[x + y + z == 5 && y == 3, {x}]

(* output: y == 3 && x == 2 - z *)

ToRules will transform this expression to a list of rules, e.g.

ToRules[Reduce[x + y + z == 5 && y == 3, {x}]]

(* output: {y -> 3, x -> 2 - z} *)

You'll find the explanation in the documentation page of Solve under Options -> MaxExtraConditions, as well as under Possible Issues (in a less obvious form).

You can coerce Solve to give you a solution like this:

In[1]:= Solve[x + y + z == 5 && y == 3, {x}, MaxExtraConditions -> All]
Out[1]= {{x -> ConditionalExpression[2 - z, y == 3]}}

The MaxExtraConditions -> All setting will allow Solve to generate extra conditions, and return a solution that is valid only under these special conditions. By default Solve does not attempt this (usually computationally expensive) manoeuvre. In your specific example it tells you that there are no solutions because there are indeed no solutions unless the very specific condition that y is equal to 3 is true.

I realize that this interpretation of the equations is counterintuitive at first.

The other solution is using Reduce which always attempts to generate all conditions that are necessary for the solution to be valid, even very special ones (e.g. that a must not be zero for a x == 1 to have a solution).

Related Articles

  • How to solve an overdetermined system in MathematicaMay 30

    I would like to understand the reasons and find a way to avoid such behaviour of the Solve function in Mathematica 8. Solve[x + y + z == 5 && y == 3 , {x, y}] (* Out[1]= {{x -> 2 - z, y -> 3}} *) Solve[x + y + z == 5 && y == 3 , {x}]

  • Solving numerically system with Mathematica

    Solving numerically system with MathematicaMay 29

    I'm trying to solve the following system with Mathematica: Poblacion = { {1900, 1.65}, {1910, 1.75}, {1920, 1.86}, {1930, 2.07}, {1940, 2.30}, {1950, 2.53}, {1960, 3.02}, {1970, 3.70}, {1980, 4.45}, {1990, 5.30}, {2000, 7.29} } P[t_] := 1 / (-q (K t

  • Overdetermined System of PDEsFebruary 20

    EDIT: Just to clarify a large part of my question is whether there is a way to make Mathematica solve a system with more equations than independent variables (so a system that is overdetermined but has redundancies in it). I'm trying to solve a syste

  • Solve overdetermined set using Mathematica?

    Solve overdetermined set using Mathematica?August 12

    As shown below, this is a overdetermined system. Could you teach me how to find the optimized solution in Mathematica? I know it could be solved by the method of least square, but how to realize it in Mathematica? {E0 - 2 x + 2 y + 2 a - 2 c == 0., E

  • How to solve a nonlinear overdetermined system of equationsJuly 6

    i'm trying to solve a nonlinear overdetermined system of equations (124 equations, 123 variables) i tried this procedure (newton raphson) NewtonExtended[f_List, x_List, x0_List, eps_: 10^-12, n_: 100] := With[{jac = N[Outer[D, f, x]]}, FixedPoint[(#

  • How to solve this system in mathematica

    How to solve this system in mathematicaJanuary 31

    I want to solve this system in mathematica and i have applied various functions such as Solve, NSolve, etc. but none of them worked. could you help me how could i find my answer?

  • Havin the problem with solving a nonlinear overdetermined system of equationsFebruary 5

    I am having a problem to solve a nonlinear overdetermined system of equations. According to one of the previous posts, I tried NMinimize, but it didn't work. Shall I use any other method? I will appreciate if somebody can give me some helps. This is

  • Solving a tridiagonal system of linear equations using the Thomas algorithmMarch 9

    I'm trying to write a function that can solve a tridiagonal system of linear equations using the Thomas algorithm. It basically solves the following equation. (Details can be found at the Wiki page here Tridiagonal matrix algorithm.) $$ \begin{bmatri

  • Solve huge symbolic system of linear equationsJuly 2

    I have a system of 76 symbolic linear equations (i.e. some coefficients are symbolic) with a sparse coefficient matrix. However, neither Solve[] nor LinearSolve[] can solve this system in a reasonable amount of time (I have not received an answer in

  • How to solve a large system of non-linear equationsFebruary 15

    I would like to solve Saha equations on Fe, which have 27 unknowns. Saha equations basically give you the ratios of the unknowns, but the unknowns are subject to constraints. What function shall I use to solve this large system of equations? Because

  • Solving differential equations with Wolfram Mathematica

    Solving differential equations with Wolfram MathematicaMarch 25

    So i saw this differential equations in my textbook $\frac{{{d^4}\omega }}{{d{x^4}}} + 4{\lambda ^4}\omega = 0$ and i figured why not solve it with majestic Wolfram Mathematica, so i write this code: DSolve[ω''''[x] + 4*λ^4*ω[x] == 0, ω[x],x] the res

  • How do I solve this ODE numerically in Mathematica?

    How do I solve this ODE numerically in Mathematica?June 17

    I want to solve these equations numerically in Mathematica and plot them. \begin{equation} u'(t)=1.5\,u(t)\,v(t)-u(t) \space \space \space \text{and} \space \space u(0)=0.001 \end{equation} \begin{equation} v'(t)=-1.5\,u(t)\,v(t) \space \space \space

  • How to solve a linear system by LinearSolve when the variables are duplicate?October 23

    Given that I have a set of equations about varible $x_0,x_1,\cdots,x_n$, which own the following style: $ \left( \begin{array}{cccccccc} \frac{1}{6} & \frac{2}{3} & \frac{1}{6} & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{1}{6} & \

  • Solving numerically a system of equations using different methods

    Solving numerically a system of equations using different methodsJanuary 20

    I will use, as an example, the simple Henon-Heiles potential V = 1/2*(x^2 + y^2) - y*(1/3*y^2 - x^2); Vx = D[V[x, y], x]; Vy = D[V[x, y], y]; Vxx = D[V[x, y], {x, 2}]; Vyy = D[V[x, y], {y, 2}]; Vxy = D[V[x, y], x, y]; Vyx = D[V[x, y], y, x]; which ha

  • How to solve this recursive system?

    How to solve this recursive system?February 4

    I try to solve the equation system as p[n_] := Piecewise[{{a, Mod[n, 2] == 0}, {b, Mod[n, 2] == 1}}] q[n_] := Piecewise[{{c,Mod[n,2]==0},{d,Mod[n,2]==1}}] RSolve[ {x[n + 1] == (p[n] + y[n])/(p[n] + y[n - 2]), y[n + 1] == (q[n] + x[n])/(q[n] + x[n - 2

  • Solving an overdetermined set of equations with lsqcurvefit in MATLABFebruary 14

    I have a problem similar to this question: How to solve an overdetermined set of equations using non-linear lest squares in Matlab I have 9 equations with 2 unknowns x and y, as follows: A11=(sin(x))*(cos(y))*(sin(x))*(cos(y)); A12=(sin(x))*(cos(y))*

  • Using Mathematica to solve a recursive system of differential equations May 8

    I believe I have a difficult problem to work on specially because I don't have any previously experience using Mathematica in this kind of situation. So I'll try to describe it as best as I can hoping that you can tell how should I proceed. Φ -> is t

  • How to search a file in a particular system using MathematicaJuly 18

    I want to know if there is any function which can search a file from the whole system and gives the whole path for that particular file. I have tried $Path but it gives some default paths also. Addendum: If the file is stored in multiple locations an

  • Are there suitable versioning systems for Mathematica notebooks?

    Are there suitable versioning systems for Mathematica notebooks?September 29

    I am considering a project using Mathematica and openCL. I know that the openCL C source code can be tracked. Has anyone used a versioning site or software so multiple developers can modify a common notebook? Is it possible to: check out a notebook n

  • How to solve this trigonometric system of equations numerically?December 14

    How can the following trigonometric system of equations be solved numerically? sys= { 1 - Cos[theta1] - 2/3 Sin[phi + π/6] == 0.227746, h + 2/3 Cos[phi + π/6] - Sin[theta1] == -0.714585, -1. - Cos[theta2] - 2/3 Sin[phi - π/6] == (3 Cos[psi2])/4, 2/5

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.782 s.