Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by MicroSun ( 15 years ago )
public class Functions {
    public static int n = 5;


    static float f1(float x[]) {
        return (float) (Math.cos(x[0])/50f + Math.sin(x[1])/ 50f);
    }

    static float f2(float x[]) {
        return (float) (Math.cos(x[1]) / 50f + Math.sin(x[2]) / 50f);
    }

    static float f3(float x[]) {
        return (float) (Math.cos(x[2]) / 50f + Math.sin(x[3]) / 50f);
    }

    static float f4(float x[]) {
        return (float) (Math.cos(x[3]) / 50f + Math.sin(x[4]) / 50f);
    }

    static float f5(float x[]) {
        return (float) (Math.cos(x[4]) / 50f + Math.sin(x[0]) / 50f);
    }

    static float df1_dx0(float x[]) {
        return (float) (-Math.sin(x[0]) / 50f );
    }

    static float df1_dx1(float x[]) {
        return (float) (Math.cos(x[1]) / 50f);
    }

    static float df1_dx2(float x[]) {
        return 0;
    }

    static float df1_dx3(float x[]) {
        return 0;
    }

    static float df1_dx4(float x[]) {
        return 0;
    }

    static float df2_dx0(float x[]) {
        return 0;
    }

    static float df2_dx1(float x[]) {
        return (float) (-Math.sin(x[1]) / 50f );
    }

    static float df2_dx2(float x[]) {
        return (float) (Math.cos(x[2]) / 50f);
    }

    static float df2_dx3(float x[]) {
        return 0;
    }

    static float df2_dx4(float x[]) {
        return 0;
    }

    static float df3_dx0(float x[]) {
        return 0;
    }

    static float df3_dx1(float x[]) {
        return 0;
    }

    static float df3_dx2(float x[]) {
        return (float) (-Math.sin(x[2]) / 50f );
    }

    static float df3_dx3(float x[]) {
        return (float) (Math.cos(x[3]) / 50f);
    }

    static float df3_dx4(float x[]) {
        return 0;
    }

    static float df4_dx0(float x[]) {
        return 0;
    }

    static float df4_dx1(float x[]) {
        return 0;
    }

    static float df4_dx2(float x[]) {
        return 0;
    }

    static float df4_dx3(float x[]) {
        return (float) (-Math.sin(x[3]) / 50f );
    }

    static float df4_dx4(float x[]) {
        return (float) (Math.cos(x[4]) / 50f);
    }

    static float df5_dx0(float x[]) {
        return (float) (Math.cos(x[0]) / 50f);
    }

    static float df5_dx1(float x[]) {
        return 0;
    }

    static float df5_dx2(float x[]) {
        return 0;
    }

    static float df5_dx3(float x[]) {
        return 0;
    }

    static float df5_dx4(float x[]) {
        return (float) (-Math.sin(x[4]) / 50f );
    }

    public static float[][] makeMatr(float[][] a, float[] x) {

        a[0][0] = df1_dx0(x);
        a[0][1] = df1_dx1(x);
        a[0][2] = df1_dx2(x);
        a[0][3] = df1_dx3(x);
        a[0][4] = df1_dx4(x);
        a[1][0] = df2_dx0(x);
        a[1][1] = df2_dx1(x);
        a[1][2] = df2_dx2(x);
        a[1][3] = df2_dx3(x);
        a[1][4] = df2_dx4(x);
        a[2][0] = df3_dx0(x);
        a[2][1] = df3_dx1(x);
        a[2][2] = df3_dx2(x);
        a[2][3] = df3_dx3(x);
        a[2][4] = df3_dx4(x);
        a[3][0] = df4_dx0(x);
        a[3][1] = df4_dx1(x);
        a[3][2] = df4_dx2(x);
        a[3][3] = df4_dx3(x);
        a[3][4] = df4_dx4(x);
        a[4][0] = df5_dx0(x);
        a[4][1] = df5_dx1(x);
        a[4][2] = df5_dx2(x);
        a[4][3] = df5_dx3(x);
        a[4][4] = df5_dx4(x);
        return a;
    }

    public static float[] makeVec(float[] b, float[] x) {
        b[0] = -f1(x);
        b[1] = -f2(x);
        b[2] = -f3(x);
        b[3] = -f4(x);
        b[4] = -f5(x);
        return b;
    }
}

 

Revise this Paste

Your Name: Code Language: