tomleslie

13876 Reputation

20 Badges

15 years, 176 days

MaplePrimes Activity


These are answers submitted by tomleslie

to get this to work the way I would expect, I had to specify both 'parts' in the Parts() command, as in

restart;
with(IntegrationTools):
A:=(diff(f(x,y),x)+g(x,y))*(diff(k(x,y),x)+h(x,y));
AI:=int(A,x);
Parts(AI, op(1,A), op(2,A));

For future problems, please use the big green up-arrow in the edit toolbar to upload code, rather than using pictures. It saves on the (error-prone) retyping

I don't think that one can routinely obtain a partial derivative from the numeric solution of a PDE system. Sometimes this can be achieved, by adding an appropriate equation to the PDE system - in your case of the form p(x,t)=diff(C(x,t),x), then solving the expanded system, then using pdsolve() to solve for both p(x,t) and C(x,t), where the former is actually the partial derivative which you want. I tried this approach, but kept running into numerical problems: not saying that this approach couldn't be made to work, just that I didn't succeed.

So I went for the second approach, which basically comprises, the steps

  1. pdsolve() the original PDE system
  2. fit a 'function' to the returned numeric values of C(x,t),. I used cubic splines many other fitting strategies are avaliable)
  3. Now one can work with the fitted function - differentiate it, integrate it whatever. Bear in mind that because it is a fitted function it should only be used in the range over which it was fitted. If you extrapolate - all bets are off

You had a syntax error in the way the piecewise boundary condition is defined. You cannot use relations such as 0 <=x <= L . You have to use  0 <=x and x <= L, so I fixed this as well.

My "solution" is shown in the attached worksheet

pdeProb.mw

restart;
A := [1, 2, 3/2, 4, 5/9]:
B := [2, 5, -7, 1, 8]:
C := [-1, -2, -3, -4, -5/3]:
for i to nops(A) do
    printf( cat( "The equation ",
                         convert(x^2*A[i]+x*B[i]+C[i] = 0, string),
                      " has two solutions which are %s\n"
                    ),
              latex( [solve( A[i]*x^2+B[i]*x+C[i] = 0)],
                         output=string
                      )
           ):
od;

or, for output to a file

restart;
myFileName:="C:/Users/TomLeslie/Desktop/testLtx.txt":
A := [1, 2, 3/2, 4, 5/9]:
B := [2, 5, -7, 1, 8]:
C := [-1, -2, -3, -4, -5/3]:
for i to nops(A) do
    fprintf( myFileName,
                 cat( "The equation ",
                           convert(x^2*A[i]+x*B[i]+C[i] = 0, string),
                        " has two solutions which are %s\n"
                      ),
                latex( [solve( A[i]*x^2+B[i]*x+C[i] = 0)],
                          output=string
                        )
           ):
od;
close(myFileName);

 

frcc(t) just emans the fractional part of the variable t: inother words if t=1.75, this has fractional part 0.75. Thus 1+frac(t) will give the curve whihc you have produced - since frac(t) just ranges from 0 to 1, then repeats, so 1+frac(t) ranges from 1 to 2.

Is it correct? Well it is at least consistent! If you compute laplace(g,t,s), then your original function is returned. So I am assuming that this particular laplace pair is stored in Maple's table of known transforms - sd it certainly ought to be correct.

I would expect evalr( 1/INTERVAL(-1 .. 1)) to evaluate to INTERVAL(-infinity .. -infinity) - which it doesn't. I assume that the singularity at the origin "breaks" something. However if I use the equivalent(?) sequence of ranges  evalr(1/INTERVAL(-1..x,x..1)), without specifying 'x', then INTERVAL(-infinity .. infinity) is returned - nno real idea why!

I'm not sure what is meant by your second example evalr( INTERVAL(-1,-1,1,1) ), since the arguments to INTERVAL() have to be given as a sequence of ranges. I would have expected Maple to return an error if no range inputs are given.  If I interpret your argument as evalr(INTERVAL(-1..-1,1..1)), then the simple sequence -1, 1 is returned. NB not a sequence or an INTERVAL, just a sequence of two values. I would consider this evaluation to be "correct"

Using the latest version of your worksheet, I got the same "error" as you.

However, reading the code convinced me that it should not be happening. I concluded that it was some "side-effect" of using 2D-input (as Carl suggested): so I stripped out all the non-executable text, and converted the 2D-input to 1D-input. The "error" still happened ;-(

Don't ask me why, but I got the impression that even in this 1D-input, some "non-printing" character(s) still existed somewhere in the worksheet.

Cutting/pasting this 1D-input into a new, clean, worksheet - the error persisted. So instead I pasted this 1D-input from Maple into a text editor, to look for anything anomalous. Nothing!

I then pasted code from text editor, back into a new worksheet. "Error" has disappeared :-)

Converted this "error-free" 1D-Input, to 2D-input - still no error. Opened a new worksheet in "document mode" and pasted the 2-D code into this - still no error. This last worksheet is attached.

weirdOne.mw

I still think that your problem was caused by some 'non-printing' characters in your original fileand that these were "stripped out" when transferring to/from the text editor. Hence I would strongly advise against doing any cut+paste from your the file you originally supplied (or any of its antecedents) - otherwise the problem might reappear. In fact I recommend deleting them and using only the attached.

without a lot of useless confusing crap, then I would probably use

 restart:
 with(plottools):
 with(plots):
 m:= [ polygon( [[2, 2], [2, 3], [4, 3], [4, 2]],
                            color = blue
                        ),
           polygon( [[1, 1], [1, 4], [5, 4], [5, 1]],
                            color = red
                        ),
           polygon( [[1, 4], [3, 6], [5, 4]],
                           thickness = 3,
                           color = red
                        ),
           curve( [[4.5, 5.5], [5, 6]] ),
           curve( [[5.5, 6], [6, 6.5]] ),
           polygon( [[3.5, 5], [4, 5.5], [4.5, 5], [4, 4.5]],
                           color = red
                        )
        ]:
 display(m);

 

is that you define quantities 'E1' and 'E2', but then you then use fsolve() with 'Eq1' and 'Eq2'.

Even if you fix this by rewriting your fsolve command as

res := fsolve({E1-1, E2-1}, {a, b})

then your second problem is that 'E1' contins the variables 'a' and 'y', whilst 'E2' contains the variables 'a', 'b', and 'y'. In other words you have two equations in three unknowns - never a good idea in an fsolve() command

but I am always concerned when I read something like this, that the OP may not grasp the difference between 'local' and 'global' variables - in fact variable 'scope' in general

Now I am absolutely certin that Kitonum knows this distiinction, but OP might wnat to consider why

restart:
g:=(m,n)->alpha(m,n)*beta(m,n);
h:=(p,q)->alpha(p,q)+beta(p,q);
f:=(r,s)->D[1](g)(r,s)*h(r,s);
f(u,v);

produces exactly the same answer as Kitonum's original solution

restart;
with(IntegrationTools):
A:=diff(f(x,y),x)*diff(c(x,y),x);
B:=int(A,x,y,z);
Parts(B, diff(f(x,y),x), applytoall);

with executable code, because

with(Statistics):
A := Sample(Normal(0,1), 1000):
Histogram(A, legend="fred");

works for me

but maybe either

restart;
A := [1, 2, 3/2, 4, 5/9]:
B := [2, 5, -7, 1, 8]:
C := [-1, -2, -3, -4, -5/3]:
for i to nops(A) do
    printf("The equation x^2*A[i]+x*B[i]+C[i] = 0 has two solutions which are %s\n",
            latex([solve( A[i]*x^2+B[i]*x+C[i] = 0)],output=string)
           ):
od;

or (for output to a file)

restart;
myFileName:="C:/Users/TomLeslie/Desktop/testLtx.txt":
A := [1, 2, 3/2, 4, 5/9]:
B := [2, 5, -7, 1, 8]:
C := [-1, -2, -3, -4, -5/3]:
for i to nops(A) do
    fprintf( myFileName, "The equation x^2*A[i]+x*B[i]+C[i] = 0 has two solutions which are %s\n",
            latex([solve( A[i]*x^2+B[i]*x+C[i] = 0)],output=string)
           ):
od;
close(myFileName);

will work

This will output 'latex' results to the Maple environment

restart;
A := [1, 2, 3/2, 4, 5/9]:
B := [2, 5, -7, 1, 8]:
C := [-1, -2, -3, -4, -5/3]:
for i to nops(A) do
     latex([solve( A[i]*x^2+B[i]*x+C[i] = 0)]):
od;

This will send  'latex' resuts to the specified output file - note that you will have to change the file name to something appropriate for your machine/OS

restart;
myFileName:="C:/Users/TomLeslie/Desktop/testLtx.ltx":
A := [1, 2, 3/2, 4, 5/9]:
B := [2, 5, -7, 1, 8]:
C := [-1, -2, -3, -4, -5/3]:
for i to nops(A) do
    latex([solve( A[i]*x^2+B[i]*x+C[i] = 0)], myFileName, append):
od;

 

but one of the following ought to do what you want

a:=0.6364562590;
evalf[3](a);
round(a);
floor(a);
ceil(a);
trunc(a);

 

a:=[1,2,3,4,5];
select(i -> i<4, a);

First 154 155 156 157 158 159 160 Last Page 156 of 207