stochastic calculus – Solving an Ornstein-Uhlenbeck style SDE

Solve the SDE $frac{dN}{dt}=a N log(frac MN)+sigma NdB_t,$ where $M,a in mathbb{R}$.

Apply Ito’s formula to $ f = log(N)$ gives

begin{align*}
df &= frac{partial f}{partial N} dN +frac{1}{2}frac{partial ^2 f}{partial N^2} dlangle Nrangle_t\
&= left(frac{partial f}{partial N}aNlogleft(frac MNright) +frac{sigma^2}{2}frac{partial ^2 f}{partial N^2} right)dt + frac{partial f}{partial N}sigma dB_t\
&=a logleft(frac {M}{N}right)dt+sigma dB_t – frac{sigma^2}{2}dt\
&=left(alog(M) – af -frac{sigma^2}{2}right)dt – sigma dB_t
end{align*}

which looks like an Ornstein-Uhlenbeck SDE. How can I proceed from here?

equation solving – FindRoot blocked by Jacobian in multi-valued function

Clear(t, r, z)
c = 1; gam = 1.; tm = 16.;
r(t_) = 2 c ArcTanh(Tan(t/(2 Sqrt(1 - Cot(gam)^2)))); 
z(t_) = r(t) Cot(gam);
plr = PolarPlot(r(t), {t, 0, tm}, GridLines -> Automatic, 
  PlotStyle -> {Blue, Thick})
rad = Plot(r(t), {t, 0, tm}, GridLines -> Automatic, 
  PlotStyle -> {Red, Thick})
pp3 = ParametricPlot3D({r(t) Cos(t), z(t), r(t) Sin(t)}, {t, -tm, tm},
   PlotStyle -> {Magenta, Thick})
FindRoot(r(t) = 1.25, {t, 1.2345})

The last line FindRoot does not work due to Jacobian singularity. Can there be some work around? Thanks for help.

differential equations – Solving pde in mathematica

I want to solve a pde of the form

$frac{partial}{partial x}left(C1(x,y)u(x,y)right)+frac{partial}{partial y}left(C2(x,y)u(x,y)right)+frac{partial^2}{partial x^2}left(C3(x,y)u(x,y)right)+frac{partial^2}{partial x partial y}left(C4(x,y)u(x,y)right)+frac{partial^2}{partial y^2}left(C5(x,y)u(x,y)right)=0$, with no-flux boundary conditions (derivative is 0 on the boundary), on the trinagular domain $x+yleq1$.

I’m struggling a lot with getting this into mathematica.

What I’ve got so far is included below

g = 0.15;
a = 0.2;
b = 0.2;
NN = 1500;
C1(x, y) = -2 a*x + 2 a*x^2 + g*g + a*x*y;
C2(x, y) = 2 g + (2 a - 2 g)*x - 2 a*x^2 - (a + b + 3 g)*y - 2 a*x*y - (a/2)*y^2;
C3(x, y) = 2 a*x - 2 a*x^2 + g*y - a*x*y;
C4(x, y) = C3(x, y);
C5(x, y) = 2 g - 2 a*x^2 + (a + b - g)*y - (a/2)*y^2 + (2 a - 2 g)*x - 2 a*x*y;
uval = NDSolveValue({D(C1(x, y)*u(x, y), x) + D(C2(x, y)*u(x, y), y)
 + (1/(2 NN))*D(C3(x, y)*u(x, y), x, x) - (1/NN)*D(C4(x, y)*u(x, y), x, y)
 + (1/(2*NN))*D(C5(x, y)*u(x, y), y, y) == 0, 
u(x, 1) == 1, u(x, 0) == u(0, y) == u(x, 1 - y) == 0}, {x, 0, 1}, {y, 0, 1 - x});

This alone tells me that I have more dependent variables than equations, so the system is undetermined. In the above, I’ve just implemented dirichlet boundary conditions as I’m struggling to understand how to put in neumann conditions (even after reading the documentation). Any help would be much appreciated!

Solving the Knapsack problem in $O(n^2P)$, where P is the maximum weight of all items

Assume for the regular knapsack problem we have additional information – maximal weight of every item – lets denote it as P. Using this information, I want to solve the problem using dynamic programming in $O(n^2P)$.
Anyone have an idea how to solve it?

Understanding the usage of lemma 16 on pg.47 (in Royden “Real analysis”) in solving a problem.

Here is the I want to answer:

Define $E = {x in (0,1) : |x – frac{p}{q}| < q^{-3} text{ for infinitely many } p,q in mathbb{N} }.$ Prove that $m(E) = 0.$

My thoughts are:

1-I was thinking about using the fact that: Any countable set is measurable. But I do not know how to give a rigorous proof that the given set $E$ is countable. Could anyone help me in doing so?

2- Also I was having an idea of using lemma 16 on pg.47 (in Royden “Real analysis”) which states that:

Let $E$ be a bounded measurable set of real numbers. Suppose there is a bounded, countably infinite set of real numbers $Lambda$ for which the collection of translates of $E, {lambda + E }_{lambda in Lambda},$ is disjoint. Then $m(E) = 0.$

But I do not know how to use this. And I am guessing that we can not use this lemma here in our question as my set $E$ is unbounded (I am not sure from this. Am I correct?). Also, I do not know if there is a bounded, countably infinite set of real numbers $Lambda$ for which the collection of translates of $E, {lambda + E }_{lambda in Lambda},$ is disjoint.

Also, in the statement of the lemma 16, I am not sure why we need $Lambda$ to be bounded. Could anyone explain this to me, please?

Could anyone help me in refining my thoughts and telling me what is correct and what is wrong and also, help me prove my question?

equation solving – Cannot get conditional Take[…] from List[…] to work inside a user-defined function

Abstract I have a function eqsfromMatrix(...) that does exactly as it sounds. It returns a list of equations given matrix m for different augmented vectors in b so that eqs = m.vars == b. It takes last few letters in alphabet to form the variables i.e. {x, y, z}. If b not supplied but set to b = 1 in arguments it takes the first few letters in alphabet to form scalers b = {a,b,c} or if b set in arguments as b = 0 it will supply list of zeroes b = {0, 0, 0,...}. It starts using letters for variables where I set a pivot which is a desired soft start point “x”.

Problem is it won’t work if the length of the matrix m is longer than the position of the pivot in the supplied alphabet.

About the Code If using m1 and b1 and I replace vars = Take(abc, {start(m), end(m)}); with vars = Take(abc, {23, 26}); it works just fine.

What am I doing wrong?

eqsfromMatrix(mat_, b_ : None, piv_ : "x") := 
 Module({len, abc, pivot, diff, vars, scals, eqs},
  len = Length(mat);
  abc = Alphabet();
  pivot = Flatten(Position(abc, piv))((1)); (* desired soft start point at x returns 24 *)
  start(m_) := pivot /; len <= 3;
  start(m_) := Length(abc) - len + 1;
  end(m) = start(m) + len - 1;
  vars = Part(abc, {start(m), end(m)});
  eqs = mat.vars;
  scals = 
   Switch(b, None, Return(eqs), _List, b, 1, Take(abc, {1, len}), 0, 
    Table(0, len));
  Table(eqs((i)) == scals((i)), {i, 1, len})
  )

ClearAll(m1,m2,b1,b2)
m1 = {{1, 0, 1, 3}, {-1, 3, 2, 1}, {3, 2, 4, 5}, {8, 3, 5, 3}};
b1 = {-1, 3, 2, 4};(* m1, b1 work , length is longer than pivot position from end of alphabet *)
m2={{1,2},{3,2}} 
b2={1,-2}(* m2, b2 work, length is shorter than pivot position from end of 
eqsfromMatrix(m1) (* dont work *)
eqsfromMatrix(m1,b1) (* dont work *)
eqsfromMatrix(m1,1) (* dont work *)
eqsfromMatrix(m1,0) (* dont work *)
eqsfromMatrix(m2) (* works *)
eqsfromMatrix(m2,b2) (* works *)
eqsfromMatrix(m2,1) (* works *)
eqsfromMatrix(m2,0) (* works *)

Numerically solving integro-differential PDE

I’ve got equation (boltzmann-type) on the function $f = f(t,x,y)$
$$frac{{partial f}}{{partial t}} – frac{partial }{{partial x}}(a(x){ c(x) cdot y + b(x)} cdot f) – frac{partial }{{partial y}}{ (1 – {y^2})(frac{{c(x) cdot f}}{{alpha (x)}} + a(x)beta (x)frac{{partial f}}{{partial y}})} = S$$
where
$$S = k cdot intlimits_{gamma (x)}^{ + infty } {(a(xi )varphi (x,xi )intlimits_{ – 1}^1 {f(t,xi ,eta )deta } } )$$
with boudary condition
$$a(x){ c(x) cdot y + b(x)} cdot f(t,{x_{min }},y) = 0$$
$$a(x){ c(x) cdot y + b(x)} cdot f(t,{x_{max }},y) = 0$$
$${left. {frac{{(1 – {y^2})c(x)}}{{alpha (x)}}f(t,x,y) + (1 – {y^2})a(x)beta (x)frac{{partial f}}{{partial y}}} right|_{y = pm 1}} = 0$$
(the last one is true all time)
and some initial condition
$$f(0,x,y) = psi (x,y)$$
I think it doesn’t really matter what it’s physical meaning, but is there a way to solve this type of equations in Wolfram Mathematica? We’ve got an algorithm on C++, but I think it’s realisation in mathematica is not the best way.

equation solving – Help me please!

Thanks for contributing an answer to Mathematica Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

equation solving – Finding analytic expression with replacement rules

I have a function defined as

f(k_):= Maximize({(x^2/(1+x^2))((1-x^(2k))/(1+x^(2k+1)))^2, 0 <= x <= 1}, x)

I would like to find an analytic form of $f$ as a function of $k$.

Differentiating the argument of the Maximize in $f$ with respect to $x$, I obtain the condition:

1+x^(3+4k) - x^(2k)(1+x)(x^2(1+2k)- x + (1+2k)) == 0

Is there a way I can write a replacement rule in Mathematica to substitute the above condition on $x$, and get $f$ as a function of $k$ alone?

reference request – Solving multilinear equations

Let $N={1,2,ldots,n}$. Suppose we are given $n$ equations, with each equation taking the form $sum_{Asubseteq N}left(c_A prod_{iin A}x_i right) = 0$, where each $c_A$ is a real number constant. (So each equation contains at most $2^n$ terms.) An example for $n=3$ is:

$$2x_1x_2x_3 – 4x_1x_2+5x_3+2=0$$

$$7x_1x_3 – 6x_2-4=0$$

$$-x_1x_2x_3 + x_1 – 2x_2 +9 = 0$$

We want to find a solution $(x_i)_{iin A}$ such that $0leq x_ileq 1$ for all $i$ (assuming we know such a solution exists). Is there a known algorithm to do this?

I searched for terms like “multilinear equations”, but could not find anything relevant.