• Aucun résultat trouvé

Solving Algebraic Equations

Dans le document Second Edition (Page 184-192)

Three-Dimensional Graphics

6.1 Solving Algebraic Equations

Solutions of general algebraic equations may be found using the Solve command. The command is easy to use, but one must be careful to use a double equal sign, , between the left- and right-hand sides of the equation. (Recall that the double equal sign is a logical equality: lhs  rhs has a value of True if and only if lhs and rhs have the same value, False otherwise.)

Solve[equations, variables] attempts to solve equations for variables.

The roots determined by Solve are expressed as of a list of the form

{{x → x1},{x → x2}, ...}

The notation x → x1 indicates that the solution, x, is x1, but x is not replaced by this value. If the equation has roots of multiplicity m > 1, each is repeated m times. If only one variable is present, variables may be omitted.

EXAMPLE 1 In this example, there is only one variable so the specification of variables is unnecessary.

Solve[7 x + 3  3 x + 8]

x 5

→4

{ { } }

If we solve the equation ax = b for x, Solve tells us that x = b/a. However, if a = b = 0, then every number x is a solution. The command Reduce can be used to describe all possible solutions.

Reduce[equations, variables] simplifies equations, attempting to solve for variables. If equations is an identity, Reduce returns the value True. If equations is a contradiction, the value False is returned.

In describing the solutions, Reduce uses the symbols && (logical and) and || (logical or). && takes precedence over ||.

EXAMPLE 2

Solve[a x  b, x]

x b

→ a

{ { } }

Reduce[a x  b, x]

(b 0 & &a 0)|| a 0 & & x b

≠ a

⎛⎝ ⎞

Either a = b = 0 or a 0 and x = b/a.

Reduce[x2 – 9  (x + 3)(x – 3), x]

True

Reduce[x2– 10  (x + 3)(x – 3), x]

False

  

If we try to solve an equation that contains two or more variables, we must specify which variable we are solving for.

EXAMPLE 3

Solve[a y + b  c x + d]

Solve õ svars : Equations may not give solutions for all "solve" variables.  {{b → d + c x – a y}}

We must specify which variable we wish to solve for:

Solve[a y + b  c x + d, x]

For systems of equations, equations is a list of the form {equation1, equation2, . . .} and variables represents either a single variable or a list of several. Alternatively, equations may be represented by the individual equations separated by && (logical and).

EXAMPLE 4 Here is an easy example that shows how to solve a simple system: 2 3 7

3 4 10

In this example, the specification of {x, y} is not necessary because we do not have more variables than equations. If you have more unknown variables than equations, you must specify which variables you wish to solve for. Otherwise you get Mathematica’s default.

EXAMPLE 5

Of course, Solve is not limited to solving only linear equations.

EXAMPLE 6

Observe that Mathematica gives the general solution in terms of arbitrary a, b, and c unless values are assigned to these variables.

Note the space between a and y and between c and x.

This is important. may be used instead.

Note the space between a and y and between c and x.

This is important. may be used instead.

EXAMPLE 7

Solve[x3 + y2  5 && x + y  3]

{y2, x1}, y

{

4 – 5, x– 1 + 5 , y

} {

4 + 5, x– 1 – 5

}

{ }

Because Mathematica returns the solutions of equations as a nested list, they cannot be used directly as input to other mathematical structures. However, we can access their values without unnecessary typing or pasting by using /.

If we wish to compute the value of an expression using the solutions obtained from Solve, we can use the /. replacement operator and Mathematica will substitute the appropriate values.

EXAMPLE 8 Suppose we wish to solve the equations x y

x y We use the Solve command and the object solutions for convenience.

solutions = Solve[{x2 + y  5, x + y  3},{x, y}]

{{y → 1, x → 2}, {y → 4, x → –1}}

x + y2 2 /. solutions 5, 17

{ }

Mathematica produces a list containing both values of the expression.

EXAMPLE 9 Suppose we wish to find the sum of the squares of the roots of x6−21x5+175x4−735x3+1 624, x2−1 764, x+720=0

We use the Solve command:

solutions = Solve[{x6 – 21 x5 + 175 x4 – 735 x3 + 1624 x2 – 1764 x + 720  0]

{{x → 1}, {x → 2}, {x → 3}, {x → 4}, {x → 5}, {x → 6}}

Now we can define a list containing the solutions listed above.

list = x /. solutions

{1, 2, 3, 4, 5, 6}

Now we can easily compute the sum of the squares of the elements of the list.

Total[list2] 91

Solve is designed to solve algebraic equations, but can sometimes be used to find limited solutions of transcendental equations. A warning message is given to indicate that not all solutions can be found.

EXAMPLE 10

Solve[Sin[x]  1/2, x]

Solve õ ifun : Inverse functions are being used by Solve, so some solutions may not be found;

use Reduce for complete solution information.  x

{ { }

→6π

}

To get a more general solution to this equation, use Reduce.

Reduce[Sin[x]  1/2, x]

If the equations to be solved are inconsistent, Mathematica returns an empty list.

x= π π

6 or 56 plus any integer multiple of 2π

x= π π

6 or 56 plus any integer multiple of 2π

EXAMPLE 11

Solve[{2 x + 3 y  5, 4 x +6 y  11}]

{}

If the roots of an equation involve complex numbers, they are represented as rational powers of –1.

However, if a more traditional expression is desired, the function ComplexExpand can be used.

EXAMPLE 12 Solve[x3  1]

{{x → 1},{x → –(–1)1/3},{x → (–1)2/3}}

Solve[x3  1] //ComplexExpand

{x }, x –1 ,

A system of equations need not have a unique solution. For example, a system of two equations in three unknowns will either be inconsistent or have an infinite number of solutions. In the latter case it is possible to eliminate one or more variables from the system.

Eliminate[equations, variables] eliminates variables from a set of simultaneous equations.

equations is a list of simultaneous equations, and variables may be a single variable or a list of two or more.

EXAMPLE 13 (a) Eliminate the variable z; (b) eliminate the variables y and z from the following equations:

w x y z

Not all algebraic equations are solvable by Mathematica, even if theoretical solutions exist. If Mathematica is unable to solve an equation, it will represent the solution in a symbolic form. For the most part, such solutions are useless and a numerical approximation is more appropriate. Numerical approxima-tions are obtained with the command NSolve.

NSolve [equations, variables] solves equations numerically for variables.

NSolve [equations, variables, n] solves equations numerically for variables to n digits of precision.

As with Solve, the list of variables may be omitted if there is no ambiguity.

EXAMPLE 14 Solve the equation x5+x4+ +x3 x2+ + =x 2 0. SOLUTION

Solve[x5 + x4 + x3 + x2 + x + 2  0]

 

{{x → Root[2 + #1 + #12 + #13 + #14 + #15&, 1]},

{x → Root[2 + #1 + #12 + #13 + #14 + #15&, 2]},

{x → Root[2 + #1 + #12 + #13 + #14 + #15&, 3]},

{x → Root[2 + #1 + #12 + #13 + #14 + #15&, 4]},

{x → Root[2 + #1 + #12 + #13 + #14 + #15&, 5]}}

Mathematica cannot solve this equation exactly, so it returns a symbolic solution. However, we can obtain a numerical approximation.

NSolve[x5 + x4 + x3 + x2 + x + 2  0]

{{x → –1.21486},{x → –0.522092–1.06118 },{x → –0.522092 + 1.06118 },

{x → 0.629523 – 0.883585 },{x → 0.629523 + 0.883585 }}

An extraneous solution is a number that is technically not a solution of the equation, but evolves from the solution process. When solving radical equations, one typically encounters extraneous solutions. For example, when solving x = −3, which has no real solution, the squaring process yields x = 9.

VerifySolutions is an option that determines whether Mathematica should verify if solutions obtained are extraneous. The default, VerifySolutions ã True, eliminates extraneous solutions from the solution list. If such solutions are desired, the option VerifySolutions ã False should be used.

Solve[{17 + a + 4 b + c  0, 53 + 2 a + 7 b + c  0,137 + 4 a + 11 b + c  0}]

6.5 Find, to 20 significant digits, a real number such that the sum of itself, its square, and its cube is 30.

SOLUTION

NSolve[x + x2 + x3  30, x, 20]

{{x → – 1.8557621138713175532 – 2.7604410593413850003 },

{x → – 1.8557621138713175532 + 2.7604410593413850003 },

{x → 2.7115242277426351064}}

The only real solution is x =2.7115242277426351064.

6.6 Solve the trigonometric equation 2 sin2 x + 1 = 3 sin x for sin x and then for x.

SOLUTION

To solve for sin x, we can write

Solve[2 Sin[x]2 + 1  3 Sin[x]]

Sin[x] 1

2 , Sin[x] 1

{

}

{ }

{ }

If we solve for x, only the principal solutions (using inverse functions) are obtained.

Solve[2 Sin[x]2 + 1  3 Sin[x], x]

Solve õ ifun : Inverse functions are being used by Solve, so some solutions may not be found;

use Reduce for complete solution information.  x 6 , x

→ 2

{ } {

}

{

π π

}

Using Reduce we can get all the solutions.

Reduce[2 Sin[x]2 + 1  3 Sin[x], x]

Solve õ ifun : Inverse functions are being used by Solve, so some solutions may not be found;

use Reduce for complete solution information. x Log 1 points of intersection exactly and approximately.

SOLUTION any integer multiple of 2π

x= π π π 2,

6,or 56 plus any integer multiple of 2π

  

xvalues = Solve[f[x]  g[x], x];

a . Verify this for the equation 20x7+32x6−221x5−118x4+725x3−18x2−726x+252=0

This solution presumes a ≠ c. A more general solution is obtained using Reduce.

Reduce[a x + b  c x + d, x]

(b d && a c) || a – c 0 && x –b + d a – c

(

)

6.11 Eliminate the variable x from the nonlinear system

x y z

SOLUTION

Eliminate[{x3 + y2 + z  1, x + y + z  3}, x]

(26 – 18 y + 3 y2) z + (–9 + 3 y) z2 + z3  26 – 27 y + 10 y2 – y3

Dans le document Second Edition (Page 184-192)