<jupyter_start><jupyter_text>Finding the length of the curve - Declare first a circle function- Create and run a new function<jupyter_code>def circle(x):
    return sqrt(1-x**2)

def curve_length2(f,a,b,num=1000):
    """Returns the length of f between\
       a and b using num slices"""
    output = 0
    width = (b-a)/num
    for i in range(num):
        output += sqrt((f(a+(i+1)*width)-f(a+i*width))**2 \
                        + width**2)
    return output<jupyter_output><empty_output><jupyter_text>- Print the output of the function, measuring from x=-1 to x=-1<jupyter_code>print(curve_length2 (circle,-1,1))<jupyter_output>3.1415663562164773<jupyter_text>Finding the Length of a Sine Wave<jupyter_code># Now, import the library, sin and pi
from math import sin,pi
# We've already written our curve function. We just need to tell it the function to use, and the beginning and ending x values
print(curve_length2(sin,0,2*pi))<jupyter_output>7.640391636335927<jupyter_text>---<jupyter_code>def opposite(a,b,C):
    """Returns the side opposite the given angle in
       a triangle using the Law of Cosines
       Enter side, side, angle"""
    c = sqrt(a**2 + b**2 - 2*a*b*cos(C))
    return c

from math import sqrt,cos,pi
def spiral(r,a,b,step=0.0001):
    """Returns length of spiral r from
       a to b taking given step size"""
    length = 0
    theta = a
    while theta < b:
        length += opposite(r(theta),r(theta+step),step)
        theta += step
    return length

def r(theta):
    return 5 + 0.12892*theta
spiral(r,0,2*pi*7.5)<jupyter_output><empty_output><jupyter_text>Finding the Length of the Polar Spiral Curve In this exercise, you will find the length of the polar spiral curve, which starts at (3,0), makes 12 complete revolutions around the center, and ends at (16,0). - We don't know the formula for this spiral, but we do know that the radius increases 13 units (from 3 to 16) in 12 revolutions. This means that for every increase of 2π in the angle, θ, the radius increases 13/12 units. So, we divide 13/12 by 2π.<jupyter_code>def r(theta):
    return 3 + 0.1724*theta

# Check to make sure
print(r(0),r(24*pi))
# So simply put that in our spiral function
spiral(r,0,2*pi*12)<jupyter_output><empty_output><jupyter_text>---  Finding the Length of Insulation in a Roll You measure the roll and find that the center is an empty circle whose diameter is 4 inches (so r(0) = 2). The outer diameter of the roll is 26 inches. You count the layers from the center to the outside and estimate that the spiral takes 23 and a half turns, so r(2π*23.5)= 26/2 = 13<jupyter_code># Let's define the code!

def r(theta):
    return 2+0.0745*theta

spiral(r,0,2*pi*23.5) # 1,107 inches is just over 92 feet of insulation<jupyter_output><empty_output><jupyter_text>---  Finding the Length of Archimedean Spiral<jupyter_code>from math import e

def r(theta):
    return 2*e**(0.315*theta)<jupyter_output><empty_output><jupyter_text>- Run the spiral function from 0 to 2π<jupyter_code>spiral(r,0,2*pi)<jupyter_output><empty_output><jupyter_text>---<jupyter_code>def partial_d(f,u,v,w,num=10000):
    """returns the partial derivative of f
    with respect to u at (v,w)"""
    delta_u = 1/num
    try:
        if u == 'x':
            return (f(v+delta_u,w) - f(v,w))/delta_u
        else:
            return (f(v,w+delta_u) - f(v,w))/delta_u
    except ValueError:
        pass
def cross(u,v):
    """Returns the cross product of 2 3D vectors
    [[i,j,k],\
    [1,0,dz/dx],\
    [0,1,dz,dy]]
    cross([1,-1,2],[2,3,-5])
    >>> [-1, -9, 5]
    """
    return [u[1]*v[2]-v[1]*u[2],\
            -u[0]*v[2]+v[0]*u[2],\
            u[0]*v[1]-v[0]*u[1]]
print(cross([2,3,4],[5,6,7]))
from math import sqrt
def sphere(x,y):
    """Sphere of radius 1"""
    return sqrt(1-x**2-y**2)
def area(f,ax,bx,ay,by,num=1000):
    """Returns area of parallelogram formed by
    vectors with given partial derives"""
    running_sum = 0
    dx = (bx-ax)/num
    dy = (by-ay)/num
    for i in range(num):
        for j in range(num):
            x = ax+i*dx
            y = ay+j*dy
            dz_dx=partial_d(f,'x',x,y)
            dz_dy=partial_d(f,'y',x,y)
            try:
                running_sum += mag(cross([1,0,dz_dx],[0,1,dz_dy]))*dx*dy
            except:
                pass
    return running_sum<jupyter_output><empty_output><jupyter_text>Finding the Area of a 3D Surface Part 1<jupyter_code>from math import sin, cos, sqrt
def surface(x,y):
    return 10*sin(sqrt(x**2+y**2))
print("Area of wave surface:",area(surface,-5,5,-5,5))<jupyter_output>Area of wave surface: 0<jupyter_text>Finding the Area of a 3D Surface Part 2<jupyter_code>def surface(x,y):
    return 3*cos(x)+2*cos(x)*cos(y)

print("Area of surface:",area(surface,0,6.28,0,6.28))<jupyter_output>Area of surface: 0<jupyter_text>Finding the Area of a 3D Surface Part 3<jupyter_code>def surface(x,y):
    return sqrt(1+sin(x)*cos(y))
print("Area of surface:",area(surface,0,6.28,0,6.28))<jupyter_output>Area of surface: 0
{'fraction_non_alphanumeric': 0.13726273726273727, 'fraction_numerical': 0.047752247752247755, 'mean_word_length': 3.6266173752310538, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '166639', 'license': 'Apache-2.0', 'n_tokens_mistral': 1988, 'n_tokens_neox': 1814, 'n_words': 529, 'path': 'Work_11/work_11-1.ipynb', 'repo_name': 'samyon7/Statistics-Python', 'size': '5005'}