vv

13837 Reputation

20 Badges

9 years, 318 days

MaplePrimes Activity


These are answers submitted by vv

The integrand has the form

F := a*exp(b*v^2)*v^c;
So,
int(F, v) :  simplify(%);


i.e. it can be expressed via incomplete GAMMA ( = the  2-arguments GAMMA).

 

If you select that line and convert it to 1D Math input (even if it appears to be 1D), the asterisk will be visible.

Why don't you use worksheet mode with 1D input?

L1 := [{3,5},{4,3},{4,6},{3,2},{2,6}]:
L2 := [1,5,4]:
evalb( `union`(L1[]) intersect {L2[]} <> {} );

    true

pde0:=diff(u(x,t),t)+diff(u(x,t),x)=0;
sol0:=pdsolve(pde0,u(x,t)) assuming x>0;
pdetest(sol0,pde0);

diff(u(x, t), t)+diff(u(x, t), x) = 0

 

u(x, t) = _F1(-x+t)

 

0

(1)

pde:=diff(u(x,t),t)+diff(u(x,t),x)=0;
bci:= u(0,t)=0, u(x,0)=sin(x);
sol:=pdsolve([pde,bci],u(x,t)) assuming x>0;
pdetest(sol,pde);

diff(u(x, t), t)+diff(u(x, t), x) = 0

 

u(0, t) = 0, u(x, 0) = sin(x)

 

u(x, t) = -sin(-x+t)*Heaviside(x-t)

 

0

(2)

restart;

# Executing all (with (!!!)) ==> 0
# Executing then only the 2nd execution group ==> <>0

#    Dirac(t-x)*sin(t)*cos(x)-Dirac(t-x)*cos(t)*sin(x)-Dirac(x-t)*sin(t)*cos(x)+Dirac(x-t)*cos(t)*sin(x)

 

This is strange but not a real bug. Let's call it "semi-bug".

Note first that the solution of the pde (with bci) is not a classic one. In fact, the solution (containing Heaviside) is continuous but not C^1; actually the partial derivatives do not exist on the line x=t.

I don't know what pdetest does to test the solution but obviously sol does not satisfy the pde everywhere. On the other side, the nonzero result of pdetest  simplifies to 0 with assuming x>t; also for assuming x<t

So, both results of pdetest(sol,pde)  (zero or not zero)  are correct; the problem is that this depends on the order of execution!

 

I mention that I used Maple 2018.2 without any update.

 

 


Download pde!!!.mw

I'd use

A:=[x1,x2,x3]:
B:=[f(x),g(x)]:
[seq([seq(eval(b,x=a),a=A)],b=B)];

        [[f(x1), f(x2), f(x3)], [g(x1), g(x2), g(x3)]]

The command  Get('xxx1')   returns a string, but you need an exprseq. Use parse(Get('xxx1')).
Or, simply add the line
xxx := parse(xxx);  o := parse(o);  co := parse(co);

These are mathematical conventions. For degree(0) alternative conventions are -1  and "undefined".
- infinity is preferable because e.g. the equality  degree(f*g) = degree(f) + degree(g)  remains valid.
These conventions are related (and compatible) with other two standard ones:
max({}) = - infinity  and  min({}) = infinity.

Try the old-fashioned solution:

f:=x->x^2:
printf("a=?");
a:=parse(readline());
'f(a)'=f(a);

 

Using a translation, we may suppose that the center of the sphere is (0,0,0).
Even so, the number of the solutions is large and not very easy to obtain (the brute force is out of the question).
E.g.  for the radius of the sphere in the interval  2.10 .. 2.11  here are 32 solutions (actually almost 6 times greater because the permutations are not included; probably other symmetries should have been excluded too):

{{[-20, -3, -3], [-20, 3, 3], [20, -3, 3], [20, 3, -3]}, {[-20, -3, 3], [-20, 3, -3], [20, -3, -3], [20, 3, 3]}, {[-19, -3, -3], [-19, 3, 3], [19, -3, 3], [19, 3, -3]}, {[-19, -3, 3], [-19, 3, -3], [19, -3, -3], [19, 3, 3]}, {[-18, -3, -3], [-18, 3, 3], [18, -3, 3], [18, 3, -3]}, {[-18, -3, 3], [-18, 3, -3], [18, -3, -3], [18, 3, 3]}, {[-17, -3, -3], [-17, 3, 3], [17, -3, 3], [17, 3, -3]}, {[-17, -3, 3], [-17, 3, -3], [17, -3, -3], [17, 3, 3]}, {[-16, -3, -3], [-16, 3, 3], [16, -3, 3], [16, 3, -3]}, {[-16, -3, 3], [-16, 3, -3], [16, -3, -3], [16, 3, 3]}, {[-15, -7, -1], [-15, 7, 1], [15, -5, -5], [15, 5, 5]}, {[-15, -7, -1], [-5, -13, -9], [5, 15, 5], [15, 5, 5]}, {[-15, -7, 1], [-15, 7, -1], [15, -5, 5], [15, 5, -5]}, {[-15, -7, 1], [-5, -13, 9], [5, 15, -5], [15, 5, -5]}, {[-15, -5, -5], [-15, 5, 5], [15, -7, -1], [15, 7, 1]}, {[-15, -5, -5], [-5, -15, -5], [5, 13, 9], [15, 7, 1]}, {[-15, -5, 5], [-15, 5, -5], [15, -7, 1], [15, 7, -1]}, {[-15, -5, 5], [-5, -15, 5], [5, 13, -9], [15, 7, -1]}, {[-15, -3, -3], [-15, 3, 3], [15, -3, 3], [15, 3, -3]}, {[-15, -3, 3], [-15, 3, -3], [15, -3, -3], [15, 3, 3]}, {[-15, 5, -5], [-5, 15, -5], [5, -13, 9], [15, -7, 1]}, {[-15, 5, 5], [-5, 15, 5], [5, -13, -9], [15, -7, -1]}, {[-15, 7, -1], [-5, 13, -9], [5, -15, 5], [15, -5, 5]}, {[-15, 7, 1], [-5, 13, 9], [5, -15, -5], [15, -5, -5]}, {[-13, -6, -1], [0, -14, -11], [0, 11, 4], [13, 4, 5]}, {[-13, -6, 1], [0, -14, 11], [0, 11, -4], [13, 4, -5]}, {[-13, -4, -5], [0, -11, -4], [0, 14, 11], [13, 6, 1]}, {[-13, -4, 5], [0, -11, 4], [0, 14, -11], [13, 6, -1]}, {[-13, 4, -5], [0, -14, 11], [0, 11, -4], [13, -6, 1]}, {[-13, 4, 5], [0, -14, -11], [0, 11, 4], [13, -6, -1]}, {[-13, 6, -1], [0, -11, 4], [0, 14, -11], [13, -4, 5]}, {[-13, 6, 1], [0, -11, -4], [0, 14, 11], [13, -4, -5]}}

The radii above are:
2.100420126, 2.102918181, 2.104995276, 2.106740650, 2.108221156, 2.108878475, 2.109487662

I don't post the code now because it is not clean & tested.

 

Increasing Digits (e.g. to 25) will solve the problem.
(There are also options such as 'abserr', 'relerr').
BTW, why are you so sure that rkf45 is the best method for your ODE? If you are not, let dsolve choose the method.

F:=<x[1]^(2)*sin(x[1]*x[2])+x[2]^(3)-5,    
    exp(x[1]^(2))*x[2]^(2)+3* x[1]^(2)*x[2]+x[2]^(2)-6>;

Vector(2, {(1) = x[1]^2*sin(x[1]*x[2])+x[2]^3-5, (2) = exp(x[1]^2)*x[2]^2+3*x[1]^2*x[2]+x[2]^2-6})

(1)

V:=<x[1],x[2]>;  # Variables

Vector(2, {(1) = x[1], (2) = x[2]})

(2)

G:=Matrix(2, (i,j) -> diff(F[i],V[j])):  # Jacobian

G1:=G^(-1):

X[0] := <0.1, 2.>;  # Initial iteration

Vector(2, {(1) = .1, (2) = 2.})

(3)

for k from 0 to 6 do
  X[k+1] := eval(V - G1.F, Equate(V, X[k]));
od;

Vector(2, {(1) = 0.58600855e-1, (2) = 1.750059558})

 

Vector(2, {(1) = .1847971795, (2) = 1.710602709})

 

Vector(2, {(1) = .1444078366, (2) = 1.709551622})

 

Vector(2, {(1) = .1388413340, (2) = 1.709461608})

 

Vector(2, {(1) = .1387315960, (2) = 1.709460320})

 

Vector(2, {(1) = .1387315523, (2) = 1.709460320})

 

Vector[column](%id = 18446744074402171950)

(4)

fsolve([F[1],F[2]], {x[1]=0..1, x[2]=1..3}); # compare with fsolve

{x[1] = .1387315528, x[2] = 1.709460319}

(5)

 


Download Newton2.mw

For functions of a single variable such as fsolve(f(x), x=a..b)  the initial iteration is usually indeed (a+b)/2.
It is not easy to grasp the fsolve code for such a complex command. But you can do some tests to see the evaluation points of the function.
For example:

f:=proc(x)  print(x) ; cos(x)-x end:
fsolve(f, 0.5 .. 10);

                          5.250000000
                          5.250005250
                          5.249947500
                          2.875000000
                          2.875002875
                          2.874971250
                          7.625000000
                          7.625007625
                          7.624923750
                        3.87708345542864
                          1.687500000
                          1.687501688
                          1.687483125
                       0.782569730439221
                       0.742447770776506
                       0.739097995069612
                       0.739085133328356
                  0.7390851333290950851333284
                  0.7390851332151606416581575
                          0.7390851332

 

 

After declare(...), the derivatives of any function (declared or not) are printed indexed.

A non-derivated function f(x,y) is printed as f  iff  f(x,y) appears in declare().

 

PDEtools[declare](y(t));

` y`(t)*`will now be displayed as`*y

(1)

diff(y(t),t) + y(t) + y(x);  
diff(p(s),s) + p(s) + p(x)

diff(y(t), t)+y(t)+y(x)

 

diff(p(s), s)+p(s)+p(x)

(2)

 

The restart command resets the "seed" of the random number generator to a default value.
You can remove the restart  or  insert a  randomize();  after it.

By default the arrow width depends on length. So, use e.g.:

PlotVector( [...], width=0.1);

 

First 58 59 60 61 62 63 64 Last Page 60 of 120