August 2nd, 2016, 09:13 AM  #1 
Member Joined: Aug 2016 From: afghanistan Posts: 55 Thanks: 1  numerical method questions ...?
i had this subject called "computer oriented numerical methods in c language" ... Code: #include<stdio.h> #include<conio.h> #include<math.h> void main() { float x[10],y[10],temp=1,f[10],sum,p; int i,n,j,k=0,c; clrscr(); printf("\nhow many record you will be enter: "); scanf("%d",&n); for(i=0; i<n; i++) { printf("\n\nenter the value of x%d: ",i); scanf("%f",&x[i]); printf("\n\nenter the value of f(x%d): ",i); scanf("%f",&y[i]); } printf("\n\nEnter X for finding f(x): "); scanf("%f",&p); for(i=0;i<n;i++) { temp = 1; k = i; for(j=0;j<n;j++) { if(k==j) { continue; } else { temp = temp * ((px[j])/(x[k]x[j])); } } f[i]=y[i]*temp; } for(i=0;i<n;i++) { sum = sum + f[i]; } printf("\n\n f(%.1f) = %f ",p,sum); getch(); } Code: /* ______________________________________ OUT PUT ______________________________________ how many record you will be enter: 4 enter the value of x0: 0 enter the value of f(x0): 0 enter the value of x1: 1 enter the value of f(x1): 2 enter the value of x2: 2 enter the value of f(x2): 8 enter the value of x3: 3 enter the value of f(x3): 27 Enter X for finding f(x): 2.5 f(2.5) = 15.312500 */ i have few doubts from it .. in certain equations why do we change the unit of x to delta x , and the unit of y to delta y ?? 
August 2nd, 2016, 09:35 AM  #2 
Senior Member Joined: Jun 2015 From: England Posts: 915 Thanks: 271 
I couldn't see where the delta x and delta y appeared, can you point it out in some way please. Without that is not another name for (x1  x2) and (x0x1)  delta x? 
August 2nd, 2016, 09:57 AM  #3 
Member Joined: Aug 2016 From: afghanistan Posts: 55 Thanks: 1 
studiot , thanks for the reply ... i thought solving certain differential equations with numerical methods always involved ...changing the unit of x to delta x , and the unit of y to delta y ... in here for example ... why are we changing it like that ?? 
August 2nd, 2016, 12:34 PM  #4 
Senior Member Joined: Jun 2015 From: England Posts: 915 Thanks: 271 
You don't 'change x to delta x...... etc' Delta x is a difference between the values of x at two points. It is never the value of x at any point. However many equations contain derivatives or may be solved by differentiating or may already be a diferential equation. In that case an numerical approximation of the value of the derivative may be very useful. So in this case we can replace $\displaystyle \frac{{dy}}{{dx}}$ by $\displaystyle \frac{{\Delta y}}{{\Delta x}}$ Numerically we can calculate delta y / delta x as $\displaystyle \frac{{{y_2}  {y_1}}}{{{x_2}  {x_1}}}$ for two points 1 and 2. Then the derivative reduces to a number we can put instead of the derivative in the equation so reducing it to an algebraic one. But we don't have to do this, we can treat the derivative as a D operator and the equation as a polynomial in D to be solved numerically. It is true that differences (deltas) can be uesd to solve polynomial equations but again this is not the only way. For example consider the polynomial $\displaystyle 5{x^4}  3{x^3} + 25{x^2}  14 = 0$ This can be rearranged to give $\displaystyle x = \frac{1}{5}\sqrt {14 + 3{x^3}  5{x^4}} $ In this form the polynomial can be readily and quickly solved with a few iterations, starting from a trial guess of x = 1 and feeding the output back into the equation. No differences or deltas are required. 
August 2nd, 2016, 11:23 PM  #5 
Member Joined: Aug 2016 From: afghanistan Posts: 55 Thanks: 1 
studiot , thanks a lot ... i guess i will just focus on one question at a time .. all these requires some time to learn ... we had all these packed into one semester ... just 6 months to learn a lot of mathematics and the c programming language associated with it ... i have also been following this book , which i found online ... http://ins.sjtu.edu.cn/people/mtang/textbook.pdf Euler's Method for example ... Our goal is to find a numerical solution, i.e. we must find a set of points which lie along the initial value problem's solution Numerical MethodsEuler's Method Numerical MethodsEuler's Method yn+1 = yn + h f(xn, yn) 11. Euler's Method  a numerical solution for Differential Equations We'll finish with a set of points that represent the solution, numerically. is this like function behavior at certain points?? 
August 3rd, 2016, 08:26 AM  #6  
Senior Member Joined: Jun 2015 From: England Posts: 915 Thanks: 271  Quote:
The solution to an algebraic equation is a single number or a handful of numbers. If you like it is a single point or a few points. The solution to an ordinary differential equation is a specific function, which has lots of points plus one or more arbitrary constants of integration. The solution to partial differential equation is again a specific function but this time plus one or more arbitrary functions. Numerical methods attempt to reproduce these functions by 'calculating' the graph in steps rather than deducing an algebraic expression for the graph. For the purposes of this post I am taking the word graph as the same as the function it represents.  
August 3rd, 2016, 12:03 PM  #7  
Member Joined: Aug 2016 From: afghanistan Posts: 55 Thanks: 1 
studiot , thanks a lot for the answers ... i don't know if i am wording it right ... usually for differential equation questions ... isn't it a bit like this ?? find the function , that has this instantaneous rate of change ... Quote:
and the answer is a function that has the property of ,this instantaneous rate of change ... Quote:
Quote:
so with numerical methods the answer is a set of points that has certain underlying qualitative property of , this instantaneous rate of change ... ??  
August 3rd, 2016, 01:07 PM  #8 
Senior Member Joined: Jun 2015 From: England Posts: 915 Thanks: 271 
Don't forget that only the first derivative represents the instantaneous rate of change. Differential equations can contain higher derivatives. When you are learning about methods or testi ng them it is handy to have an analytical solution to calibrate of compare. In engineering many differential equations are non linear and/or have no known analytic solutions. So in that case the only approach available is a numeric one. Often engineers simplify (they love it) so in finite elements difficult equations are often replaced by simpler ones that ease computer resources. Gauss / Green / Divergence theorems are used to replace interior elements with boundary elements, which also reduces calculation effort. 
August 3rd, 2016, 08:43 PM  #9 
Member Joined: Aug 2016 From: afghanistan Posts: 55 Thanks: 1 
studiot , thanks a lot for all the replies ... 
September 26th, 2016, 11:28 PM  #10  
Member Joined: Aug 2016 From: afghanistan Posts: 55 Thanks: 1 
i have few more doubts , i need a little bit more clarity . sorry for messing up the post like this .but i still have some doubts let me try this again ... this was supposed to start with a program for a polynomial factorization first ... Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
example ... this is an instantaneous rate of change dy/dx gives you the change in 'y' with respect to change in 'x' find the function that gives you this rate of change in 'y' with respect to change in 'x' ... and the answer is a function that has the property of ,this instantaneous rate of change in 'y' with respect to change in 'x' ... ... example ... this is an instantaneous rate of change ... find the function ,the solution , the answer which is a set of points that has certain underlying qualitative property which produced, this instantaneous rate of change ... Quote:
Quote:
Code: #include<stdio.h> #include<math.h> main() { float x; /*defining variables*/ float y; float h; float targetx; puts("This program will solve the differential equation y' = y  x \nusing Euler's Method with y(0)=1/2 \n\n"); puts("Please enter the desired constant step size. (hvalue)\n\n"); scanf("%f", &h); /* Defining step size*/ puts("\n\nNow enter the desired xvalue to solve for y.\n\n"); scanf("%f", &targetx); y = 0.5; x = 0.0; puts("\n\nX Y"); while ( x != targetx ) { printf("\n\n%f %f", x, y); y = y + ((y  x)*h); x= x+h; } printf("\n\n%f %f\n", x, y); printf("\nThe value of y at the given x is %f.\n\n", y, h); system("pause"); } in the case of an analytic solution : this is an instantaneous rate of change dy/dx gives you the change in 'y' with respect to change in 'x' find the function that gives you this rate of change in 'y' with respect to change in 'x' ... in the case of an numerical solution : this is an instantaneous rate of change dy/dx gives you the change in 'y' with respect to change in 'x' find the function that gives you this rate of change in 'y' with respect to change in 'x' ... ?? Last edited by porchgirl; September 26th, 2016 at 11:45 PM.  

Tags 
method, numerical, questions 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
numerical method to solve equation  coenter  Differential Equations  4  January 27th, 2015 10:24 PM 
Steffensen's method in Numerical Analysis  bounces  Calculus  0  November 14th, 2014 05:48 AM 
About Numerical method  mathisdifficult  Applied Math  1  October 24th, 2012 07:51 AM 
Newton raphson methodnumerical function  meriens  Applied Math  2  May 25th, 2012 02:43 AM 
Numerical Linear Algebra, Conjugate Gradient Method  hgd7833  Linear Algebra  0  May 4th, 2012 03:50 AM 