Introduction to Mathematica for High School Math (for Students and Teachers) #9
Author
Ruth Dover
Title
Introduction to Mathematica for High School Math (for Students and Teachers) #9
Description
Introduction to Mathematica for High School Math
Category
Educational Materials
Keywords
Mathematics, education
URL
http://www.notebookarchive.org/2021-09-6h2b887/
DOI
https://notebookarchive.org/2021-09-6h2b887
Date Added
2021-09-14
Date Last Modified
2021-09-14
File Size
33.41 kilobytes
Supplements
Rights
Redistribution rights reserved



Tutorial 9: Solving
Tutorial 9: Solving
R. Dover, IMSA
Basics
Basics
Solve
==
Solve[-x-60,x]
2
x
Solve[-x+60,x]
2
x
Solve[2-Sin[x]-10,x]
2
Sin[x]
(Impressive, huh?):
Solve[+xy+34,x]
2
x
2
y
Edit the preceding line to solve for rather than .
y
x
Another Curiosity
Another Curiosity
Try these literal equations:
Solve[a+bx+c0,x]
2
x
This is about as we would expect, but we must also remember the restrictions. can help this issue, but the solution does become more complicated. The is the logical "and," while refers to the logical "or."
Reduce
&&
||
In[]:=
Reduce[a+bx+c0,x]
2
x
Some Work… and Some Do Not
Some Work… and Some Do Not
Solve[-6x+20,x]
3
x
Interesting. Though it is a cubic equation, there were not nice roots. Basically, the Wolfram Language™ is telling you that you really do not want to see the exact solutions. It gives approximations and notation to show you that it changed things behind the scenes. Hovering over the outputs shows that it is the solution to that cubic. Oh…
Instead, try :
NSolve
NSolve[-6x+20,x]
3
x
NSolve[-
4
x
2x
+3x6,x]Try some others.
But this will not take care of everything:
NSolve[x-Cos[x]0,x]
Another Method
Another Method
Solve and NSolve work on algebraic equations. The command works on other stuff. It is a variation of Newton's method, and it requires an initial input that is fairly close to the actual root being sought. Consider the equation . Plot the two functions defined by the two sides of the equality to see what is reasonable:
FindRoot
x=cos(x)
Plot[{x,Cos[x]},{x,-2,2}]
Given this graph, start with an initial guess of :
x=1
FindRoot[x==Cos[x],{x,1}]
As another example, consider the cubic and let . First, we will define the functions and plot them together to get a clue as to where they intersect:
f(x)=+5−7
3
x
2
x
g(x)=x+2sin(3x−1)
f[x_]:=+5-7;g[x_]:=x+2Sin[3x-1]
3
x
2
x
Plot[{f[x],g[x]},{x,-5.4,2}]
There is a point of intersection near , so we will enter that first:
x=−5
FindRoot[f[x]g[x],{x,-5}]
Find the other two solutions (use Insert ▶ Input from Above and then edit the initial guess in the command):
Clear[f,g]
Checking
Checking
First, we will define a function :
f
f[x_]:=+12-305-1056x+3220
4
x
3
x
2
x
We will call our solution set :
solns
solns=Solve[f[x]0,x]
Check these values by replacing them into the function:
f[x]/.solns
This shows one of the reasons that Mathematica® presents the solution set in this format: to make substitution quite easy. Then clear both and :
f
solns
Clear[f,solns]
Systems
Systems
Here, we will solve a system of two equations, and -5x+2xy+=6. First, we will graph the system to check for approximate solutions. We will use a new method to do this. We will create and name each plot separately (but withhold the actual plot) and then use to put them together:
y=2x–3
2
x
2
y
Show
gr1=Plot[2x-3,{x,-2,4}];
gr2=ContourPlot[-5x+2xy+6,{x,-2,5},{y,-5,5}];
2
x
2
y
Show[gr1,gr2]
To solve, we need a list of equations and a list of variables for which we wish to solve:
NSolve[{-5x+2xy+6,y2x-3},{x,y}]
2
x
2
y
Exercises
Exercises
Use NSolve with the function . When you are done, clear your function.
k(x)=−6+3x+8
4
x
3
x
Next, we will review several commands with one extended exercise.
Consider two polynomials: and . First, define both functions.
f(x)=−6+2x+5
4
x
2
x
g(x)=−3x+1
3
x
Now, plot both functions together, finding an appropriate domain. Add options to distinguish the graphs more clearly.
Now try to find the intersections of the equations using NSolve.
Substitute this list into either or to find the corresponding values. Do the ordered pairs seem to agree with your graphical approximations?
f
g
y


Cite this as: Ruth Dover, "Introduction to Mathematica for High School Math (for Students and Teachers) #9" from the Notebook Archive (2021), https://notebookarchive.org/2021-09-6h2b887

Download

