Blog

Phypythonics

Euler’s method (solving 1st order differential equation)

Theory:- dy/dx=f(x,y) is 1st order equation, for approximation, a tangent at a given point will be fairly close to the original curve. Derivative at this point (x0,y0) is (dy/dx)x=x0 = f(x0,y0) Now, the tangent (y-y0)/(x-x0)=f(x0,y0) or, y=y0+f(x0,y0)*(x-x0)……..(I) if x1 is close enough to x0, we can say equation (I) can be the equation of the…

Newton-raphson method.

To find a root , f(x)=0 now, by Taylor series expansion and neglecting the higher orders. f(x)=f(x0)-f'(x0)*(x-x0)=0 or, x=x0-f(x0)/f'(x0) , x0 being the initial guess. generally:- xi=xi-1- f(xi)/f'(xi) i>=1 we iterate the values of x to reach as close to the actual root as possible.. Output:- so , generally Newton raphson method doesn’t require bounded…

Root finding by Bisection method.

Root of a function f(x) is that point where f(x) cuts x axis,(let’s say at x=c), which means f(c)=0. In question, we are told to find roots between two given points say a and b. A)) If f(a)*f(b)>0 , which is only possible if both f(a) and f(b) are positive, or both of them are…

Addition, multiplication and transpose of lists in python.

Addition of matrices:- Take the size of the matrix as user input, accept the two matrices and print the resultant matrix after adding the original two matrices. Output:- We have taken inputs the row and column number , accepted the values of two lists. Then we made a zeros matrix c[] of the accepted order,…

Matrices using lists in python.

Contents of this blog: Matrix in python: list. Accepting list elements from user. Matrix is nothing but 2D lists, containing rows and columns. Elements in the 2D lists have positions(index). a=[[1,2,4],[2,4,7],[1,9,7]] is an example of 2D list. Column➡row ⬇ 0 1 2 0 1(0,0) 2(0,1) 4(0,2) 1 2(1,0) 4(1,1) 7(1,2) 2 1(2,0) 9(2,1) 7(2,2) Row…

Jump statement in python (break and continue)

Jump statements in python are used to change or terminate the flow of a loop. Break statement:- Break statement is used to terminate a loop. Suppose in the loop , you are adding the iterables, you want to stop the loop when sum reaches a certain value. That can be achieved by, Continue statement:- This…

Getting started and Decision making in python.

Contents of this blog: Python program to find sum, difference and product. Program to find area and perimeter of rectangle. Decision making in python. if statement if else statement nested if statement Program to accept three numbers. If they are unequal,display the greatest number. Program to accept a number and if it’s an even number,…

General components of python programming.

Contents of this blog: Variables Data types Print statement Type conversion Input statement Variables are named memory locations containing value. Variables can store values of different types.You can assign a value to a variable using a equal sign(=). Eg:- a=10. If you assign a new value to the same variable, previous value will be erased…

Palindrome number checking in python.

Palindrome number is a number which remains the same when digits are reversed. Eg:- 121, 434, 2442. Output:- Explanation:- we store the value of x in some variable sum, because x will get updated through the course of programming and we will lose the original number. And p is initialised to 0. x= rem p…

Loading…

Something went wrong. Please refresh the page and/or try again.


Follow My Blog

Get new content delivered directly to your inbox.

Design a site like this with WordPress.com
Get started