Logo elodees  elodees

A caring AI for a better world













Only alphabetic characters accented or not as well as the space are accepted

Logo IA




Math





No account yet ?

Sign up to access all content




PI Calculation



Tested in Anaconda and Python 3.7

k = 1
pi = 0
 
for i in range(1000000): 
    if i % 2 == 0: 
        pi += 4/k 
    else: 
        pi -= 4/k 
    k += 2
 
print(pi)
 


3.1415916535897743



Integral calculation



Tested in Anaconda and Python 3.7

# integration numerique par la methode des rectangles avec alpha = a
 
import numpy as np
import matplotlib.pyplot as plt
 
xmin = 0
xmax = 3*np.pi/2
nbx = 20
nbi = nbx - 1 # nombre d'intervalles
 
x = np.linspace(xmin, xmax, nbx)
y = np.cos(x)
plt.plot(x,y,"bo-")
 
integrale = 0
for i in range(nbi):
    integrale = integrale + y[i]*(x[i+1]-x[i])
    # dessin du rectangle
    x_rect = [x[i], x[i], x[i+1], x[i+1], x[i]] # abscisses des sommets
    y_rect = [0   , y[i], y[i]  , 0     , 0   ] # ordonnees des sommets
    plt.plot(x_rect, y_rect,"r")
print("integrale =", integrale)
 
plt.show()
 


integrale = -0.8708583208502408



Free image provided by pexel.com


Bilinear interpolation of a curve



Tested in Anaconda and Python 3.7

from scipy import interpolate
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-15.01, 15.01, 1.00)
y = np.arange(-15.01, 15.01, 1.00)
xx, yy = np.meshgrid(x, y)
z = np.cos(xx**2+yy**2)
f = interpolate.interp2d(x, y, z, kind='quintic')
xnew = np.arange(-15.01, 15.01, 1e-2)
ynew = np.arange(-15.01, 15.01, 1e-2)
znew = f(xnew, ynew)
plt.plot(x, z[0, :], 'ro-', xnew, znew[0, :], 'b-')
plt.show()
 


Free image provided by pexel.com


Fibonacci suite



The Fibonacci sequence is a sequence of integers in which each digit or number is the sum of the two digits or numbers that precede it. It starts with the terms 0 and 1.



Tested in Anaconda and Python 3.7

# -*- coding: utf-8 -*-
"""
Created on Wed Aug 24 16:23:30 2022
 
@author: Ricore
"""
fibonacciList = [0, 1]
# finding 10 terms of the series starting from 3rd term
N = 25
term = 3
while term < N + 1:
    value = fibonacciList[term - 2] + fibonacciList[term - 3]
    fibonacciList.append(value)
    term = term + 1
 
print(fibonacciList)
 


0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368













Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !

Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License