[PDF] #--------------------------- # INTEGRALS and DERIVATIVES





Previous PDF Next PDF



OLCF

16 févr. 2023 • hipfort (HIP bindings for fortran). – https://github.com ... • Condensed short tutorial video: https://www.youtube.com/watch?v=6Ts6k2Nas5w.



Introduction à la programmation en R

qu'une capsule vidéo est disponible dans la chaîne YouTube de l'auteur sur On conviendra que cette convention héritée du Fortran



MUltifrontal Massively Parallel Solver (MUMPS version 4.2 beta

17 avr. 2019 The software is written in Fortran 90 although there is a basic C interface available (see Section 6). The parallel version of MUMPS requires ...



Bridging HPC Communities through the Julia Programming Language

10 nov. 2022 programming languages (e.g. C



Codes de calcul industriels pour la simulation des écoulements

19 juil. 2023 Film ici : https ://www.youtube.com/watch ?v=c8zKWaxohng. 31. Domaine ... programme en fortran ou C. ✄ Inconvénient : limité `a un petit nombre ...



First OpenMP Users Monthly Telecon of 2021

16 mars 2021 1. SLATE: https://www.youtube.com/watch?v=bmz-NqihvVg&feature=youtu.be ... ▷ Fortran best practices to program devices. ▷ Interop ...



2nd March 2022 Joachim Aertebjerg EMEA Technical Sales Director

2 mars 2022 ▫ Interoperable with existing programming models and code bases (C++ Fortran



Codes de calcul industriels pour la simulation des écoulements

youtube.com/watch ?v=c8zKWaxohng. 31. Domaine entier. Zoom (échelle 2). Zoom ... fortran ou C. ✄ Inconvénient : limité `a un petit nombre de processeurs.



COMPUTATiONAL CRySTALLOGRAPhy NEWSLETTER

New video tutorials have been added to the. Phenix Tutorial YouTube channel.2 and Fortran. The project agreed upon a few years ago



Water Erosion Prediction Project (WEPP) Windows Interface Tutorial

This WEPP software consists of an erosion prediction model (WEPP) written in the Fortran programming language a climate generator program (CLIGEN) also written 



1 Steps to install Gfortran for Windows using MinGW Version 1.0 5

May 27 2015 Steps to install Gfortran for Windows using MinGW. Version 1.0 ... gcc --version. Reference: https://www.youtube.com/watch?v=oVfAU1ziOjg.



Tutorial Rápido de Fortran (Incluye versiones Fortran 77 y 90)

Los usuarios deben ser cuidadosos con la versión 77 del lenguaje Fortran. Aunque los compiladores más recientes pueden trabajar con código desarrollado en dicho 



#--------------------------- # INTEGRALS and DERIVATIVES

https://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html in Fortran or C. They will thus execute much faster than pure Python code.



fftw3.pdf

Dec 10 2020 7 Calling FFTW from Modern Fortran......... 77 ... 1 You can read the tutorial in bit-reversed order after computing your first transform.



Lattice Diamond Tutorial (v3.5)

The design in this tutorial consists of a Verilog HDL module two VHDL modules



Modeling and Simulation Workbench for NONMEM: Tutorial on

Jun 26 2013 Fortran-derived syntax (NM-TRAN). In addition



Stata Users Guide

Programming Reference Manual however



Introducción a FORTRAN

Compilar y correr programas en FORTRAN. 4. 3. Elementos básicos de un programa en FORTRAN. 5. 4. Constantes y variables. 6. 4.1. Tipos de datos .



A short tutorial on GrADS – Grid Analysis and Display System

Within the scripts it is possible to develop interactivity with functions expressions or external routines written with other programming languages. (FORTRAN

#---------------------------# INTEGRALS and DERIVATIVES#---------------------------# Chapter 5 of the book# Some YouTube videos about integrals# https://www.youtube.com/watch?v=eis11j_iGMs# https://www.youtube.com/watch?v=4grhQ5Y_MWo# SciPy page about integrals# https://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html# SINGLE INTEGRAL: area under a curve# DOUBLE INTEGRAL: volume under a surface#---------------------------# SCIPY#---------------------------# We can do derivatives and integrals using SCIPY## Page with explanantions about SciPy

# https://www.southampton.ac.uk/~fangohr/teaching/python/book/html/16-

scipy.html## Numpy module: vectors, matrices and linear algebra tools.# Matplotlib package: plots and visualisations.# Scipy package: a multitude of numerical algorithms.## Many of the numerical algorithms available through scipy and numpy are # provided by established compiled libraries which are often written # in Fortran or C. They will thus execute much faster than pure Python code.# As a rule of thumb, we expect compiled code to be two orders of magnitude # faster than pure Python code.# Scipy is built on numpy. # All functionality from numpy seems to be available in scipy as well.import numpy as npx = np.arange(0, 10, 1.)y = np.sin(x)print(y)import scipy as spx = sp.arange(0, 10, 1.)y = sp.sin(x)print(y)

#%%#---------------------------# LAMBDA FUNCTION#---------------------------print()# Lambda function is similar to a definition,# but # *) the lambda definition does not include a return statement;# *) we can put a lambda definition anywhere a function is expected;# *) we don't have to assign it to a variable at all.# Go through:

# https://www.southampton.ac.uk/~fangohr/teaching/python/book/html/16-

scipy.html# https://www.tutorialspoint.com/scipy/scipy_integrate.htm## Comparedef func(x): return x ** 3print(func(5))print()fanc = lambda x: x ** 3print(fanc(5))#%%# # NUMERICAL INTEGRAL# ------------# Example 1# -----------print()import scipy.integrate as integrateimport numpy as npimport mathfunc = lambda x: math.exp(-x**2)# ------------------------------# numpy could also have been used#func = lambda x: np.exp(-x**2)# ------------------------------------

# definition could also have been used#def func(x): return math.exp(-x**2)sol1=integrate.quad(func, 0, 1)print(sol1)# The solution contains two numbers. # The first is the solution of the of integral # and the second value is # the estimate of the absolute error in the value of the integral.## If we just want to see the solution, we can writeprint()print("Printing just the solution:")sol,err=integrate.quad(func, 0, 1)print(sol)# The scipy documentation states that integrate.quad uses # a technique from the Fortran library QUADPACK. # QUADPACK provides several routines using different techniques.# As scipy is open source, you can actually read the code for integrate.quad at# https://github.com/scipy/scipy/blob/master/scipy/integrate/quadpack.py#%%### MULTIPLE INTEGRALS#### quad: Single integration# dblquad: Double integration# tplquad: Triple integration## # https://www.tutorialspoint.com/scipy/scipy_integrate.htm# ------------# Example 2# -----------import scipy.integratefrom numpy import expfrom math import sqrtfunc = lambda x, y : 16*x*ylowY = lambda x : 0highY = lambda x : sqrt(1-4*x**2)int = scipy.integrate.dblquad(func, 0, 0.5, lowY, highY)print (int)

# %%# MORE EXAMPLES MORE EXAMPLES MORE EXAMPLES# ---------------------# SINGLE INTEGRAL# ---------------------import scipy.integrate as integrateimport numpy as npimport math# Either we define the function like thisdef func(x): return x ** 3sol=integrate.quad(func, 0, 1)print(sol)# Or we lambdify itfanc = lambda x: x ** 3sol=integrate.quad(fanc, 0, 1)print(sol)# ---------------------# DOUBLE INTEGRAL# ---------------------from scipy import integrateimport numpy as npimport math# EITHERdef func(y,x): return 1/math.sqrt(x*y-x**2)def flow(x): return x+2def fup(x): return x+3sol=integrate.dblquad(func, 1, 2, flow, fup)print(sol)# VERY CAREFUL above!! The order of the variables in func matters!!!# If we are going to integrate y first and then x, make sure to have# func(y,x) and NOT func(x,y)# ORfunc = lambda y, x: 1/math.sqrt(x*y-x**2)sol=integrate.dblquad(func, 1, 2, lambda x: x+2, lambda x: x+3)print(sol)

# OR yetdef func(y,x): return 1/math.sqrt(x*y-x**2)sol=integrate.dblquad(func, 1, 2, lambda x: x+2, lambda x: x+3)print(sol)#%%#---------------------------# SYMPY#---------------------------# https://www.sympy.org/en/index.html# SumPy is a Python library for symbolic mathematics.# # SYMBOLIC INTEGRAL# ------------# Example 3# -----------import scipy.integrate as integrateimport sympy as sypx = syp.Symbol('x')intSym = syp.integrate(3.0*x**2+1,x)print( intSym )#%%# # METHODS of INTEGRATION# # Trapezoidal rule# Simpson's rule# Romberg integration# Gaussian quadrature # -------------------------------------# Example 4: # Integral of a semicircle of radius 1# ------------------------------------print()

import scipy.integrate as integrateimport numpy as npfunc = lambda x: np.sqrt(1.-x**2)print()print("The exact solution is Pi/2:",np.pi/2.)print()print("Using quad from scipy")sol,err=integrate.quad(func, -1, 1)print("Solution:",sol, " Error:", err)# --------------# RECTANGLES#---------------print()print("Writing our own code: adding rectangles")print()print("Just 10 intervals")Ntot=10som=0.Xlast=1.Xfirst=-1.delt=(Xlast-Xfirst)/Ntotprint("increment=",delt)for n in range(Ntot): print("where func is evaluated:",Xfirst+n*delt) som=som + func(Xfirst+n*delt)*deltprint("Solution for 10 intervals:",som)print()Ntot=100print(Ntot, "intervals")som=0.Xlast=1.Xfirst=-1.delt=(Xlast-Xfirst)/Ntotfor n in range(Ntot): som=som + func(Xfirst+n*delt)*deltprint("Solution:",som)print()Ntot=1000print(Ntot, "intervals")som=0.Xlast=1.Xfirst=-1.delt=(Xlast-Xfirst)/Ntotfor n in range(Ntot):

som=som + func(Xfirst+n*delt)*deltprint("Solution:",som)#%%### -----------------------------------------# STUDENTS READ THE BOOK (see Canvas)# about the TRAPEZOIDAL RULE and SIMPSON'S RULE# # STUDENTS PRESENT ON THE BOARD # (student selected by chance)# One student presents the TRAPEZOIDAL RULE# One student presents the SIMPSON'S RULE# This exercise can be done in pairs or groups#### -----------------------------------------# LET US NOW CONSIDER THE FUNCTION## x^4 - 2 x +1# in the interval x=0 to x=2## and compare the results that we obtain # by adding rectangles for N=10,100,100 and # by employing # the TRAPEZOIDAL RULE and SIMPSON'S RULE# -----------------------------------------func = lambda x: x**4 - 2.*x + 1.Xfirst = 0Xlast = 2.print()print("Exact solution")var=2exac=var**5/5 - var**2 + varprint("x^5/5-x^2+x in [0,2] is ", exac)print()Ntot=10print(Ntot, "intervals")delt=(Xlast-Xfirst)/Ntotsom=0.print("increment=",delt)

for n in range(Ntot): som=som + func(Xfirst+n*delt)*deltprint("Solution:",som)print("Percentage Error:", 100*abs(som-exac)/exac,"%")print()Ntot=100print(Ntot, "intervals")delt=(Xlast-Xfirst)/Ntotsom=0.for n in range(Ntot): som=som + func(Xfirst+n*delt)*deltprint("Solution:",som)print("Percentage Error:", 100*abs(som-exac)/exac,"%")print()Ntot=1000print(Ntot, "intervals")delt=(Xlast-Xfirst)/Ntotsom=0.for n in range(Ntot): som=som + func(Xfirst+n*delt)*deltprint("Solution:",som)print("Percentage Error:", 100*abs(som-exac)/exac,"%")# ------------------# TRAPEZOIDAL RULE#------------------# Exercise 1# Students solve in class for Ntot=10,100,1000# -----------------------------------------# SIMPSON'S RULE# The number of slices need to be EVEN !!!#------------------------------------------# Exercise 2# Students solve in class for Ntot=10,100,1000# --------------------------------------------# ROMBERG INTEGRATION# and# GAUSSIAN QUADRATURE# Read the book if you want to learn about them.#---------------------------------------------

#%%# -----------------------------------------------# -------------------# ERRORS ON INTEGRALS#--------------------# When the integrand f(x) is known,# there are equations available for # 1) the error using the TRAPEZOIDAL RULE is# error = [f'(a)-f'(b)]*(h^2/12)## 2) the error using the SIMPSON'S RULE is# error = [f'''(a)-f''''(b)]*(h^4/90)## where # f' = first derivative# f''' = third derivative# Integral performes from x=a to x=b# h = (b-a)/N and N = number of slices# ------------------------------# PRACTICAL ESTIMATION OF ERRORS# ------------------------------# valid also when f(x) is not known## Solve the integral with N1 steps and get I1# Solve the integral with N2=2*N1 steps and get I2# 1) the error for I2 using the TRAPEZOIDAL RULE is# error = abs(I2 - I1)/3## 2) the error for I2 using the SIMPSON'S RULE is# error = abs(I2 - I1)/15# -----------# Exercise 3# -----------# Students solve in class.# Use the trapezoidal rule with 20 slices and # calculate the integral of x^4 - 2 x +1# in the interval x=0 to x=2. # Using the "practical estimation of errors", # compute also the error. For this, get the integral for N1=10 and N2=20.

# ------------------------------# CHOOSING THE NUMBER OF STEPS# that gives a desired accuracy# ------------------------------# Read the Section 5.3 of the book# You will need this to solve Exercise 4 of the assignment#%%# ------------------------------# INTEGRALS OVER INFINITE RANGES# ------------------------------# The previous methods do not work,# because we would need an infinite number of sample points.# The solution to this problem is to change variables.## For an integral in x from 0 to infinity, # the standard change of variables from x to z is# # z = x/(1+x) so x = z/(1-z)## Then dx = dz/(1-z)^2# and# \int_0^infinity f(x) dx = \int_0^1 ( 1/(1-z)^2 ) f(z/(1-z)) dz## Many other choices work, so sometimes we need to play around# to find which works better, but # the choice above is often a first good guess (see exception in assignment!).# When the range is from a to infinity,# change x to y: y = x-a# and then y to z: z = y/(1+y)# See equations in the book.# When the range is from -infinity to a,# change z to -z# When the range is from -infinity to infinity,# split the integrals.# -----------# Exercise 4# -----------# Students solve in class the integral # \int_0^infinity exp(-t^2) dt## !!!!!!! CAREFUL !!!!!!!!!!!# At z=1, 1/(1-z) goes to infinity,

# so use z = 0.999999999999999# To solve it analytically, look at YouTube movie # https://www.youtube.com/watch?v=nqNzKeVCYBU## Show in class that:# \int_{-infinity}^{infinity} exp(-a x^2) dx = sqrt(pi/a) ## Use # (i) \int_{-infinity}^{infinity} exp(-a x^2) dx =

# sqrt[ (\int_{-infinity}^{infinity} exp(-a x^2) dx) (\int_{-infinity}

^{infinity} exp(-a y^2) dy) ]# (ii) x = r cos(theta) and y = r sin(theta)# Jacobian: | dx/dr dx/dtheta | # | dy/dr dy/dtheta | = r dr dtheta# (iii) z = r^2 and dz = 2 r dr# %%# ------------# DERIVATIVES# ------------# Forward difference# f' ~ [ f(x+h) - f(x) ]/h for small h# Backward difference# f' ~ [ f(x) - f(x-h) ]/h for small h# Central difference [BETTER OPTION]# f' ~ [ f(x+h/2) - f(x-h/2) ]/h for small h# For second derivatives and partial derivatives# see the book # ------------# Using SYMPY# ------------import sympy as sypx = syp.Symbol('x')ff = syp.diff(syp.sin(x),x)print(ff)

quotesdbs_dbs9.pdfusesText_15
[PDF] fortran tutorialspoint pdf

[PDF] fortran vs c for scientific computing

[PDF] fortunately definition

[PDF] fortunately in spanish

[PDF] fortunately meaning

[PDF] fortunately the milk

[PDF] fortunately to meet you

[PDF] fortunately unfortunately

[PDF] fortunately unfortunately book

[PDF] foss concentration tutorial

[PDF] foss mixtures and solutions module

[PDF] foss mixtures and solutions module investigation 2

[PDF] foss mixtures and solutions study guide

[PDF] foss next generation mixtures and solutions module

[PDF] foss science stories mixtures and solutions