math

Nullcline Plot for Nonlinear System of ODEs

孤人 提交于 2020-01-25 11:12:06
问题 I am attempting to plot the nullcline (steady state) curves of the Oregonator model to assert the existence of a limit cycle by applying the Poincare-Bendixson Theorem. I am close, but for some reason the plot that is produced shows two straight lines. I think it has something to do with the plotting stage. Any ideas? Also any hints for how to construct a quadrilateral to apply the theorem with would be most appreciated. Code: import numpy as np import matplotlib.pyplot as plt # Dimensionless

Next permutation in lexicographic order n k

孤街醉人 提交于 2020-01-25 10:11:48
问题 I'm want to write function that returns next permutation in lexicographic order n choose k. So far I found following algorithm class Permutation { public function swap(& $a, $first, $second) { $tmp = $a[$first]; $a[$first] = $a[$second]; $a[$second] = $tmp; } function nextPermutation(& $a, $n, $k) { do { $first = $n - 2; while ($first != -1 && $a[$first] >= $a[$first + 1]) $first--; if ($first == -1) return false; $second = $n - 1; while ($a[$first] >= $a[$second]) $second--; $this->swap($a,

Next permutation in lexicographic order n k

梦想与她 提交于 2020-01-25 10:10:11
问题 I'm want to write function that returns next permutation in lexicographic order n choose k. So far I found following algorithm class Permutation { public function swap(& $a, $first, $second) { $tmp = $a[$first]; $a[$first] = $a[$second]; $a[$second] = $tmp; } function nextPermutation(& $a, $n, $k) { do { $first = $n - 2; while ($first != -1 && $a[$first] >= $a[$first + 1]) $first--; if ($first == -1) return false; $second = $n - 1; while ($a[$first] >= $a[$second]) $second--; $this->swap($a,

Is there an “inverted” trunc function in C or C++? [duplicate]

亡梦爱人 提交于 2020-01-25 07:57:11
问题 This question already has answers here : c++ rounding of numbers away from zero (5 answers) Closed 8 hours ago . Is there a function in C or C ++ - similar to trunc - that rounds off negative numbers and rounds up positive numbers? Like in this example: -3.3 to -4 or 2.1 to 3 I could only find the "inverse" function trunc. But can hardly believe that this does not exist. Do I really have to first query the positivity via if and then round it up accordingly? I need this because I have the sign

Finding the nth number of primes

倾然丶 夕夏残阳落幕 提交于 2020-01-25 07:39:25
问题 I can not figure out why this won't work. Please help me from math import sqrt pN = 0 numPrimes = 0 num = 1 def checkPrime(x): '''Check\'s whether a number is a prime or not''' prime = True if(x==2): prime = True elif(x%2==0): prime=False else: root=int(sqrt(x)) for i in range(3,root,2): if(x%i==0): prime=False break return prime n = int(input("Find n number of primes. N being:")) while( numPrimes != n ): if( checkPrime( num ) == True ): numPrimes += 1 pN = num print("{0}: {1}".format

How do I determine whether a 3-dimensional vector is contained within the acute region formed by three other vectors?

孤街醉人 提交于 2020-01-24 22:07:54
问题 I'm working on a project in C# where I have three vectors in R3, and I need to find out if a third vector is contained within the region formed by those vectors. The three basis vectors have a maximum angle of 90 degrees between any two of them, and they are all normalized on the unit sphere. They can be negative. So far, I've tried matrix-vector multiplication to find the transformed coordinates of the vector. From there, I check whether all three components are positive. This method works

How do I determine whether a 3-dimensional vector is contained within the acute region formed by three other vectors?

青春壹個敷衍的年華 提交于 2020-01-24 22:07:33
问题 I'm working on a project in C# where I have three vectors in R3, and I need to find out if a third vector is contained within the region formed by those vectors. The three basis vectors have a maximum angle of 90 degrees between any two of them, and they are all normalized on the unit sphere. They can be negative. So far, I've tried matrix-vector multiplication to find the transformed coordinates of the vector. From there, I check whether all three components are positive. This method works

Finding size of rotated image to match top-line based on angle

落爺英雄遲暮 提交于 2020-01-24 22:07:09
问题 (illustration for reference: https://i.stack.imgur.com/Wsge0.png) Code example https://jsfiddle.net/waaentz/htrqdwjp/9/ const width = 1000; const height = 100; const canvas = document.createElement("canvas"); const stage = new createjs.Stage(canvas); const img = new Image(); const bitmap = new createjs.Bitmap(img); const baseGrid = new createjs.Shape(); const angle = 45; // Is dynamic const magicScaleFormular = 1.39 // Find scale based on height and angle img.src = getBase64(); img

Finding size of rotated image to match top-line based on angle

微笑、不失礼 提交于 2020-01-24 22:07:06
问题 (illustration for reference: https://i.stack.imgur.com/Wsge0.png) Code example https://jsfiddle.net/waaentz/htrqdwjp/9/ const width = 1000; const height = 100; const canvas = document.createElement("canvas"); const stage = new createjs.Stage(canvas); const img = new Image(); const bitmap = new createjs.Bitmap(img); const baseGrid = new createjs.Shape(); const angle = 45; // Is dynamic const magicScaleFormular = 1.39 // Find scale based on height and angle img.src = getBase64(); img

Find the arc of the intersection between circle and rectangle

末鹿安然 提交于 2020-01-24 21:08:44
问题 I need to find the largest arc created from the intersection of a circle and a rectangle. I have the center of the circle, the radius and the coordinates of the rectangle, and I need to find the angle of the intersection points with the center of the circle. I have a code that works, but it computes the solution iterating the points of the circumference, and I was wondering if there's a more elegant way to calculate the solution using trigonometry instead of "brute force". That's my code: