• No se han encontrado resultados

7. DIAGNÓSTICO DEL CEDI DE COLNOTEX S.A

7.1. Desperdicios

An expression like x^2 + 2 x - 7 == 0 represents an equation in Mathematica. You will often need to solve equations like this, to find out for what values of x they are true.

This gives the two solutions to the quadratic equation x2+ 2 x - 7 = 0. The solutions are given as replacements for x.

In[1]:= Solve@x ^ 2 + 2 x - 7 == 0, xD

Out[1]= ::x Ø -1 - 2 2 >, :x Ø -1 + 2 2 >>

Here are the numerical values of the solutions.

In[2]:= N@%D

Out[2]= 88x Ø -3.82843<, 8x Ø 1.82843<<

You can get a list of the actual solutions for x by applying the rules generated by Solve to x using the replacement operator.

In[3]:= x ê. %

Out[3]= 8-3.82843, 1.82843<

You can equally well apply the rules to any other expression involving x.

In[4]:= x ^ 2 + 3 x ê. %%

Out[4]= 83.17157, 8.82843<

Solve@lhs==rhs,xD solve an equation, giving a list of rules for x xê.solution use the list of rules to get values for x

exprê.solution use the list of rules to get values for an expression Finding and using solutions to equations.

Solve always tries to give you explicit formulas for the solutions to equations. However, it is a basic mathematical result that, for sufficiently complicated equations, explicit algebraic formu-las in terms of radicals cannot be given. If you have an algebraic equation in one variable, and the highest power of the variable is at most four, then Mathematica can always give you formu-las for the solutions. However, if the highest power is five or more, it may be mathematically impossible to give explicit algebraic formulas for all the solutions.

Mathematica can always solve algebraic equations in one variable when the highest power is less than five.

In[5]:= Solve@x ^ 4 - 5 x ^ 2 - 3 == 0, xD

Out[5]= ::x Ø - 5 2 + 37

2 >, :x Ø 5 2 + 37

2 >, :x Ø -Â 1

2 -5 + 37 >, :x Ø Â 1

2 -5 + 37 >>

It can solve some equations that involve higher powers.

In[6]:= Solve@x ^ 6 == 1, xD

Out[6]= 98x Ø -1<, 8x Ø 1<, 9x Ø -H-1L1ë3=, 9x Ø H-1L1ë3=, 9x Ø -H-1L2ë3=, 9x Ø H-1L2ë3==

There are some equations, however, for which it is mathematically impossible to find explicit formulas for the solutions. Mathematica uses Root objects to represent the solutions in this case.

In[7]:= Solve@2 - 4 x + x ^ 5 == 0, xD

Out[7]= 99x Ø RootA2 - 4 Ò1 + Ò15&, 1E=, 9x Ø RootA2 - 4 Ò1 + Ò15&, 2E=,

9x Ø RootA2 - 4 Ò1 + Ò15&, 3E=, 9x Ø RootA2 - 4 Ò1 + Ò15&, 4E=, 9x Ø RootA2 - 4 Ò1 + Ò15&, 5E==

Even though you cannot get explicit formulas, you can still evaluate the solutions numerically.

In[8]:= N@%D

Out[8]= 88x Ø -1.51851<, 8x Ø 0.508499<, 8x Ø 1.2436<, 8x Ø -0.116792 - 1.43845 Â<, 8x Ø -0.116792 + 1.43845 Â<<

In addition to being able to solve purely algebraic equations, Mathematica can also solve some equations involving other functions.

After printing a warning, Mathematica returns one solution to this equation.

In[9]:= Solve@Sin@xD == a, xD

Solve::ifun : Inverse functions are being used by Solve, so some

solutions may not be found; use Reduce for complete solution information.à Out[9]= 88x Ø ArcSin@aD<<

It is important to realize that an equation such as sinHxL = a actually has an infinite number of possible solutions, in this case differing by multiples of 2 p. However, Solve by default returns just one solution, but prints a message telling you that other solutions may exist. You can use Reduce to get more information.

There is no explicit "closed form" solution for a transcendental equation like this.

In[10]:= Solve@Cos@xD == x, xD Solve::tdep :

The equations appear to involve the variables to be solved for in an essentially non-algebraic way.à Out[10]= Solve@Cos@xD ã x, xD

You can find an approximate numerical solution using FindRoot, and giving a starting value for x.

In[11]:= FindRoot@Cos@xD == x, 8x, 0<D

Out[11]= 8x Ø 0.739085<

Solve can also handle equations involving symbolic functions. In such cases, it again prints a warning, then gives results in terms of formal inverse functions.

Mathematica returns a result in terms of the formal inverse function of f.

In[12]:= Solve@f@x ^ 2D == a, xD

InverseFunction::ifun : Inverse functions are being used. Values may be lost for multivalued inverses.à

Out[12]= ::x Ø - fH-1L@aD >, :x Ø fH-1L@aD >>

Solve@8lhs1==rhs1,lhs2==rhs2,…<,8x,y,…<D

solve a set of simultaneous equations for x, y, … Solving sets of simultaneous equations.

You can also use Mathematica to solve sets of simultaneous equations. You simply give the list of equations, and specify the list of variables to solve for.

Here is a list of two simultaneous equations, to be solved for the variables x and y.

In[13]:= Solve@8a x + y == 0, 2 x + H1 - aL y == 1<, 8x, y<D

Here are some more complicated simultaneous equations. The two solutions are given as two lists of replacements for x and y.

This uses the solutions to evaluate the expression x + y.

In[15]:= x + y ê. %

Out[15]= :- 2

5 , 2

5 >

Mathematica can solve any set of simultaneous linear or polynomial equations.

When you are working with sets of equations in several variables, it is often convenient to reorganize the equations by eliminating some variables between them.

This eliminates y between the two equations, giving a single equation for x.

In[16]:= Eliminate@8a x + y == 0, 2 x + H1 - aL y == 1<, yD

Out[16]= I2 - a + a2M x ã 1

If you have several equations, there is no guarantee that there exists any consistent solution for a particular variable.

There is no consistent solution to these equations, so Mathematica returns 8<, indicating that the set of solutions is empty.

In[17]:= Solve@8x == 1, x == 2<, xD

Out[17]= 8<

There is also no consistent solution to these equations for almost all values of a.

In[18]:= Solve@8x == 1, x == a<, xD

Out[18]= 8<

The general question of whether a set of equations has any consistent solution is quite a subtle one. For example, for most values of a, the equations 8x == 1, x == a< are inconsistent, so there is no possible solution for x. However, if a is equal to 1, then the equations do have a solution. Solve is set up to give you generic solutions to equations. It discards any solutions that exist only when special constraints between parameters are satisfied.

If you use Reduce instead of Solve, Mathematica will however keep all the possible solutions to a set of equations, including those that require special conditions on parameters.

This shows that the equations have a solution only when a == 1. The notation a == 1 && x == 1 represents the requirement that both a == 1 and x == 1 should be True.

In[19]:= Reduce@8x == a, x == 1<, xD

Out[19]= a ã 1 && x ã 1

This gives the complete set of possible solutions to the equation. The answer is stated in terms of a combination of simpler equations. && indicates equations that must simultaneously be true;

»» indicates alternatives.

In[20]:= Reduce@a x - b == 0, xD

Out[20]= Hb ã 0 && a ã 0L »» a ≠ 0 && x ãb a

This gives a more complicated combination of equations.

In[21]:= Reduce@a x ^ 2 - b == 0, xD

Out[21]= Hb ã 0 && a ã 0L »» a ≠ 0 && x ã - b a

»» x ã b a

This gives a symbolic representation of all solutions.

In[22]:= Reduce@Sin@xD == a, xD

Out[22]= C@1D œ Integers && Hx ã p - ArcSin@aD + 2 p C@1D »» x ã ArcSin@aD + 2 p C@1DL

Solve@lhs==rhs,xD solve an equation for x Solve@8lhs1==rhs1,lhs2==rhs2,…<,8x,y,…<D

solve a set of simultaneous equations for x, y, … Eliminate@8lhs1==rhs1,lhs2==rhs2,…<,8x,…<D

eliminate x, … in a set of simultaneous equations Reduce@8lhs1==rhs1,lhs2==rhs2,…<,8x,y,…<D

give a set of simplified equations, including all possible solutions

Functions for solving and manipulating equations.

Reduce also has powerful capabilities for handling equations specifically over real numbers or integers. "Equations and Inequalities over Domains" discusses this in more detail.

This reduces the equation assuming x and y are complex.

In[23]:= Reduce@x ^ 2 + y ^ 2 == 1, yD

Out[23]= y ã - 1 - x2 »» y ã 1 - x2

This includes the conditions for x and y to be real.

In[24]:= Reduce@x ^ 2 + y ^ 2 == 1, y, RealsD

Out[24]= -1 § x § 1 && y ã - 1 - x2 »» y ã 1 - x2

This gives only the integer solutions.

In[25]:= Reduce@x ^ 2 + y ^ 2 == 1, y, IntegersD

Out[25]= Hx ã -1 && y ã 0L »» Hx ã 0 && y ã -1L »» Hx ã 0 && y ã 1L »» Hx ã 1 && y ã 0L

Documento similar