Estoy intentando generar un Triángulo de Sierpinski en Python utilizando el Juego del Caos. Los cálculos de los puntos a plotear parecen correctos, sin embargo, en lugar de graficar miles de puntos, solo se grafican alrededor de 10. import math import numpy as np import random as rand import matplotlib.pyplot . . . Read more
class ODEsolver(): def __init__(self): self.init=self def Euler(self, fcn, x0, y0, xend, h): estimate=[y0] z=y0 b=0 t=x0 while(t<xend): slope1=fcn(bisection(t,301,1200,10**-4)) y=z+slope1*h/8 t+=h z=y estimate.append(y) return estimate def heun(self, fcn, x0, y0, xend, h): pass def rungekutta(self,fcn,x0,y0,xend,h): pass def solve(self,which, fcn, x0, y0, xend, h): if which==0: return self.euler(fcn,x0,y0,xend,h) elif which==1: return self.heun(fcn,x0,y0,xend,h) . . . Read more
Tengo una función muy extraña que se parece a esto: T(n) = 2T(n/2) + n* log2(n) Necesito resolver esto con el método de sustitución, pero no he sido capaz de llegar a una respuesta decisiva. Necesito los pasos para resolverlo y el big-O.
¿Cómo funciona ‘k’ en el código a continuación? #include <stdio.h> define R 2 define C 2 int main(void) { int a[R][C], b[R][C], mul[R][C], i, j, k; for (i = 0; i < R; ++i) for (j = 0; j < C; ++j) { scanf_s(“%d”, &a[i][j]); } for (i = 0; . . . Read more
Estoy intentando usar Python para determinar las fracciones continuas de pi siguiendo el árbol de Stern-Brocot. Es simple, si mi estimación de pi es demasiado alta, tiro a la izquierda, si mi estimación de pi es demasiado baja, tiro a la derecha. Estoy usando mpmath para obtener números flotantes de . . . Read more