Program Integration Trapezoidal
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace TrapRule
{
class Program
{
//Quick Demo of Numerical integration
static void Main(string[] args)
{
//Show results for different numbers of trapezoids
for (int i = 3; i < 100; ++i)
[Link]([Link]() + ": " +
TrapezRule(x => x * x, 1, 2, i));
//Change x * x above to numerically integrate
//a different function than f(x) = x^2
//Above integrates between x=1 and x=2
if ([Link])
[Link]();
}
static double TrapezRule(Func<double, double> func, double a, double b, int n)
{
double area = 0;
double w = (b - a) / n;
area += (func(a) + func(b)) / 2;
for (int p = 1; p < n; ++p)
area += func(a + w * p);
return w * area;
}
}
Program Multi Step Predictor, n=4
#include<stdio.h>
#include<math.h>
#include<iostream>
#define true 1
#define false 0
#define MAX_N 2000
static double F(double, double);
using namespace std;
int main()
{
double A, B, ALPHA, H, T, W[MAX_N], K1, K2, K3, K4;
int I, N;
A = 0.0;
B = 2.0;
N = 10;
[Link](ios::fixed, ios::floatfield);
[Link](10);
H = (B - A) / N;
T = A;
W[0] = 0.5; // initial value
K1 = H * F(T, W[I - 1]);
K2 = H * F(T + H / 2.0, W[I - 1] + K1 / 2.0);
K3 = H * F(T + H / 2.0, W[I - 1] + K2 / 2.0);
K4 = H * F(T + H, W[I - 1] + K3);
W[I] = W[I - 1] + 1 / 6.0 * (K1 + 2.0 * K2 + 2.0 * K3 + K4);
cout << "At time " << T << " the solution = " << W[I] << endl;
for (I = 4; I <= N; I++)
{
K1 = 55.0 * F(T, W[I - 1]) - 59.0 * F(T - H, W[I - 2]) + 37.0 * F(T - 2.0 * H, W[I - 3]) - 9.0 * F(T - 3.0 *
H, W[I - 4]);
W[I] = W[I - 1] + H / 24.0 * K1;
/* COMPUTE T(I) */
T = A + I * H;
cout << "At time " << T << " the solution = " << W[I] << endl;
}
return 0;
Program Polygon
MsSql2008GeometryReader geometryReader = new MsSql2008GeometryReader();
MsSql2008GeometryWriter geometryWriter = new MsSql2008GeometryWriter();
using (SqlConnection con = new SqlConnection(@"Data Source=localhost;Initial Catalog=Northwind;
Integrated Security=True"))
{
[Link]();
using (SqlCommand command = new SqlCommand("SELECT * FROM MY_SPATIAL_TABLE", con))
using (SqlDataReader dataReader = [Link]())
{
while ([Link]())
{
IGeometry geom = [Link]((byte[])dataReader["my_geometry_field"]);
[Link][0].X = 1;
[Link][0].Y = 1;
byte[] outputMsSqlGeom = [Link](geom);
}
}
}
TUGAS KELOMPOK
DASAR KOMPUTER I
Ketua:
- Indra Rizal A
Anggota:
- Kodar Komarudin
- Wafa Nadia
- Rezki Vila Patra
- Chika Khoerunnisa
TEKNIK KIMIA
INSTITUT TEKNOLOGI NASIONAL
BANDUNG
2017