From 335927a157ded9d5371b06df9084280a19643c77 Mon Sep 17 00:00:00 2001 From: nandard Date: Sat, 10 Sep 2022 15:53:36 +0700 Subject: [PATCH] Edit denumerator --- 442385_Nanda_Sisken_Assign_3.ipynb | 88 ++++++++++++++++++------------ README.md | 46 ++++++++-------- 2 files changed, 77 insertions(+), 57 deletions(-) diff --git a/442385_Nanda_Sisken_Assign_3.ipynb b/442385_Nanda_Sisken_Assign_3.ipynb index 212dde0..dddfa3e 100644 --- a/442385_Nanda_Sisken_Assign_3.ipynb +++ b/442385_Nanda_Sisken_Assign_3.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 132, + "execution_count": 1, "metadata": { "id": "aDtFkeqAvLX2" }, @@ -15,7 +15,7 @@ }, { "cell_type": "code", - "execution_count": 133, + "execution_count": 4, "metadata": { "id": "Letb52yp47Gb" }, @@ -46,8 +46,12 @@ "\n", " for i in range(2, height+2):\n", " for j in range(height-1):\n", - " arr[i][j] = (arr[i-1][0]*arr[i-2][j+1] - arr[i-2][0]*arr[i-1][j+1])/arr[i-1][0]\n", + " arr[i][j] = (arr[i-1][0]*arr[i-2][j+1] - arr[i-2][0]*arr[i-1][j+1])\n", " arr[i][j] += 0\n", + " try:\n", + " arr[i][j] /= arr[i-1][0]\n", + " except ZeroDivisionError:\n", + " arr[i][j] = 0\n", " \n", " self.df = pd.DataFrame(arr)\n", " self.show_tab()\n", @@ -82,27 +86,27 @@ }, { "cell_type": "code", - "execution_count": 134, + "execution_count": 5, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Je19fGrvtOu4", - "outputId": "c99b1159-f745-4c3f-c012-c2f464b8edb0" + "outputId": "bcf1f997-2fa1-4838-eac7-3aa5156d4a43" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Enter your polynomial: 1 2 3 4 5\n", - "Enter your K: 6\n", - " 0 1 2\n", - "0 1.0 3.0 5.0\n", - "1 2.0 4.0 6.0\n", - "2 1.0 2.0 0.0\n", - "3 0.0 3.0 0.0\n", - "4 -2.0 0.0 0.0\n", + "Enter your polynomial: 1 3 5 7\n", + "Enter your K: 9\n", + " 0 1 2\n", + "0 1.000000 5.0 9.0\n", + "1 3.000000 7.0 0.0\n", + "2 2.666667 9.0 0.0\n", + "3 -3.125000 0.0 0.0\n", + "4 9.000000 -0.0 0.0\n", "SYSTEM IS UNSTABLE\n" ] } @@ -119,28 +123,28 @@ }, { "cell_type": "code", - "execution_count": 136, + "execution_count": 6, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "kFgcxNcscafI", - "outputId": "25aadcc4-6a29-4c16-c992-46d95a56cbfb" + "outputId": "e67322ca-5a85-4434-a690-655b07c9404a" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Enter your polynomial: 12 56 37 80\n", - "Enter your K: 17\n", - " 0 1 2\n", - "0 12.0 37.0 17.0\n", - "1 56.0 80.0 0.0\n", - "2 556.0 476.0 0.0\n", - "3 8912.0 0.0 0.0\n", - "4 2121056.0 0.0 0.0\n", - "SYSTEM IS STABLE\n" + "Enter your polynomial: 11 15 19 21\n", + "Enter your K: 29\n", + " 0 1 2\n", + "0 11.000000 19.0 29.0\n", + "1 15.000000 21.0 0.0\n", + "2 3.600000 29.0 0.0\n", + "3 -99.833333 0.0 0.0\n", + "4 29.000000 -0.0 0.0\n", + "SYSTEM IS UNSTABLE\n" ] } ], @@ -156,26 +160,26 @@ }, { "cell_type": "code", - "execution_count": 137, + "execution_count": 7, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "jaif_A4_hfeJ", - "outputId": "0b387e7e-efbf-4f5c-fb45-d98489bbba3e" + "outputId": "a231e081-6ff2-4e13-db18-759225fcd948" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Enter your polynomial: 1.2 6.81 7.31\n", + "Enter your polynomial: 1.2 6.78 11.11\n", "Enter your K: 3.141\n", - " 0 1\n", - "0 1.20 7.310\n", - "1 6.81 3.141\n", - "2 23.00 0.000\n", - "3 36.00 0.000\n", + " 0 1\n", + "0 1.200000 11.110\n", + "1 6.780000 3.141\n", + "2 10.554071 0.000\n", + "3 3.141000 0.000\n", "SYSTEM IS STABLE\n" ] } @@ -189,6 +193,15 @@ "rs.set_k(k_in)\n", "rs.calc_routh()" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "SjkQCR9chk6P" + }, + "outputs": [], + "source": [] } ], "metadata": { @@ -197,11 +210,18 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3.8.10 64-bit", + "language": "python", "name": "python3" }, "language_info": { - "name": "python" + "name": "python", + "version": "3.8.10" + }, + "vscode": { + "interpreter": { + "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" + } } }, "nbformat": 4, diff --git a/README.md b/README.md index 0599caa..d2f6212 100644 --- a/README.md +++ b/README.md @@ -92,39 +92,39 @@ rs.calc_routh() ``` It takes coefficient of polynomial and K from user, insert it into ```RouthStability``` class as constructor parameter, insert the K value, and generate Routh Table. The result can be found below: ``` -Enter your polynomial: 1 2 3 4 5 -Enter your K: 6 - 0 1 2 -0 1.0 3.0 5.0 -1 2.0 4.0 6.0 -2 1.0 2.0 0.0 -3 0.0 3.0 0.0 -4 -2.0 0.0 0.0 +Enter your polynomial: 1 3 5 7 +Enter your K: 9 + 0 1 2 +0 1.000000 5.0 9.0 +1 3.000000 7.0 0.0 +2 2.666667 9.0 0.0 +3 -3.125000 0.0 0.0 +4 9.000000 -0.0 0.0 SYSTEM IS UNSTABLE ``` ## Testing 2 ``` -Enter your polynomial: 12 56 37 80 -Enter your K: 17 - 0 1 2 -0 12.0 37.0 17.0 -1 56.0 80.0 0.0 -2 556.0 476.0 0.0 -3 8912.0 0.0 0.0 -4 2121056.0 0.0 0.0 -SYSTEM IS STABLE +Enter your polynomial: 11 15 19 21 +Enter your K: 29 + 0 1 2 +0 11.000000 19.0 29.0 +1 15.000000 21.0 0.0 +2 3.600000 29.0 0.0 +3 -99.833333 0.0 0.0 +4 29.000000 -0.0 0.0 +SYSTEM IS UNSTABLE ``` ## Testing 3 ``` -Enter your polynomial: 1.2 6.81 7.31 +Enter your polynomial: 1.2 6.78 11.11 Enter your K: 3.141 - 0 1 -0 1.20 7.310 -1 6.81 3.141 -2 23.00 0.000 -3 36.00 0.000 + 0 1 +0 1.200000 11.110 +1 6.780000 3.141 +2 10.554071 0.000 +3 3.141000 0.000 SYSTEM IS STABLE ``` ### Notes