Categories
Ask Mathematics

Complex number proof involving angles

I need to show that (3 + i)^3 = 18 + 26i and use this to show that the angle AOC = 3AOB, where O, A, B, C are points in the plane given by O = (0, 0), A = (1, 0), B = (3, 1) and C = (18, 26). This is what […]

Categories
Ask Mathematics

Algorithm: Counting elements of Polyomino coverings

Given a set of free Polyominoes $\mathcal{P}$ (translation, flipping and rotating of pieces is allowed) and a test shape $S$ that is also a valid Polyomino, I am trying to find an algorithm $f(S, \mathcal{P}) : S \times \mathcal{P} \to (\mathcal{P}, \mathbb{N})$ that counts the number of times entries in $\mathcal{P}$ are used to generate […]

Categories
Ask Mathematics

Algorithm: Counting elements of Polyomino coverings

Given a set of free Polyominoes $\mathcal{P}$ (translation, flipping and rotating of pieces is allowed) and a test shape $S$ that is also a valid Polyomino, I am trying to find an algorithm $f(S, \mathcal{P}) : S \times \mathcal{P} \to (\mathcal{P}, \mathbb{N})$ that counts the number of times entries in $\mathcal{P}$ are used to generate […]

Categories
Development

how to open jupyter widget in a separate window

%matplotlib qt from ipywidgets import interact, interactive, fixed, interact_manual import ipywidgets as widgets import matplotlib.pyplot as plt import numpy as np def f(m, b): plt.figure(2) x = np.linspace(-10, 10, num=1000) plt.plot(x, m * x + b) plt.ylim(-5, 5) plt.show() interactive_plot = interactive(f, m=(-2.0, 2.0), b=(-3, 3, 0.5)) interactive_plot This just plots all the lines in […]

Categories
Development

How do I add a second plot behind the first one in matplotlib.pyplot? It’s either on top or invisible

I want to make a bar graph showing current measurements compared to a one-month moving average, by placing blue bars for current data (‘a’) on top of slightly wider grey bars for the one-month average (‘b’). Here is the simplest version of my code: import matplotlib.pyplot as plt import pandas as pd import numpy as […]

Categories
Development

how do i destructure an object only when key is present

how do I destructure an object only when key is present in the object or should I say destructuring using conditionals const arts = { a: 23, b: 3, c: 5} const {a, d} = arts console.log(d) // result produces an error on execution I want a code where “d” won’t be destructured if it’s […]

Categories
Development

Insert parent/child via stored procedure into a Postgresql

I have sample made up structure { parent: { children: [ { a: “a”, b: 1, c: 2 }, { a: “b”, b: 3, c: 4 } … ] } } How to insert it via single stored procedure call into 2 postgresql tables? I figured out 3 options: 1) Hstore, but it’s a string/string […]

Categories
Development

Function does not return any errors, but does not work once I edited the code

So the task is : 1. If the argument c is passed and it is a function, it is executed after calling the sum function. 2. The function f must return the result of the function of argument c, if any, or the result of the function sum. Here is my code. function c(){ return […]

Categories
Development

Function does not return any errors, but does not work once I edited the code

So the task is : 1. If the argument c is passed and it is a function, it is executed after calling the sum function. 2. The function f must return the result of the function of argument c, if any, or the result of the function sum. Here is my code. function c(){ return […]

Categories
Development

Python Dict Sorting based on values and Key [closed]

Sort Dict based on values desc but also consider alphabetical order for same values {‘a’: 2, ‘b’: 3, ‘c’: 2, ‘d’: 1, ‘e’: 1}