Carl Love

Carl Love

28035 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

I combined your two Posts into the above. If you wish to include additional material, please put it as a Comment to this Post rather than as a separate Post.

@sand15 Hyperlinks can be directly embedded in MaplePrimes posts by using Ctrl-K or the toolbar item that looks like two links of chain. I edited your posts in this thread to convert your links to true hyperlinks.

@Samir Khan I don't know if MapleFlow supports the remove statement yet, but if it does, then a more direct way to Answer the Question (as originally posed) is

remove(type, L, string)

What is the axis of revolution? If you use one of the coordinate axes, you'll get something closer to a sphere than to a torus.

@rlopez These Typesetting-based adjustments only affect the display of expressions. The determination of equality is up to the kernel, not the GUI display.

@ecterrab: The width of the n-dash is fine by me. However, I think that the vertical thickness of the line is too thin. Could it be made bold? It also seems too low vertically when applied to a numeral (this might depend on the font).

What about the other issue that I showed in that worksheet, the extra very thin space between the n and the minus sign in the prettyprinted display of n-x, where n is a numeral? In other words, the minus sign is not exactly centered between its operands.

In the situation that you describe---"being unable to do anything (even 2+2)"---do the characters "2+2" appear on the screen as they are typed?

The coloring conditional can be simplified in a much more understandable way with xor, i.e., "exclusive or":

a xor b  iff  (a or b) and not (a and b)  iff  (a and not b) or (b and not a)

The evalf[4](evalhf(...)) is better handled by first making an hfloat Array and then rounding it to 4 decimal places:

restart:
RC:= (0..35, 0..9):
DocumentTools:-Tabulate(
    <
        <x, seq(nprintf(`#mi("%.2f");`, j/100), j= RC[2])>^%T,
        <
            <seq(nprintf(`#mi("%.1f");`, i/10), i= RC[1])>  |
            (evalf[4]~@rtable)(
                RC, (i,j)-> (1+erf((10*i+j)/100/sqrt(2)))/2, datatype= hfloat
            )
        >
   >,
   exterior= none,
   fillcolor= ((T,i,j)-> `if`(i=1 xor j=1, "LightBlue", "White"))
):

@Christopher2222 As far as I can tell, ToInert does nothing in your example, nor would I expect it to. The alias commands do all the work. Indeed, if ToInert did do something here, that would definitely be a bug, because it would mean that ToInert has an unintentional and undocumented side effect.

Here is your worksheet, which I've re-executed, and the only change I made was commenting out the ToInerts.
 

NULL

General metric

Lecture 5 in Math Prediction

NULL

NULL

restart

with(Physics); Setup(mathematicalnotation = true); Setup(signature = `+---`)

[signature = `+ - - -`]

ds2 := exp(v(r, t))*c^2*dt^2-exp(lambda(r, t))*dr^2-r^2*(da^2+sin(a)^2*dp^2)

exp(v(r, t))*c^2*dt^2-exp(lambda(r, t))*dr^2-r^2*(da^2+sin(a)^2*dp^2)

Setup(coordinatesystems = (Z = [t, r, a, p]), metric = ds2)

[coordinatesystems = {Z}, metric = {(1, 1) = exp(v(r, t))*c^2, (2, 2) = -exp(lambda(r, t)), (3, 3) = -r^2, (4, 4) = -r^2*sin(a)^2}, spaceindices = lowercaselatin_is]

g_[]

Physics:-g_[mu, nu] = Matrix(%id = 36893490730637264524)

Christoffel[`~alpha`, mu, nu, nonzero]

Physics:-Christoffel[`~alpha`, mu, nu] = {(1, 1, 1) = (1/2)*(diff(v(r, t), t)), (1, 1, 2) = (1/2)*(diff(v(r, t), r)), (1, 2, 1) = (1/2)*(diff(v(r, t), r)), (1, 2, 2) = (1/2)*exp(-v(r, t)+lambda(r, t))*(diff(lambda(r, t), t))/c^2, (2, 1, 1) = (1/2)*c^2*exp(v(r, t)-lambda(r, t))*(diff(v(r, t), r)), (2, 1, 2) = (1/2)*(diff(lambda(r, t), t)), (2, 2, 1) = (1/2)*(diff(lambda(r, t), t)), (2, 2, 2) = (1/2)*(diff(lambda(r, t), r)), (2, 3, 3) = -exp(-lambda(r, t))*r, (2, 4, 4) = -exp(-lambda(r, t))*r*sin(a)^2, (3, 2, 3) = 1/r, (3, 3, 2) = 1/r, (3, 4, 4) = -sin(a)*cos(a), (4, 2, 4) = 1/r, (4, 3, 4) = cot(a), (4, 4, 2) = 1/r, (4, 4, 3) = cot(a)}

Ricci[nonzero]

Physics:-Ricci[mu, nu] = {(1, 1) = (1/4)*(2*((diff(diff(v(r, t), r), r))*r+(1/2)*(diff(v(r, t), r))*((diff(v(r, t), r))*r-(diff(lambda(r, t), r))*r+4))*c^2*exp(v(r, t)-lambda(r, t))-2*(diff(diff(lambda(r, t), t), t)-(1/2)*(diff(lambda(r, t), t))*(diff(v(r, t), t)-(diff(lambda(r, t), t))))*r)/r, (1, 2) = (diff(lambda(r, t), t))/r, (2, 1) = (diff(lambda(r, t), t))/r, (2, 2) = (1/4)*(2*(diff(diff(lambda(r, t), t), t)-(1/2)*(diff(lambda(r, t), t))*(diff(v(r, t), t)-(diff(lambda(r, t), t))))*r*exp(-v(r, t)+lambda(r, t))-2*((1/2)*r*(diff(v(r, t), r))^2-(1/2)*r*(diff(v(r, t), r))*(diff(lambda(r, t), r))+(diff(diff(v(r, t), r), r))*r-2*(diff(lambda(r, t), r)))*c^2)/(c^2*r), (3, 3) = 1+(1/2)*(-(diff(v(r, t), r))*r+(diff(lambda(r, t), r))*r-2)*exp(-lambda(r, t)), (4, 4) = -(1/2)*(-2+((diff(v(r, t), r))*r-(diff(lambda(r, t), r))*r+2)*exp(-lambda(r, t)))*sin(a)^2}

Ricci[scalar]

(1/2)*(-exp(v(r, t))*(diff(lambda(r, t), r))*(diff(v(r, t), r))*exp(-v(r, t)-lambda(r, t))*c^2*r^2+exp(v(r, t))*(diff(v(r, t), r))^2*exp(-v(r, t)-lambda(r, t))*c^2*r^2+2*exp(v(r, t))*(diff(diff(v(r, t), r), r))*exp(-v(r, t)-lambda(r, t))*c^2*r^2-2*exp(v(r, t))*(diff(lambda(r, t), r))*exp(-v(r, t)-lambda(r, t))*c^2*r+2*exp(v(r, t))*(diff(v(r, t), r))*exp(-v(r, t)-lambda(r, t))*c^2*r+exp(lambda(r, t))*(diff(v(r, t), t))*(diff(lambda(r, t), t))*exp(-v(r, t)-lambda(r, t))*r^2-exp(lambda(r, t))*(diff(lambda(r, t), t))^2*exp(-v(r, t)-lambda(r, t))*r^2-2*exp(lambda(r, t))*(diff(diff(lambda(r, t), t), t))*exp(-v(r, t)-lambda(r, t))*r^2-2*(diff(lambda(r, t), r))*exp(-lambda(r, t))*c^2*r+2*exp(-lambda(r, t))*(diff(v(r, t), r))*c^2*r+4*exp(-lambda(r, t))*c^2-4*c^2)/(c^2*r^2)

NULL

NULL

alias(diff(v(t), t) = diff(v(r, t), t))

alias(diff(v(t), t, t) = diff(v(r, t), t, t))

alias(diff(v(x), x) = diff(v(r, t), r))

alias(diff(v(x), x, x) = diff(v(r, t), r, r))

NULL

alias(diff(lambda(t), t) = diff(lambda(r, t), t))

alias(diff(lambda(x), x) = diff(lambda(r, t), r))

alias(diff(lambda(x), x, x) = diff(lambda(r, t), r, r))

alias(diff(lambda(t), t, t) = diff(lambda(r, t), t, t))

NULL

Ricci[scalar]

(1/2)*(-exp(v(r, t))*`&lambda;'`*`v'`*exp(-v(r, t)-lambda(r, t))*c^2*r^2+exp(v(r, t))*`v'`^2*exp(-v(r, t)-lambda(r, t))*c^2*r^2+2*exp(v(r, t))*(diff(`v'`, r))*exp(-v(r, t)-lambda(r, t))*c^2*r^2-2*exp(v(r, t))*`&lambda;'`*exp(-v(r, t)-lambda(r, t))*c^2*r+2*exp(v(r, t))*`v'`*exp(-v(r, t)-lambda(r, t))*c^2*r+exp(lambda(r, t))*(diff(v(t), t))*(diff(lambda(t), t))*exp(-v(r, t)-lambda(r, t))*r^2-exp(lambda(r, t))*(diff(lambda(t), t))^2*exp(-v(r, t)-lambda(r, t))*r^2-2*exp(lambda(r, t))*(diff(diff(lambda(t), t), t))*exp(-v(r, t)-lambda(r, t))*r^2-2*`&lambda;'`*exp(-lambda(r, t))*c^2*r+2*exp(-lambda(r, t))*`v'`*c^2*r+4*exp(-lambda(r, t))*c^2-4*c^2)/(c^2*r^2)

NULL

NULL

Download ToInert.mw

@sursumCorda The command ArrayTools:-Alias can be used to create a separate in-place pointer to an rtable (ArrayMatrixVector) with a different dimensionality. So you can switch back and forth between matrices and vectors, whatever your commands prefer, with no copying of the data.

@jalal That's good.

You can get rid of the displayed quotes, get rid of interface, and simplify the coloring conditional like this:  

restart:
DocumentTools:-Tabulate(
    <
        <x, seq(nprintf(`#mi("0.0%d");`, j), j= 0..9)>^%T,
        <
            <seq(nprintf(`#mi("%d.%d");`, iquo(i,10,'r'), r), i= 0..35)> |
            Matrix((36,10), (i,j)-> evalf[4](evalhf((1+erf((10*i+j-11)/100/sqrt(2)))/2)))
        >
   >,
   exterior= none,
   fillcolor= ((T,i,j)-> `if`(i*j = 1 or i*j > max(i,j), "White", "LightBlue"))
):

@sursumCorda Yes, you're right. Thanks for noticing that. So a corrected Matrix constructor is

<
    <x, seq(nprintf("%4.2f", j/100), j= 0..9)>^%T,
    <
        <seq(nprintf("%3.1f", i/10), i= 0..35)> |
        Matrix((36,10), (i,j)-> evalf[4](evalhf((1+erf((10*i+j-11)/100/sqrt(2)))/2)))
    >
>;

I came up with a much simpler explanation of how to derive the equation. It's essentially the same as the above with the steps to compute removed because it's easy to see that the sum of the distances to the foci is exactly the major-axis length. I also made explicit the steps needed to get rid of the square roots to get the standard polynomial form.

restart:
Dist:= (P,Q)-> sqrt(add((P-Q)^~2)):  #Euclidean distance between points P and Q

P:= <x,y>:                       #An arbitrary symbolic point on the ellipse
F:= [<0,-5>, <5, 0>]:  MA:= 12:  #Givens: Foci and major-axis length

(* An ellipse's defining property: The sum of the distances from any of its
points to its foci is constant. I'll call that constant C for the moment. 

The major axis is the line segment that the ellipse cuts from the line 
through the foci. If we measure the distances from either of the points where
that line meets the ellipse (those points are called vertices) to the foci, then
you can see that C is the length of the major axis. *)

add(map(Dist, F, P)) = MA;
             sqrt(x^2 + (-5 - y)^2) + sqrt((5 - x)^2 + y^2) = 12

expand(%^2);  #Squaring gets both sqrts into a single term
                    2*x^2 + 2*y^2 + 10*y + 50 + 
      2*sqrt(x^2 + y^2 + 10*y + 25)*sqrt(x^2 + y^2 - 10*x + 25) - 10*x = 
                                144

#Separate terms with and without sqrt:
selectremove(hastype, (lhs-rhs)(%), anything^(1/2));
             2*sqrt(x^2 + y^2 + 10*y + 25)*sqrt(x^2 + y^2 - 10*x + 25),
                         2*x^2 + 2*y^2 - 10*x + 10*y - 94

`-`(expand([%]^~2)[]);  #Square both groups, then subtract
                476*x^2 - 200*x*y + 476*y^2 - 2880*x + 2880*y - 6336

(primpart/sign)(%);  #Cancel common integer factors of the coefficients
                  119*x^2 - 50*x*y + 119*y^2 - 720*x + 720*y - 1584


 

@mmcdara Because of the special evaluation rule of piecewisedecisions is seen as 1 argument rather than 2, just like it is with `if`. So piecewise acts as if it has 2 arguments. When piecewise has an even number of arguments, then a default value is used in case all the conditions are false. Usually, the default value is 0, but it's possible for the user to change it.

@hojat You can skip the derivatives entirely; NLPSolve will compute them in the background if needed. Doing simply

NLPSolve(I1, assume= nonnegative),

I get

[1.53301315530314795*10^(-13), [gh1 = 0.154462739528209, gh2 = 0.371529041174829, gi1 = 1.37108385850808, gi2 = 0.860957036085277, gl1 = 12.9569226548585, gl2 = 9.39082402975947, gs1 = 1.04561251174819, gs2 = 0.586651783990275, p_i0 = 8.48431621548923*10^(-7), p_i1 = 0., p_i2 = 0., ph0 = 2.39549267065501, ph1 = 1.88487638439243*10^(-8), ph2 = -8.56043422781661*10^(-10), pl0 = 0., pl1 = 4.86320524745181*10^(-7), pl2 = 0., ps0 = 0.599755159534200, ps1 = 0., ps2 = 0.]]

I don't know whether nonnegative is a valid solution for you. It's just an example.

@hojat Why "estimate" or approximate the derivatives when you can compute them exactly, as you already have?

First 46 47 48 49 50 51 52 Last Page 48 of 708