Error while giving initial condition in NDSolve

I am trying to solve following differential equation $ $ \frac{d^2y}{dx^2}+(a+b \frac{2}{\pi}\tan^{-1} x)y=0$ $ with the initial condition $ y(-10)=e^{10i\sqrt{a+b}}$ and $ y'(-10)=-i\sqrt{a+b}e^{10i\sqrt{a+b}}$ .

To implement it I write the following code

s = ParametricNDSolve[{y''[x] + (a + b (2 + 2/Pi ArcTan[x])) y[x] ==  0, y[-10] = Exp[I 10 Sqrt[a + b]], y'[-10] = -I Sqrt[ a + b]*Exp[ I 10 Sqrt[a + b]] }, y, {x, -10, 10}, {a, b}] 

But I am getting an error that ParamatericNDSolve expects equation or list of equations instead of $ e^{10i\sqrt{a+b}}$ in the first argument. Can anyone point me out where am I making the mistake?

Solving Nonlinear Heat Equation with initial Conditions

I have the following setup for the linear heat equation on an infinite rod (see below). This is a pretty standard setup and the initial condition is $ e^{-x^2}$ . This initial condition is not special, it just provides a way to ensure that the code works.

Clear[x, t]; With[{u = u[t, x]}, eq = D[u, t] == k D[D[u, x], x];  ic = u == Exp[-x^2] /. t -> 0;  bc = D[u, x] == 0 /. x -> 0;] asol = DSolveValue[{eq, ic, bc}, u, {t, x}, Assumptions -> {k > 0}]; asol[t, x] 

What I want to do is test different ideas and so I want to modify this linear heat equation into the nonlinear heat equation or another PDE that is similar but is different than a linear PDE.

The nonlinear heat equation is defined as the following

\begin{equation} \frac{\partial u}{\partial t} = \frac{\partial}{\partial x}\left[g(u) \frac{\partial u}{\partial x}\right] \end{equation}

and further literature on the nonlinear heat equation can be found here.

If we assume that $ g(u) = u$ then I would expect that I could modify the setup as:

Clear[x, t]; With[{u = u[t, x]}, eq = D[u, t] == k D[ u D[u, x], x];  ic = u == Exp[-x^2] /. t -> 0;  bc = D[u, x] == 0 /. x -> 0;] asol = DSolveValue[{eq, ic, bc}, u, {t, x}, Assumptions -> {k > 0}]; asol[t, x] 

However, Mathematica simply regurgitates the code and does not produce an output.

I also wish to have a different type of setup such as:

\begin{equation} \frac{\partial u}{\partial t} = \frac{\partial}{\partial x}\left[h(x) \frac{\partial u}{\partial x}\right] \end{equation}

and modify the first block of code for this as well.

If anyone can help me understand why my latter setup doesn’t work and can show me how to set it up correctly, I would be very thankful.

Also this is not for a class. It is for my own personal understanding.

Datatypes as initial algebras

I’m refining my understanding of the connection between initial algebras and datatypes. This paper suggests that one could even represent the categories corresponding to datatypes definitions:

enter image description here

as follows:

enter image description here

Where $ 1$ is the terminal object of the category.

My question is, how can I justify that $ 1$ is the terminal object of the category? Do I have to postulate that any type has a unique morphism to $ 1$ ? This morphisms would be different that the datatype definitions which would not be nice…

Initial state of checkboxes for basic list filtering

I’m developing a web application which features a list of items. The list can be filtered by type, and the user can choose to view one or more types at once. Let’s say the types are Red, Green, Blue, and Yellow.

My idea was to use checkboxes, one for each type, so that e.g. when Blue and Yellow is selected, then the list contains the sum of these two. Basic logic.

Checkboxes unselected

Now, the default view is as above: no type is selected. In the app’s logic, this is treated the same as selecting all types – in other words, all items are visible on the list. The user can now click on the type they’re interested in, and the list will only contain that.

Is this an intuitive approach?
Or maybe all the checkboxes should be selected on init instead?
Or perhaps a completely different mechanic should be used in place of checkboxes?

I couldn’t decide and made a list of pros and cons:

  • All checkboxes empty on init
    • 🙂 One click required to filter by one given type
    • 🙁 It doesn’t make much sense that nothing checked means all shown
  • All checkboxes checked on init
    • 🙁 Three clicks required to filter by one given type
    • 🙂 Makes more sense that all checked means all shown

I’m not sure if my reasoning is correct. Looking at shops which let you e.g. select a laptop brand, it’s normal for them to start with all options unchecked. But since my app’s list is rather short and filtering results are immediate, I’m not sure if any of these approaches is better than the other, or maybe I’m missing a better way.

System of delay differential equations: using first interpolation as second initial condition

I am trying to solve numerically the following system of two coupled delay differential equations:

$ $ \dot x(t)=-\gamma x(t)-\frac{\gamma}{4}e^{i\omega_0\tau_1}y(t-\tau_1)\theta(t-\tau_1)+\frac{\gamma}{4}e^{i\omega_0\tau_2}y(t-\tau_2)\theta(t-\tau_2)+\frac{\gamma}{2}e^{i\omega_0\tau_3}x(t-\tau_3)\theta(t-\tau_3),$ $ $ $ \dot y(t)= -\frac{\gamma}{2}y(t)-\frac{\gamma}{4}e^{i\omega_0\tau_1}x(t-\tau_1)\theta(t-\tau_1)+\frac{\gamma}{4}e^{i\omega_0\tau_2}x(t-\tau_2)\theta(t-\tau_2).$ $ where $ \tau_1<\tau_2<\tau_3$ . The parameters $ \gamma, \omega_0$ are constants, and $ \theta(t)$ is the Heaviside step function. The history of the system is known for $ 0\leq t\leq\tau_1$ : $ $ x(t)=e^{-\gamma t}, y(t)=e^{-\gamma t/2}.$ $ Here what I tried:

I first solved the system for $ 0\leq t\leq\tau_2$ using the aforementioned initial history using NDSolve:

\[Gamma] = 1.0; \[Omega]0 = 2 Pi; \[Tau]1 = 1.0; \[Tau]2 = 2.0; \[Tau]3 = 3.0;  sol1 = NDSolve[{x'[   t] == - \[Gamma] x[t] - (\[Gamma]/4) E^(I \[Tau]1 \[Omega]0)     y[t - \[Tau]1],  y'[t] == - 0.5 \[Gamma] y[t] - (\[Gamma]/4) E^(    I \[Tau]1 \[Omega]0) x[t - \[Tau]1],  x[t /; t <= \[Tau]1] == (1.0/Sqrt[2.0]) Exp[-\[Gamma] t],  y[t /; t <= \[Tau]1] == (1.0/Sqrt[2.0]) Exp[-0.5 \[Gamma] t]}, {x,  y}, {t, 0, \[Tau]2}]; 

I get the following solution for $ |x(t)|^2$ and $ |y(t)|^2$ : abs[x]^2,abs[y]^2

The problem arises when I use this first interpolated solution as the initial history to solve for the next interval of time:

sol2 = NDSolve[{x'[   t] == - \[Gamma] x[t] - (\[Gamma]/4) E^(I \[Tau]1 \[Omega]0)     y[t - \[Tau]1] + (\[Gamma]/4) E^(I \[Tau]2 \[Omega]0)     y[t - \[Tau]2],  y'[t] == - 0.5 \[Gamma] y[t] - (\[Gamma]/4) E^(    I \[Tau]1 \[Omega]0) x[t - \[Tau]1] + (\[Gamma]/4) E^(    I \[Tau]2 \[Omega]0) x[t - \[Tau]2],  x[t /; t <= \[Tau]2] == Evaluate[x[t] /. sol1],  y[t /; t <= \[Tau]2] == Evaluate[y[t] /. sol1]}, {x, y}, {t,  0, \[Tau]3}];  

This time I get the following messages: enter image description here enter image description here

It seems that the second NDSolve (sol2) does not allow the interpolation of the first result as initial history. Any suggestion? Thank you in advance.

Addition of 3 bits using Full Adder when the initial carry bit is 0

How do I add 3 bits using full adder and basic gates, when the initial carry bit is 0??

I have tried using two full adders where two terminals of the first adder gets the first two inputs then the output of this adder goes to of the inputs of the second adder and the third input is given to the second input terminal of the second adder. The carry out from the first adder goes to the carry input of the second adder.

I’ve added a picture of the circuit which was created by using Logisim(software for designing digital logic circuit).

But it doesn’t give the right answer.

normally in binary system, for addition of three bit sum is 1 and carry output bit is 1.

1+1+1 = 1 & carry bit = 1

But as you can see in the picture of the circuit I designed below, output of my circuit for adding three binary digit, sum is 0 and carry output bit is 1. which is not the right answer

1+1+1, is sum = 0 & carry = 1

The reason of this is clear to me. But I can’t design the exact circuit. How do I design the circuit that can add 3 bit when initial carry is 0?

enter image description here

FindRoot returns the initial guess (Having large magnitude)

In my program (Big Enough, no need to see, pasted here :, I am trying to find the root of equation by FindRoot in range of order of $ 10^{12}$ or so. but FindRoot returns the initial guess,

Now if I change the coefficients of equation slightly then also, It returns the initial guess.

Ex- Initial Guess: $ 1.06154*10^{12}$ , Answer: $ 1.06154*10^{12}$

Any way out please ?

How to compute a system of ordinary differential equations with initial condictions over a continuous range

I have some questions about Mathematica programming and would appreciate if you could help me.

I want to solve a system of ordinary differential equations \ [Mu] ‘[t] and \ [Lambda]’ [t] and each equation contains a large number of terms so it is impractical to write them explicitly. I express these terms as two functions F1 and F2 that depend on two parameters P1 and P2 and \ [Lambda] [t] and \ [Mu] [t].

I have been able to solve this system for a couple of initial conditions \ [Lambda] [0] = ic1 and \ [Mu] [0] = ic2, but I would like to solve my system of equations for a continuum of values ​​\ [Lambda] [0] = {0, …., Pi / 2} and \ [Mu] [0] = {0, …., Infinity} and then get \ [Lambda] [t] and \ [Mu] [t] and use them to perform an integral on \ [Lambda]= \ [Lambda] [0] ={0, …., Pi / 2} and \ [Mu] =\ [Mu] [0] ={0, …., Infinity} that are precisely our initial conditions.

I integrate the product of a function G in the time t (where \ [Lambda] [t] and \ [Mu] [t] are taken into account for a certain initial condition defined by the continuous ranges of the integral) with the same function, but in t = 0 (where the initial conditions are taken into account with the continuous ranges of the integral).

The structure of the program is:

ode = {\[Mu]'[t] ==  F1[p1, p2, \[Lambda][t], \[Mu][t]], \[Lambda]'[t] ==  F2[p1, p2, \[Lambda][t], \[Mu][t]], \[Mu][0] == {0, ....,   Pi/2}, \[Lambda][0] == {0, ...., Infinity}};   Sol = NDSolve[ode, {\[Mu], \[Lambda]}, {t, 0, 1},`Method -> "Some method to choose"]     \[Mu]1[t_] := Evaluate[\[Mu][t] /. Sol] // First \[Lambda]1[t_] := Evaluate[\[Lambda][t] /. Sol] // First   data = ParallelTable[{t,  NIntegrate[   G[p1, p2, \[Mu]1[      t] "for the initial condition \[Mu]=\[Mu][0]", \[Lambda]1[      t] "for the initial condition \[Lambda]=\[Lambda][0]"] G[p1,     p2, \[Mu] "=\[Mu][0]", \[Lambda] "=\[Lambda][0]"] , {\[Mu] "=`\[Mu][0](initial condition)", 0,    Pi/2}, {\[Lambda] "=\[Lambda][0](initial condition)", 0,    Infinity}, Method -> {"Some method to choose"}]}, {t, 0, 1}];`