Are the following Mathematica codes correct for solving wave equation PDE?

I wanna solve the following PDE of wave equation using Mathematica.

$ u_{tt}=u_{xx}$

$ 0<x<\pi , t>0$

Initial Conditions:

$ \begin{cases}u(x,0)=sin(x) \u_{t}(x,0)=1\end{cases}$

Boundary Conditions:

$ \begin{cases}u(0,t)+u_{x}(0,t)=1\u(\pi,t)+u_{x}(\pi,t)=-1\end{cases}$

  • I know the boundary and initial conditions are inconsistent.

Are the following codes correct?

weqn = D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}]; ic = {u[x, 0] == Sin[x],Derivative[0, 1][u][x, 0] == 1 }; bc = {u[0, t] + Derivative[1, 0][u][0, t] == 1,     u[Pi, t] + Derivative[1, 0][u][Pi, t] == -1}; sol = NDSolve[{weqn, ic, bc}, u, {x, 0, Pi}, {t, 0, 10}]; 

PC Problem Solving and repair Online for $15

I can assist you with most of you IT Related problems from issues with word email setup problem solving , intalling software and removal of viruses I will Strive to assist as quickly as possible and if the problem is not resolved there will only be a small fee for time spent . I have 16 years of experience in the IT services and am confident that i will be able to assist

by: Misterwizard
Created: —
Category: Virtual Assistant
Viewed: 89


Solving a difficult differential equation

Well, I’ve to solve the following DE:

$ $ y(t)=x(t)\cdot\text{a}+\text{b}\cdot\ln\left(1+\frac{x(t)}{\text{c}}\right)+\int_0^tx(\tau)\cdot p(t-\tau)\space\text{d}\tau\tag1$ $

And I’ve no idea how to start.

Some background information: this DE describes a current in an electric circuit. For the values of $ a,b$ and $ c$ I know that they are real and positive. For $ c$ I know that $ 10^{-4}\le c\le10^{-16}$ . The function $ y(t)=k\cdot\theta\left(t-m\right)+(n-k)\cdot\theta\left(t-v\right)$ where all the values of the constants are ral and positive and $ \theta$ is the Heaviside Theta function. The function $ p(t-\tau)=\mathcal{L}_\text{s}^{-1}\left\{\frac{1}{\frac{1}{R_2+sl}+\frac{s}{sR_3+\frac{1}{z}}}\right\}_{\left(t-\tau\right)}$ where all the constants are again real and positive.

Solving T(n) = 3T(n-1) + 2

I am trying to get better at recurrence relation solving, so I am making my own simple relations and try to solve them. I have made the below recurrence

T(n) = 3T(n-1) + 2 and we say that T(1) = 1  T(n) = 3 [3T(n-2) + 2] + 2 T(n) = 3 [3[3T(n-3) + 2] + 2] + 2 T(n) = 3 [3[3[3T(n-4) + 2] + 2] + 2] + 2 = T(n) = 81 T(n-4) + 8 . . . We say that k = n-1 T(n) = 3^k T(n-k) + 2*k T(n) = 3^k T(1) + 2*k 

I am stuck on how to finish this and how to find out what the time complexity is in Big O.

Microphone recording has slight static and crackling despite all attempts at solving it

Exactly what the title states. I have a microphone that works well on Windows but regardless of distro, there’s always some slight crackling when using the microphone.

I have tried everything, adding load-module module-hal-detect tsched=0 to /etc/pulse/default.pa, fiddling with the voice levels on alsamixer, you name it, I tried it, and it didn’t work. It continues to crackle no matter what I throw at it.

I’d appreciate any solutions you might offer.

Thanks.

Solving $xu_x+yu_y=y$ through the method of characteristics


Consider the following first order PDE

\begin{cases} x\partial_x{u}+y\partial_y{u}=y, \ u\big|_\Gamma=x. \end{cases}

where $ \Gamma:=\{(x,1)\}\subset \mathbb{R^2}$

  1. State the condition which guarantees that the initial surface $ \Gamma$ is not characteristic.
  2. Use the method of characteristics to find a solution of the PDE and discuss for which $ (x,y)\in\mathbb R^2$ the solution exists.

Here is my attempted solution.

Following the method of characteristics, we can first write the general form as $ au_x+bu_y=f$ . Therefore, we have that

$ $ \frac{dx}{a}=\frac{dy}{b}=\frac{du}{f}$ $ or $ $ \frac{dx}{x}=\frac{dy}{y}=\frac{du}{y}$ $

In order to solve these equations, we need to find the value of two constants $ C_1$ and $ C_2$ . First, let

$ $ \frac{dx}{x}=\frac{dy}{y}$ $

Then,

$ $ \frac{1}{x}dx=\frac{1}{y}dy~~\Rightarrow~~~ ln(y) = ln(x)+C ~~\Rightarrow~~~ C=\ln\Big(\frac{y}{x}\Big) ~~\Rightarrow~~~ C_1=\frac{y}{x}$ $

Next, let

$ $ \frac{dy}{y}=\frac{du}{y}$ $

Then

$ $ \frac{dy}{du}=\frac{y}{y} ~~\Rightarrow~~~ dy=du~~\Rightarrow~~~ y=u+C ~~\Rightarrow~~~ C_2=y-u $ $

So, we have that $ C_1=\frac{y}{x}$ and $ C_2=y-u $ . We can combine the two constants such that $ C_2=F(C_1)$ where $ F$ is an arbitrary differentiable function. Then,

$ $ y-u =F\Big(\frac{y}{x}\Big)$ $

or

$ $ u=y-F\Big(\frac{y}{x}\Big)$ $

We now need to apply our initial data. We are given that $ u(x,1)=x$ . Therefore,

$ $ x=1-F\Big(\frac{1}{x}\Big) ~~\Rightarrow~~~ F\Big(\frac{1}{x}\Big)=1-x$ $

Letting $ w=\frac{1}{x}$ , we see that $ x=\frac{1}{w}$ .

So, $ F(w)=1-\frac{1}{w}$ . Therefore,

$ $ u=y-F\Big(\frac{y}{x}\Big) = y-\Big(1-\frac{x}{y}\Big) = y-1+\frac{x}{y} $ $

Hence, to answer the questions

  1. State the condition which guarantees that the initial surface $ \Gamma$ is not characteristic.

I’m not sure. $ \Gamma:=\{(x,1)\}\subset \mathbb{R^2}$ appears to be defined everywhere.

  1. Use the method of characteristics to find a solution of the PDE and discuss for which $ (x,y)\in\mathbb R^2$ the solution exists.

Assuming we don’t need to worry about

$ $ u=y-F\Big(\frac{y}{x}\Big)$ $

and can directly apply what was found for $ u$ ,

$ $ u= y-1+\frac{x}{y}$ $

The solution exists for all $ x\in\mathbb R$ . For $ y\in\mathbb R$ , we need to require that $ y\neq{0}$ . Therefore, the solution exists for all $ (x,y)\in\mathbb R^2$ where $ y\neq{0}$ .

I’m not sure if I am analyzing the correct material for the questions.

Solving a linear program with few nonzero variables

Consider the linear program:

$ $ A x = b, ~~~~~~ x\geq 0 $ $ where $ A$ is an $ m$ -by-$ n$ matrix, $ x$ is an $ n$ -by-1 vector, $ b$ is an $ m$ -by-1 vector, and $ m<n$ .

It is known that, if this program has a solution, then it has a basic feasible solution, in which at most $ m$ variables are non-zero and at least $ n-m$ variables are zero.

QUESTION: what is the run-time complexity of checking whether the system has a solution in which at most $ m-1$ variables are non-zero?

NOTE: the question is a special case of Min-RVLS – finding a solution with a smallest number of non-zero variables. Min-RVLS is known to be NP-hard and hard to approximate within a multiplicative factor. Finding an additive approximation is hard too.

But, here our goal is much more modest – all we want is to find a solution with one less than the maximum ($ m$ ). Is this special case easier?

Solving Steady Navier Stokes Equation

I am trying to solve the Steady Navier Stokes equation in a two-dimensional domain.

I found a code online in freefem++ which at some point reads:

// //  Define u1, u1o, u2, u2o, p, trial functions. // Xh u1, u1o, u2, u2o; Qh p; // //  Define v1, v2, q, test functions. // Xh v1, v2; Qh q; // //  Define the problem. // problem navierstokes ( [u1,u2,p], [v1,v2,q] ) = int2d ( Th, qforder = 3 )(                             visc*(dx(u1)*dx(v1) + dx(u2)*dx(v2) + dy(u1)*dy(v1) + dy(u2)*dy(v2))                             + u1*dx(u1o)*v1 + u2*dy(u1o)*v1 + u1o*dx(u1)*v1 + u2o*dy(u1)*v1                             + u1*dx(u2o)*v2 + u2*dy(u2o)*v2 + u1o*dx(u2)*v2 + u2o*dy(u2)*v2                             - p*(dx(v1) + dy(v2))                             + q*(dx(u1) + dy(u2))                             - eps*p*q) - int2d ( Th, qforder = 3 )(                             u1o*dx(u1o)*v1 + u2o*dy(u1o)*v1                             + u1o*dx(u2o)*v2 + u2o*dy(u2o)*v2) + on(Inner,u1=0,u2=0) + on(Outer,u1=omega*(-y),u2=omega*x); 

I am able to solve the Stokes problem but I am having trouble working around the convective term in the Navier-Stokes equation.

Then they use a fixed point iteration to find the solution:

// //  Seek a solution of the nonlinear equations via a fixed point iteration. // for ( int i = 0; i < 10; i++ ) {     u1o = u1;     u2o = u2;     navierstokes; } 
  • I do not understand what is the trial function (u1o,u2o) that they are using in the code…?
  • How do I write down the weak formulation associated to this problem?
  • Are they using Oseen, Stokes or Newton method?

minimization problem solving and its step limits?

I am trying to solve the following minimization problem:

enter image description here

  • x : is my unknown value (input) with complex elements and known size, here (4×1)
  • y : is the output vector (known)
  • c : is a ‘skaling’ vector

I am very new to this so my approach may seem basic. I simply loop over all combination of c (non-redundant) and according to the computed minimization value and condition I update my results. My questions are the following:

  • Is this correct and is there a better approach to this?
  • This code fails with a small step due to the huge size of combinations, so how to solve that?

My code:

from itertools import combinations from random import randint import numpy as np   def deg2rad(phase):     return round(((phase*3.14)/180),3)  def excitation(amplitude, phase):     return complex(round(amplitude * (np.cos(deg2rad(phase))),3), round(amplitude*(np.sin(deg2rad(phase))),3))  def compute_subject_equation_result(x):     M            = 12     difference   = []     y            = [randint(10, 20) for i in range(M)]      for m in range(0, M):               c  = np.array([randint(0, 9), randint(10,20), randint(0, 9), randint(0,20)]).reshape(4,1)         ch = c.conjugate().T         eq  = (y[m] - (abs(np.dot(ch, x))[0])**2)**2         difference.append(eq**2)     return round(sum(difference)[0], 3)  def compute_main_equation_result(x, beta):     norm1  = np.linalg.norm(x,1)     norm2  = np.linalg.norm(x,2)     return round(norm1 + beta*(norm2**2), 3)  def optimize(x, min_x, min_phi_x):     min_result      = 10**25      # compute the optimization formals and check for the min value     main_equation_result    = compute_main_equation_result(c, beta)     subject_equation_result = compute_subject_equation_result(c)      # update min value if min detected'       if subject_equation_result < epsilon and main_equation_result < min_result:         min_result = main_equation_result         min_x      = x         min_phi_x  = phx             return min_x, min_phi_x  # initialization phases    = [alpha for alpha in range(0, 361, 90)] beta      = 1 epsilon   = 10**25 min_x     = np.array([]) min_phi_x = np.array([])  phases_combinations = [list(comb) for comb in combinations(phases, 4)]  # start checking all combinations for phx in  phases_combinations:     phi1, phi2, phi3, phi4 = phx[0], phx[1], phx[2], phx[3]            # build the hypothesis for the excitations vector c      c = np.array([ excitation(1, phi1), excitation(1, phi2), excitation(1, phi3), excitation(1, phi4) ]).T.reshape(4,1)     min_x, min_phi_x = optimize(c, min_x, min_phi_x)     print('    --------------------------------------------------')     print('-----> new_min_c     = ', list(min_x))     print('-----> new_min_phi_c = ', min_phi_x) 

Remark: When trying phases = [alpha for alpha in range(0, 361, 1)] I get a Memory error. This, I can avoid using a higher step, However I am not sure about my approach in general nor of the step change effect on the accuracy