How to solve system equations with sum and vectors

I`m trying to solve this system of equations relatively $ \beta$ : $ \sum_{i=1}^{3}w_i(r_i-x_i*\beta)x_i^T=\vec0$

where is $ \beta$ – column vector, $ x_i$ -row vector.

I use this sample code:

w = {4, 3, 5}; r = {1, 2, 3}; x = {{1, 2}, {1, 3}, {1, 4}}; vec = {{0}, {0}}; Solve[Sum[  w[[i]]*(r[[i]] - x[[i]].beta)[[1]]*Transpose[{x[[i]]}], {i, 1,   3}] == vec, beta]; 

Output: Solve::ivar: {1} is not a valid variable. There is a problem?

Is unification over regular expression equations doable?

By way of example, suppose I know that $ X + \{a\} = \{b\} + Y$ where $ X$ and $ Y$ are variables standing for regular expressions, then $ (X, Y) = (\{b\}, \{a\})$ is a solution to this set of equations.

Generalizing over all such equations, is there a computable (decidable) procedure for calculating the regular expressions which the variables must stand for in order for the equation to be solvable? Is there some kind of uniqueness, e.g. of minimal solutions?

In case the alphabet size matters: you can represent $ \{1, \ldots, n\}$ in unary using just two symbols, so I assume the answer for $ k$ – and $ m$ -symbol alphabets are the same when $ k \geq 2 \land m \geq 2$ , in which case I care primarily for alphabets of size $ \geq 2$ —the reason I stress the word “assume” is that I know some properties of regular languages don’t hold for regular expression equations (when suitably translated).

The application I have in mind is miniKanren-style logic programming.

Since families of sets closed under union form a semilattice, and the family of regular languages is one such closed family, programming with regular languages seems straightforward. For example, let each logic variable $ V$ represent some indeterminate language $ L$ . For each $ V$ store a pair of bounds $ (sub, disj)$ expressing the knowledge $ sub \subseteq L \land (L \cap disj) = \emptyset$ , i.e. store two sets of strings for which the membership-ness is known. Grow them in the variable unification part and fail when $ sub \cap disj \not= \emptyset$ .

It would be nice to add logic over regular expressions and not just regular languages. No obvious approach occurs to me, and I suspect it’s a whole other ballgame.

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.

Solving system of equations with Summation

I have these three equations (eq1, eq2, eq3):

Clear["Global`*"] r[i]=Sqrt[(x[i]-a)^2+(y[i]-b)^2+(z[i]-c)^2]; eq1=(1/m)Sum[x[i],{i,1,m}]+(1/(m^2))Sum[r[i],{i,1,m}]Sum[(a-x[i])/r[i],  {i,1,m}]-a; eq2=(1/m)Sum[y[i],{i,1,m}]+(1/(m^2))Sum[r[i],{i,1,m}]Sum[(b-y[i])/r[i],  {i,1,m}]-b; eq3=(1/m)Sum[z[i],{i,1,m}]+(1/(m^2))Sum[r[i],{i,1,m}]Sum[(c-z[i])/r[i],  {i,1,m}]-c; 

I want to solve them for (a,b,c) making eq1, eq2 and eq3 equal to zero. I saw this technique but I can’t make it work for a system of equations. Can it be done for an arbitrary value of m?

ReplaceAll error on solving system of differential equations

here’s my problem, I’m trying to solve symbolically a system of differential equations (simplified example):

fun[F_, P_, x0_, y0_, tau_, A_, t_] =   x /. First[    DSolve[{ x'[t] == -F * (x[t] - y[t]) +  x[t] * A * Exp[-t / tau] ,       y'[t] == +F * (x[t] - y[t]) - P * (y[t] - y0), x[0] == x0,       y[0] == y0}, {x, y}, t]] 

which doesn’t work:

ReplaceAll: {(x^\[Prime])[t]==A E^(-(t/tau)) x[t]-F y[t],(y^\[Prime])[t]==F  (x[t]-y[t]),x[0]==x0,y[0]==y0}is neither a list of replacement rules nor a valid dispatch table,      and so cannot be used for replacing, 

it only works if I take out the inhomogeneous term:

 fun[F_, P_, x0_, y0_, tau_, A_, t_] =       x /. First[        DSolve[{ x'[t] == -F * (x[t] - y[t]) +  x[t] * A ,           y'[t] == +F * (x[t] - y[t]) - P * (y[t] - y0), x[0] == x0,           y[0] == y0}, {x, y}, t]] 

in which case works fine. My question is: is this a mistake on my part or is this just because this goes beyond the capabilities of DSolve?

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}];` 

Is finding a minimal set of seed variables for a complete deduction of a system of equations NP-complete?

Suppose we have a set of variables $ V$ . We also have a set of equations $ E$ , which are sets of at least two variables. We don’t know anything about these equations, except if we know all but one of the variables in an equation, we can deduce the missing one.

Does there exist a set of variables $ R \subseteq V$ with $ |R| \leq k$ such that revealing these variables allows us to deduce all variables?

Is this problem NP-complete? What if all equations have degree $ \leq d$ ?

I’m ultimately interested in the search version of this problem (where we actually need to find minimal $ R$ ).

Quadratic equations using 2 different approaches

I am reading Mark Newman’s Computational Physics and at chapter 4 page 133 in Exercise 4.2 he asks

a) Write a program that takes as input three numbers, a, b, and c, and prints out the two solutions to the quadratic equation $ ax^2 + bx + c = 0$ using the standard formula $ x = −b± (b^2 − 4ac)^{1/2}/2a$ . Use your program to compute the solutions of $ 0.001x^2 + 1000x + 0.001 = 0$ .

b) There is another way to write the solutions to a quadratic equation. Multiplying top and bottom of the solution above by $ -b∓ (b^2 − 4ac)^{1/2} $ , show that the solutions can also be written as $ x = 2c/−b∓(b^2 − 4ac)^{1/2}$ . Add further lines to your program to print these values in addition to the earlier ones and again use the program to

I tried both ways and a) gives me

[-9.99989425e-13 -1.00000000e+00] and

b) [-1.00000000e-06 -1.00001058e+06]

how can I understand which one is correct ? Or why is this happening ?

Solution to Diophantine equations

I am trying to solve a problem that boils down to finding the number of solutions of a linear Diophantine equation with restrictions. To be precise for equations :

$ ax + by + cz = k$ and $ x + y + z = n$

Refer the solution under “Diophantine Systems with Restrictions” on this page. How do I code this mathematical solution? My constraints include $ k$ ranging from $ 10^{-9}$ to $ 10^9$ and $ n$ from $ 1$ to $ 10^5$ . Also, what would be the run time. I can code this but in a very haphazard and inefficient manner. Is there a neat or maybe a standard solution to this?