%
%
%
%
Script P3
Eight Ways of Approximating the Perimeter of a Ellipsoid
Esther Hwang
UID: 904411480
% Get input data
a = input('Input first semiaxis: ');
b = input('Input the other semiaxis: ');
% 1st approximation formula for the perimeter
P1 = pi*(
Esther Hwang
UID: 904411480
CEE/MAE M20
June 23, 2016
Since method 4 requires the use of the departure from circlehood , must be computed before
proceeding to method 4. The script does this step in between methods 3 and 4. The given formula
for obtaining
When the user inputs semiaxis values of
(1, .4), we obtain the following output.
Esther Hwang
UID: 904411480
CEE/MAE M20
June 23, 2016
When the user inputs semiaxis values of
(1, .2), we obtain the following output.
Input first semiaxis: 1
Input first
When the user inputs semiaxis values of
(1, .8), we obtain the following output.
Esther Hwang
UID: 904411480
CEE/MAE M20
June 23, 2016
When the user inputs semiaxis values of
(1, .6), we obtain the following output.
Input first semiaxis: 1
Input first
Do you speak machine?
The computers CPU relies on very basic instructions to
perform tasks on smallest units of data: Machine language.
Writing a program in machine language would be tedious and is usually unnecessary.
Instead, we rely on highlevel langu
%
%
%
%
Script P2
Table of Inradius, OutRadius, and Edge Length of Various Platonic Solids
Esther Hwang
UID: 904411480
% r is the inradius, R is the outradius, E is the edge length
% the inradius of the outside shape equals the outradius of the shape nest
1.2
Esther Hwang
UID: 904411480
CEE/MAE M20
June 23, 2016
Models and Methods
The first step is to realize that the inradius of the outside solid equals the outradius of the solid
nested directly inside. Thus, the inradius of the unit sphere equals the out
Is there an app for that?
For many common computational tasks, we can rely on offtheshelf software to achieve our needs
Word processing and presentation construction
Mechanical or electronic design
Web browsing
etc.
For other tasks, we need customized so
=
4
2
Largest tetrahedron that fits inside a unit sphere:
Largest cube that fits inside tetrahedron:
https:/www.quora.com/HowdoIfindthesideofthelargestcubecompletelycontainedinsidearegulartetrahedronofsides
Largest octahedron that fits in
Compiled vs Interpreted
In a compiled language, the instructions in the code are first
compiled and linked into an executable.
The compiler translates user code into machine language. Specific to machine.
Compiler can optimize the order of instructions, m
https:/www.coursehero.com/sitemap/schools/394UCLA/courses/4704081M20/#/documents
Largest cube that fits inside T
Find the maximum edge with respective to the inradius:
1
= _
2
1
=
2
=
6
12
6
4
2
3
Find the maximum edge with respective to the outradius:
%
%
%
%
Script P1
Surface Area of an Oblate Spheroid
Esther Hwang
UID: 904411480
% Acquire the input data
r1 = input('Enter equatorial radius (kilometers):');
r2 = input('Enter polar radius (kilometers; note this should be smaller than the
equatorial radi
What is code?
A computer code is a set of instructions, usually too difficult to
carry out by hand
User
Instructions
Inputs
Outputs
Sensor data
Measurements
Big data
Visualization
Control of other systems
Data written to file
Computer
CEE/MAE M20
6
o
Should not have a report over 10 pages
o
Each hw will be out of 100 points
Report is 50%
Source Code is 50%
o
In report, explain your problemsolving logic and the significance of your findings.
o
Source code is based on its ability to product correct r
Esther Hwang
UID: 904411480
CEE/MAE M20
June 23, 2016
Finally, after the two surface areas are calculated, the script uses MATLABs clc function to first
clear the command window and then outputs the results using the fprintf function in MATLAB.
The below
Why computer programming?
To calculate a result from a complicated algorithm
To analyze limited measurement data in order to estimate the state of a system
To simulate, e.g., natural phenomena or behavior of engineered systems
To control a system to behav
Esther Hwang
UID: 904411480
CEE/MAE M20
June 23, 2016
Homework 1
1. Oblate Spheroid Calculations
1.1
Introduction
The objective in this problem is to create a script for an oblate spheroid that takes the equatorial and
polar radii as inputs and outputs an
Example from start to finish
Step 3: Develop algorithm(s)
Step 4: Break down the algorithm into simple tasks
Step 5: Formulate tasks as pseudocode
Pseudocode:
1. Begin with an arbitrary positive starting value x0 (the closer to the actual square root of
Requirements of a program, 5 THINGS:
1. Reliability does it do what it is suppose to do?
2. Robustness  can it gracefully handle problematic inputs?
a. Give a helpful error message instead of just selfdestructing
3. Usability does it have a clear interf
Syllabus Additional Notes
Other TA or Jordan will be available online to give feedback = virtual office hours
MatLab access

Remote Desktop Connection to access via SEASNet

Look into how to
Use doc or help in command prompt
Watch prerecorded video lec
Esther Hwang
UID: 904411480
CEE/MAE M20
June 23, 2016
The discrepancies among the perimeter formulae increase in magnitude as the ellipse becomes more
oblong in shape. Furthermore, we see that from semiaxis inputs (1, 1) to (1, .1), the number of
perimet
Requirements of a program
1. Reliability: Does it do what it is supposed to do?
2. Robustness: Can it gracefully handle problematic inputs?
3. Usability: Does it have a clear interface with the user?
4. Readability: Can someone else figure out what it doe
Example from start to finish
Step 1: State the objective
Objective: Determine the squareroot of a given real number S.
Input
S
Computer Program
(code)
Outputp
x
S
Step 2: Express the underlying model (
)
usually through mathematics
x
p
S
!
!
!
!
p
x+e= S

Im having a problem with

So far, Ive done this

Initially I tried modifying this

Does that sound right?

If it isnt, how can I.

Or do I even need to
Introduction to Programming Additional Notes
What is code?

A set of instructions usually too d
Example from start to finish
Step 6: Translate pseudocode into actual code
Step 7: Debug the code
Step 8: Make code run more efficiently!
function x = sqrtHeron(S)
% Choose a suitable initial guess
xold = S/2;
x = mean([xold S/xold]);
% Repeat until you