Does any of this make sense?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <math.h>
#include <vector>
#include <string>
#include <iostream.h>
using namespace std;

int main(){

    //define vectors

    vector<double> fofx_values;
    vector<double> fofy_values;
    vector<double> g_values;
    vector<double> g_primed_values;
    vector<double> t_values;
    vector<double> x_values;
    vector<double> y_values;

    //define stepsize

    double newton_raphson_error;
    double N=10.0;
    int n=7.0;
    int i, j;
    double h=N/n;

    //define vector size

    fofx_values.reserve(n+1);
    fofy_values.reserve(n+1);
    g_values.resize(j+1);
    g_primed_values.resize(j+1);
    t_values.reserve(n+1);
    x_values.resize(j+1);
    y_values.reserve(n+1);

    //initialise vectors

    fofy_values[0]=0;
    fofx_values[0]=0;
    g_values[0]=0;
    g_primed_values[0]=0;
    t_values[0]=0;
    x_values[0]=0;
    y_values[0]=1;

    //begin computation

    for (i=0;i<n;i++){
    t_values[i]=(i)*h;
    fofy_values[i]=((-8.0*t_values[i])/(1+(t_values[i]*t_values[i])))*y_values[i];
        for (j=0; (newton_raphson_error)<0.001;j++){
        fofx_values[j]=((-8.0*t_values[i+1])/(1+(t_values[i+1]*t_values[i+1])))*x_values[j];
        g_values[j]=(0.5*h*(fofy_values[i]+fofx_values[j]))+y_values[i]-x_values[j];
        g_primed_values[j]=(0.5*h*((-8.0*t_values[i+1])/(1+(t_values[i+1]*t_values[i+1]))))-1;
        x_values[j+1]=x_values[j]-(g_values[j]/g_primed_values[j]);
        newton_raphson_error=fabs(x_values[j+1]-x_values[j]);
    }
    }
    cout << fofy_values[i] << endl;

  return 0;
}
yes
Looks like someone likes redundant parentheses.
Topic archived. No new replies allowed.