Blog Archives

norms_Math_unsolved

function x = norms_Math(A) home if nargin == 0 A = [ 1 2 3; 4 9 6; 0 -5 120]; end [m,n] = size(A); if m > 1 & n> 1 flag = 0; fprintf(‘exoume pinaka !\n’) else flag

Posted in Uncategorized

GaussSeidel_aa1

function x = GaussSeidel(A,b,es,maxit) % A = coefficient matrix % b = right hand side vector % es = stop criterion (default = 0.00001%) % maxit = max iterations (default = 50) if nargin<2,error(‘at least 2 input arguments required’),end if

Posted in Uncategorized

jacobi_aa1

function [x, iflag, itnum] = Jacobi(A,b,x0,delta,max_it) % x0: initial guess % delta: error tolerance for the relative difference between two consecutive iterates % max_it: maximum number of iterations to be allowed % % iflag: 1 if a numerical solution satisfying

Posted in Uncategorized

lesson13_ear_16_17_3

d=dict() for x in range(1,16): d[x]=x**2 print(d) d = {‘Red’: 1, ‘Green’: 2, ‘Blue’: 3} for color_key, value in d.items(): print(color_key, ‘corresponds to ‘, d[color_key]) keys = [‘red’, ‘green’, ‘blue’] values = [‘#FF0000′,’#008000’, ‘#0000FF’] color_dictionary = dict(zip(keys, values)) print(color_dictionary) color_dict

Posted in Uncategorized

lesson13_ear_16_17_2

def recursive_list_sum(data_list): total = 0 for element in data_list: if type(element) == list: total = total + recursive_list_sum(element) else: total = total + element return total print( recursive_list_sum([1, 2, [3,4],[5,6]]))  

Posted in Uncategorized

lesson13_ear_16_17_1

x = 11 counter = 0 while x != 1: print x x = x / 2 counter = counter + 2 if counter > 6: break print counter print ‘new’ x = 12.5 counter = 0 while x !=

Posted in Uncategorized

lesson12_ear_16_17_2

class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self.items[len(self.items)-1] def size(self): return len(self.items) s=Stack() print(s.isEmpty()) s.push(4) s.push(‘dog’) print(s.peek()) s.push(True) print(s.size()) print(s.isEmpty()) s.push(8.4) print(s.pop()) print(s.pop())

Posted in Uncategorized

lesson12_ear_16_17_1

class Queue: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def enqueue(self, item): self.items.insert(0,item) def dequeue(self): return self.items.pop() def size(self): return len(self.items) q = Queue() print q.size() print q.isEmpty() q.enqueue(8.4) q.enqueue(18) print q.dequeue() print q.size()  

Posted in Uncategorized

lesson_10_ear_16_17

# -*- coding: utf-8 -*- “”” Use of nested lists @authors: katkaranikola stkarlos “”” def nested_list(m,n): l = [] for i in range(0,m): k = [] for j in range(0,n): x = raw_input(“give 1 number: “) k.append(float(x)) l.append(k) print l

Posted in Uncategorized

lesson11_ear_16_17

# -*- coding: utf-8 -*- “”” Created on Mon May 29 09:36:54 2017 @author: 07sta “”” from numpy import * a = array([[3,8,1],[8,4,1],[2,1,4]]) print linalg.inv(a) print linalg.eig(a) import numpy as np import matplotlib.pyplot as plt x = np.linspace(0,2*np.pi,100) y =

Posted in Uncategorized