Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hi everyone,
I am currently trying to solve a differential equation in Mathcad. However, after watching a bunch of Youtube-Tutorials on how to use the solve-block with ODEs, I am still not able to get the result. What am I doing wrong? Your help is much appreciated 🙂
greetings
nerphan
Solved! Go to Solution.
If you don't mind the red errors from the numeric engine when defining your functions, you can leave your worksheet unchanged and just add the two regions with the substitute commands and change the first line in your solve block (and of course lower the time end value). And you may use different function names for the new functions if you don't want to overwrite the old definitions.
But personally I would prefer avoiding the errors by adding the function as a second argument to the functions as shown above.
BTW, when you try to duplicate the regions with the substitute commands you will notice that ever so often Prime infamous "auto-labelling feature" comes in the way. You have to try to give the various phi the label which finally works. Sometimes its necessary to change the label from "-" (meaning "automatic") to "variable", sometimes you have to do just the opposite. Prime auto-labelling sure is a PITA, especially when you use the symbolic engine.
See if it works with this. (I cannot check, I'm limited to Prime Express).
Success!
Luc
Hi Luc,
thx for you answer. Mathcad still gives me an error unfortnately 😞
First problem:
Which propagates:
You need to reformulate the solve block equations to reflect the true expression for the function you're solving for.
I can't run it (constrained to Express), but attached file is an attempt at an edit.
Hi Fred_Kohlhepp,
I can't open your document, as my Prime 2.0 does not seem to be compatible with it. But I think your answer is identical to that, what luc did (see screenshot in my reply to him)
Fred saved the file from Prime 7 (There's no way in Prime to save to the format of a previous version), so you cannot open that in Prime 2.
I've created a translation to Prime 2 of Fred's file, so you can see for yourself.
I've also built the system in Mathcad 11, and it will not solve. Mathcad 11 complains "Cannot evaluate this accurately at one or more of the values you specified"... whatever that may mean.
Success!
Luc
Have you tried to change the end value from 6 s to something as low as just 1 s? See my approach below which works up to t.end=1.2 seconds. Just be curious if MC11 can cope with your approach using a more reasonable end value.
I was surprised that your posted attempt by copy and paste the function terms directly to the solve block did not work (it also didn't by lowering the end value).
Here is my try.
It works, but not up to 6 seconds. Can't get it farther than 1,2 seconds. As you can see in the plot the values for phi shoot high up.
Guess you should check your equations.
I attach a pdf print and the worksheet in Prime 6 format.
Luc seems to have found a method to convert sheets back to older versions so maybe he can convert the sheet to Prime 2 format for you.
I could not make it work without redefining F.a and h by substituting the function phi(t) and its derivative by simple variables. Thats a bit awkward but at least I could avoid having to copy and paste expressions.
If you don't mind the red errors from the numeric engine when defining your functions, you can leave your worksheet unchanged and just add the two regions with the substitute commands and change the first line in your solve block (and of course lower the time end value). And you may use different function names for the new functions if you don't want to overwrite the old definitions.
But personally I would prefer avoiding the errors by adding the function as a second argument to the functions as shown above.
BTW, when you try to duplicate the regions with the substitute commands you will notice that ever so often Prime infamous "auto-labelling feature" comes in the way. You have to try to give the various phi the label which finally works. Sometimes its necessary to change the label from "-" (meaning "automatic") to "variable", sometimes you have to do just the opposite. Prime auto-labelling sure is a PITA, especially when you use the symbolic engine.
Hallo Werner,
thanks alot man, your solution worked for me and you were right about the equations, I found the mistake and now the solution looks more plausible.
How can you evaluate the time needed to travel to 90°?
I tried this, but it didn't work:
"Sometimes its necessary to change the label from "-" (meaning "automatic") to "variable","
I did not understand that, could you show me an explample please?
Here's an example, in Prime 2.
Prime has this miraculous DANGEROUS feature of autolabelling. It labels whatever you type to one of the 7 types of label that I put in.You can select any mathematical item on your sheet and look at the Label that Prime has set for it. If necessary (and sometimes it IS necessary) you can change the label of the item.
If an item is 'not labelled' it shows in Prime 2 as (none), in some later version of Prime that was renamed to (-) which means "automatic".
Two items with (exactly) the same name, but different labels are treated as different items. That's clear for a unit m versus a variable m, because the unit shows differently from a variable.
Now the display of a (none) or (Variable) labelled item is the same, so it is easy to overlook this and often times this causes problems, especially in symbolics.
Hope this helps.
Success!
Luc
Thanx alot Luc on explaining on that. So far, this auto-albelling bug did not seem to occur on Prime 2.0
How can you evaluate the time needed to travel to 90°?I tried this, but it didn't work:
The symbolic solve won't work with the only numerically derived function phi.
You may use either a solve block
or the "root" command - either by providing a guess value
or by providing a range
"Sometimes its necessary to change the label from "-" (meaning "automatic") to "variable","
I did not understand that, could you show me an explample please?
As you obviously were able to retype what I had shown in the picture(s) you were lucky and did not run into the troubles I experienced. Maybe the problem with the auto-labelling feature and symbolic evaluations was introduced in a later version than the one you are using.
According to variable labels Luc has already answered in more detail.
Seems to work ok if you make n have the same dimensions as nleer, and if you change the functions to be functions of phi not t.
.
Hi AlanStevens,
thanks for the answer mate :). As I had a mistake in one of the equation (see below)
the diagramm after the corrected equation does not seem to represent the expected solution. I think it matters, if i make all the functions depended on phi instead of t.
forgot to post the diagramm:
The difference is because I assumed x' was derivative with respect to phi, rather than with respect to t. Correcting that I get:
Alan
Thanks alot to you guys! Wouldn't be able to make this progress without your help.
Could you please explain me the following things?
ad 1) Asking for the shortest t.90 time seems senseless as the larger you chose i, the shorter the time
ad 2) not clear what you mean. What exactly do you want to "stop"?
pdf of the modified file attached.
P.S.: I had to play around with the definition of n to get it to work finally as of big troubles with Primes auto-label "feature". Really looks like this problem was introduced after the version you are using.
Hi Werner_E,
thanks alot. All your answers helped me to successfully complete my calculations! 🙂
Could you please explain what you did here? This is something I could never think of.
odesolve usually return a function, so the normal usage would be
f := odesolve(....)
And you can use that function as expected, like f(2)=...
In your case the solve block is additionally dependent on a variable i.
Dependent on i a different function is returned.
So actually phi(i) is something like a function NAME (like f in the example above).
But Prime wont allow us to use it like phi(i)(2)=... and also not like phi(i,2)=....
So I defined a new function phi(i,t) which first calls the solve block and "stores" the result (a function) in f and then calls that function with the desired argument t. It may not have been the best idea to give it that function the same name phi. Probably naming the result of the solve block phi.temp(i) and calling that function in the definition of phi would have been more clear.
There is a drawback with that definition, though: If you use the phi(i,t) for plotting and the plot is, lets say, evaluated for 1000 points, then the solve block would be called 1000 times! The same applies if you numerically integrate that function.
If things like that should be done, it would be more efficient to use something like
f:=phi(3) (lets say we are interested in the result function with i=3) and then plot or integrate the function f(t).