Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.5K Views
|
9 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Avoid DSolve error for the following differential equation?

I keep getting an error with DSolve that I do not understand. It finds the solution then says it can't use it. Please see the attached file.

Attachments:
POSTED BY: Orest Gogosha
9 Replies

Thank you for clarifying the use of ClearAll. What happens is that when DSolve finds a solution, which has happened when I don't use units, it asks if you want to convert that solution into a function. Once you pick that option, you get a function. However, if you now reevaluate the notebook for some reason, you get the error. I don't use Mathematica much. Although it's been a long time, I can still solve simple ODEs by hand. What I'm trying to do is get my students interested in making programming an integral part of their way of doing scientific and engineering computations. It's hard to do when a program has so many idiosyncrasies.

POSTED BY: Orest Gogosha

I am not concerned about the "Not all solutions warning. I understand that. I don't understand the cannot be used as a function." It comes and goes. Please compare the attached files.

Thanks,

GOGO

POSTED BY: Orest Gogosha
Posted 6 years ago
POSTED BY: Bill Nelson
Anonymous User
Anonymous User
Posted 6 years ago

You have initial conditions x[0] == 1, x'[0] == 0.

You'll find for ODE sometimes you'll get a solution if you omit the IC where with the IC Mathematica yields no solution. (But with the full general solution you can solve constants for those IC using Solve having the (general in this case) solution.)

This may be because Mathematica will show nothing rather than give you an answer that is "vague" - so if you inadvertently give IC that could allow more than one solution: mm may show you nothing.

You should substitute the solution you get, and in general and ask if there are singular solutions (points outside the general solution) or other "gotchas". For homework of course, you'll likely set that aside.

POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 6 years ago

NSolve::ifun: Inverse functions are being used by NSolve, so some solutions may not be found; use Reduce for complete solution information.

This means what is says. however: remember that PDE may have functions as arbitrary while ODE constants as arbitrary, and moreso that some ODE you hope to find "a solution" while others you can say "are likely general" while other (by definition or by analysis) are certainly general (all solutions).

My point is before worrying whether your inverse is all solutions ask if you had any chance of finding all solutions.

Use of numbers like ".001" are a bad idea for DSolve - use arbitrary precision numbers (fractions). also - nsolve is not needed for the simple harmonic motion equation (mm can do it).

x''[t] + x[t] == c

is a linear differential equation of order two, non-homogenous

You can find an equation showing all solutions of it by knowing your theorems tell you that is the case . yp+yc, yc can be found using undetermined coefficients.

Your characteristic equation is (m^2+1) will involve imaginary number, which is parlayed into sin/cos function in a sensible way for use with wave equations. You may have a table of simple harmonic equations with the solution outcomes in your book (undamped or damped and unforced or not) so you can plug in constants to known solutions (tenenbaum).

POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 6 years ago

DSolve::dsfun: -0.0102625+0.110263 Cos[22.3607 t] cannot be used as a function.

that means you have a typo, you've tried to use the above as a function - just like the message says. your "unkown function" (ie, y''[x]) has to have form f[u], f'[u], ... which is likely what you intended. (obviously u might have substitution, see help how and where such can be used). if you look again, compare it to Help examples, you'll see the simple typo

POSTED BY: Anonymous User

Something interesting is going on. I restarted windows. The results are attached. The solution with units still doesn't work, but others do.

POSTED BY: Orest Gogosha

Thank you for the quick response. I tried your suggestion. Please see the attached file.

GOGO

Attachments:
POSTED BY: Orest Gogosha
Posted 6 years ago

One way of getting around that error is

ClearAll[all];
mice=50.*10^-3;
thetaslope=30.*Pi/180;
kspring=25.;
xspring=100.*10^-3;
g=-9.8;
DSolve[{mice*x''[t]+kspring*x[t]==thetaslope*mice*g,x[0]==.1,x'[0]==0},x[t],t]

which returns

{{x[t]->-0.0102625+0.110263 Cos[22.3607 t]}}

Check the documentation on ClearAll because you might also be using that incorrectly.

POSTED BY: Bill Nelson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard