Thread: Mathematical Operation

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    14

    Mathematical Operation

    prepare a report which contains the C source code, the documentation and the flow charts, along with drawings explaining the mathematical background related to the calculation of-



    insert
    Code:
    F(x)= 5.x^2 + e ^(1/2.x) / 1/3.x^2+25.x+1.6


    in the range x ∑{A,B}




    With a step of B-a/y, e.g. y= 1000.




    The range, i i.e. a,b along with the step discretisation should be user defined. The results of the calculation should be stored in a file in the current directory which is also user defined.




    in a second independent program, calculate the area (integral from a to b)

    f (x).dx for the discrete value of an f(x) passed to the program through a user defined file located in the current directory. The output of the previous program




    in a third independent program calculate f`(x)= dy/dx for all values provided the output file of the first prgram with the assumption that dy/dx= ∆y/∆x, ∆x→0

    How would I do this? I have taken a c language class but have never did equatons or mathematical operations, also how do flow charts work?

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Don't just copy & paste your assignment on here. Ask a specific question.

    Most of the operators are what you'd find on a calculator, ie + (add), - (minus). Get a good book, it'll help. It seems you don't have to parse any math equations, so it all should be fairly straight forward (providing you have a good point of reference / book).
    Last edited by zacs7; 07-08-2008 at 12:50 AM.

  3. #3
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    F(x)= 5.x^2 + e ^(1/2.x) / 1/3.x^2+25.x+1.6
    What a hell is that! :S

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    14
    that says that the function F(x) is equal to 5.x^2 + e ^(1/2.x) / 1/3.x^2+25.x+1.6 , the ^`s are used to show powers. e^(1.2.x) is exponent to the power of .5 times x. Do you understand now? I only know the basics of C, but am not sure whether a source code is correct or has errors. Can someone please help me with the source code?

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Sounds like you did not satisfy all the prerequisites for your class, and it's come back to bite you. Happened to me once too, taking Calculus 3 without Calc 1 and 2 (I took business calculus by accident...I was going to school a night). I survived Physical Chemistry without Calc 3 just fine.

    You need to either address this with your professor or withdraw from the class. It's the right thing to do.
    Last edited by rags_to_riches; 07-08-2008 at 03:55 PM. Reason: Missing word

  6. #6
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    Can someone please help me with the source code?
    Where is it? May us help you?

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    14
    insert
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    main ()
    {
    double a,b,x;
    printf("range[a,b]=");
    scanf("%lf %lf",&a,&b);
    
    printf("input [a,b]=(%lf %lf)\n",a,b)
    if (a>b)
    {
    printf("error:a>b\n");
    exit(1);
    }
    FILE *fd;
    if((fd=fopen("sample.txt","w"))==NULL)
    {
    printf("cannot open file.\n");
    }
    x=a;
    while(x<=b)
    {
    fprintf(fd,"%lf\t%lf\n",x,(3+exp(0.5*x))/0.3*x*X+25*x+1.6));
    x=x+(b-a)/1000;
    }
    close(fd);
    exit(0);
    }
    This is the source code for the first problem, is it correct? how can i do the flow charts and documentation?

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    This is the source code for the first problem, is it correct?
    Most certainly not, since it lacks proper formatting to make it readable. As to whether it works as expected... that should be tested by you.

    how can i do the flow charts and documentation?
    Do you need a soft copy of the flow charts and other drawings? If not, it would be pretty easy to sketch them out by hand.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by madahmad1 View Post

    This is the source code for the first problem, is it correct? how can i do the flow charts and documentation?
    It's your code, didn't you run it and see if it gives the right answer on several test sets of data?

    You just post up code, but didn't test it! Brilliant! Absolutely *brilliant*!

    Usually, you do flow charts by seating yourself, reviewing you class notes and text books on flow charts, and beginning the work. And let me emphasize the YOU DOING the WORK, part of it.

    Ditto with your request for the program's documentation.

    There is no big shortcut to learning how to program - *you* have to do a lot of work, plain and simple.

  10. #10
    Registered User
    Join Date
    Jul 2008
    Posts
    14
    Can I get any of your emails to contact you guys? I do not have the program to test the code, thats the problem. Can anyone test it for me? I would really appreciate it.

  11. #11
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I do not have the program to test the code, thats the problem.
    That problem is easily solved. You can download compilers available at zero price online. For example, for Windows users, the MinGW port of gcc is packaged with the open source IDE Code::Blocks, and Microsoft's optimising compiler (for both C and C++) is available with the free Microsoft Visual C++ 2008 Express.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  12. #12
    Registered User
    Join Date
    Jul 2008
    Posts
    14
    Can I get your email laserlight? I would like to contact you about something.Thanks for your help, I will try downloading these compilers.

  13. #13
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I would like to contact you about something.
    Pose your questions to the community here.

    Thanks for your help, I will try downloading these compilers.
    You're welcome
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  14. #14
    Registered User
    Join Date
    Jul 2008
    Posts
    14
    Can anyone here give me help outside of the message board? Just post your email address.

  15. #15
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Why? What's wrong with posting the questions here?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to change this simple opeation into power operation..
    By transgalactic2 in forum C Programming
    Replies: 9
    Last Post: 12-20-2008, 03:17 PM
  2. Replies: 5
    Last Post: 12-04-2008, 08:15 PM
  3. Mathematical Operation
    By madahmad1 in forum C Programming
    Replies: 3
    Last Post: 08-18-2008, 10:46 AM
  4. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  5. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM