Using Dsolve with Assumptions/Conditions - wolfram-mathematica

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.

Related

How can I ask Wolfram Alpha to rearrange an equation?

I have an equation (parentheses are used because of VBA code)
Y=(P/(12E((bt^3)/12))*A
and i know every variables but not "b". Is there any way how to ask Wolfram Alpha to "redefine" (not solve) equation so I can see something like following: I tried to do it manually (but result is not OK)
b=((P/EY)*12A))/t^3
I wish to see how right equation will look.
Original equation is on picture below
where
equation in [,] I simplified by A
I'm not sure if there's a way to tell Wolfram|Alpha to rearrange for a particular variable; in general it will usually try to rearrange for x or y.
If I substitute b for x in your equation and use the following query:
solve Y - (P/(12E((xt^3)/12))*A) = 0
then Wolfram Alpha returns the result you're looking for: x (b) expressed in terms of the other variables. Specifically:
x = A P / (E t^3 Y) for tY != 0 and AP != 0
I know that your question was about Wolfram Alpha, that you do not want to "solve", but here is one way you could do it in Mathematica using your real question. I renamed I into J because I is a reserved symbol in Mathematica for the imaginary unit.
J = b t^3/12;
expr = (P / (12 E J) ) (4 L1^3 + 3 R ( 2 Pi L1^2 + Pi R^2 + 8 L1 R ) + 12 L2 (L1 + R)^2)
Solve[ Y == expr , b]
Result
{{b -> (P (4 L1^3 + 12 L1^2 L2 + 24 L1 L2 R + 6 L1^2 \[Pi] R + 24 L1 R^2 + 12 L2 R^2 + 3 \[Pi] R^3))/(E t^3 Y)}}

mathematica, Simplify trig function

if say i have a function given :
singlepattern = Cosh[theta] + Cosh[3theta]
How do i get a rational expression in terms of x of the function if i want to substitute Cosh[theta] by
"Cosh[theta] = ( x )/ 2 "
expression?
I retagged the question as a homework. You should look into ChebyshevT polynomials. It has the property that ChebyshevT[3, Cos[th] ]==Cos[3*th]. So for your problem the answer is
In[236]:= x/2 + ChebyshevT[3, x/2]
Out[236]= -x + x^3/2
Alternatively, you could use TrigExpand:
In[237]:= Cos[th] + Cos[3*th] // TrigExpand
Out[237]= Cos[th] + Cos[th]^3 - 3 Cos[th] Sin[th]^2
In[238]:= % /. Sin[th]^2 -> 1 - Cos[th]^2 // Expand
Out[238]= -2 Cos[th] + 4 Cos[th]^3
In[239]:= % /. Cos[th] -> x/2
Out[239]= -x + x^3/2
EDIT The reason the above has to do with the explicit question, is that Cosh[theta] == Cos[I*u] for some u. And since u or theta are formal, results will hold true.
Use Solve to solve for theta, then substitute, Expand, and Simplify:
In[16]:= TrigExpand[Cosh[3 theta] + Cosh[theta]] /.
Solve[Cosh[theta] == (x)/2, theta] // FullSimplify
During evaluation of In[16]:= Solve::ifun: Inverse functions are being used by Solve,
so some solutions may not be found; use Reduce for complete solution information. >>
Out[16]= {1/2 x (-2 + x^2), 1/2 x (-2 + x^2)}
This might interest you:
http://www.wolframalpha.com/input/?i=cosh%28x%29+%2B+cosh%283*x%29

How do I get the inverse of a function?

If I have some function y[x_]:=ax+b (just an example), how do I obtain x[y_]:=(y-b)/a in Mathematica? I've tried InverseFunction,Collect and they don't work.
Treat it as an equation and use Solve.
In:=Solve[y-ax-b==0,x]
Out={{x -> (-b + y)/a}}
If you want to define a function, you could do:
x[y_] := x /. Solve[y == a x + b, x][[1]]
x[1]
-> (1 - b)/a
http://mathworld.wolfram.com/InverseFunction.html
Specifically the line:
In Mathematica, inverse functions are
represented using InverseFunction[f].
One way is with Solve:
In[29]:= Solve[y == a x + b, x]
Out[29]= {{x -> (-b + y)/a}}

How to substitute an aggregate expression

For example, I have symbollically
1/n*Sum[ee[k] + 1, {k, j, n}]^2
And I want to substitute Sum[ee[k], {k, j+1, n}] to be x. How can I do this? May thanks for your help!
You may use the recurrence relation for the sum. For example:
f[j] := f[j + 1] + (ee[j] + 1);
1/N f[j]^2 /. f[j + 1] -> x
Out
(1 + x + ee[j])^2/N
Edit
Based on several questions you posted, I think you are somehow misinterpreting what the Replace[] command does. It is not "algebraic" based, but "pattern" based. It doesn't understand nor use more algebraic transformations than those already defined (by you or by Mma itself).
For example:
x/. (x-1)->y
will not match anything. But
(x-1) /. x->y-1
Will give you (y-2) because the pattern x is matched.
Moreover:
x = 3;
(x - 1) /. x -> y - 1
will give you 2 because x is evaluated before the possible match, and the x in the pattern is also evaluated (just paste, execute and look at the symbol color).
1/N*Sum[ee[k] + 1, {k, j, N}]^2 /. Sum[ee[k] + 1, {k, j, N}] -> x
Doesn't that work, or do I misunderstand? By the way, you shouldn't use N as a variable. It's a Mathematica function.

How to get rid of denominator in numerator and denominator in mathematica

I have the following expression
(-1 + 1/p)^B/(-1 + (-1 + 1/p)^(A + B))
How can I multiply both the denominator and numberator by p^(A+B), i.e. to get rid of the denominators in both numerator and denominator? I tried varous Expand, Factor, Simplify etc. but none of them worked.
Thanks!
I must say I did not understand the original question. However, while trying to understand the intriguing solution given by belisarius I came up with the following:
expr = (-1 + 1/p)^B/(-1 + (-1 + 1/p)^(A + B));
Together#(PowerExpand#FunctionExpand#Numerator#expr/
PowerExpand#FunctionExpand#Denominator#expr)
Output (as given by belisarius):
Alternatively:
PowerExpand#FunctionExpand#Numerator#expr/PowerExpand#
FunctionExpand#Denominator#expr
gives
or
FunctionExpand#Numerator#expr/FunctionExpand#Denominator#expr
Thanks to belisarius for another nice lesson in the power of Mma.
If I understand you question, you may teach Mma some algebra:
r = {(k__ + Power[a_, b_]) Power[c_, b_] -> (k Power[c, b] + Power[a c, b]),
p_^(a_ + b_) q_^a_ -> p^b ( q p)^(a),
(a_ + b_) c_ -> (a c + b c)
}
and then define
s1 = ((-1 + 1/p)^B/(-1 + (-1 + 1/p)^(A + B)))
f[a_, c_] := (Numerator[a ] c //. r)/(Denominator[a ] c //. r)
So that
f[s1, p^(A + B)]
is
((1 - p)^B*p^A)/((1 - p)^(A + B) - p^(A + B))
Simplify should work, but in your case it doesn't make sense to multiply numerator and denominator by p^(A+B), it doesn't cancel denominators

Resources