48221 Lecture 4: tut 4

38 views3 pages
26 Jun 2018
School
Department
Course
Professor
Tutorial 4 Problem 3 code:
Public Function ACT_2(x, y)
ACT_2 = 10 * x - 20 * y + 150
End Function
Public Function SFsin(x, y)
If x <= 1 Then
SFsin = Sqr((1 - Exp(-x)) ^ 2 + Sin(y) ^ 2)
Else
SFsin = Sqr((Exp(1 - x) - Exp(-x)) ^ 2 + Sin(y) ^ 2)
End If
End Function
Tutorial 4 problem 5 code:
Public Sub Simpsons_rule_calc()
'first step:clear all previous values
Range("M7:Q100").ClearContents
'inputs xa, xb, dx
xa = Range("B1").Value
xb = Range("B2").Value
dx = Range("B3").Value
y = Range("D1").Value
'final input is the number of loop iterations
'think of N as the number of rows used
N = (xb - xa) / dx + 1
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Act_2 = 10 * x - 20 * y + 150. Sfsin = sqr((1 - exp(-x)) ^ 2 + sin(y) ^ 2) Sfsin = sqr((exp(1 - x) - exp(-x)) ^ 2 + sin(y) ^ 2) "inputs xa, xb, dx xa = range(b1). value xb = range(b2). value dx = range(b3). value y = range(d1). value. "final input is the number of loop iterations. "think of n as the number of rows used. N = (xb - xa) / dx + 1. "starting value of x is xa and goes before the loop x = xa. "everything that needs to loop must be between for/next. For k = 1 to n step 1 counter = counter + 1. Range(m6). offset(counter, 0). value = x fx = exp(x) * sin(x) ^ 2. If k = 1 or k = n then coeff = 1. Elseif k = 2 then coeff = 4. "simpsons rule calculation simp = 1 / 3 * dx * coeff * fx.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents