``'*'`` star marker

``'h'`` hexagon1 marker

``'H'`` hexagon2 marker

``'+'`` plus marker

``'x'`` x marker

``'D'`` diamond marker

``'d'`` thin_diamond marker

``'|'`` vline marker

``'_'`` hline marker

================ ===============================



The following color abbreviations are supported:


========== ========

character color

========== ========

'b' blue

'g' green

'r' red

'c' cyan

'm' magenta

'y' yellow

'k' black

'w' white

========== ========


In addition, you can specify colors in many weird and

wonderful ways, including full names (``'green'``), hex

strings (``'#008000'``), RGB or RGBA tuples (``(0,1,0,1)``) or

grayscale intensities as a string (``'0.8'``). Of these, the

string specifications can be used in place of a ``fmt`` group,

but the tuple forms can be used only as ``kwargs``.


Line styles and colors are combined in a single format string, as in

``'bo'`` for blue circles.


The *kwargs* can be used to set line properties (any property that has

a ``set_*`` method). You can use this to set a line label (for auto

legends), linewidth, anitialising, marker face color, etc. Here is an

example::


plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2)

plot([1,2,3], [1,4,9], 'rs', label='line 2')

axis([0, 4, 0, 10])

legend()


If you make multiple lines with one plot command, the kwargs

apply to all those lines, e.g.::


plot(x1, y1, x2, y2, antialiased=False)


Neither line will be antialiased.


You do not need to use format strings, which are just

abbreviations. All of the line properties can be controlled

by keyword arguments. For example, you can set the color,

marker, linestyle, and markercolor with::


plot(x, y, color='green', linestyle='dashed', marker='o',

markerfacecolor='blue', markersize=12).


See :class:`~matplotlib.lines.Line2D` for details.


The kwargs are :class:`~matplotlib.lines.Line2D` properties:



===================================================================================== ===============================================================================================================================================

Property Description

===================================================================================== ===============================================================================================================================================

:meth:`agg_filter <matplotlib.artist.Artist.set_agg_filter>` unknown

:meth:`alpha <matplotlib.artist.Artist.set_alpha>` float (0.0 transparent through 1.0 opaque)

:meth:`animated <matplotlib.artist.Artist.set_animated>` [True | False]

:meth:`antialiased <matplotlib.lines.Line2D.set_antialiased>` or aa [True | False]

:meth:`axes <matplotlib.artist.Artist.set_axes>` an :class:`~matplotlib.axes.Axes` instance

:meth:`clip_box <matplotlib.artist.Artist.set_clip_box>` a :class:`matplotlib.transforms.Bbox` instance

:meth:`clip_on <matplotlib.artist.Artist.set_clip_on>` [True | False]

:meth:`clip_path <matplotlib.artist.Artist.set_clip_path>` [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]

:meth:`color <matplotlib.lines.Line2D.set_color>` or c any matplotlib color

:meth:`contains <matplotlib.artist.Artist.set_contains>` a callable function

:meth:`dash_capstyle <matplotlib.lines.Line2D.set_dash_capstyle>` ['butt' | 'round' | 'projecting']

:meth:`dash_joinstyle <matplotlib.lines.Line2D.set_dash_joinstyle>` ['miter' | 'round' | 'bevel']

:meth:`dashes <matplotlib.lines.Line2D.set_dashes>` sequence of on/off ink in points

:meth:`drawstyle <matplotlib.lines.Line2D.set_drawstyle>` ['default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post']

:meth:`figure <matplotlib.artist.Artist.set_figure>` a :class:`matplotlib.figure.Figure` instance

:meth:`fillstyle <matplotlib.lines.Line2D.set_fillstyle>` ['full' | 'left' | 'right' | 'bottom' | 'top' | 'none']

:meth:`gid <matplotlib.artist.Artist.set_gid>` an id string

:meth:`label <matplotlib.artist.Artist.set_label>` string or anything printable with '%s' conversion.

:meth:`linestyle <matplotlib.lines.Line2D.set_linestyle>` or ls ['solid' | 'dashed', 'dashdot', 'dotted' | (offset, on-off-dash-seq) | ``'-'`` | ``'--'`` | ``'-.'`` | ``':'`` | ``'None'`` | ``' '`` | ``''``]

:meth:`linewidth <matplotlib.lines.Line2D.set_linewidth>` or lw float value in points

:meth:`marker <matplotlib.lines.Line2D.set_marker>` :mod:`A valid marker style <matplotlib.markers>`

:meth:`markeredgecolor <matplotlib.lines.Line2D.set_markeredgecolor>` or mec any matplotlib color

:meth:`markeredgewidth <matplotlib.lines.Line2D.set_markeredgewidth>` or mew float value in points

:meth:`markerfacecolor <matplotlib.lines.Line2D.set_markerfacecolor>` or mfc any matplotlib color

:meth:`markerfacecoloralt <matplotlib.lines.Line2D.set_markerfacecoloralt>` or mfcalt any matplotlib color

:meth:`markersize <matplotlib.lines.Line2D.set_markersize>` or ms float

:meth:`markevery <matplotlib.lines.Line2D.set_markevery>` [None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float]

:meth:`path_effects <matplotlib.artist.Artist.set_path_effects>` unknown

:meth:`picker <matplotlib.lines.Line2D.set_picker>` float distance in points or callable pick function ``fn(artist, event)``

:meth:`pickradius <matplotlib.lines.Line2D.set_pickradius>` float distance in points

:meth:`rasterized <matplotlib.artist.Artist.set_rasterized>` [True | False | None]

:meth:`sketch_params <matplotlib.artist.Artist.set_sketch_params>` unknown

:meth:`snap <matplotlib.artist.Artist.set_snap>` unknown

:meth:`solid_capstyle <matplotlib.lines.Line2D.set_solid_capstyle>` ['butt' | 'round' | 'projecting']

:meth:`solid_joinstyle <matplotlib.lines.Line2D.set_solid_joinstyle>` ['miter' | 'round' | 'bevel']

:meth:`transform <matplotlib.lines.Line2D.set_transform>` a :class:`matplotlib.transforms.Transform` instance

:meth:`url <matplotlib.artist.Artist.set_url>` a url string

:meth:`visible <matplotlib.artist.Artist.set_visible>` [True | False]

:meth:`xdata <matplotlib.lines.Line2D.set_xdata>` 1D array

:meth:`ydata <matplotlib.lines.Line2D.set_ydata>` 1D array

:meth:`zorder <matplotlib.artist.Artist.set_zorder>` any number

===================================================================================== ===============================================================================================================================================



kwargs *scalex* and *scaley*, if defined, are passed on to

:meth:`~matplotlib.axes.Axes.autoscale_view` to determine

whether the *x* and *y* axes are autoscaled; the default is

*True*.


Notes

-----


In addition to the above described arguments, this function can take a

**data** keyword argument. If such a **data** argument is given, the

following arguments are replaced by **data[<arg>]**:


* All arguments with the following names: 'y', 'x'.





Additional kwargs: hold = [True|False] overrides default hold state



In [17]: pylab.plot(x, y, 'o')

Out[17]: [<matplotlib.lines.Line2D at 0x1db4d6f6518>]


In [18]: pylab.plot(x, y, 'o-')

Out[18]: [<matplotlib.lines.Line2D at 0x1db4d756ba8>]


In [19]: pylab.plot(x, y, 'o--')

Out[19]: [<matplotlib.lines.Line2D at 0x1db4d7b3780>]


In [20]: pylab.plot(x, y, 'o:')

Out[20]: [<matplotlib.lines.Line2D at 0x1db4d80ef28>]


In [21]: pylab.plot(x, y, 'ro:')

Out[21]: [<matplotlib.lines.Line2D at 0x1db4d86d7f0>]


In [22]: %matplotlib qt


In [23]: pylab.plot(x, y, 'ro:')

Out[23]: [<matplotlib.lines.Line2D at 0x1db4da60400>]


In [24]: %matplotlib inline


In [25]: pylab.plot(x, y, 'ro:')

Out[25]: [<matplotlib.lines.Line2D at 0x1db4dcdfb00>]


In [26]: from scipy.optimize import bisect


In [27]: help(bisect)

Help on function bisect in module scipy.optimize.zeros:


bisect(f, a, b, args=(), xtol=1e-12, rtol=4.4408920985006262e-16, maxiter=100, full_output=False, disp=True)

Find root of a function within an interval.


Basic bisection routine to find a zero of the function `f` between the

arguments `a` and `b`. `f(a)` and `f(b)` cannot have the same signs.

Slow but sure.


Parameters

----------

f : function

Python function returning a number. `f` must be continuous, and

f(a) and f(b) must have opposite signs.

a : number

One end of the bracketing interval [a,b].

b : number

The other end of the bracketing interval [a,b].

xtol : number, optional

The routine converges when a root is known to lie within `xtol` of the

value return. Should be >= 0. The routine modifies this to take into

account the relative precision of doubles.

rtol : number, optional

The routine converges when a root is known to lie within `rtol` times

the value returned of the value returned. Should be >= 0. Defaults to

``np.finfo(float).eps * 2``.

maxiter : number, optional

if convergence is not achieved in `maxiter` iterations, an error is

raised. Must be >= 0.

args : tuple, optional

containing extra arguments for the function `f`.

`f` is called by ``apply(f, (x)+args)``.

full_output : bool, optional

If `full_output` is False, the root is returned. If `full_output` is

True, the return value is ``(x, r)``, where x is the root, and r is

a `RootResults` object.

disp : bool, optional

If True, raise RuntimeError if the algorithm didn't converge.


Returns

-------

x0 : float

Zero of `f` between `a` and `b`.

r : RootResults (present if ``full_output = True``)

Object containing information about the convergence. In particular,

``r.converged`` is True if the routine converged.


See Also

--------

brentq, brenth, bisect, newton

fixed_point : scalar fixed-point finder

fsolve : n-dimensional root-finding



In [28]: from scipy.optimize import newton


In [29]: help(newton)

Help on function newton in module scipy.optimize.zeros:


newton(func, x0, fprime=None, args=(), tol=1.48e-08, maxiter=50, fprime2=None)

Find a zero using the Newton-Raphson or secant method.


Find a zero of the function `func` given a nearby starting point `x0`.

The Newton-Raphson method is used if the derivative `fprime` of `func`

is provided, otherwise the secant method is used. If the second order

derivate `fprime2` of `func` is provided, parabolic Halley's method

is used.


Parameters

----------

func : function

The function whose zero is wanted. It must be a function of a

single variable of the form f(x,a,b,c...), where a,b,c... are extra

arguments that can be passed in the `args` parameter.

x0 : float

An initial estimate of the zero that should be somewhere near the

actual zero.

fprime : function, optional

The derivative of the function when available and convenient. If it

is None (default), then the secant method is used.

args : tuple, optional

Extra arguments to be used in the function call.

tol : float, optional

The allowable error of the zero value.

maxiter : int, optional

Maximum number of iterations.

fprime2 : function, optional

The second order derivative of the function when available and

convenient. If it is None (default), then the normal Newton-Raphson

or the secant method is used. If it is given, parabolic Halley's

method is used.


Returns

-------

zero : float

Estimated location where function is zero.


See Also

--------

brentq, brenth, ridder, bisect

fsolve : find zeroes in n dimensions.


Notes

-----

The convergence rate of the Newton-Raphson method is quadratic,

the Halley method is cubic, and the secant method is

sub-quadratic. This means that if the function is well behaved

the actual error in the estimated zero is approximately the square

(cube for Halley) of the requested tolerance up to roundoff

error. However, the stopping criterion used here is the step size

and there is no guarantee that a zero has been found. Consequently

the result should be verified. Safer algorithms are brentq,

brenth, ridder, and bisect, but they all require that the root

first be bracketed in an interval where the function changes

sign. The brentq algorithm is recommended for general use in one

dimensional problems when such an interval has been found.



In [30]: from scipy.optimize import brentq


In [31]: help(brentq)

Help on function brentq in module scipy.optimize.zeros:


brentq(f, a, b, args=(), xtol=1e-12, rtol=4.4408920985006262e-16, maxiter=100, full_output=False, disp=True)

Find a root of a function in given interval.


Return float, a zero of `f` between `a` and `b`. `f` must be a continuous

function, and [a,b] must be a sign changing interval.


Description:

Uses the classic Brent (1973) method to find a zero of the function `f` on

the sign changing interval [a , b]. Generally considered the best of the

rootfinding routines here. It is a safe version of the secant method that

uses inverse quadratic extrapolation. Brent's method combines root

bracketing, interval bisection, and inverse quadratic interpolation. It is

sometimes known as the van Wijngaarden-Dekker-Brent method. Brent (1973)

claims convergence is guaranteed for functions computable within [a,b].


[Brent1973]_ provides the classic description of the algorithm. Another

description can be found in a recent edition of Numerical Recipes, including

[PressEtal1992]_. Another description is at

http://mathworld.wolfram.com/BrentsMethod.html. It should be easy to

understand the algorithm just by reading our code. Our code diverges a bit

from standard presentations: we choose a different formula for the

extrapolation step.


Parameters

----------

f : function

Python function returning a number. f must be continuous, and f(a) and

f(b) must have opposite signs.

a : number

One end of the bracketing interval [a,b].

b : number

The other end of the bracketing interval [a,b].

xtol : number, optional

The routine converges when a root is known to lie within xtol of the

value return. Should be >= 0. The routine modifies this to take into

account the relative precision of doubles.

rtol : number, optional

The routine converges when a root is known to lie within `rtol` times

the value returned of the value returned. Should be >= 0. Defaults to

``np.finfo(float).eps * 2``.

maxiter : number, optional

if convergence is not achieved in maxiter iterations, an error is

raised. Must be >= 0.

args : tuple, optional

containing extra arguments for the function `f`.

`f` is called by ``apply(f, (x)+args)``.

full_output : bool, optional

If `full_output` is False, the root is returned. If `full_output` is

True, the return value is ``(x, r)``, where `x` is the root, and `r` is

a RootResults object.

disp : bool, optional

If True, raise RuntimeError if the algorithm didn't converge.


Returns

-------

x0 : float

Zero of `f` between `a` and `b`.

r : RootResults (present if ``full_output = True``)

Object containing information about the convergence. In particular,

``r.converged`` is True if the routine converged.


See Also

--------

multivariate local optimizers

`fmin`, `fmin_powell`, `fmin_cg`, `fmin_bfgs`, `fmin_ncg`

nonlinear least squares minimizer

`leastsq`

constrained multivariate optimizers

`fmin_l_bfgs_b`, `fmin_tnc`, `fmin_cobyla`

global optimizers

`basinhopping`, `brute`, `differential_evolution`

local scalar minimizers

`fminbound`, `brent`, `golden`, `bracket`

n-dimensional root-finding

`fsolve`

one-dimensional root-finding

`brentq`, `brenth`, `ridder`, `bisect`, `newton`

scalar fixed-point finder

`fixed_point`


Notes

-----

`f` must be continuous. f(a) and f(b) must have opposite signs.



References

----------

.. [Brent1973]

Brent, R. P.,

*Algorithms for Minimization Without Derivatives*.

Englewood Cliffs, NJ: Prentice-Hall, 1973. Ch. 3-4.


.. [PressEtal1992]

Press, W. H.; Flannery, B. P.; Teukolsky, S. A.; and Vetterling, W. T.

*Numerical Recipes in FORTRAN: The Art of Scientific Computing*, 2nd ed.

Cambridge, England: Cambridge University Press, pp. 352-355, 1992.

Section 9.3: "Van Wijngaarden-Dekker-Brent Method."



In [32]: d = {}


In [33]: type(d)

Out[33]: dict


In [34]: d[0] = "Monday"


In [35]: d[1] = "Value"


In [36]: d[1] = "Tuesday"


In [37]: d

Out[37]: {0: 'Monday', 1: 'Tuesday'}


In [38]: d[0]

Out[38]: 'Monday'


In [39]: d[1]

Out[39]: 'Tuesday'


In [40]: l = ["Monday", "Tuesday"]


In [41]: l[0]

Out[41]: 'Monday'


In [42]: l[1]

Out[42]: 'Tuesday'


In [43]: d = {}


In [44]: d[(0, 0)] = "Monday"


In [45]: d[(0, 1)] = "Tuesdy"


In [46]: d

Out[46]: {(0, 0): 'Monday', (0, 1): 'Tuesdy'}


In [47]: d[(0, 0)]

Out[47]: 'Monday'


In [48]: dir(d)

Out[48]:

['__class__',

'__contains__',

'__delattr__',

'__delitem__',

'__dir__',

'__doc__',

'__eq__',

'__format__',

'__ge__',

'__getattribute__',

'__getitem__',

'__gt__',

'__hash__',

'__init__',

'__iter__',

'__le__',

'__len__',

'__lt__',

'__ne__',

'__new__',

'__reduce__',

'__reduce_ex__',

'__repr__',

'__setattr__',

'__setitem__',

'__sizeof__',

'__str__',

'__subclasshook__',

'clear',

'copy',

'fromkeys',

'get',

'items',

'keys',

'pop',

'popitem',

'setdefault',

'update',

'values']


In [49]: d.keys()

Out[49]: dict_keys([(0, 1), (0, 0)])


In [50]: d.values()

Out[50]: dict_values(['Tuesdy', 'Monday'])


In [51]: for i in d.keys():

    ...: print("The value corr. to the key {} is {}".format(i, d[i]))

    ...:

The value corr. to the key (0, 1) is Tuesdy

The value corr. to the key (0, 0) is Monday


In [52]: runfile('//filestore.soton.ac.uk/users/oh1m12/mydocuments/20172018/Lecture7/lecture7_1.py', wdir='//filestore.soton.ac.uk/users/oh1m12/mydocuments/20172018/Lecture7')

y is 0.25


In [53]: runfile('//filestore.soton.ac.uk/users/oh1m12/mydocuments/20172018/Lecture7/lecture7_1.py', wdir='//filestore.soton.ac.uk/users/oh1m12/mydocuments/20172018/Lecture7')

Reloaded modules: lecture7

y is 0.25


In [54]: runfile('//filestore.soton.ac.uk/users/oh1m12/mydocuments/20172018/Lecture7/lecture7.py', wdir='//filestore.soton.ac.uk/users/oh1m12/mydocuments/20172018/Lecture7')

Reloaded modules: lecture7

Hello World


In [55]: runfile('//filestore.soton.ac.uk/users/oh1m12/mydocuments/20172018/Lecture7/lecture7_1.py', wdir='//filestore.soton.ac.uk/users/oh1m12/mydocuments/20172018/Lecture7')

Hello World

y is 0.25


In [56]: