PhysLabNov15
pdf
keyboard_arrow_up
School
San Francisco State University *
*We aren’t endorsed by this school
Course
256
Subject
Mathematics
Date
Jan 9, 2024
Type
Pages
8
Uploaded by MinisterProtonBoar36
Your lab grade will be based on the following:
Item
Grade based on
Points
Feedback
Thoroughness
/1
In-class
Thoroughness, sense-making
/5
Problems
Accuracy, thoroughness, sense-making
/2
Summary
Whether conclusion is appropriate
Whether evidence supports
conclusion Whether example is
reasonable
/2
TOTAL
/10
© 2020, San Francisco State University. Do Not Distribute.
Summary: look at your lab notes while doing this!
1. Write down one major conclusion you can draw from this week’s
laboratory. For example, describe the interactions between positive,
negative and neutral objects. Please explain
in detail
.
2. Describe the experimental evidence that supports your conclusion.
Please explain
in detail
.
3. Give one example of applications/situations for the finding(s) you
described above in your everyday life outside of physics lab. Describe
in
detail
.
© 2020, San Francisco State University. Do Not Distribute.
Mathematica Exercise
To run your code in Mathematica press "[shift]+[enter]".
Notation matters! If your code doesn’t work check your brackets, commas, and
capitalization.
They all matter.
The help page and google are your friends. Mathematica has been around for many, many
years so if you run into a problem, chances are other people have run into the same problem
and solved it. Google the phrase, ‘how to “fill in the blank” in Mathematica’, and you will almost
always find the answer.
You can save your code + graphs to a pdf, or you can print them out.
Define Variables:
First you need to define some variables. This tells the worksheet what x and y are.
Type
x = 3
This will replace the variable x with a 3 every time it is encountered by Mathematica.
x=y
Will replace “x” with “y” every time it is encountered.
These direct assignments will be stored in Mathematica for the entirety of your session. In order
to clear variables assigned in this manner is to use the Clear function, or quit the kernel. The
latter will completely reset the session and any functions, or assignments, you have made will
also be reset.
You can set variables to a constant.
x=3
y=3
And you can do logical queries by using a ‘==’. Type
x==y
Now hit the ‘shift’ and ‘enter.’. It should return
︠True
Because 3 does equal 3.
Indefinite Integrals:
Try evaluating the following:
Integrate[x, x]
If you want to include a coefficient you can define it as a variable to be set later. Run
© 2020, San Francisco State University. Do Not Distribute.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Integrate[A*x, x]
Note that you have to use * to denote multiplication. Try these integrals next.
Here are a few more complicated ones.
Definite Integrals:
This code says to integrate x from 0 to 10.
Integrate[x, {x, 0, 10}]
Try it out!
Run these integrals.
© 2020, San Francisco State University. Do Not Distribute.
Numerical Integration:
Mathematica is unable to analytically evaluate some integrals. Try this one and see what you
get.
Integrate[Sin[Sin[x]], x]
Even with limits it will not work, try this.
Integrate[Sin[Sin[x]], {x, 0, Pi}]
So we will try numerical integration. This is not an exact solution but it can be very precise.
This is how you write a numerical integration
NIntegrate[Sin[Sin[x]], {0, Pi}]
Try numerically integrating
from 10 to 20.
Differentiation:
You can also use Mathematica to calculate derivatives.
Start with this one.
D[x, x]
Try to find the derivatives of these functions.
You can take higher order derivatives like this
© 2020, San Francisco State University. Do Not Distribute.
D[Log[x], {x, 5}]
Find the 1st through 5th derivative of
Plotting:
Making graphs is one of the most useful things Mathematica can do. Start by plotting a sine
wave.
Plot[Sin[x], {x, 0, 6*Pi}]
There are several options that you can include.
Plot[Sin[x], {x, 0, 6 π}, PlotStyle -> Red]
Try graphing these functions.
And you can plot more than one function on the same graph.
Plot[{Sin[x], Sin[2*x], Sin[3*x]}, {x, 0, 2 Pi}, PlotLegends -> "Expressions"]
Plot all four of these functions on the same graph so it is easy to tell them apart.
Root Finding:
If you never want to use the quadratic formula again, you can use Mathematica to find the roots
of a formula.
FindRoot[y = -3 x + 5, {x, 0}] (Don’t forget to declare x as a variable)
Find the root of Tan(x).
To find the intersection of 2 functions run a command like this.
Solve[{y == -x + 1, y == x - 1}, {x, y}]
© 2020, San Francisco State University. Do Not Distribute.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Find the intersection of
Challenge Problem
3D Plotting:
Every once in a while, it is nice to have a 3D plot.
The electric field from to a positive point charge, of charge Q, is given by E = (1/4πϵ0) Q/r
2
. In
cartesian coordinates, the vector form can be written as follows (Q/4πϵ0)(x/x
2
+y
2
+z
2
,
y/x
2
+y
2
+z
2
, z/x
2
+y
2
+z
2
). Using the VectorPlot3D function, plot the electric field given above with
appropriate axes labels. Does the plot look like what you expect it should? Describe its key
features.
© 2020, San Francisco State University. Do Not Distribute.
Phys 232 Mathematica introduction post lab.
1.
One of the last things you did in the worksheet is to find the intersection of these two
equations
. Please write down the lines of code you used to
find the intersection and the answer you got when you ran your code.
2.
Now, plot these two lines and visually show that the answer you got in part 1 is correct.
CODE:
NUMERICAL SOLUTION:
PLOT:
Feedback: Please tell us what you liked about this lab, what you disliked and
why. If there was any part/s that helped you or any part/s that were
particularly unhelpful please let us know.
© 2020, San Francisco State University. Do Not Distribute.