Packages in Julia. Downloading Packages A Word of Caution Sawtooth, Revisited

Similar documents
2.9 Linear Approximations and Differentials

Finding a Global Maximum. Method 2: Sawtooth Method (Shubert-Piyavskii Method)

Tangent line problems

3.7. Vertex and tangent

Intro. Speed V Growth

MITOCW ocw f99-lec07_300k

Increasing/Decreasing Behavior

AP Calculus. Extreme Values: Graphically. Slide 1 / 163 Slide 2 / 163. Slide 4 / 163. Slide 3 / 163. Slide 5 / 163. Slide 6 / 163

Section 7.6 Graphs of the Sine and Cosine Functions

Math 3 Coordinate Geometry Part 2 Graphing Solutions

Increasing/Decreasing Behavior

Objectives. Materials

MITOCW ocw f99-lec12_300k

Post Experiment Interview Questions

What's the Slope of a Line?

Handout 2 - Root Finding using MATLAB

Assignment 10 Solutions Due May 1, start of class. Physics 122, sections and 8101 Laura Lising

3.7, Graphing Calculator Fun. Sketch a full picture of the following graphs. Draw axes and indicate the x and y max and min.

Wednesday. Wednesday, September 17, CS 1251 Page 1

1 MATH 253 LECTURE NOTES for FRIDAY SEPT. 23,1988: edited March 26, 2013.

4.3, Math 1410 Name: And now for something completely different... Well, not really.

MITOCW watch?v=zm5mw5nkzjg

Note: Please use the actual date you accessed this material in your citation.

4.7 Approximate Integration

Objectives. Materials

1 extrema notebook. November 25, 2012

Denotational semantics

CALCULUS LABORATORY ACTIVITY: Numerical Integration, Part 1

Euler s Method for Approximating Solution Curves

True/False. MATH 1C: SAMPLE EXAM 1 c Jeffrey A. Anderson ANSWER KEY

Texturing laying out Uv's part I - Levitateme

How to Improve Your Campaign Conversion Rates

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

PROFESSOR: Well, yesterday we learned a bit about symbolic manipulation, and we wrote a rather stylized

MITOCW watch?v=yarwp7tntl4

I'm Andy Glover and this is the Java Technical Series of. the developerworks podcasts. My guest is Brian Jakovich. He is the

John's Tutorial on Everyday Mathcad (Version 9/2/09) Mathcad is not the specialist's ultimate mathematical simulator

CS61A Notes Week 1A: Basics, order of evaluation, special forms, recursion

Writing code that I'm not smart enough to write. A funny thing happened at Lambda Jam

I DO NOT OWN ITUNES OR ANYTHING IN THE THUMBNAIL THIS IS ALL OWNED BY APPLE.

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s.

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between

Distance. Dollars. Reviewing gradient

6 Using Technology Wisely

From time to time Google changes the way it does things, and old tutorials may not apply to some new procedures.

MITOCW watch?v=4dj1oguwtem

2.4. Rates of Change and Tangent Lines. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Prentice Hall

Quadratic Functions CHAPTER. 1.1 Lots and Projectiles Introduction to Quadratic Functions p. 31

AP Computer Science Unit 3. Programs

Piecewise Defined Functions

mid=81#15143

MA 113 Calculus I Fall 2015 Exam 2 Tuesday, 20 October Multiple Choice Answers. Question

2.1 Basics of Functions and Their Graphs

AB Calculus: Extreme Values of a Function

2.1 Derivatives and Rates of Change

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.

Most of the class will focus on if/else statements and the logical statements ("conditionals") that are used to build them. Then I'll go over a few

mayatocorona Manual Version 0.1

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Module 02 Lecture - 45 Memoization

MITOCW watch?v=penh4mv5gag

Section 1.1 Graphs Graphs

1

1.7 Limit of a Function

MITOCW watch?v=se4p7ivcune

6.001 Notes: Section 6.1

AP Calculus. Slide 1 / 213 Slide 2 / 213. Slide 3 / 213. Slide 4 / 213. Slide 4 (Answer) / 213 Slide 5 / 213. Derivatives. Derivatives Exploration

Rasterization: Geometric Primitives

Here's an example of how the method works on the string "My text" with a start value of 3 and a length value of 2:

y= sin( x) y= cos( x)

1 Getting used to Python

Android Programming Family Fun Day using AppInventor

Git Workbook. Self-Study Guide to Git. Lorna Mitchell. This book is for sale at

Partial Derivatives (Online)

MITOCW watch?v=9h6muyzjms0


FUNCTIONS AND MODELS

Inverse and Implicit functions

The Bisection Method versus Newton s Method in Maple (Classic Version for Windows)

Approximate Solutions to Differential Equations Slope Fields (graphical) and Euler s Method (numeric) by Dave Slomer

Troubleshooting Maple Worksheets: Common Problems

MITOCW MIT6_172_F10_lec18_300k-mp4

Transcriber(s): Aboelnaga, Eman Verifier(s): Yedman, Madeline Date Transcribed: Fall 2010 Page: 1 of 9

6.001 Notes: Section 8.1

Can You Run Internet Explorer 10 On Windows 8.1

MITOCW watch?v=rvrkt-jxvko

An attribute used in HTML that is used for web browsers screen reading devices to indicate the presence and description of an image Module 4

The Addition Formulas in Trigonometry. Scott Fallstrom Faculty Director, Math Learning Center

BEGINNER PHP Table of Contents

Itunes Manually Delete Songs From Iphone Not

Skill 1: Multiplying Polynomials

Stanko Tadić

Part 1 Your First Function

Calculus Chapter 1 Limits. Section 1.2 Limits

ReviewUsingDerivatives.nb 1. As we have seen, the connection between derivatives of a function and the function itself is given by the following:

MITOCW watch?v=ytpjdnlu9ug

Instructor: Craig Duckett. Lecture 07: Tuesday, April 17 th, 2018 Conflicts and Isolation, MySQL Workbench

P1_L3 Operating Systems Security Page 1

MITOCW watch?v=r6-lqbquci0

2 Unit Bridging Course Day 2 Linear functions I: Gradients

Transcription:

Packages in Julia Downloading Packages A Word of Caution Sawtooth, Revisited

Downloading Packages Because Julia is an open-source language, there are a ton of packages available online that enable such things as graphics capabilities, specialized programs or functionality, and yes even calculus. The main repository for most of these packages is GitHub, https://github.com.

Downloading Packages The main screen of GitHub will make you think you have to sign up. You don't. The search window is here. Everything's free. GitHub is a great place to research available packages, though if you need something specific combine GitHub with a google search to narrow things down. There is a lot of stuff on this site, not just for Julia but for all languages.

Downloading Packages If you already know what package you want to download, you can instruct Julia to take care of it for you. It's easiest to type it into the Julia console (the command-screen of the main program), but it should work in most IDEs as well. To see how it works, type this in: Pkg.add("Calculus") then wait.

Downloading Packages After a while Julia will let you know it is done. Now you have the Calculus package installed. Next, try this: using Calculus (this loads up the Calculus package, must be done every time you open a new session) f(x) = x^2 f(generic ) f'(5) 9.99999 f(x) = cos(x) f(generic ) f'(pi/2) -0.99999 f(x) = 4x^3 f(generic ) f'(3) 108.0000 f''(3) f'''(3) 72.000069 22.37032 (this is supposed to be 24)

But WAIT! The Calculus package can do symbolic differentiation. It will give you an exact answer. Try this: differentiate("4x^3", :x):(4*(3*x^2)) Whoa, that's awesome! You just got an exact derivative. The : (colon) means that Julia is treating (4*(3*x^2))as a symbol that you can evaluate. Try: x = 3 eval(differentiate("4x^3", :x)) 108

But WAIT! There's more! Try a second derivative: eval(differentiate(differentiate("4x^3", :x))) 72 And the third derivative, which went terribly wrong when we tried f'''(x): eval(differentiate(differentiate (differentiate("4x^3", :x)))) 24 (this is supposed to be 24)

But WAIT! Why would we ever use f' when eval(derivative( gives an exact answer? Symbolic differentiation is more accurate than numerical differentiation, but it is also much slower. This makes a difference in programs with lots of loops. Also, derivative( requires a string in quotes as its first argument, and you can't pass in a variable. This is extremely limiting.

A Word of Caution More about the functionality of the Calculus package in a moment. First, a caution. You just downloaded onto your computer, from the internet, a segment of code that communicates directly with the brains of your computer. Thank you for trusting me.

A Word of Caution Although it is very simple and looks so innocent, it is never a good idea to randomly download stuff from the internet (or app store, or whatever) without doing proper research first. This particular program, "Calculus.jl", was written by John Myles White. (That information is available on GitHub, or by googling "julia calculus".) Take a moment to google John Myles White. Find at least 4 pieces of evidence that he's a good guy. You should always do this type of search. always. always!

Now, Back to Calculus There are several other functions in the Calculus package, including: integrate(f, a, b) Full documentation is available on the GitHub page for Calculus, at github.com/johnmyleswhite/calculus.jl. The main functions we'll be using are derivatives.

Practice Problem 1 a. Find the derivative of y = 3x 2 + 2sinx at x = 4 using your derivative program, using the Calculus package, and by hand. Compare the answers. b. Find the integral of y = e x + 3x 2 from 3 to 5 using your integral program, using the Calculus package, and by hand. Compare the answers.

Sawtooth, Revisited Another application for calculus, which we used in the second unit, involves the Sawtooth Method. This method attempted to find a global maximum by drawing a series of lines of slope ±m from various points on the function, with m being a slope such that the function never got steeper than that slope.

Sawtooth, Revisited The basic procedure was this: 1. Draw lines of slope ±m from the function at the midpoint and endpoints of the interval. 2. Find the intersection points of the lines. 3. Find the highest y-value among the intersection points. 4. Draw lines of slope ±m from the function at the y-value corresponding to that x-value. 5. Repeat 2 5.

Sawtooth, Revisited What we didn't do, at that time, was calculate the limiting slope, m. The method will not work if the slope of the function is steeper than the value of m (or m). Without calculus, you can guess the value of m (as long as you guess too high) or use a graph to estimate it; but with calculus you can find the limiting slope using derivatives.

Practice Problem 2 a. Find, by hand, the steepest slope attained by the function f(x) = 5x 3 + 2x 2 on the interval [- 2, 5]. This slope may be either negative or positive. b. Repeat for f(x) = 3x 4-2x 2 on [-0.5, 0.5]

Sawtooth, Revisited As you (hopefully) recalled on problem 2, the maximum and minimum values of a function must occur either at the endpoints, or where its derivative equals 0. If your function is a derivative, you are looking for where the second derivative equals 0. This assumes that you know the equation of the second derivative, which is fine if you're doing it by hand; but a computer does not derive by hand.

Sawtooth, Revisited In pairs or groups, discuss how you could find the maximum or minimum slope values with the following tools: 1. The original equation 2. The ability to find f'(a) values of the derivative 3. The ability to find f''(a) values of the second derivative 4. Any existing programs you have from earlier units Remember, you may not use the equation of the derivative or second derivative!

Practice Problem 3 Write a program that, given a function and endpoints, returns the limiting value of the slope for use in a sawtooth program. If you plan to use the Calculus package, you will need to type the line using Calculus before the opening function line. Test and document and save your code!