{{#items}}

{{text}}

{{/items}} {{ctaText}}

{{#items}} {{/items}}

showing results for - "trapezoid rule python"

Charlene

02 Jan 2019

```
1def trap1(f,a,b):
2 '''heildi f frá a til b með ósamsettri trapisureglu'''
3 I = (b-a)*(f(a)+f(b))/2
4 return I
5
6import math
7def g(x): return math.sin(x)/x
8def h(x): return math.e**x
9
10I1 = trap1(g,1,2)
11I2 = trap1(h,0,1)
12print(f'I1={I1:.3f}, I2={I2:.3f}')
13 # prentar "I1=0.648, I2=1.859"
14
```

similar questions

are all parallelograms trapeziumspython calculate scalene trianglefloyd triangle pythonpython how to draw trianglesierpinski carpet python turtleherons rule pythonare all squares trapeziumspascal 27s triangle pythonarea of a right angle triangle in pythonreplicate pythonannotate diagonal pythonpython create a matrix with one in diagonalpython matrix condensed to square your answer for

you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content

please ensure to add code which is syntactically corrent and executes properly

ask question on maxinterview

you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content

please be clear, to the point and respectful