1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Leya [2.2K]
3 years ago
13

The "divide and average" method, an old-time method for approximating the square root of any positive number a, can be formulate

d as:
x= (x +a/x)/2

Write a well-structured M-file function based on the while...break loop structure to implement this algorithm. Use proper indentation so that the structure is clear. At each step estimate the error in your approximation as:

ε= |x^new- x^old/x^new|

Repeat the loop until ε is less than or equal to a specified value. Design your program so that it returns both the result and the error. Make sure that it can evaluate the square root of numbers that are equal to and less than zero. For the latter case, display the result as an imaginary number. For example, the square root of -4 would return 2i. Test your program by evaluating a = 0,2, 10 and-4 for ε = 10^-4

Engineering
1 answer:
Shalnov [3]3 years ago
4 0

Answer:

<u>note:</u>

find the attachment:

You might be interested in
The link acts as part of the elevator control for a small airplane. If the attached aluminum tube has an inner diameter of 25 mm
aksik [14]

Answer:

Tmax=14.5MPa

Tmin=10.3MPa

Explanation:

T = 600 * 0.15 = 90N.m

T_max =\frac{T_c}{j}  = \frac{x}{y}  = \frac{90 \times 0.0175}{\frac{\pi}{2} \times (0.0175^4-0.0125^4)}

=14.5MPa

T_{min} =\frac{T_c}{j}  = \frac{x}{y}  = \frac{90 \times 0.0125}{\frac{\pi}{2} \times (0.0175^4-0.0125^4)}

=10.3MPa

7 0
3 years ago
computer language C++ (Connect 4 game)( this is all the info that was givin no input or solution) I used the most recent version
Mariana [72]

Answer:

C++ code explained below

Explanation:

#include "hw6.h"

//---------------------------------------------------

// Constructor function

//---------------------------------------------------

Connect4::Connect4()

{

ClearBoard();

}

//---------------------------------------------------

// Destructor function

//---------------------------------------------------

Connect4::~Connect4()

{

// Intentionally empty

}

//---------------------------------------------------

// Clear the Connect4 board

//---------------------------------------------------

void Connect4::ClearBoard()

{

// Initialize Connect4 board

for (int c = 0; c < COLS; c++)

for (int r = 0; r < ROWS; r++)

board[r][c] = ' ';

// Initialize column counters

for (int c = 0; c < COLS; c++)

count[c] = 0;

}

//---------------------------------------------------

// Add player's piece to specified column in board

//---------------------------------------------------

bool Connect4::MakeMove(int col, char player)

{

// Error checking

if ((col < 0) || (col >= COLS) || (count[col] >= ROWS))

return false;

// Make move

int row = count[col];

board[row][col] = player;

count[col]++;

return true;

}

//---------------------------------------------------

// Check to see if player has won the game

//---------------------------------------------------

bool Connect4::CheckWin(char player)

{

// Loop over all starting positions

for (int c = 0; c < COLS; c++)

for (int r = 0; r < ROWS; r++)

if (board[r][c] == player)

{

// Check row

int count = 0;

for (int d = 0; d < WIN; d++)

if ((r+d < ROWS) &&

(board[r+d][c] == player)) count++;

if (count == WIN) return true;

 

// Check column

count = 0;

for (int d = 0; d < WIN; d++)

if ((c+d < COLS) &&

(board[r][c+d] == player)) count++;

if (count == WIN) return true;

 

// Check first diagonal

count = 0;

for (int d = 0; d < WIN; d++)

if ((r+d < ROWS) && (c+d < COLS) &&

(board[r+d][c+d] == player)) count++;

if (count == WIN) return true;

 

// Check second diagonal

count = 0;

for (int d = 0; d < WIN; d++)

if ((r-d >= 0) && (c+d < COLS) &&

(board[r-d][c+d] == player)) count++;

if (count == WIN) return true;

}

return false;

}

//---------------------------------------------------

// Print the Connect4 board

//---------------------------------------------------

void Connect4::PrintBoard()

{

// Print the Connect4 board

for (int r = ROWS-1; r >= 0; r--)

{

// Draw dashed line

cout << "+";

for (int c = 0; c < COLS; c++)

cout << "---+";

cout << "\n";

// Draw board contents

cout << "| ";

for (int c = 0; c < COLS; c++)

cout << board[r][c] << " | ";

cout << "\n";

}

// Draw dashed line

cout << "+";

for (int c = 0; c < COLS; c++)

cout << "---+";

cout << "\n";

// Draw column numbers

cout << " ";

for (int c = 0; c < COLS; c++)

cout << c << " ";

cout << "\n\n";

}

//---------------------------------------------------

// Main program to play Connect4 game

//---------------------------------------------------

int main()

{

  int choice;

  int counter = 0;

  srand (time(NULL));

  Connect4 board;

  cout << "Welcome to Connect 4!" << endl << "Your Pieces will be labeled 'H' for human. While the computer's will be labeled 'C'" << endl;

  board.PrintBoard();

  cout << "Where would you like to make your first move? (0-6)";

  cin >> choice;

  while (board.MakeMove(choice,'H') == false){

  cin >> choice;

  }

  counter++;

  while (board.CheckWin('C') == false && board.CheckWin('H') == false && counter != 21){

  while (board.MakeMove(rand() % 7, 'C') == false){}

  board.PrintBoard();

  cout << "Where would you like to make your next move?" << endl;

  cin >> choice;

  board.MakeMove(choice,'H');

  while (board.MakeMove(choice,'H') == false){

  cin >> choice;

  }

  counter++;

  }

 

  if (board.CheckWin('C')){

  cout << "Computer Wins!" << endl;}

  else if (counter == 21){cout << "Tie Game!" << endl;}

  else {cout << "Human Wins!" << endl;}

  board.PrintBoard();

}

4 0
3 years ago
Consider a 2-shell-passes and 8-tube-passes shell-and-tube heat exchanger. What is the primary reason for using many tube passes
Maru [420]

Answer:

See explanation

Explanation:

Solution:-

- The shell and tube heat exchanger are designated by the order of tube and shell passes.

- A single tube pass: The fluid enters from inlet, exchange of heat, the fluid exits.

- A multiple tube pass: The fluid enters from inlet, exchange of heat, U bend of the fluid, exchange of heat, .... ( nth order of pass ), and then exits.

- By increasing the number of passes we have increased the "retention time" of a specific volume of tube fluid; hence, providing sufficient time for the fluid to exchange heat with the shell fluid.

- By making more U-turns we are allowing greater length for the fluid flow to develop with " constriction and turns " into turbulence. This turbulence usually at the final passes allows mixing of fluid and increases the heat transfer coefficient by:

                                U ∝ v^( 0.8 )    .... ( turbulence )

- The higher the velocity of the fluids the greater the heat transfer coefficient. The increase in the heat transfer coefficient will allow less heat energy carried by either of the fluids to be wasted ; hence, reduced losses.

Thereby, increases the thermal efficiency of the heat exchanger ( higher NTU units ).

5 0
3 years ago
Three point charges, each with q = 3 nC, are located at the corners of a triangle in the x-y plane, with one corner at the origi
lawyer [7]

Answer:

\vec F_{A} = -67500\,N\cdot (i + j)

Explanation:

The position of each point are the following:

A = (0\,m,0\,m,0\,m), B = (0.02\,m,0\,m,0\,m), C = (0\,m,0.02\,m,0\,m)

Since the three objects report charges with same sign, then, net force has a repulsive nature. The net force experimented by point charge A is:

\vec F_{A} = \vec F_{AB} + \vec F_{AC}

\vec F_{A} = -\frac{k\cdot q^{2}}{r_{AB}^{2}}\cdot i - \frac{k\cdot q^{2}}{r_{AC}^{2}}\cdot j

\vec F_{A} = - \frac{k\cdot q^{2}}{r^{2}} \cdot (i + j)

\vec F_{A} = -\frac{(9 \times 10^{9}\,\frac{N\cdot m^{2}}{C^{2}} )\cdot (3\times 10^{-9}\,C)}{(0.02\,m)^{2}}\cdot (i + j)

\vec F_{A} = -67500\,N\cdot (i + j)

6 0
3 years ago
If we have silicon at 300K with 10 microns of p-type doping of 4.48*10^18/cc and 10 microns of n-type doping at 1000 times less
liq [111]

Answer:

The resistance is 24.9 Ω

Explanation:

The resistivity is equal to:

R=\frac{1}{N_{o}*u*V } =\frac{1}{4.48x10^{15}*1500*106x10^{-19}  } =0.93ohm*cm

The area is:

A = 60 * 60 = 3600 um² = 0.36x10⁻⁴cm²

w=\sqrt{\frac{2E(V_{o}-V) }{p}(\frac{1}{N_{A} }+\frac{1}{N_{D} })

If NA is greater, then, the term 1/NA can be neglected, thus the equation:

w=\sqrt{\frac{2E(V_{o}-V) }{p}(\frac{1}{N_{D} })

Where

V = 0.44 V

E = 11.68*8.85x10¹⁴ f/cm

V_{o} =\frac{KT}{p} ln(\frac{N_{A}*N_{D}}{n_{i}^{2}  } , if n_{i}=1.5x10^{10}cm^{-3}  \\V_{o}=0.02585ln(\frac{4.48x10^{18}*4.48x10^{15}  }{(1.5x10^{10})^{2}  } )=0.83V

w=\sqrt{\frac{2*11.68*8.85x10^{-14}*(0.83-0.44) }{1.6x10^{-19}*4.48x10^{15}  } } =3.35x10^{-5} cm=0.335um

The length is:

L = 10 - 0.335 = 9.665 um

The resistance is:

Re=\frac{pL}{A} =\frac{0.93*9.665x10^{-4} }{0.36x10^{-4} } =24.9ohm

7 0
3 years ago
Other questions:
  • A(n)______ is a device used to ensure positive position of a valve or damper actuator A. calibrator B. positioner C. actuator D.
    6·1 answer
  • In the contemporary approach to control systems, benefits of continuous monitoring include which one of the following? Multiple
    9·1 answer
  • How many sets of equations (V and M equations) would you need to describe shear and moment as functions of x for this beam? In o
    12·1 answer
  • Balanced forces will result in which of the following
    9·1 answer
  • Calculate total hole mobility if the hole mobility due to lattice scattering is 50 cm2 /Vsec and the hole mobility due to ionize
    5·2 answers
  • A designer needs to select the material for a plate under tensile stress. Assuming that the applied tensile force is 13,000 lb a
    5·1 answer
  • ¿Cómo nos podría ayudar una hoja de cálculo en nuestro estudio?
    11·1 answer
  • Given below are the measured streamflows in cfs from a storm of 6-hour duration on a stream having a drainage area of 185 mi^2.
    11·1 answer
  • The mean of 10 numbers is 9, then the sum (total) of these numbers will be​
    10·2 answers
  • . An ideal vapor compression refrigeration cycle operates with a condenser pressure of 900 kPa. The temperature at the inlet to
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!