My Math Forum numerical method questions ...?

 Differential Equations Ordinary and Partial Differential Equations Math Forum

 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 #include #include 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
 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 (x0-x1) - 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. Thanks from porchgirl
 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 Methods--Euler's Method Numerical Methods--Euler'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:
 is this like function behavior at certain points??
I'm not sure what you mean by this question.

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:
 An analytical solution to a problem is one that has a "proof": a series of logical steps that can be followed and verified as correct. If you use the quadratic formula to solve for x in a quadratic equation, this is an analytical solution to the problem. In contrast to this, some problems are solved via other means. If, instead of using the quadratic formula, you try a lot of values for x and y, this is a numerical solution. Some problems simply do not have analytical solutions and must be approximated using numerical methods -- for example, many complicated integrals.

and the answer is a function that has the property of ,this instantaneous rate of change ...

Quote:
 Say we were to solve the initial value problem: y′ = 2x y(0) = 0 It's so simple, you could find a formulaic solution in your head, namely y = x2. On the other hand, say we were to use a numerical technique. (Yes, I know we don't know how to do this yet, but go with me on this for a second!) The resulting numerical solution would simply be a table of values. To get a better feel for the nature of these two types of solution, let's compare them side by side, along with the graphs we would get based on what we know about each one: Notice that the graph derived from the formulaic solution is smoothly continuous, consisting of an infinite number of points on the interval shown. On the other hand, the graph based on the numerical solution consists of just a bare eight points, since the numerical method used apparently only found the value of the solution for x-increments of size 0.2. Using Numerical Solutions So what good is the numerical solution if it leaves out so much of the real answer? Well, we can respond to that question in several ways: The numerical solution still looks like it is capturing the general trend of the "real" solution, as we can see when we look at the side-by-side graphs. This means that if we are seeking a qualitative view of the solution, we can still get it from the numerical solution, to some extent. The numerical solution could even be "improved" by playing "join-the-dots" with the set of points it produces. In fact this is exactly what some solver packages, such as Mathematica, do do with these solutions. (Mathematica produces a join-the-dots function that it calls InterpolatingFunction.) When actually using the solutions to differential equations, we often aren't so much concerned about the nature of the solution at all possible points. Think about it! Even when we are able to get formulaic solutions, a typical use we make of the formula is to substitute values of the independent variable into the formula in order to find the values of the solution at specific points. Did you hear that? Let me say it again: to find the values of the solution at specific points. This is exactly what we can still do with a numerical solution

Quote:
 Originally Posted by studiot I'm not sure what you mean by this question. 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.

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. Thanks from porchgirl
 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:
 mathematical expressions equations in one variable equations in two variables system of 2 equations containing 2 variables functions in one variable functions in two variables differential equations first order differential equations second order differential equations higher order differential equations ... linear differential equations separable differential equations exact differential equations homogeneous differential equations non homogeneous differential equations using the method of undetermined coefficients ... partial differential equations ...
Quote:
 Peter Selby, Steve Slavin Practical Algebra_ A Self-Teaching Guide Tom M. Apostol Calculus, Volume I_ One-Variable Calculus, with an Introduction to Linear Algebra Tom M. Apostol Calculus, Volume II_ Multi-Variable Calculus and Linear Algebra, with Applications to Differential Equations and Probability Numerical Analysis - Richard L. Burden (Author), J. Douglas Faires (Author), Annette M. Burden (Author) Numerical recipes in C -The Art of Scientific Computing Computer oriented numerical methods - N Datta Computer Fundamentals and Programming in C - J.B. Dixit

Quote:
 A linear equation is always a polynomial of degree 1 (for example x+2y+3=0). In the two dimensional case, they always form lines; in other dimensions, they might also form planes, points, or hyperplanes. Their "shape" is always perfectly straight, with no curves of any kind. This is why we call them linear equations. Every other equation is nonlinear. Higher degree polynomials are nonlinear. Trigonometric functions (like sin or cos) are nonlinear. Square roots are nonlinear. The main exception is if the nonlinear piece can evaluate to a constant--for example, sqrt(4)*x is linear because sqrt(4) is just 2, and 2x is linear. Linear equations have some useful properties, mostly in that they are very easy to manipulate and solve. Although they are quite limited in what they can represent, it is often useful to try and approximate complicated systems using linear equations so that they will be easier to think about and deal with. Nonlinear equations, for the most part, are much harder to solve and manipulate. Sometimes you need them--nature doesn't always work in straight lines, and nor do mathematicians--but generally speaking, you can only solve nonlinear equations if the systems are fairly small and simple. Solving a linear system with a million interacting variables is very doable with a computer, and most nonlinear solvers aren't going to get even close to that

Quote:
 for example , for a polynomial ... a solution of a polynomial equation is also called a root of the polynomial ... a value for the variable that makes the polynomial zero if you can't find an exact expression, then you can use numerical methods to get approximations ... with numerical methods you can choose how close to zero you want, and it will give you a value that's at least that close ...
Quote:
 The (standard) calculus is broken into two pieces. i) Differential calculus - which is looking at the instantaneous rates of change of objects with respect to some variables. We have the notion of the derivative of a function. ii) Integral calculus - which is calculating the area under curves, calculating volumes and so on. This is all given in terms if the (indefinite or definite) integral of a function. The two notions are tied together via the fundamental theorem of calculus. This says that the derivative and indefinite integral are basically mutual inverses (but not quite)
Quote:
 An equation containing the derivatives of one or more dependent variables, with respect to one or more independent variables, is said to be a differential equation

Quote:
 An analytical solution to a problem is one that has a "proof": a series of logical steps that can be followed and verified as correct. If you use the quadratic formula to solve for x in a quadratic equation, this is an analytical solution to the problem. In contrast to this, some problems are solved via other means. If, instead of using the quadratic formula, you try a lot of values for x and y, this is a numerical solution. Some problems simply do not have analytical solutions and must be approximated using numerical methods -- for example, many complicated integrals.

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:
 Say we were to solve the initial value problem: y' = 2x y(0) = 0 It's so simple, you could find a formulaic solution in your head, namely y = x2. On the other hand, say we were to use a numerical technique. (Yes, I know we don't know how to do this yet, but go with me on this for a second!) The resulting numerical solution would simply be a table of values. To get a better feel for the nature of these two types of solution, let's compare them side by side, along with the graphs we would get based on what we know about each one: Notice that the graph derived from the formulaic solution is smoothly continuous, consisting of an infinite number of points on the interval shown. On the other hand, the graph based on the numerical solution consists of just a bare eight points, since the numerical method used apparently only found the value of the solution for x-increments of size 0.2. Using Numerical Solutions So what good is the numerical solution if it leaves out so much of the real answer? Well, we can respond to that question in several ways: The numerical solution still looks like it is capturing the general trend of the "real" solution, as we can see when we look at the side-by-side graphs. This means that if we are seeking a qualitative view of the solution, we can still get it from the numerical solution, to some extent. The numerical solution could even be "improved" by playing "join-the-dots" with the set of points it produces. In fact this is exactly what some solver packages, such as Mathematica, do do with these solutions. (Mathematica produces a join-the-dots function that it calls InterpolatingFunction.) When actually using the solutions to differential equations, we often aren't so much concerned about the nature of the solution at all possible points. Think about it! Even when we are able to get formulaic solutions, a typical use we make of the formula is to substitute values of the independent variable into the formula in order to find the values of the solution at specific points. Did you hear that? Let me say it again: to find the values of the solution at specific points. This is exactly what we can still do with a numerical solution

Quote:
 Solving an ordinary differential equation (ODE) or initial value problem means finding a clear expression for y in terms of a finite number of elementary functions of x. Euler’s method is one of the simplest method for the numerical solution of such equation or problem. This C program for Euler’s method considers an ordinary differential equations, and the initial values of x and y are known. Mathematically, here, the curve of solution is approximated by a sequence of short lines i.e. by the tangent line in each interval. (Derivation) Using these information, the value of the value of ‘yn’ corresponding to the value of ‘xn‘ is to determined by dividing the length (xn – x) into n strips. Therefore, strip width= (xn – x)/n and xn=x0+ nh. Again, if m be the slope of the curve at point, y1= y0 + m(x0 , yo)h. Similarly, values of all the intermediate y can be found out. Below is a source code forEuler’s method in C to solve the ordinary differential equation dy/dx = x+y. It asks for the value of of x0 , y0 ,xn and h. The value of slope at different points is calculated using the function ‘fun’. The values of y are calculated in while loop which runs till the initial value of x is not equal to the final value. All the values of ‘y’ at corresponding ‘x’ are shown in the output screen. dy/dx = x+y

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. (h-value)\n\n");
scanf("%f", &h);                                                           /* Defining step size*/
puts("\n\nNow enter the desired x-value 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 Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post coenter Differential Equations 4 January 27th, 2015 10:24 PM bounces Calculus 0 November 14th, 2014 05:48 AM mathisdifficult Applied Math 1 October 24th, 2012 07:51 AM meriens Applied Math 2 May 25th, 2012 02:43 AM hgd7833 Linear Algebra 0 May 4th, 2012 03:50 AM

 Contact - Home - Forums - Cryptocurrency Forum - Top