Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

It's a trivial application of LinearAlgebra:-LinearSolve:

d:= < <1,0,0> | <0,-2,0> | <1,0,1> >: #The basis from the wiki page.
Rep:= (D,v)-> LinearAlgebra:-LinearSolve(D,v);
Rep(d, <1,1,1>);

Here's an example to show what the results returned by DirectSearch:-SolveEquations mean and how to extract the individual results.


restart:

f,g:= 'randpoly([x,y]) + rand(0..99)()' $ 2;

-4*x^3*y-83*x^2*y^2-10*y^4+97*x^2-73*y^2-62*x+33, 72*x^3*y^2+37*x^2*y^3-23*x*y^4-92*x^4+6*x*y^3+74*y^4+58

Sol:= DirectSearch:-SolveEquations([f,g]);

Sol := [8.98117704412354*10^(-17), Vector(2, {(1) = 0.3667096848e-8, (2) = 0.8738659574e-8}), [x = 1.06474017545247, y = .656111069248074], 86]

The third component is the solutions, obviously. The second component is the vector of residuals:

eval(<f,g>, Sol[3]);

Vector(2, {(1) = 0.3667105730e-8, (2) = 0.8738652468e-8})

The first component is the sum of the squares of the residuals:

add(r^2, r in Sol[2]);

HFloat(8.98117704412354e-17)

The fourth component is the number of times that the system of equations was evaluated, which is verified below.

F:= proc(X,Y)
global Fcnt;
     Fcnt:= Fcnt+1;
     eval(f, [x= X, y= Y])
end proc:  

G:= proc(X,Y)  eval(g, [x= X, y= Y])  end proc:

Fcnt:= 0:

DirectSearch:-SolveEquations([F,G]);

[8.98500185640660*10^(-17), Vector(2, {(1) = 0.3667210646e-8, (2) = 0.8739263535e-8}), Vector(2, {(1) = 1.06474017545246, (2) = .656111069248073}), 86]

Fcnt;

86

The individual solutions can be extracted like this:

eval(x, Sol[3]); eval(y, Sol[3]);

HFloat(1.064740175452467)

HFloat(0.6561110692480737)

 

``


Download SolveEquations.mw

You need to split the inequality into two and use solve. Like this:

T:= 4477.25+.25*(t-32450):
solve({4477.25 <= T,T <= 16042.25}, t);

Use * to represent multplication:

y - y1 = m*(x - x1);

 

Your original formulation returns the error "Initial Newton iteration is not converging":

restart:
ode:=
     diff(f(eta),eta$3) + f(eta)*diff(f(eta),eta$2) - (diff(f(eta),eta))^2 +
     lambda*(2*f(eta)*(diff(f(eta),eta))*(diff(f(eta),eta,eta)) -
            f(eta)^2*diff(f(eta),eta,eta,eta)) -
     k*(diff(f(eta),eta)-1) =
     0:
params:= [lambda= 0.1, k= 0.2, inf= 10]:
BCs:= f(0) = 0, D(f)(0) = 1, D(f)(inf) = 0:
dsolve(eval({ode, BCs}, params), numeric);

Error, (in dsolve/numeric/bvp) initial Newton iteration is not converging

This is a common error for numeric BVPs. It can often be corrected by introducing a "continuation parameter." (See ?dsolve,bvp,advanced .) Notice the C that I added to your ode below. It is in front of the fourth term, next to lambda. There is a lot of guesswork involved in deciding where to put the parameter. I usually start with making it a coefficient of the most complicated term, which is what worked here.

ode:=
     diff(f(eta),eta$3) + f(eta)*diff(f(eta),eta$2) - (diff(f(eta),eta))^2 +
     C*lambda*(2*f(eta)*(diff(f(eta),eta))*(diff(f(eta),eta,eta)) -
            f(eta)^2*diff(f(eta),eta,eta,eta)) -
     k*(diff(f(eta),eta)-1) =
     0:

Sol:= dsolve(eval({ode, BCs}, params), numeric, continuation= C);
plots:-odeplot(Sol, [eta, f(eta)], 0..10, thickness= 2);

I is reserved as the imaginary unit in Maple. You can change this by declaring another symbol to be the imaginary unit, let's say II, by the command

interface(imaginaryunit= II);

In Maple 17+, you can also declare local variables at the top level:

local I;

and then use I as you wish.

The imaginary parts are small and probably spurious (i.e., due simply to round-off error). You can plot the real parts with Re:

plot(Re(eq), x= 0..1);

If you have some theoretical reason to believe that this expression eq should be purely real for x= 0..1, then you can verify that the imaginary parts are truly small and safe to ignore by plotting the imaginary parts:

plot(Im(eq), x= 0..1);

Doing this, I see that the real parts are of order 1 and the imaginary parts are of order 10^(-6). Considering the huge size of your coefficients, I think that it is safe to ignore the imaginary parts, if you have some theoretical reason to do so

 

 

 

Student:-Calculus1:-VolumeOfRevolution(
     x^2, sqrt(x), x= 0..1, axis= horizontal , distancefromaxis= -1,
     output= animation, partition= 40,
     volumeoptions= [color= yellow]
);

If you you want to do the rotation about the line x = -1 by the washer method, then you need to integrate with respect to y. Because your functions are inverses of each other, the command is the same as above with x changed to y, which in reality changes nothing. More interesting is to do it by shells. For this change the axis option to axis= vertical.

To get a Maple plot similar to the kgraph plot, use the view option to restrict the view:

plot(A[.., 1], A[.., 2], view= [-1.5e-9..2.5e9, -2..2]);

Since you are using (1D) Maple Input, it is incorrect to define a function (procedure) by

g(t):= f(x(t), alpha(t), beta(t))

The correct syntax is

g:= t-> f(x(t), alpha(t), beta(t)).

If you use the "g(t):=", then you are defining an expression that will only work when the is explicitly used. That is, g(t) will work, but g(1.0) will not.

 

Example:

Ell:= x^2+4*y^2-2*x-16*y+13=0:
# Make sure the x and y ranges are large enough to contain the entire ellipse by  viewing the plot.
plots:-implicitplot(Ell, x= -5..5, y= -5..5, gridrefine= 3);
A:= op([1,1], %); #Extract point data array from plot.

Let's say that the function that you want to save is named F. Then do

save F, "C:/users/carl/desktop/F.map":
restart:

read "C:/users/carl/desktop/F.map":

This process is can be used to save any variables, not just functions.

Since you are using select, I assume that you want to select the terms that have second derivatives rather than selecting the derivatives themselves. To do this, we convert the expression to D form, do the select, then convert back to diff form:

convert(select(has, convert(eq[1], D), D@@2), diff);

I'm still thinking about your second question.

First the operation `^` of 10.2^20 is carried out by "automatic simplification", as is all basic arithmetic. So it is done in the 10-digit default environment. Then that result, already rounded to 10 digits, is passed to evalf. The automatic simplifcation is not delayed by the "special evaluation rules" of evalf. However, if you change the exponentiation into a procedure call, then it can be delayed.

use `^`= ((x,y)-> :-`^`(x,y)) in evalf(10.2^20, 50) end use;

The residual sum of squares that you got applies to the underlying linear model. The help at ?ExponentialFit has this caveat:

However, it is important to note that these options, including the output option for obtaining additional results, apply to the transformed model.

LinearFit([1,x], X, ln~(Y), x, output= residualsumofsquares);

0.00216641200893470

To get the residual sum of squares for the exponential model, you'll need to do something like

F:= unapply(ExponentialFit(X, Y, x), x):
add((F(X[k])-Y[k])^2, k= 1..numelems(X));

 

 

 

 

 

 

First 302 303 304 305 306 307 308 Last Page 304 of 395