Using Dsolve in mathematica - wolfram-mathematica

I was using dsolve to find the solved differential equation for the Schrodinger equations involving magnetic resonance and i am getting an error.
DSolve[{I*a'[t] == .5*(w0*a[t] + w1*Cos[w*t]*b[t]),
I*b'[t] == .5*(w1*Cos[w*t]*a[t] - w0*b[t]),
a[t]^2 + b[t]^2 == 1}, {a, b}, t]
from this i am getting the reply
There are fewer dependent variables than equations, so the system is \
overdetermined.
i see 3 equation and 3 unknowns so i do not really know why it is doing this.
Any help would be appreciated.

Perhaps this will help.
Ref. NMR Transition Rate in a Oscillating B Field
DSolve[
b'[t] == ((I w1)/2) (Exp[I (w + w0) t] + Exp[-I (w - w0) t]) - I w0 b[t],
b[t], t] // Simplify

Related

Give Matematica Solve function only references to equations instead of whole equations?

How do I supply the Matematica Solve function with only references to equations, instead of whole equations?
I.e. let's say I have multiple equations, like:
eq1 = {x + y == 0}
eq2 = {x y - 2 == 0}
However, when I try to put them in Solve, Matematica throws an error:
Solve[{eq1 && eq2}, {x, y}]
Solve::naqs: {x+y==0}&&{-2+x y==0} is not a quantified system of equations and inequalities.
At the same time, re-writing whole equations works
Solve[x + y == 0 && x y - 1 == 0, {x, y}]
{{x->-I,y->I},{x->I,y->-I}}
but can quickly become cumbersome when the number and complexity of equations increases.

Using Dsolve with Assumptions/Conditions

I would like to solve the following equation:
DSolve[u''[x]+k^2 u[x], u[x],x]
if k^2<0 the solution is
u[x]-> C[1] e^(kx) + C[2] e^(-kx)
if k^2>0 the solution is
u[x] -> C[1] Sin [kx] + C[2] Cos[kx]
in my equation
k^2=(a-b)/(c-d)
when b >a and c >d, meaning k^2<0
when I plug the equation into Mathematica, it reverses the sign and given me the exponents solution and not the cosine one.
does anyone have an idea how to plug the Assumptions or Conditions into the equation? Or patch between the two so I'll get the true solution?
Cheers
introduce a constant k2n which is the negative of your assumed negative k^2:
First#DSolve[{u''[x] - k2n u[x] == 0 }, u[x], x]
E^(Sqrt[k2n] x) C[1] + E^(-Sqrt[k2n] x) C[2]
now we know k2n>0 so back substitute
% /. Sqrt[k2n] -> k
E^(k x) C[1] + E^(-k x) C[2]
As a general answer I don't think there is a way to tell DSolve to make assumptions about parameters.

Mathematica's error by solving an ODE

I would know what is the problem with this Mathematica's code. Is there anyone that can give me an explanation of the bug, and also that can tell me how to improve the code?
V[x_, y_, z_] := x^2 + y - z;
m = 10;
DSolve[m*x''[t] == -Grad[V[x, y, z], {x, y, z}]*x[t], x[t], t]
Model of a particle in a potential-field. In this model we consider a particle as being a point of mass which describes a trajectory in space which is modeled by a function giving its coordinates in space as a function of time. The potential field is given by a function V : R^3 → R and the trajectory is a solution of the differential equation
Note this model assumes the particle is a point mass, which is certainly known to be false in many cases in which we use this model; for example, as a model of planetary motion.
Actual equation:
First: don't trust Wikipedia. It good for some basic knowledge, but for something specific better use some field-specific sources.
The correct equation is:
And the correct code:
V[x_, y_, z_] := x^2 + y - z;
m = 10;
DSolve[m*{x''[t], y''[t], z''[t]} ==
-(Grad[V[x, y, z], {x, y, z}] /. {x -> x[t], y -> y[t], z -> z[t]})
, {x[t], y[t], z[t]}, t]
Solution:
{{x[t] -> C[1] Cos[t/Sqrt[5]] + C[2] Sin[t/Sqrt[5]],
y[t] -> -(t^2/20) + C[3] + t C[4],
z[t] -> t^2/20 + C[5] + t C[6]}}

Mathematica: Tangent of Two Curves

I asked this question yesterday but not sure if I made clear what I was looking for. Say I have two curves defined as f[x_]:=... and g[x_]:=... as shown below. I want to use Mathematica to determine the abscissa intersection of the tangent to both curves and store value for each curve separately. Perhaps this is really a trivial task, but I do appreciate the help. I am an intermediate with Mathematica but this is one I haven't been able to find a solution to elsewhere.
f[x_] := x^2
g[x_] := (x - 2)^2 + 3
sol = Solve[(f[x1] - g[x2])/(x1 - x2) == f'[x1] == g'[x2], {x1, x2}, Reals]
(* ==> {{x1 -> 3/4, x2 -> 11/4}} *)
eqns = FlattenAt[{f[x], g[x], f'[x1] x + g[x2] - f'[x1] x2 /. sol}, 3];
Plot[eqns, {x, -2, 4}, Frame -> True, Axes -> None]
Please note that there will be many functions f and g for which you won't find a solution in this way. In that case you will have to resort to numerical problem solving methods.
You just need so solve a system of simultaneous equations:
The common tangent line is y = a x + b.
The common slope is a = f'(x1) = g'(x2)
The common points are a x0 + b = f(x0) and a x1 + b = g(x1).
Depending on the nature of the functions f and g this may have no, one, or many solutions.

Converting vector equation to a list of equations in Mathematica

Due to DSolve syntax, systems of differential equations have to be given as lists of equations and not as a vector equation (Unlike Solve, which accepts both).
So my simple question is how to convert a vector equation such as:
{f'[t],g'[t]}=={{a,b},{c,d}}.{f[t],g[t]}
To list of equations:
{f'[t]==a*f[t]+b*g[t],g'[t]==c*f[t]+d*g[t]}
I think I knew once the answer, but I can't find it now and I think it could benefit others as well.
Try using Thread:
Thread[{f'[t], g'[t]} == {{a, b}, {c, d}}.{f[t], g[t]}]
(* {f'[t] == a f[t] + b g[t], g'[t] == c f[t] + d g[t] *)
It takes the equality operator == and applies it to each item within a list with the same Head.
The standard answer to this question is that which Brett presented,
i.e., using Thread.
However, I find that for use in DSolve, NDSolve, etc... the command LogicalExpand is better.
eqn = {f'[t], g'[t]} == {{a, b}, {c, d}}.{f[t], g[t]};
LogicalExpand[eqn]
(* f'[t] == a f[t] + b g[t] && g'[t] == c f[t] + d g[t] *)
It doesn't convert a vector equation to a list, but it is more useful since it automatically flattens out matrix/tensor equations and combinations of vector equations.
For example, if you wanted to add initial conditions to the above differential equation, you'd use
init = {f[0], g[0]} == {f0, g0};
LogicalExpand[eqn && init]
(* f[0] == f0 && g[0] == g0 &&
f'[t] == a f[t] + b g[t] && g'[t] == c f[t] + d g[t] *)
An example of a matrix equation is
mEqn = Array[a, {2, 2}] == Partition[Range[4], 2];
Using Thread here is awkward, you need to apply it multiple times and Flatten the result. Using LogicalExpand is easy
LogicalExpand[mEqn]
(* a[1, 1] == 1 && a[1, 2] == 2 && a[2, 1] == 3 && a[2, 2] == 4 *)

Resources