tprak

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 825403318ee7db3d58af231dfde6a5a27f9bd52a
Author: miksa234 <milutin@popovic.xyz>
Date:   Tue,  6 Apr 2021 18:23:29 +0200

started theoretical physics praktikum done small exercise 4.3'

Diffstat:
A.ipynb_checkpoints/Untitled-checkpoint.ipynb | 6++++++
Atp43.py | 32++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/tp43.py b/tp43.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3.9 + +from sympy import * + +def main(): + p_, n, nprime = symbols('p_, n, nprime') + vr = Matrix([p_, n, nprime]) # array of variables + + p = Matrix([1, 0.8, 1.2]) # initial guess + y = Matrix([0.8, 1.2, 1, 1]) # observables + P = eye(4)*25 # inverse convariace matrix + f = Matrix(([n*p_, nprime*p_, n, nprime])) # parameters + + + for _ in range(10): + + f0 = f.subs({p_:p[0], n:p[1], nprime:p[2]}) + I0 = y - f0 + + # design matrix + A = f.jacobian(vr).subs({p_:p[0], n:p[1], nprime:p[2]}) + + dp=(A.T @ P @ A).inv() @ A.T @ P @ I0 + + p = p + dp + + cov = (A.T @ P @ A).inv() + for i in range(3): + print(f'{vr[i]}:\t {p[i]}\t\\pm {sqrt(cov[i, i])}') + +if __name__ == "__main__": + main()