Carl Love

## 25831 Reputation

10 years, 359 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

## Indefinite integrals cannot be numerical...

@Markiyan Hirnyk The inconvenience of having an indefinite integral in a dsolve solution is that it can't be numerically evaluated in a convenient way. Here's an example of plotting. Here I use the Asker's new version of the ODE, for which dsolve produces essentially the same indefinite integral.

 > restart;
 > DQ:= -((D@@2)(y))(r)-2*y(r)/r+y(r) = (2*(2-1/r^2))*r*exp(-r):
 > Y:= rhs(dsolve(DQ, y(r))):
 > YY:= simplify(value(subs(Ei(1,-2*r)= -Ei(2*r), Y))):
 > plot(eval(YY, [_C1= 0, _C2= 0]), r= 1..9);

 > plot(eval(Y, [_C1= 0, _C2= 0]), r= 1..9);

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

## ln(2) is constant of integration...

...which differs from mathematica in the particular solution, there is on more term, namely: 2*r*exp(-r)*ln(2) which is already covered in the term r exp(-r)*_C2 of the general solution. What could be said to this?

If you put the new differential equation into the worksheet that I posted and run through the steps, then I think you'll see what's going on. The integration generates a term -ln(2*r), which becomes -ln(2) - ln(r) on simplification. One way to think of it is that the indefinite integral produces a constant of integration, but the int command does not supply an arbitrary constant . Since there are already two constants provided by dsolve, it is necessary that this extra constant matches up with a term which already has one of the dsolve-supplied constants. I guess that this can be used as a sort of accuracy check.

Maple's indefinite integration usually, but not always, produces 0 as the constant of integration; it depends on what is convenient. Here's a simple example, pretty close to the case at hand, where it doesn't.

 > int(ln(2*x)/x, x);

 > expand(%);

Clearly 1/2*ln(2)^2 is a more convenient constant than 0 for the unexpanded form in this case.

Plaese let me know whether this explanation satisfies you.

## ln(2) is constant of integration...

...which differs from mathematica in the particular solution, there is on more term, namely: 2*r*exp(-r)*ln(2) which is already covered in the term r exp(-r)*_C2 of the general solution. What could be said to this?

If you put the new differential equation into the worksheet that I posted and run through the steps, then I think you'll see what's going on. The integration generates a term -ln(2*r), which becomes -ln(2) - ln(r) on simplification. One way to think of it is that the indefinite integral produces a constant of integration, but the int command does not supply an arbitrary constant . Since there are already two constants provided by dsolve, it is necessary that this extra constant matches up with a term which already has one of the dsolve-supplied constants. I guess that this can be used as a sort of accuracy check.

Maple's indefinite integration usually, but not always, produces 0 as the constant of integration; it depends on what is convenient. Here's a simple example, pretty close to the case at hand, where it doesn't.

 > int(ln(2*x)/x, x);

 > expand(%);

Clearly 1/2*ln(2)^2 is a more convenient constant than 0 for the unexpanded form in this case.

Plaese let me know whether this explanation satisfies you.

## That timing not valid because of remembe...

@Markiyan Hirnyk Your timing is not valid because of remember tables. You have to test on different numbers. Here's a better test. Actually, doing the integration symbolically first is about 25 times faster using 512 evaluation points.

 > restart;
 > DQ:= -((D@@2)(y))(r)-2*y(r)/r+y(r) = ((4/9-exp(-r)/r)*2)*r*exp(-r):
 > Y:= rhs(dsolve({DQ, y(1)=1, D(y)(1)=2}, y(r))):
 > L1,L2:= seq(RandomTools:-Generate(list(float(range= 1..9), 2^9)), k= 1..2):
 > st:= time():
 > Y1:= simplify(Y):
 > CodeTools:-Usage(assign('EY1', [seq](evalf(eval(Y1, r= x)), x= L1))):

memory used=2.49GiB, alloc change=60.01MiB, cpu time=25.38s, real time=24.55s

 > t1:= time()-st;

 > st:= time():
 > Y2:= simplify(value(applyrule(Ei(1,_X::algebraic)= -Ei(-_X), Y1))):
 > CodeTools:-Usage(assign('EY2', [seq](evalf(eval(Y2, r= x)), x= L2))):

memory used=81.38MiB, alloc change=0 bytes, cpu time=860.00ms, real time=809.00ms

 > t2:= time()-st;

 > t1/t2;

## That timing not valid because of remembe...

@Markiyan Hirnyk Your timing is not valid because of remember tables. You have to test on different numbers. Here's a better test. Actually, doing the integration symbolically first is about 25 times faster using 512 evaluation points.

 > restart;
 > DQ:= -((D@@2)(y))(r)-2*y(r)/r+y(r) = ((4/9-exp(-r)/r)*2)*r*exp(-r):
 > Y:= rhs(dsolve({DQ, y(1)=1, D(y)(1)=2}, y(r))):
 > L1,L2:= seq(RandomTools:-Generate(list(float(range= 1..9), 2^9)), k= 1..2):
 > st:= time():
 > Y1:= simplify(Y):
 > CodeTools:-Usage(assign('EY1', [seq](evalf(eval(Y1, r= x)), x= L1))):

memory used=2.49GiB, alloc change=60.01MiB, cpu time=25.38s, real time=24.55s

 > t1:= time()-st;

 > st:= time():
 > Y2:= simplify(value(applyrule(Ei(1,_X::algebraic)= -Ei(-_X), Y1))):
 > CodeTools:-Usage(assign('EY2', [seq](evalf(eval(Y2, r= x)), x= L2))):

memory used=81.38MiB, alloc change=0 bytes, cpu time=860.00ms, real time=809.00ms

 > t2:= time()-st;

 > t1/t2;

## Need to reduce Digits for fsolve...

If you're trying to solve with fsolve, then you need to drastically reduce the value of Digits.

## Need to reduce Digits for fsolve...

If you're trying to solve with fsolve, then you need to drastically reduce the value of Digits.

## cos^2 + sin^2 = 1...

Your g(x) reduces to g(x) = A, because of most-well-known trig identity: cos^2 + sin^2 = 1. So, there is not really any parameter C.

## Nice plot. 0 => 12?...

Nicely detailed plot!

I don't how clock faces usually appear in your culture, but I think that in most of the Western World the position that you have labeled as 0 is labeled as 12 (even though mathematicians and especially computer programmers must wish it was 0). It is so culturally ingrained that we refer to an distant object directly in front of us as "at 12 o'clock" and a distant overhead object as being "12 o'clock high".

## What keyboard...

@Christopher2222 Like I said, bytes and alt-codes are not the same for me, except that the regular keyboard characters 32-127 are the same. Maybe it has something to do with what language keyboard you're using. I'm uaing USA Standard English. What are you using?

## What keyboard...

@Christopher2222 Like I said, bytes and alt-codes are not the same for me, except that the regular keyboard characters 32-127 are the same. Maybe it has something to do with what language keyboard you're using. I'm uaing USA Standard English. What are you using?

## Typesetting Level => Standard, not Exten...

@Joe Riel You're right, the Output Display can be set to 2D Math Notation or Typseset. However, I still need Typesetting Level set to Standard, not Extended. Which begs the question, What is Extended Typesetting for?

## Typesetting Level => Standard, not Exten...

@Joe Riel You're right, the Output Display can be set to 2D Math Notation or Typseset. However, I still need Typesetting Level set to Standard, not Extended. Which begs the question, What is Extended Typesetting for?

## 13 equations, 12 unknowns...

You have 13 equations and only 12 unknowns. It is possible to remove the last equation? Using fsolve on the first 12 equations, I get RT = -10.054. Is that feasible for your problem? Do you have feasibility ranges for the other variables?

## Adjusted output display settings to make...

@brian bovril I got Joe's code to work after a bunch of fiddling with my output settings. I am running in a Standard worksheet with 1D input (Maple Input). I load the code out of a Code Edit Region, but the good old bold red Maple Input works as well. In order for it do anything interesting, however, the output display needs to be set to "Typeset Notation" and the Typesetting Level needs to be set to "Maple Standard". These settings are accessed via the Tools => Options => Display menu.

Joe, where can I find documentation for these MathML codes? Particularly, I am interested in the identifier names the begin `#mrow. There doesn't seem to be anything about it in packages TypeSetting, MathML, DocumentTools, Worksheet, or XMLtools.

Minor point, easily correctable: I think you missed the point about the searches needing to be case insensitive. Perhaps you haven't seen the opening credits of the show. For example, the actor name Anna Gunn is shown as AnNa Gunn, with the Na highlighted as the sodium block from the periodic table.

 First 648 649 650 651 652 653 654 Last Page 650 of 671
﻿