User Profile

Collapse

Profile Sidebar

Collapse
wuzertheloser
wuzertheloser
Last Activity: Dec 4 '07, 06:55 AM
Joined: Oct 19 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • wuzertheloser
    replied to normalization of vectors
    in C
    Found the problem and here is the corrected code =]

    Code:
    #include <stdio.h>
    #include <math.h>
    void prob1(void);
    void prob2(void);
    
    double func(double x);
    double unit_vector(double *v, double *w, int num_n);
    
    main()
    {
    int menu;
    printf("There are two functions: prob1() and prob2().\n");
    printf("Enter the function number to
    ...
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    started a topic normalization of vectors
    in C

    normalization of vectors

    Use the program skeleton below (starting with #include <stdio.h>)
    as the starting point for quiz4. Add the necessary code to the
    functions prob1() and prob2(), and add the other 2 functions, as
    described in the text below.

    You do not need to change anything in main().

    In void prob1(void), take a double floating-point number x from
    the keyboard and compute the function f(x), which is...
    See more | Go to post

  • wuzertheloser
    replied to help with matrices
    in C
    Okay, here is my code now

    Code:
    #include <stdio.h>
    #include <math.h>
    double unit_norm(double vec[4], int cols);
    void matrix_mult(double a[4][4], double b[4], double c[4], int rows);
    main()
    {
     double K[4][4] = { { 2., -4.,  1.,  0.},
                        {-4.,  5., -2.,  1.},
                        { 1., -2.,  6., -3.},
                        { 0.,  1., -3.,
    ...
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    started a topic help with matrices
    in C

    help with matrices

    Develop a program which computes the current value of the vector {x}
    based on the following forward iteration:

    {x}(n+1) = [K] {x}(n), n = 0,1,2, ... ,8,9.

    In other words, the next vector {x} is equal to the product of [K] and
    the current vector {x}.

    Perform the matrix multiplication by using the function:

    void matrix_mult(dou ble a[4][4], double b[4], double c[4], int rows);...
    See more | Go to post

  • wuzertheloser
    replied to shadowing a parameter
    in C
    any idea how you would integrate
    A*x^m/n! ?

    mathematically i know how to do it. but the only inputs i'm allowed to have are A, m, and n. Therefore, x would have no defined value.
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    replied to shadowing a parameter
    in C
    program works fine now
    only problem is the output i get for the integral

    my output:


    Enter the exponents (double)m and (int)n in f(x) = A*x^m/n! : 3.25 5

    Enter the coefficient A in f(x) = A*x^m/n! : -1.5

    Enter the bounds for the integration interval, a < b : 1.5 3.75

    Integrate f(x) on [a,b]
    Enter the number of trapezoids : 1000

    The value of the...
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    replied to shadowing a parameter
    in C
    oh just for clarification
    what does the function
    double Intgr() output?

    i need it to output the sum, but i don't think it's doing that.
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    replied to shadowing a parameter
    in C
    okay, thanks for the help everyone! i appreciate it =] i'll let you know how everything goes.

    i'm not quite sure which compiler i'm using because it comes from my professor's website.

    the program is called
    SSH secure shell
    and it uses vi editor to make the C files. not sure if that helps.
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    started a topic shadowing a parameter
    in C

    shadowing a parameter

    Write a program which calculates the integral of the function

    f(x)=(A*x^m)/n!

    on the interval from a to b (0<a<b). In the main program, scanf
    a double value for m and a non-negative integer value for n,
    a double value of A, and positive double values for a and b>a.
    Call the function Intgr() to evaluate the integral.

    Your main program should be followed...
    See more | Go to post

  • help - closing brakets to make program output correctly

    The correct program should look like this:

    Total number of voting cards: 55

    Votes for candidate 1: 1
    Votes for candidate 2: 10
    Votes for candidate 3: 8
    Votes for candidate 4: 13
    Votes for candidate 5: 8
    Votes for candidate 6: 12
    Votes for candidate 7: 3

    Percent votes for Mr. Adams : 1.82 %
    Percent votes for Mr. Camacho : ...
    See more | Go to post

  • wuzertheloser
    started a topic Help with data files
    in C

    Help with data files

    Define the file-pointers *Infile and *Outfile and link them to
    a given input file Sale.dat (which is in the homework/directory)
    and the output file Comm.dat (which you will create in this
    assignment). Use while(fgets()!= NULL) to read all the lines in
    Sale.dat. For odd number lines (containing full names) sscanf
    name and surname, print the full name on the screen and in
    the output file Comm.dat. For even number...
    See more | Go to post

  • wuzertheloser
    started a topic can someone check this for me?
    in C

    can someone check this for me?

    sum += pow(-1., (double)n) * ((pow((2. * angle_rad),(2. * (double)n))) / factori
    al);
    value = 0.5 * (1 + sum);


    this is the equation i wrote out for

    cos^2(x)=0.5*(1 +Sum[(-1)^n (2*x)^(2n)/(2n)!])

    assuming i set up all the variables correctly, does this seem right?
    See more | Go to post

  • wuzertheloser
    replied to Using Taylor Series
    in C
    This is my program so far. I got the factorial to work.


    #include <stdio.h>
    #include <math.h>
    #define PI 3.141592654

    main()
    {
    int n_terms, n=0;
    double angle_deg, angle_rad, csa, csa2, value, sum, factorial;
    printf("\n\nPar t A:\nCalculation of True and Approximate Values of cos^2(x)\n\n");
    printf("Enter x_deg: \n");
    scanf("%lf",...
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    replied to Using Taylor Series
    in C
    okay, i tried to do what you said. this is the code i came up with.

    #include <stdio.h>
    #include <math.h>
    #define PI 3.141592654

    main()
    {
    int n_terms, n=0;
    double angle_deg, angle_rad, csa, csa2, value;
    printf("\n\nPar t A:\nCalculation of True and Approximate Values of cos^2(x)\n\n"
    );
    printf("Enter x_deg: \n");
    scanf("%lf",...
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    replied to Using Taylor Series
    in C
    okay thanks
    i'll see if that works and update if it does or not =]
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    replied to Using Taylor Series
    in C
    sorry, i'm new to programming
    could you give like a simple example of how to do it? how many double / float values would i need to define?
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    started a topic Using Taylor Series
    in C

    Using Taylor Series

    I need help with Taylor Series

    Part A:
    Scan the angle in degrees x_deg. Express this angle in
    radians by using x=PI*x_deg/180, and calculate Y=cos^2(x)
    by using the math.h library of functions (pow() and cos()
    functions). Compare the so calculated value of Y=cos^2(x)
    with the approximate value y obtained by using n_term
    terms of the Taylor series

    ...
    See more | Go to post

  • wuzertheloser
    replied to how to stop program after input
    in C
    program works exactly the way it should now
    thank you sooooo much =]
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    replied to how to stop program after input
    in C
    one last question. now that i have the loop to work, i need the program to recognize whether or not the value inputed has been used in an interval already. If it has, then the program needs to tell the user to input from another interval like so:

    iacs5.ucsd.edu% a.out
    Enter (double) A, B, C:
    1.5 -2.1 0.5

    Enter (double) x:
    -0.75
    Case 1
    x value is = -0.750 and y value is = -1.45781...
    See more | Go to post

    Leave a comment:


  • wuzertheloser
    replied to how to stop program after input
    in C
    Thanks! Program works with loop now! if i have any other questions, i'll post =]
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...