Carl Love

Carl Love

28025 Reputation

25 Badges

12 years, 313 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

You use the command sign in your for loop. You need to change that to either signum or csgn (which one doesn't matter in this case)The command sign in Maple is something completely different and unrelated. This is a very common error in Maple. If you make the change, you'll get the answer

     sol1 := {y0 = 57.69046866}

from fsolve. See ?signum, ?csgn, and ?sign.

Yes, you convert those equations which contain integrals to differential equations by taking the derivatives with respect to t of each side. You are correct that that makes the initial conditions disappear. They are supplied separately to the dsolve command. So equation A becomes

diff(u[smooth](t), t) = - i[smooth](t)/C[smooth]

and likewise for equation C.

You made two errors: First, you must consistently refer to functions of t as functions of t. So i[komp] in equation B and i[load] in equation D need (t) appended. Second, you have u[loadt] in equation D where you intended (I presume) u[load].

The command to solve this DAE IVP system is dsolve. The specific command is

dsolve(
     {igl, u[smooth](0)=US0, u[ckomp](0) = UC0},
     {u[smooth](t), i[smooth](t), i[komp](t), i[load](t), u[ckomp](t), u[load](t)}
);

Note that I represented the initial conditions as US0 and UC0. This system can be solved symbolically by dsolve, but the solution is much too long to copy here. It's in the attached worksheet:

igl.mw

If you're writing purely numeric Maple code in double precision, it is possible to have that code automatically translated to C, compiled, and linked to your Maple. To the user, it seems just like running an ordinary Maple procedure. See ?Compiler,Compile. It is often possible to run such code in parallel using the Threads package, thereby utilizing 100% of your processor.

If you post some of your code, I may be able to quickly show you how it's done.

That error message is so weak and unhelpful that it's pathetic. What, it can't even detect that you mispelled an option name? You just need to change numerical to numeric.

About your second error, you need to change your decimal constants to exact fractions. You can do that like this:

pdsolve({convert(Selkov[1], rational), convert(Selkov[2], rational)});

I don't know if the above command will ever return an answer---I got tired of waiting---but it won't give you the "general case of floats" error.

The 3/8 rule can be derived in three steps with Maple. We take four arbitrary points with evenly spaced x-coordinates and find the interpolating polynomial. Then integrate that and simplify the result. Like this:

CurveFitting:-PolynomialInterpolation([four x-values], [four y-values], x, form= Newton);
int(%, x=
...);
factor(%);

I leave it to you to fill in the four x-values, the four y-values, and the interval of integration. The results of the first two commands will be surprisingly long and complicated. Let Maple worry about that and don't be discouraged. As you can see, the result of the third command is exactly what you're looking for.

I'm assuming that you have a one-dimensional set of data (a set of real numbers). Then simply compute the mean mu and standard deviation sigma of the data. Then the best fit is Normal(mu, sigma). For the mean, use Statistics:-Mean, and for the standard deviation, use Statistics:-StandardDeviation.

If you have a two-dimensional set of data (a set of pairs of real numbers), let me know.

This will handle most cases, including negative, fractional, decimal, and symbolic exponents and expressions that don't contain the variable.

power:= (E::algebraic, t::name)-> simplify(t*diff(expand(ln(E)),t)):

Example of use:

power(0.5*t^5*r^(-1)*V, t);

     5

Stylistically it's better to define a procedure that takes an expression and a variable rather than one that just takes an expression. It'll give you much more flexibility later on.

Any function can be made inert by prepending a % to the name. The inert function can be converted its non-inert form by value. This is exactly analogous to Int being the inert form of int

Any function foo(...) can be made to prettyprint as something else by defining a procedure `print/foo`. This only affects the way that expressions containing the function prettyprint; it doesn't affect the lprint of those expressions, nor does it change their values.

Putting these two ideas together leads, in my opinion, to a more-elegant solution to your problem:

 

`print/%pi`:= ()-> Pi:

pi:= ()-> Pi:

term:= proc(lst::list, k::integer)
local n:= nops(lst);     
     seq(lst[m+1]*exp(-I * 2*%pi()/n *(k*m)), m= 0..n-1)
end proc:


r:= term([1,2,3], 1);

1, 2*exp(-((2/3)*I)*%pi()), 3*exp(-((4/3)*I)*%pi())

(1)

value([%]);

[1, -1-I*3^(1/2), -3/2+((3/2)*I)*3^(1/2)]

(2)

 

 

Download Inert_pi.mw

I didn't need to use %pi and pi to do the above; it would've worked had I used %foo and foo. Thus we don't have to rely on the fact that Pi has another expression, pi, that ordinarily prints the same---a fact that is somewhat idiosyncratic to Pi.

By the way, the reason that subs gave you an error message is that r was an expression sequence, not a list. So it looked to subs as if you were passing it four arguments, which would only be valid if the first three were equations. I find expression sequences dangerous to work with and almost always convert them to lists.

Note that most of your code didn't appear in your Question. So I can't answer your first question. Try uploading code with the green uparrow tool, which is the last tool on the second row of the toolbar in the MaplePrimes editor.

Regarding your question about display: This command is in the package plots, so you either need to refer to it as plots:-display or issue the command with(plots).

 

As I believe you've already figured out, the problem is a small amount of noise in the x-coordinates: They're not all exactly equal to 1. That's because first it computes 1/cos(t) in polar coordinates and then multiplies that by [cos(t), sin(t)] to get the [x,y] coordinate for display.

Consider the following procedural parametric plot in Cartesian coordinates, which is symbolically equivalent to the given polar plot:

plot([1, tan, 0..Pi/3]);

It produces the expected plot of a vertical line segment. Now consider this procedural parametric plot, which is computationally equivalent to the given polar plot:

plot([
     proc(t) local r,x; r:= 1/cos(t); x:= r*cos(t) end proc,
     proc(t) local r,y; r:= 1/cos(t); y:= r*sin(t) end proc,
     0..Pi/3
]);

It produces a plot identical to the "junk" plot.

Without specifying a viewing range for the x-coordinate, I think that this bug would be extremely difficult to fix, if it is even to be considered a bug. What if someone wanted a plot that showed the small variations in x?

Use the save and read commands. See ?save and ?read.

You need to use the value command so that solve can "look inside" the inert Sums. The value command converts inert functions into their active forms.

solve(
     value(simplify(syssub) union {simplify(f[1](0))=2, simplify(f[2](0))=1}),
     {a[0][1], a[0][2], a[1][1], a[1][2], a[2][1], a[2][2]}
);

I had to retype your code, which I hate doing. In the future, please post code in plaintext form and/or include an uploaded worksheet. You can upload worksheets by using the green uparrow tool that is the last item on the second row of the toolbar in the MaplePrimes editor.

The functions' names are f[i], so that is what should appear on the left of the assignment operator.

N:= 3:
for i from 1 to 2 do
     f[i]:= unapply(a[0][i]+Sum(a[j][i]*t, j= 1..N), t)
od;

The command unapply turns an expression into a procedure (or function). It works better than -> in this case because you want i to be evaluated at the time the function is defined rather than the time it is called. The function calls should be made as f[1](0), not f(0)[1].

You simply need to apply the combine command to the result of diff.

w:= x-> Sum(a[j]*x^j, j= 0..infinity);

(By the way, note the preferred syntax for defining a function: w:= x-> ..., rather than w(x):= ....)

diff(w(x), x);

combine(%);

If you declare a Units environment (such as Standard) and give your unknown variable y appropriate units, then the solve will work:

restart:
with(Units:-Standard):
Q:= 20*Unit('m')^3/Unit('s');
I__e:= 0.2e-1;
B:= 2*Unit('m');
k:= 0.3e-2*Unit('m');
g := 9.82*Unit('m')/Unit('s')^2;
M:= 8.1*g^(1/2)/k^(1/6); #Manning's number
Y:= y*Unit('m');
A:= Y*B;
R:= Y*B/(B+2*Y);
V:= M*R^(2/3)*sqrt(I__e);
y__0:= solve(Q = V*A, y);

First 268 269 270 271 272 273 274 Last Page 270 of 395