Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization Numerical Integration #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions profiling/numerical_integration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse

import numpy as np
import matplotlib.pyplot as plt


Expand All @@ -21,13 +21,11 @@ def parse_arguments():


def integrate_f(f, a, b, n):
s = []
for i in range(n):
dx = (b - a) / n
x = a + (i + 0.5) * dx
y = f(x)
s = s + [y * dx]
return sum(s)
dx = (b - a) / n
x = (np.arange(n) + 0.5) * dx + a
y = f(x)
s=y * dx
return np.sum(s)


def measure_integration_errors(f, F, n_max, a, b):
Expand Down