Carl Love

## 26084 Reputation

11 years, 51 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

## Edges need two vertices...

I replaced Tree := Tree, {whattype(elem),elem} with Tree := Tree, {whattype(elem)} and I get the following output and error :

Error, (in GraphTheory:-Graph) invalid edge/arc: {2}

Well, of course. Every edge needs two vertices.

## Edges need two vertices...

I replaced Tree := Tree, {whattype(elem),elem} with Tree := Tree, {whattype(elem)} and I get the following output and error :

Error, (in GraphTheory:-Graph) invalid edge/arc: {2}

Well, of course. Every edge needs two vertices.

## @STHence  Is there any way that ...

Is there any way that Maple only solves first 9 equations and then substitutes the resluts to the last equation at each instant?

Like I said, I already did solve it for only the first 9 equations. Doing so, each "instant" would take on the order of 53 minutes of CPU time. So if the integration uses, say, 200 evaluation points, then that could take a week or more. (Although there may be a "learning" effect where subsequent evaluation points take less time.)

Update: In addition, without last ODE, by using "eliminate" function in order to remove lambda 1 and lambda 2 from the equations, Maple can solve first 9 ODEs without any errors or warning.

Like I said, the dsolve itself ran fine in 22 seconds. It is using the results of the dsolve that takes a lot of time.

There's a chance that increasing the error tolerances and settings Digits to, say, 4 will make it run significantly faster. I don't have much hope for this approach though. It might be possible to simplify the equations after the eliminate and before the dsolve. And it might be possible to apply a code optimizer like codegen[optimize] to the procedure that dsolve returns.

## @STHence  Is there any way that ...

Is there any way that Maple only solves first 9 equations and then substitutes the resluts to the last equation at each instant?

Like I said, I already did solve it for only the first 9 equations. Doing so, each "instant" would take on the order of 53 minutes of CPU time. So if the integration uses, say, 200 evaluation points, then that could take a week or more. (Although there may be a "learning" effect where subsequent evaluation points take less time.)

Update: In addition, without last ODE, by using "eliminate" function in order to remove lambda 1 and lambda 2 from the equations, Maple can solve first 9 ODEs without any errors or warning.

Like I said, the dsolve itself ran fine in 22 seconds. It is using the results of the dsolve that takes a lot of time.

There's a chance that increasing the error tolerances and settings Digits to, say, 4 will make it run significantly faster. I don't have much hope for this approach though. It might be possible to simplify the equations after the eliminate and before the dsolve. And it might be possible to apply a code optimizer like codegen[optimize] to the procedure that dsolve returns.

## Initial conditions...

> How would one determine these?

There has to be some context in the original problem for them. For example, if a problem says "A gun is fired straight up from a height of 10 m with an initial velocity of 500 m/s. What is the height H(t) of the projectile at time t?" then the initial conditions are H(0) = 10 and H'(0) = 500.

> Cause I use maple to assist with this?

Once you determine the initial conditions, Maple can help with solving for the constants.

You should post the entire original problem and your call to dsolve. It's hard to believe that you are dealing with Mathieu functions with three parameters and six constants of integration and yet you had to ask those two questions. So my guess is that you've entered the problem incorrectly into dsolve.

## Initial conditions...

> How would one determine these?

There has to be some context in the original problem for them. For example, if a problem says "A gun is fired straight up from a height of 10 m with an initial velocity of 500 m/s. What is the height H(t) of the projectile at time t?" then the initial conditions are H(0) = 10 and H'(0) = 500.

> Cause I use maple to assist with this?

Once you determine the initial conditions, Maple can help with solving for the constants.

You should post the entire original problem and your call to dsolve. It's hard to believe that you are dealing with Mathieu functions with three parameters and six constants of integration and yet you had to ask those two questions. So my guess is that you've entered the problem incorrectly into dsolve.

Great that you have access to a later version, because I was about to write a downgrade for Maple 13. Try it out on your desired Int and diff commands, although I clearly see the need for some mods to get shorter labels.

Great that you have access to a later version, because I was about to write a downgrade for Maple 13. Try it out on your desired Int and diff commands, although I clearly see the need for some mods to get shorter labels.

@JamesK Please attach the worksheet where you get the error. I don't understand why you are getting the error about Prefix not being exported (although I do know what the error message means). And what version of Maple are you using?

As for the Int and diff, I'll have to think about that a bit. But they will be handled like any other unevaluated function call. You can get a function tree for an entire worksheet by using the Worksheet package. And my module should handle it and give you a graph. You'd be able to work with the graph programatically, but it would be too big to plot.

@JamesK Please attach the worksheet where you get the error. I don't understand why you are getting the error about Prefix not being exported (although I do know what the error message means). And what version of Maple are you using?

As for the Int and diff, I'll have to think about that a bit. But they will be handled like any other unevaluated function call. You can get a function tree for an entire worksheet by using the Worksheet package. And my module should handle it and give you a graph. You'd be able to work with the graph programatically, but it would be too big to plot.

## Ah, the plot command is taking the time...

@STHence Okay, I am getting the problem now. The eliminate and dsolve take a minute or two, but the plot takes an incredibly long time. I let it run for about 45 minutes of processor time before I killed it.

The solution provided by dsolve is very complicated. The solution procedure sol is 90MB of code. I tried to evaluate a single point, sol(1.). I let it run for 5 minutes before I killed it. Perhaps simplifying the input equations after eliminate but before dsolve will help. Or maybe it would be better to do the integral the old way (rather than in dsolve) in this case.

Edit: Update: I took out the last ODE, the one to get the integral. After that, the dsolve ran in 22 seconds, and the generated procedure sol is 1.3 MB, so it's still complicated. To evaluate it at just one point, sol(1.), took 53 minutes of CPU time. So, even without the last ODE, it would near impossible to get a plot of the other functions.

## Ah, the plot command is taking the time...

@STHence Okay, I am getting the problem now. The eliminate and dsolve take a minute or two, but the plot takes an incredibly long time. I let it run for about 45 minutes of processor time before I killed it.

The solution provided by dsolve is very complicated. The solution procedure sol is 90MB of code. I tried to evaluate a single point, sol(1.). I let it run for 5 minutes before I killed it. Perhaps simplifying the input equations after eliminate but before dsolve will help. Or maybe it would be better to do the integral the old way (rather than in dsolve) in this case.

Edit: Update: I took out the last ODE, the one to get the integral. After that, the dsolve ran in 22 seconds, and the generated procedure sol is 1.3 MB, so it's still complicated. To evaluate it at just one point, sol(1.), took 53 minutes of CPU time. So, even without the last ODE, it would near impossible to get a plot of the other functions.

## You can start a new file (worksheet)...

@JamesK You can work in a new worksheet as long as you "Execute Code" as I described, AND the new worksheet is running in the same kernel server as the original.

Alternatively, you can save the code from the Code Edit Region to a plain text file (like with Windows Notepad). Let's say you called the file "FunctionToTree.mpl". Then make the first command in your new worksheet

where C:/.../.../ is whatever is appropriate for your system. If you do it this way, then it doesn't matter which kernel server you use.

## You can start a new file (worksheet)...

@JamesK You can work in a new worksheet as long as you "Execute Code" as I described, AND the new worksheet is running in the same kernel server as the original.

Alternatively, you can save the code from the Code Edit Region to a plain text file (like with Windows Notepad). Let's say you called the file "FunctionToTree.mpl". Then make the first command in your new worksheet

where C:/.../.../ is whatever is appropriate for your system. If you do it this way, then it doesn't matter which kernel server you use.

## Did you enter the blue code?...

@JamesK Oh, did you enter the blue code "FunctionToTree:= module()..." that your transcript shows? You're not supposed to do that. Put your mouse cursor in the code window, right click, and select "Execute Code". Then execute the commands in red. The blue code is just the output of the "Execute Code".

 First 649 650 651 652 653 654 655 Last Page 651 of 679
﻿