Skip to content

Instantly share code, notes, and snippets.

View carlos-adir's full-sized avatar

Carlos Adir carlos-adir

View GitHub Profile
@carlos-adir
carlos-adir / sort_list.cpp
Created December 3, 2019 16:57
An algorithme to sort a liste
#include <iostream>
using namespace std;
struct elemento
{
int valor;
elemento *proximo;
};
@carlos-adir
carlos-adir / interface.py
Last active September 26, 2020 21:34
Ploting curves of Bode, Nichols and Nyquist using Tkinter as GUI and sympy to treat the expressions
import tkinter as tk
import negocio
import numpy as np
import matplotlib.ticker as ticker
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg
@carlos-adir
carlos-adir / findcatenary.py
Last active April 24, 2022 17:04
This algorithm finds the solution of an non-linear equation. The equation is the catenary, which must pass the point (x0, y0). There are 0, 1 or 2 solutions for this problem
######################################
# Description #
######################################
#
# This algorithm finds the solution of an non-linear equation
# The equation is the catenary, that is like
# h(x) = a * cosh(x/a)
# We want to find the value of "a" such that h(x0) = y0
# Where (x0, y0) is known
#
@carlos-adir
carlos-adir / test_systemsolution.py
Created June 20, 2022 13:43
Block matrix reduce system for finite element
import numpy as np
import sympy as sp
from numpy import linalg as la
"""
https://mathoverflow.net/questions/425067/block-matrix-reduce-system-for-finite-element-method
"""
def random_sym_matrix(side):
F = np.random.rand(side, side)
@carlos-adir
carlos-adir / Exercise1.py
Last active June 23, 2022 19:17
Vibrations exercices
import numpy as np
import sympy as sp
sin, cos = sp.sin, sp.cos
k1, k2 = sp.symbols("k1 k2", real=True, positive=True)
L1, L2 = sp.symbols("L1 L2", real=True, positive=True)
a, p, m= sp.symbols("a p m", real=True, positive=True)
theta = sp.symbols("theta")
dtheta = sp.symbols("dtheta")
@carlos-adir
carlos-adir / CompareNumericalConvergence.py
Created November 25, 2022 01:12
This file has many functions that can iterate and plots the final result for convergence, precision is also a input
import numpy as np
import sympy as sp
from matplotlib import pyplot as plt
import mpmath as mp
mp.mp.dps = 4000
print(mp.mp)
sqrt = mp.sqrt
def xsqrta(x, a):
@carlos-adir
carlos-adir / ComputeSectionCircleValues.ipynb
Created June 25, 2023 09:30
Compute section properties of a circle by using boundary method
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@carlos-adir
carlos-adir / canon2bezier.py
Created July 21, 2023 19:13
Transforms a polynomial in canonical basis into bezier basis and vice-versa
from typing import Tuple
import sympy as sp
import numpy as np
def Bezier2Canonical(degree: int) -> np.ndarray:
"""
Returns a transformation matrix between the basis
Bezier -> Canonical
"""
matrix = np.zeros((degree+1, degree+1), dtype="object")
@carlos-adir
carlos-adir / inverse_int_frac_matrix.py
Last active July 30, 2023 07:56
Find inverse of matrix using integers and fractions
from typing import Tuple
import numpy as np
from fractions import Fraction
import math
def invert_integer_matrix(
matrix: Tuple[Tuple[int]],
) -> Tuple[Tuple[int], Tuple[Tuple[int]]]:
"""
@carlos-adir
carlos-adir / conics.py
Created August 29, 2023 20:19
Basic class to operate conic sections
import numpy as np
from matplotlib import pyplot as plt
from typing import Tuple
class Conic:
def __init__(self, coefs: Tuple[float]):
self.coefs = coefs