Computational Physics Lab I: Spring-2023
Final exam : Due 12/7

  1. Implementing a logarithm S0 4251S

    Write a python program that will compute and print the value of \(\log_{10}(2)\) with at least 6 digits of precision. Your program may not make any import statements or use any math functions, but may use the ** operator in python, which would allow you, for instance to compute \(10^x\) by writing 10**x.

    Note that the logarithm base 2 may be found by solving the equation \begin{align} 10^{\log_{10}(2)} = 2 \end{align} so you are looking for the number that when you take two that value gives you 10.

  2. Solving for logarithm graphically S0 4251S

    In this task, you will graphically solve the equation \begin{align} 10^x = 2 \end{align} which has a solution of \(x=\log_{10}(2)\).

    Write a python program that plots \(10^x\) versus \(x\). Add a horizontal line to this plot at a value of \(2\), and read off your plot the value of \(x\) at which your line and curve intersect. This value is \(\log_{10}(2)\). Confirm this by adding a vertical line at \(x=\log_{10}(2)\) (as computed by Python), and confirming that all three lines intersect at the same point. Your final program will create a plot with two lines and one curve, all intersecting.