## Discrete Mathematics – How to Solve a Diophantine Equation of the Form $X ^ {2} -Y ^ {2} = 2n$?

But avoid

• Make statements based on opinions; Support them with references or personal experiences.

Use MathJax to format equations. MathJax reference.

## How do I solve this in Python?

It is the game of life

My question is, how can I get the number of @ to print if I print the generations and tell myself what generation it is?
import numpy

import os

import time

def play_life(a):

xmax, ymax = a.shape

b = a.copy()

for x in range(xmax):

for y in range(ymax):

n = numpy.sum(a(max(x - 1, 0):min(x + 2, xmax), max(y - 1, 0):min(y + 2, ymax))) - a(x, y)

if a(x, y):

if n < 2 or n > 3:

b(x, y) = 0

elif n == 3:

b(x, y) = 1

time.sleep(0.5)

os.system("clear")

return(b)

life = numpy.zeros((10, 10), dtype=numpy.byte)

life(2, 1:4) = 1

life(7)=1

print(life)

while 1:

life = play_life(life)

i=0

for i in range(len(life(0))):

for j in range(len(life(0))):

if life(i)(j)==1:

print "@",

else:

print "-",

print ""

raw_input("")


## How do I solve these equations without errors?

I am a new user of mathematica 12. I have to draw real and imaginary solutions to two equations, Equation 1 and Equation 2, which contain the Dawson function. Here is my program:

f(a_) := - 2 DawsonF(a)+I Exp(-a^2) Sqrt((Pi))

eq1(x1_, y_, z_) := 1 - (z y^2/x1^2) - (1/(Sqrt(2) x1 y)) f(x1/(Sqrt(2) y))
eq2(x2_, y_) := 1 - (1/(2 y^2)) f'(x2/(Sqrt(2) y))

slo1(y_, z_) := Re(x1 /. FindRoot(eq1(x1, y, z), {x1, Sqrt(1 + z y^2)}));
slo2(y_) := Re(x2 /. FindRoot(eq2(x2, y), {x2, Sqrt(1 + y^2)}));

Plot({slo1(y, 5000), slo2(y)}, {y, 0.0001, 0.5},PlotRange -> {{0.0001, 0.5}, {0, 4}}, PlotRangePadding -> 0)


When I draw the graphics, I get these errors

General::munfl: Exp(-4.11658*10^7) is too small to represent as a normalized machine number; precision may be lost.

General::munfl: Exp(-4.11658*10^7) is too small to represent as a normalized machine number; precision may be lost.

FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

General::munfl: Exp(-4.11633*10^7) is too small to represent as a normalized machine number; precision may be lost.

General::stop: Further output of General::munfl will be suppressed during this calculation.

FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.


This means that the solutions presented are wrong. How can these bugs be fixed to get the exact solutions?

How can you draw imaginary solutions without errors?

Thanks a lot.

## Differential equations – solve nonlinear ODE analytically

But avoid

• Make statements based on opinions; Support them with references or personal experiences.

Use MathJax to format equations. MathJax reference.

## Differential equations – How to solve the natural frequency of the cantilever using mathematical methods

I would like to calculate the natural frequency of the boom using the theoretical method.

I find a contribution on how to solve the free oscillation frequency of a cantilever using the finite element method.

(*https://mathematica.stackexchange.com/questions/99724/finite-
element-boundary-breaking*)
ps = {Inactive(
Div)({{0, -((Y*ν)/(1 - ν^2))}, {-(Y*(1 - ν))/(2*(1
- ν^2)), 0}}.Inactive(Grad)(v(x, y), {x, y}), {x, y}) +
Inactive(
Div)({{-(Y/(1 - ν^2)),
0}, {0, -(Y*(1 - ν))/(2*(1 - ν^2))}}.Inactive(Grad)(
u(x, y), {x, y}), {x, y}),
Inactive(
Div)({{0, -(Y*(1 - ν))/(2*(1 - ν^2))}, {-((Y*ν)/(1
- ν^2)), 0}}.Inactive(Grad)(u(x, y), {x, y}), {x, y}) +
Inactive(
Div)({{-(Y*(1 - ν))/(2*(1 - ν^2)),
v(x, y), {x, y}), {x, y})} /. {Y -> 10^3, ν -> 33/100}

{vals, funs} =
NDEigensystem({ps}, {u, v}, {x, y} ∈
Rectangle({0, 0}, {5, 0.25}), 8)
theory = {0, 0, 0, 22/L^2 Sqrt((Y d^2)/(12 1)),
61.7/L^2 Sqrt((Y d^2)/(12 1)), 121/L^2 Sqrt((Y d^2)/(12 1)),
200/L^2 Sqrt((Y d^2)/(12 1)), π/L Sqrt(Y/1.)} /. {Y -> 10^3,
d -> 0.25, L -> 5}
TableForm(Transpose({Sqrt(Abs(vals)), theory}),
bcs = DirichletCondition({u(x, y) == 0, v(x, y) == 0}, x == 0);

{vals, funs} =
NDEigensystem({ps, bcs}, {u, v}, {x, y} ∈
Rectangle({0, 0}, {5, 0.25}), 5);
theory = {3.52 Sqrt((Y d^2)/(12 L^4)), 22 Sqrt((Y d^2)/(12 L^4)),
61.7 Sqrt((Y d^2)/(12 L^4)), π/2 Sqrt(Y/L^2),
121 Sqrt((Y d^2)/(12 L^4))} /. {Y -> 10^3, d -> 0.25, L -> 5.};
TableForm(Transpose({Sqrt(Abs(vals)), theory}),
Needs("NDSolveFEM")
mesh = funs((1, 1))("ElementMesh");
Column(Table(uif = funs((n, 1));
vif = funs((n, 2));
dmesh =
ElementMeshDeformation(mesh, {uif, vif}, "ScalingFactor" -> 0.1);
Show({mesh("Wireframe"),
dmesh("Wireframe"(
"ElementMeshDirective" ->
Directive(EdgeForm(Red), FaceForm())))}), {n, 5}))


But I would like to know how to solve the natural frequency of the model in the above article using the method for solving the partial differential equation.

How do you find the eigenvalues ​​of a PDE (Dynamic Euler-Bernoulli Beam)?

Inhomogeneous dynamic Euler-Bernoulli beam equation with discontinuous parameters

Analytical solution of the dynamic Euler-Bernoulli beam equation with compatibility condition

## parametric functions – problem: solve system of equations

I am trying to solve a "simple" system of equations for a theoretical-formal model that I am developing. Although I believe I have specified the system correctly, I have not yet been able to find a solution. Is it a problem with so many parameters? Can somebody help me with it?

Solve({A1*A2*y - A3*y - A4 - A5*((1/A6)^(1-A7))*((x*A8 + A9)^(A10)) + A11*((A6)^(-A12))*((y*A13)^(A14)) == 0, A15*A16*x - A17*x -A19 - A18*A6+ A5*((1/A6)^(1-A7))*((x*A8 + A9)^(A10)) - A11*((A6)^(-A12))*((y*A13)^(A14)) == 0, 00, A2>0,A3>0,A4>0,A5>0,A6>0,A7>0,A8>0,A9>0,A10>0,A11>0,A12>0,A13>0,A14>0,A15>0,A16>0,A17>0, A18>0, A19>0}, {x,y})


Thank you very much!

## script – How to create and solve a bip199 htlc with python-bitcoinlib

When I play with this script, I want to understand how to create and redeem a bip199 htlc. However, this script fails on the OP_EQUALVERIFY and I can’t understand why.

import bitcoin
import bitcoin.rpc
from bitcoin import SelectParams
from bitcoin.core import b2x, lx, b2lx, COIN, COutPoint, CMutableTxOut, CMutableTxIn, CMutableTransaction, Hash160
from bitcoin.core.script import CScript, OP_DUP, OP_IF, OP_ELSE, OP_ENDIF, OP_HASH160, OP_EQUALVERIFY, OP_CHECKSIG, SignatureHash, SIGHASH_ALL
from bitcoin.core.script import OP_DROP, OP_CHECKLOCKTIMEVERIFY, OP_SHA256, OP_TRUE
from bitcoin.core.scripteval import VerifyScript, SCRIPT_VERIFY_P2SH

import hashlib
from hashlib import sha256

SelectParams('regtest')
proxy = bitcoin.rpc.Proxy()

preimage = bytes(b'preimage'.hex(), 'utf8')
h = sha256(preimage).digest()

seckey = proxy.dumpprivkey(recipientpubkey)

lockduration = 10
blocknum = proxy.getblockcount()
redeemblocknum = blocknum + lockduration

txin_redeemScript = CScript((
OP_IF,
OP_SHA256, h, OP_EQUALVERIFY,OP_DUP, OP_HASH160, recipientpubkey,
OP_ELSE,
redeemblocknum, OP_CHECKLOCKTIMEVERIFY, OP_DROP, OP_DUP, OP_HASH160, bytes(Hash160(seckey.pub)),
OP_ENDIF,
OP_EQUALVERIFY, OP_CHECKSIG
))

txin_scriptPubKey = txin_redeemScript.to_p2sh_scriptPubKey()

amount = 1.0*COIN

txinfo = proxy.gettransaction(fund_tx)
details = txinfo('details')(0)
vout = details('vout')

txin = CMutableTxIn(COutPoint(fund_tx, vout))

default_fee = 0.001*COIN
txout = CMutableTxOut(amount - default_fee, recipientpubkey.to_scriptPubKey())

tx = CMutableTransaction((txin), (txout))

sighash = SignatureHash(txin_redeemScript, tx, 0, SIGHASH_ALL)

sig = seckey.sign(sighash) + bytes((SIGHASH_ALL))

txin.scriptSig = CScript((sig, seckey.pub, preimage, preimage, txin_redeemScript))

VerifyScript(txin.scriptSig, txin_scriptPubKey, tx, 0, (SCRIPT_VERIFY_P2SH,))

txid = proxy.sendrawtransaction(tx)



## Azure SQL database – How to solve parameter sniffing problem in a query with the & # 39; operator in & # 39;

I have a problem with parameter sniffing Azure SQL Server Query with in Operator:

    Select Col1, Col2, ..., Coln from T1 Join T2
On T1.Id = T2.T1Id
Where T2.Col2 in ('uniqueIdentifier_1','uniqueIdentifier_2',..., 'uniqueIdentifier_m')


I have about 30-40 unique identifiers in the where clause. And I can't replace them because they are primary keys from another table in another Azure SQL Database. As you can see, there are a number of different unique identifiers and it is difficult to match them.
Would you please guide me to solve a parameter sniff problem?

## Calculation – Does this algorithm, which ended in "P-time", solve the Hamilton cycle problem?

I think I have discovered an algorithm that can solve the Hamilton cycle problem in P time and ask for help to find out if I made a mistake as this is such a big claim and my solution is so easy is that I can only wonder if this is correct or if this is a serious mistake. I apologize if this is a mistake on my part.

My main approach is to expand the theory of calculating Turing machines by adding a new property to the Turing machine in which it "reproduces" itself at every time step.

Guess:
The theory of self-reproducing Turing machines can solve NP-complete problems in P-time, but this is not possible without the self-replication function

I claim that the theory of self-reproducing machines is a more general calculation theory, which is Turing Complete and contains Turing machines as a special case. Hopefully the definition should be clear. A self-reproducing machine is defined as a Turing machine that replicates itself at every time step

Hamiltonian cycle problem algorithm:
To let $$G$$ be a graph with a finite number of vertices and edges. I will now show the algorithm that is completed in P-time. Go to the number of vertices $$N$$.

Start Algorithm – (EDIT: Some comments said that this is a "non-deterministic Turing machine". This algorithm cannot easily be made random by simply labeling each vertex and edge with ordered numbers and then in a fully deterministic order from lowest to highest number, I will leave the question unprocessed for now)

1. Pick any vertex and place a self-reproducing machine on that vertex.

Rules: At each time step of the unit, the self-reproducing machines all replicate a single new copy of themselves that appears on a random adjacent vertex that is connected by an edge to the vertex of the machine that has just replicated itself. The algorithm exits under two conditions: first, if one of the machines tries to replicate itself to another vertex that already has a machine on it (this would mean that there is a cycle), or if there are no edges from the vertex machine is present If a connection is made to an unused vertex, the computer does not replicate itself

If none of the machines replicates itself during a certain time step, the algorithm ends

1. Follow the time one step, then another step, etc., and follow the rules described above until the algorithm is complete

Claim: This algorithm is completed in polynomial time.

Proof: Since the growth of self-reproducing machines is exponential, there will be first order at step T. $$2 ^ T$$ from them. Write $$N = 2 ^ {log_2N}$$we see that the algorithm will be finished when $$T> = log_2N$$. Which is an algorithm that is completed in P time.

## dnd 5e – Players are frustrated when they fail to solve a tough diplomatic problem of how to get them to think outside the box

Problem:

Players got into a diplomatic problem that they know is likely to be above their salary level in terms of difficulty. They spent one session figuring out this problem by speaking to people and performing various charisma checks to convince people they were unlikely to have a business with (roles were average, arguments were not particularly convincing). The party had no big plans, no extraordinary strategies, no clever ideas on site, but tried a very simple head-first dialogue.

This has happened in the past in relation to the fight, and the party had to think outside the box on a recent fatal encounter (one player even said, "Guys, we have to plan more and think less about it, sometimes just hacking and to cut up. "") Now it's a more diplomatic problem that doesn't seem to be as easy as doing a single charisma check and hoping it works.

In the end, the party failed to solve the diplomatic problem (although there will be room to try again with the upper hand in the future), and one of the players said they had not enjoyed the session. Player enjoyment is my top priority. But I also think dnd is best when there is risk, when you can roll the dice, when the PCs don't always win (not that I am actively looking for it).

How can I get the party to act less linearly on dialog related issues?

An example problem:

P: When you try to make a bad person with a lot of influence in the city smart

ON: There are ways to accuse the person, bribe people, spot them to find their weakness, tarnish their reputation, prove their wrongdoing by looking for evidence, and a number of other ways.

I tried to have a short session 0 discussion again about whether they would like to have problems related to the dialogue and they didn't seem to accept it but felt like they tried everything and didn't know what else to do. I also post-mortemed this issue and tried to provide various options that they could have tried, but I feel that the players still feel they have tried and failed and the session was "a waste" (although they're still exp, I still have loot and more action.

A bit of a clue as to how to address this issue, not just "Watch some podcasts for ideas, or read the X, Y, and Z resources on the subject."