{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chapter 1 : Introduction and basic concepts"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.1"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Heat needs to be transferred to the copper ball to heat it from 100 to 150 degree celsius is 92.5526285717 kJ\n",
"Average Heat Transfer by the iron ball is 51.4181269843 W\n",
"Average flux is 1636.68981481 W/m**2\n"
]
}
],
"source": [
"# Heating of a copper ball\n",
"\n",
"import math \n",
"# Variables\n",
"#(a)\n",
"#density of the copper ball\n",
"rho = 8950\t\t\t#[kg/m**3]\n",
"#Diameter of the copper ball\n",
"D = 0.1\t\t\t#[m]\n",
"#mass of the ball\n",
"m = rho*(math.pi/6)*(D**3)\t\t\t#[kg]\n",
"#Specific Heat of copper\n",
"Cp = 0.395\t\t\t#[kJ/Kg/m**3]\n",
"#Initial Temperature\n",
"T1 = 100\t\t\t#[degree C]\n",
"#Final Temperature\n",
"T2 = 150\t\t\t#[degree C]\n",
"\n",
"# Calculations and Results\n",
"# The amount of heat transferred to the copper ball is simply the change in it's internal energy and is given by\n",
"# Energy transfer to the system = Energy increase of the system\n",
"Q = (m*Cp*(T2-T1));\n",
"print \"Heat needs to be transferred to the copper ball to heat it from 100 to 150 degree celsius is \",Q,\"kJ\"\n",
"\n",
"#b\n",
"#Time interval for which the ball is heated\n",
"dT = 1800\t\t\t#[seconds]\n",
"Qavg = (Q/dT)*1000\t\t\t#[W]\n",
"print \"Average Heat Transfer by the iron ball is \",Qavg,\"W\"\n",
"\n",
"#(c)\n",
"#Heat Flux\n",
"qavg = (Qavg/(math.pi*(D**2)))\t\t\t#[W/m**2]\n",
"print \"Average flux is\",qavg,\"W/m**2\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.2"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time needed for this heater to supply 429.856 kJ of heat is 6.0 minutes\n"
]
}
],
"source": [
"# Heating of water in an Electric Teapot\n",
"\n",
"# Variables\n",
"#Mass of liquid water\n",
"m1 = 1.2\n",
"m2 = 0.5\t\t\t#[Kg]\n",
"#Initial Temperature\n",
"t1 = 15\t\t\t #[Degree Celcius]\n",
"#Final Temperature\n",
"t2 = 95\t\t \t#[Degree Celcius]\n",
"#Specific heat of water\n",
"cp1 = 4.186\t\t\t#[kJ/kG.K]\n",
"#Specific heat capacity of teapot\n",
"cp2 = .7\t\t\t#[]\n",
"\n",
"# Calculations\n",
"Em = (m1*cp1*(t2-t1))+(m2*cp2*(t2-t1))\t\t\t#[kJ]\n",
"#Rating of Electric Heating Equipment\n",
"Em1 = 1.2 \t\t\t#[kJ/s]\n",
"dt = (Em/Em1)/60\t\t\t#[seconds]\n",
"\n",
"# Results\n",
"print \"Time needed for this heater to supply \",Em,\"kJ\",\"of heat is\",round(dt),\"minutes\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.3"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The constant pressure specific heat of air at the average temperature of 330 K is 1.007 kJ/kg\n",
"mass flow rate of air through the duct is 0.261585627439 kg/s\n",
"The rate of heat loss by the air is 1.58050036099 kJ/s\n",
" Cost of heat loss to the home owner is $ 0.107863531745 per hour\n"
]
}
],
"source": [
"# Heat Loss from Heating Ducts in a Basement\n",
"\n",
"# Variables\n",
"T_in = 60+273\t\t\t#Temperature of hot air while entering the duct[K]\n",
"T_out = 54+273\t\t\t#Temperature of hot air while leaving the duct[K]\n",
"T_avg = (T_in+T_out)/2\t\t\t#Average temperature of air[K]\n",
"\n",
"# Calculations and Results\n",
"Cp = 1.007\t\t\t#[kJ/kg]\n",
"print \"The constant pressure specific heat of air at the average temperature of\",T_avg,\"K is\",Cp,\"kJ/kg\"\n",
"\n",
"P = 100 \t\t\t#Pressure of air while entering the duct[kPa]\n",
"R = 0.287\t\t\t#Universal Gas Consmath.tant[kPa.(m**3/kg).K]\n",
"v = 5\t \t\t#Average velocity of flowing air[m/s]\n",
"neta = 0.8\t\t\t#Efficiency of natural gas furnace\n",
"ucost = 1.60\t\t\t#Cost of natural gas in that area[$/therm],where 1therm = 105,500kJ\n",
"#Solution;-\n",
"rho = P/(R*T_in)\t\t\t#The density of air at the inlet conditions is[kg/m**3]\n",
"Ac = 0.20*0.25\t\t\t#Cross sectional area of the duct[m**2]\n",
"m_ = rho*v*Ac\t\t\t#[kg/s]\n",
"print \"mass flow rate of air through the duct is\",m_,\"kg/s\"\n",
"\n",
"Q_loss = m_*Cp*(T_in-T_out)\t\t\t#[kJ/s]\n",
"print \"The rate of heat loss by the air is\",Q_loss,\"kJ/s\"\n",
"\n",
"cost = (Q_loss*3600)*(ucost)*(1./105500)*(1/neta)\t\t\t#[$/h]\n",
"print \" Cost of heat loss to the home owner is\" ,\"$\",cost,\"per hour\"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.4"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The specific heat capacities of air at the average temperature of 288 K 0.72 and 1.007 kJ/kg.K\n",
"Mass of air in the room is 624.961524729 kg\n",
"The amount of energy transferred to air at constant volume is 4499.72297805 kJ\n",
"Cost of Energy is $ 0.0937442287093\n",
"The amount of energy transferred to air at constant is 6293.36255402 kJ\n",
"Cost of Energy is $ 0.131111719875\n"
]
}
],
"source": [
"# Electric Heating of a House at High Elevation\n",
"\n",
"# Variables\n",
"#(a)\n",
"t1 = 10+273\t\t\t#Initial temperature of house[K]\n",
"t2 = 20+273\t\t\t#Temperature after turning on heater[K]\n",
"\n",
"# Calculations and Results\n",
"tavg = (t1+t2)/2\t\t\t#Average temperature[K]\n",
"cp = 1.007\t\t\t#[kJ/kg.K]\n",
"cv = .720\t\t\t#[kJ/kg.K]\n",
"print \"The specific heat capacities of air\",\"at the average temperature of\",tavg,\"K\",cv,\"and\",cp,\"kJ/kg.K\"\n",
"\n",
"A = 200 \t\t\t#The floor area[m**2]\n",
"h = 3\t \t\t#Height of room[m]\n",
"V = A*h\t\t \t#Volume of the air in the house[m**3]\n",
"P = 84.6\t\t\t #Pressure [kPa]\n",
"R = 0.287\t\t\t #Universal gas consmath.tant[kPa.m**3/kg.K]\n",
"m = (P*V)/(R*t1)\t\t\t#[kg]\n",
"print \"Mass of air in the room is\",m,\"kg\"\n",
"\n",
"Eincv = m*cv*(t2-t1);\n",
"print \"The amount of energy transferred to air at constant volume is \",Eincv,\"kJ\"\n",
"\n",
"u_cost = 0.075\t\t\t#Unit math.cost of energy[$/kWh]\n",
"Cost1 = (Eincv*u_cost)/(3600)\t\t\t#[$]\n",
"print \"Cost of Energy is $\",Cost1\n",
"\n",
"#(b)\n",
"Eincp = m*cp*(t2-t1)\t\t\t#[kJ]\n",
"print \"The amount of energy transferred to air at constant is \",Eincp,\"kJ\"\n",
"\n",
"Cost2 = (Eincp*u_cost)/3600\t\t\t#[$]\n",
"print \"Cost of Energy is $\",Cost2\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.5"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The steady rate of heat transfer through the roof is 1689.6 W\n",
"The amount of heat lost through the roof 16.896 kWh and its cost is $ 1.35168\n"
]
}
],
"source": [
"# The cost of Heat loss through a Roof\n",
"\n",
"# Variables\n",
"k = 0.8\t\t\t#The thermal conductivity of the roof[W/m.degree.C]\n",
"A = 6*8\t\t\t#Area of the roof[m**2]\n",
"t1 = 15\t\t\t#temperature of inner surface roof[degree C]\n",
"t2 = 4\t\t\t#temperature of outer surface roof[degree C]\n",
"L = 0.25\t\t\t#thickness of roof[m]\n",
"\n",
"# Calculations and Results\n",
"Q_ = k*A*(t1-t2)/L\t\t\t#[W]\n",
"print \"The steady rate of heat transfer through the roof is\",Q_,\"W\"\n",
"\n",
"#(b)\n",
"dt = 10. \t\t\t#time period[h]\n",
"Q = Q_*dt/1000\t\t\t#[kWh]\n",
"u_cost = 0.08\t\t\t#Unit math.cost of energy[$/kWh]\n",
"Cost = Q*u_cost\t\t\t#[$]\n",
"print \"The amount of heat lost through the roof\",Q,\"kWh\",\"and its cost is $\",Cost\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.6"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The electrical power consumed by the resismath.tance heater and converted to heat is 44.0 W\n",
"The rate of heat flow through each sample 22.0 W\n",
"The thermal conductivity of the sample is 22.4090159873 W/mC\n"
]
}
],
"source": [
"# Measuring the Thermal Conductivity of a Material\n",
"\n",
"# Variables\n",
"V = 110\t\t\t#Voltage diffrence b/w thermocouples[V]\n",
"I = 0.4\t\t\t#Current drawn by thermocouples[A]\n",
"\n",
"# Calculations and Results\n",
"We = V*I\t\t\t#[W]\n",
"print \"The electrical power consumed by the resismath.tance heater and converted to heat is\",We,\"W\"\n",
"\n",
"q_ = We/2\t\t\t#[W]\n",
"print \"The rate of heat flow through each sample\",q_,\"W\"\n",
"\n",
"dT = 15\t\t\t#Temperature drop in the direction of heat flow[degree C]\n",
"l = .03\t\t\t#length for which temperature change is measured[m]\n",
"D = .05\t\t\t#diameter of cylinder[m]\n",
"a = (math.pi*D**2)/4\t\t\t#Cross-sectional area of the cylinder[m**2]\n",
"K = (q_*l)/(a*dT)\t\t\t#[W/m.degreeC]\n",
"print \"The thermal conductivity of the sample is\",K,\"W/mC\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.7"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The thermal conductivity of the brick in English units is 0.41601316752 Btu/h.ft.degree Farenhiet\n"
]
}
],
"source": [
"# Conversion between SI and English Units\n",
"\n",
"# Variables\n",
"W_to_btu_p_h = 3.41214\t\t\t#Conersion from Watt to btu per hour[btu/h]\n",
"m_to_ft = 3.2808\t\t\t #Conversion from meter to english unit feet[ft]\n",
"deg_C_to_deg_F = 1.8\t\t\t#Conversion from degree Celcius to degree Farenhiet\n",
"\n",
"# Calculations\n",
"W_per_m_deg_C = W_to_btu_p_h/(m_to_ft*deg_C_to_deg_F)\t\t\t#Conversion factor for 1W/m.degree Celcius[Btu/h.ft.degree Farenhiet]\n",
"k_brick = 0.72*W_per_m_deg_C \t\t\t#[Btu/h.ft.degree Farenhiet]\n",
"\n",
"# Results\n",
"print \"The thermal conductivity of the brick in English units is\",k_brick,\"Btu/h.ft.degree Farenhiet\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.8"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The rate of heat generated in the wire as a result of resismath.tance heating is 90.0 W\n",
"The convection Heat Transfer coefficient is 34.8514473924 W/m**2.degree Celcius\n"
]
}
],
"source": [
"# Measuring Convection Heat Transfer coefficient\n",
"\n",
"# Variables\n",
"T_ambient = 15\t\t\t#Temperature of room[degree Celcius]\n",
"T_surface = 152\t\t\t#Temperature of surface of wire[degree Celcius]\n",
"L = 2\t\t\t#Length of wire[m]\n",
"D = 0.003\t\t\t#Diameter of wire[m]\n",
"V = 60\t\t\t#Voltage drop across the current wire[Volts]\n",
"I = 1.5\t\t\t#Current flowing in the wire[amp]\n",
"\n",
"# Calculations and Results\n",
"#When steady conditions are reached, the rate of heat loss from the wire equals the rate of heat generation in the wire as a result of resismath.tance heating\n",
"\n",
"Q_ = V*I\t\t\t#[W]\n",
"print \"The rate of heat generated in the wire as a result of resismath.tance heating is\",Q_,\"W\"\n",
"\n",
"As = math.pi*D*L\t\t\t#Surface Area of the wire[m**2]\n",
"#Using Newton's Law of Cooling\n",
"#and assuming all heat loss in wire to occur by convection\n",
"h = Q_/(As*(T_surface-T_ambient))\t\t\t#[W/m**2.degree Celcius]\n",
"print \"The convection Heat Transfer coefficient is\",h, \"W/m**2.degree Celcius\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.9"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The net rates of radiation heat transfer from the body to the surrounding walls ,ceiling, and floor in winter and summer are respectively 152.0 and 40.9287218637 W\n"
]
}
],
"source": [
"# Radiation Effect on Thermal Comfort\n",
"\n",
"# Variables\n",
"T_room = 22+273\t\t\t#Temperature fo room[K]\n",
"T_wntr = 10+273\t\t\t#Average Temperature of inner surfaces of walls,floors and the cieling in winter[K]\n",
"T_smmr = 25+273\t\t\t#Average Temperature of inner surfaces of walls,floors and the cieling in summer[K]\n",
"T_outr = 30+273\t\t\t#Average outer surface temperature of the person[K]\n",
"A = 1.4 \t\t\t#The math.exposed surface area[m**2]\n",
"e = 0.95\t\t\t#Emissivity of person\n",
"\n",
"# Calculations\n",
"sigma = 5.67*(10**(-8))\t\t\t#Stefan's consmath.tant\n",
"Q_rad_wntr = e*sigma*A*((T_outr**4)-(T_wntr**4))\t\t\t#[W]\n",
"Q_rad_smmr = e*sigma*A*((T_outr**4)-(T_smmr**4))\t\t\t#[W]\n",
"\n",
"# Results\n",
"print \"The net rates of radiation heat transfer from the body to the surrounding walls \\\n",
",ceiling, and floor in winter and summer are respectively\",round(Q_rad_wntr),\"and\",Q_rad_smmr,\"W\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.10"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Rate of convection heat transfer from the person to the air in the room is 86.4 W\n",
"The rate of convection heat transfer from the person to the surrounding walls,cieling,fllor is 81.712671952 W\n",
"The rate of total heat transfer from the body is 168.0 W\n"
]
}
],
"source": [
"# Heat Loss from a Person\n",
"\n",
"# Variables\n",
"T_room = 20+273\t\t\t#Temperature of breezy room[K]\n",
"T_outr = 29+273\t\t\t#Average outer surface temperature of the person[K]\n",
"As = 1.6\t\t\t#math.exposed Surface Area[m**2]\n",
"h = 6\t\t\t#Convection Heat transfer coefficient[W/m**2.K]\n",
"e = 0.95\t\t\t#Emissivity of person\n",
"\n",
"# Calculations and Results\n",
"sigma = 5.67*(10**(-8))\t\t\t#Stephan's consmath.tant[W/m**2.degree Celcius]\n",
"Q_conv = h*As*(T_outr-T_room)\t\t\t#[W]\n",
"print \"Rate of convection heat transfer from the person to the air in the room is\",Q_conv,\"W\"\n",
"\n",
"Q_rad = e*sigma*As*((T_outr**4)-(T_room**4))\t\t\t#[W]\n",
"print \"The rate of convection heat transfer from the person to the surrounding walls,cieling,fllor is\",Q_rad,\"W\"\n",
"\n",
"Q_total = Q_conv+Q_rad\t\t\t#[W]\n",
"print \"The rate of total heat transfer from the body is \",round(Q_total),\"W\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.11"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The rates of conduction and radiation heat transfer between the plates through the air layer are respectively 219.0 and 369.0 W\n",
"('W', 588.0, 'Net rate of heat transfer is')\n",
"The heat transfer rate in reality will be higher because of the natural convection currents that are likely to occur in the air space between the plates\n",
"when the air space b/w the plates is evacuted there is no conduction or convection, and the only heat transfer between the plates will be by radiation. \n",
"Therefore Net rate of heat transfer is 369.0 W\n",
"An opaque solid material placed b/w the two plates blocks direct radiation heat transfer between the plates\n",
"The net rate of heat transfer through the urethane insulation is 260.0 W\n",
"The layers of superinsulation prevent any direct radiation heat transfer between the plates\n",
"The net rate of heat transfer through the layer of superinsulation is 0.2 W\n"
]
}
],
"source": [
"# Heat transfer between two Isothermal Plates\n",
"\n",
"# Variables\n",
"T1 = 300\n",
"T2 = 200.\t\t\t#Temperatures of two large parallel isothermal plates[K]\n",
"L = 0.01\t\t\t#dismath.tance between both plates[m]\n",
"e = 1\t\t\t#Emissivity of plates\n",
"A = 1\t\t\t#Surface area of plates[m**2]\n",
"\n",
"# Calculations and Results\n",
"T_avg = (T1+T2)/2\t\t\t#Average temperature[K]\n",
"sigma = 5.67*(10**(-8))\t\t\t#Stefan's consmath.tant[W/m**2.K**4]\n",
"#Solution (a)[space between plates is filled with air]\n",
"k_air = 0.0219\t\t\t#The thermal conductivity of aair at the average temperature[W/m.K]\n",
"Q_cond = k_air*A*(T1-T2)/L\t\t\t#[W]\n",
"Q_rad = e*sigma*A*((T1**4)-(T2**4))\t\t\t#[W]\n",
"print \"The rates of conduction and radiation heat transfer between the plates through\\\n",
" the air layer are respectively\",Q_cond,\"and\",round(Q_rad),\"W\"\n",
"\n",
"Q_total_a = Q_cond+Q_rad\t\t\t#[W]\n",
"print (\"W\",round(Q_total_a),\"Net rate of heat transfer is\")\n",
"print (\"The heat transfer rate in reality will be higher because of the natural convection currents that are likely to occur in the air space between the plates\")\n",
"\n",
"#Solution (b)[space between the plates is evacutaed]\n",
"print \"when the air space b/w the plates is evacuted there is no conduction or convection, \\\n",
"and the only heat transfer between the plates will be by radiation. \"\n",
"print (\"Therefore\"),\n",
"Q_total_b = Q_rad\t\t\t#[W]\n",
"print \"Net rate of heat transfer is\",round(Q_total_b),\"W\"\n",
"\n",
"#Solution (c)[space between the plates is filled with urethane insulation]\n",
"k_insu = 0.026\t\t\t#At average temperature thermal conductivity of urethane insulation [W/m.K]\n",
"print (\"An opaque solid material placed b/w the two plates blocks direct radiation heat\\\n",
" transfer between the plates\")\n",
"\n",
"Q_cond_c = k_insu*A*(T1-T2)/L\t\t\t#[W]\n",
"Q_total_c = Q_cond_c\t\t\t#[W]\n",
"print \"The net rate of heat transfer through the urethane insulation is\",round(Q_total_c),\"W\"\n",
"\n",
"#Solution (d)[the dismath.tance between the plates is filled with superinsulation]\n",
"k_super = 0.00002\t\t\t#At average temperature thermal conductvity of superinsulation[W/m.K]\n",
"print (\"The layers of superinsulation prevent any direct radiation heat transfer between the plates\")\n",
"\n",
"Q_cond_d = k_super*A*(T1-T2)/L\t\t\t#[W]\n",
"Q_total_d = Q_cond_d\t\t\t #[W]\n",
"print \"The net rate of heat transfer through the layer of superinsulation is\",Q_total_d,\"W\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.13"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The plate surface temperature is 33.4 degree Celcius\n"
]
}
],
"source": [
"# Heating of a Plate by Solar Energy\n",
"\n",
"# Variables\n",
"a = 0.6\t\t\t#absorptivity of math.exposed surface of plate\n",
"q_incident = 700\t\t\t#Rate at which solar radiation incident on the plate [W/m**2]\n",
"T_surr = 25+273\t\t\t#Surrounding air temperature[K]\n",
"h = 50\t\t\t#Combined radiation and convection heat transfer coefficient[W/m**2.K]\n",
"\n",
"# Calculations\n",
"#Temperature keeps on increamath.sing till a point comes at which the rate of heat loss from the plate equals the rate of solar energy absorbed, and the temperature of the plate no longer changes\n",
"T_surface = T_surr+(a*(q_incident)/h)\t\t\t#[K]\n",
"\n",
"# Results\n",
"print \"The plate surface temperature is\",T_surface-273,\"degree Celcius\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1.14"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 5. 1.]\n"
]
}
],
"source": [
"\n",
"from scipy.optimize import fsolve \n",
"import math \n",
"\n",
"# Non-linear equation in two variable\n",
"#x1 = x, x2 = y\n",
"def f2(x):\n",
" f = [0,0]\n",
" f[0] = x[0]-x[1]-4;\n",
" f[1] = x[0]**2+x[1]**2-x[0]-x[1]-20;\n",
" return f\n",
"#To get the desired output assign an initial value such as x0 = [1,1], [xs,fxs,m] = fsolve(f2,x0')\n",
"#To get the desired output assign an initial value such as \n",
"x0 = [1,1]\n",
"f = fsolve(f2,x0)\n",
"print f"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}