The algorithm is basically as follows. The notation is slightly different from that in the website you were given, but there is no difference in the method.
Given the initial value problem
dy/dx=f(x,y),y(a)= y_0
Euler’s Method with step size h consists in applying the iterative formula
y_(n+1)= y_n+h∙f(x_n,y_n ),n≥0
To compute successive approximations y_1,y_2,y_3,⋯ to the (true) values 〖y(x〗_1),〖y(x〗_2),〖y(x〗_3),⋯ of the exact solution y=y(x) at the points x_1,x_2,x_3,⋯, respectively.
In plain English:
You want to approximate the value of dy/dx (or y’) at some point in
an interval.
Step 1: Depending on how accurate you need to be, divide the interval up into little pieces of equal length; this length is the step size h. For purposes of discussion, let’s use the interval [0,1] and use ten intervals, so h = 0.1.
Step 2: y_0=0
Step 3: y_1=y_0+0.1f(x_0,y_0)
Step 4: y_2=y_1+0.1f(x_1,y_1)
…
Stop after ten steps, in this case. Usually the stopping criterion
is a level of accuracy.
You can easily set this up in Excel.
Exercises
Use Euler’s Method with step sizes h =0.1,0.02, 0.004, 0.0008 (that
is, do the problem 4 times, each with a more precise value of h) ,
10 equally spaced iterations.
1. y^'=x^2+y^2,y(0)=0,0≤x≤1
2. y^'=x^2-y^2,y(0)=1,0≤x≤2
3. y^'=lny,y(1)=2,1≤x≤2
4. y^'=x^(2/3)+y^(2/3),y(0)=1,0≤x≤2
5. y^'=x+√x,y(0)=1,0≤x≤2
6. y^'=x+∛x,y(0)= -1,0≤x≤2
In: Advanced Math
Homework #3-2
a) (Use software for this problem) Four independent samples are collected form four normally distributed populations. The data are:
Group 1: 12 11 14 10 12 10
Group 2: 14 12 16 15
Group 3: 17 18 20 22 23
Group 4: 10 9 13 13
The SST is equal to 305.68. Conduct a test of the null hypothesis that the group means are equal. Use a 5% significance level.
b) (Use software for this problem) The following pairs of observations were collected.
X 1 2 3 4 5
Y 2 6 4 10 15
a. Plot the values of X and Y. What relationship does the scatter diagram suggest?
b. Find the least squares line
c. Find the predicted value for each value of X
d. Find the residual for each predicted value of Y.
e. Verify that the sum of the residuals in part e is zero.
In: Statistics and Probability
Today, the continuous compound interest rate is 0.1% and one share of Amazon is $2367.92.
1. What price do you expect Amazon to be 6 months from now? What European style option should you buy in this case? Your future price can’t be a whole dollar, everyone should have different future stock price.
2. Assume the volatility of Amazon is 27% and you set your own strike price to 2 decimal places, find out how much your option in part 1 costs by using the Black-Scholes formula. You strike price can’t be a whole dollar, everyone should have different strike price.
3. Draw the profit diagram for the straddle with the strike price in part 2 above (you may need to use the put-call parity formula).
4. Use the binomial model with 4 steps to find the American style option price in part 2 above.
In: Finance
Question 1
You are trying to value the stock of Cowbell Inc. You know that the firm only uses dividends to return cash to its investors and you have forecasted the dividends for the 4 years (see table below). You believe that dividends will grow at a constant rate of 2% each year after year 4. The cost of equity is 13%. Given this information estimate the share price for Cowbell Inc. Round your answer to two decimals (do not enter the $-symbol in your answer).
| Year | ||||
| 1 | 2 | 3 | 4 | |
| Dividend per Share (in $) | 1.5 | 2 | 1.2 | 1.9 |
Question 2
Crane Inc. currently only returns cash to its investors in the form of dividends. It pays out 50% of its earnings per share. The return on new investment for Crane is 12.7%. Given this information, estimate the growth rate for the future dividends of Crane. Express your result in percent and round to two decimals (do not include the %-symbol in your answer).
In: Finance
16#2
The following table provides the starting players of a basketball team and their heights
| Player | A | B | C | D | E |
| Height (in.) | 75 | 77 | 78 | 81 | 84 |
a. The population mean height of the five players is: 79
b. Find the sample means for samples of size 2.
A, B: ?¯ =
A, C: ?¯ =
A, D: ?¯ =
A, E: ?¯=
B, C: ?¯ =
B, D: ?¯ =
B, E: ?¯ =
C, D: ?¯=
C, E: ?¯=
D, E: ?¯=
For a random sample of size 2 what is the chance that the sample mean will equal the population mean? That is, P(?¯=?) = .
For a random sample of size 2, the probability that ?¯ will be within 1 inch of ? is .
e. Find the sample means for samples of size 4.
A, B, C, D: ?¯ =
A, B, C, E: ?¯=
A, B, D, E: ?¯=
A, C, D, E: ?¯=
B, C, D, E: ?¯=
For a random sample of size 4 what is the chance that the sample mean will equal the population mean? That is, P(?¯=?) =
g. For a random sample of size 4, the probability that ?¯will be within 1 inch of ? is:
In: Statistics and Probability
To understand the value of counting loops:
Sample Result is shown below:
Enter the number of rows of matrix A: 2
Enter the number of columns of matrix A: 3
Enter the number of columns of matrix B: 3
Enter the number of columns of matrix B: 4
Enter matrix A;
1 2 3
4 5 6
Enter matrix B:
7 8 9 10
11 12 13 14
15 16 17 18
Matrix A:
1 2 3
4 5 6
Matrix B:
7 8 9 10
11 12 13 14
15 16 17 18
Product of matrix A and Matrix B ( A x B) :
74 80 86 92
173 188 203 218
In: Computer Science
1. Suppose the inverse demand function for a monopolistically competitive firm’s product is given by
? = 100 −
2?
and the cost function is given by
?? = 52 + 4?
1. Determine the profit-maximizing price and quantity
2. Determine the maximum profits.
3. Can we say that this firm is operating in the long-run or short-run equilibrium at the equilibrium price and quantity?
2. Suppose the inverse demand for a monopolist’s product is given by ? = 110 −
The monopolist can produce output in two plants. The marginal cost of producing in plant 1 is ??! = 3?!, and the marginal cost of producing in plant 2 is ??" = 2?".
1. How much output should be produced in each plant to maximize profits?
2. What price should be charged for the product?
In: Economics
ACCOUNTING FOR LEASES
Mickey’s Garage entered into a non-cancellable, five-year lease agreement on 1 April 2020 for an item of machinery. The machinery is expected to have an economic life of seven years, after which it will have no salvage or residual value and ownership is transferred at the end of the lease. Mickey’s Garage is to make five annual payments of $100,000 (to be made at the end of the year). The rate of interest implicit in the lease is 4%. The fair value of the leased asset is $445182. Mickey’s Garage also spend $10,000 on installation costs for this piece of machinery. Assume a 31 March year-end.
1. Fill-in the below table.
|
Year |
Lease Liability Open |
Cash Payment |
Interest Expense |
Principal Component |
Lease Liability Close |
|
1 |
|||||
|
2 |
|||||
|
3 |
|||||
|
4 |
|||||
|
5 |
1. Fill-in the below table.
|
Year |
Lease Liability Open |
Cash Payment |
Interest Expense |
Principal Component |
Lease Liability Close |
|
1 |
|||||
|
2 |
|||||
|
3 |
|||||
|
4 |
|||||
|
5 |
1. Fill-in the below table.
|
Year |
Lease Liability Open |
Cash Payment |
Interest Expense |
Principal Component |
Lease Liability Close |
|
1 |
|||||
|
2 |
|||||
|
3 |
|||||
|
4 |
|||||
|
5 |
2. Following from above, record any and all journal entries relating to the lease that took place anytime in the first year (i.e. for the year ending 31 March 2021). This includes the initiation of the lease, any payments made, interest, and depreciation. Round to the nearest whole dollar.
3. Following from above, show extracts of the financial position for the leased asset (also known as the right-of-use asset) and lease liability as at the end of the first year of the lease (i.e. for the year ending 31 March 2021). You answer should make it clear where in the balance sheet each component would go.
|
Statement of Financial Position for Mickey’s Garage as 31 March 2021 |
|
In: Accounting
Which has the greater octahedral field splitting energy? (Δo)
[Cr(H2O)6]2+ or [Cr(H2O)6]3+ Blank 1. Fill in the blank, read surrounding text.
[Fe(NO2)6]3- or [FeCl6]3- Blank 2. Fill in the blank, read surrounding text.
(Please Note: There was typo that was corrected in the formula. If you answered using either [Fe(NO2)6]2+ or [Fe(Cl6)6]2+ and were correct, you will still receive full credit).
Na4[V(CN)4(OH)2] or Na4[Ta(CN)4(OH)2]
In: Chemistry
Task in this assignment is to write mips_sim a simulator for a small simple subset of the MIPS .
The input to mips_sim will be the 32-bit instruction codes for MIPS instructions as hexadecimal numbers.
mips_sim.c should simulate executing these instruction like this:
cat examples/42.hex 3404002a 34020001 c 3404000a 3402000b c dcc mips_sim.c -o mips_sim ./mips_sim examples/42.hex 0: 0x3404002A ori $4, $0, 42 >>> $4 = 42 1: 0x34020001 ori $2, $0, 1 >>> $2 = 1 2: 0x0000000C syscall >>> syscall 1 <<< 42 3: 0x3404000A ori $4, $0, 10 >>> $4 = 10 4: 0x3402000B ori $2, $0, 11 >>> $2 = 11 5: 0x0000000C syscall >>> syscall 11 <<<
A reference implementation is available as 1521 mips_sim which can use to find the correctoutput for any input, like this:
cat examples/square.hex 34100004 34110003 72108002 72318802 2302020 34020001 c 3404000a 3402000b c 1521 mips_sim examples/square.hex 0: 0x34100004 ori $16, $0, 4 >>> $16 = 4 1: 0x34110003 ori $17, $0, 3 >>> $17 = 3 2: 0x72108002 mul $16, $16, $16 >>> $16 = 16 3: 0x72318802 mul $17, $17, $17 >>> $17 = 9 4: 0x02302020 add $4, $17, $16 >>> $4 = 25 5: 0x34020001 ori $2, $0, 1 >>> $2 = 1 6: 0x0000000C syscall >>> syscall 1 <<< 25 7: 0x3404000A ori $4, $0, 10 >>> $4 = 10 8: 0x3402000B ori $2, $0, 11 >>> $2 = 11 9: 0x0000000C syscall >>> syscall 11 <<<
You need to implement only these 10 MIPS instructions:
| Assembler | C | Bit Pattern |
|---|---|---|
| add $d, $s, $t | d = s + t | 000000ssssstttttddddd00000100000 |
| sub $d, $s, $t | d = s - t | 000000ssssstttttddddd00000100010 |
| slt $d, $s, $t | d = s < t | 000000ssssstttttddddd00000101010 |
| mul $d, $s, $t | d = s * t | 011100ssssstttttddddd00000000010 |
| beq $s, $t, I | if (s == t) PC += I | 000100ssssstttttIIIIIIIIIIIIIIII |
| bne $s, $t, I | if (s != t) PC += I | 000101ssssstttttIIIIIIIIIIIIIIII |
| addi $t, $s, I | t = s + I | 001000ssssstttttIIIIIIIIIIIIIIII |
| ori $t, $s, I | t = s | I | 001101ssssstttttIIIIIIIIIIIIIIII |
| lui $t, I | t = I << 16 | 00111100000tttttIIIIIIIIIIIIIIII |
| syscall | syscall | 00000000000000000000000000001100 |
You only need to implement these 3 system calls.
| Description | $v0 | Pseudo-C |
|---|---|---|
| print integer | 1 | printf("%d", $a0) |
| exit | 10 | exit(0) |
| print character | 11 | printf("%c", $a0) |
Task is to add code under execute_instructions function and
necessary additional functions.
// starting point code
// PUT YOUR HEADER COMMENT HERE
#include
#include
#include
#include
#include
#define MAX_LINE_LENGTH 256
#define INSTRUCTIONS_GROW 64
// ADD YOUR #defines HERE
void execute_instructions(int n_instructions,
uint32_t instructions[n_instructions],
int trace_mode);
char* process_arguments(int argc, char* argv[], int*
trace_mode);
uint32_t* read_instructions(char* filename, int*
n_instructions_p);
uint32_t* instructions_realloc(uint32_t* instructions, int
n_instructions);
// ADD YOUR FUNCTION PROTOTYPES HERE
// YOU SHOULD NOT NEED TO CHANGE MAIN
int main(int argc, char* argv[]) {
int trace_mode;
char* filename = process_arguments(argc, argv,
&trace_mode);
int n_instructions;
uint32_t* instructions = read_instructions(filename,
&n_instructions);
execute_instructions(n_instructions, instructions, trace_mode);
free(instructions);
return 0;
}
// simulate execution of instruction codes in instructions
array
// output from syscall instruction & any error messages are
printed
//
// if trace_mode != 0:
// information is printed about each instruction as it
executed
//
// execution stops if it reaches the end of the array
void execute_instructions(int n_instructions,
uint32_t instructions[n_instructions],
int trace_mode) {
// REPLACE CODE BELOW WITH YOUR CODE
int pc = 0;
while (pc < n_instructions) {
if (trace_mode) {
printf("%d: 0x%08X\n", pc, instructions[pc]);
}
pc++;
}
}
// ADD YOUR FUNCTIONS HERE
// YOU DO NOT NEED TO CHANGE CODE BELOW HERE
// check_arguments is given command-line arguments
// it sets *trace_mode to 0 if -r is specified
// *trace_mode is set to 1 otherwise
// the filename specified in command-line arguments is returned
char* process_arguments(int argc, char* argv[], int* trace_mode)
{
if (
argc < 2 ||
argc > 3 ||
(argc == 2 && strcmp(argv[1], "-r") == 0) ||
(argc == 3 && strcmp(argv[1], "-r") != 0)) {
fprintf(stderr, "Usage: %s [-r] \n", argv[0]);
exit(1);
}
*trace_mode = (argc == 2);
return argv[argc - 1];
}
// read hexadecimal numbers from filename one per line
// numbers are return in a malloc'ed array
// *n_instructions is set to size of the array
uint32_t* read_instructions(char* filename, int*
n_instructions_p) {
FILE* f = fopen(filename, "r");
if (f == NULL) {
fprintf(stderr, "%s: '%s'\n", strerror(errno), filename);
exit(1);
}
uint32_t* instructions = NULL;
int n_instructions = 0;
char line[MAX_LINE_LENGTH + 1];
while (fgets(line, sizeof line, f) != NULL) {
// grow instructions array in steps of INSTRUCTIONS_GROW
elements
if (n_instructions % INSTRUCTIONS_GROW == 0) {
instructions = instructions_realloc(instructions, n_instructions +
INSTRUCTIONS_GROW);
}
char* endptr;
instructions[n_instructions] = strtol(line, &endptr, 16);
if (*endptr != '\n' && *endptr != '\r' && *endptr
!= '\0') {
fprintf(stderr, "%s:line %d: invalid hexadecimal number: %s",
filename, n_instructions + 1, line);
exit(1);
}
n_instructions++;
}
fclose(f);
*n_instructions_p = n_instructions;
// shrink instructions array to correct size
instructions = instructions_realloc(instructions,
n_instructions);
return instructions;
}
// instructions_realloc is wrapper for realloc
// it calls realloc to grow/shrink the instructions array
// to the speicfied size
// it exits if realloc fails
// otherwise it returns the new instructions array
uint32_t* instructions_realloc(uint32_t* instructions, int
n_instructions) {
instructions = realloc(instructions, n_instructions * sizeof *
instructions);
if (instructions == NULL) {
fprintf(stderr, "out of memory");
exit(1);
}
return instructions;
}
In: Computer Science