acer

33193 Reputation

29 Badges

20 years, 216 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Reshu Gupta Please don't submit this as a separate Question, just because nobody has answered it yet. (I have deleted two duplicates, so far.)

If you are impatient, you could look over this response to a recent and similar request about exporting dsolve,numeric data.

@Al86 Somehow you have entered what I gave as invalid 2D Input. I provided plaintext 1D Maple notation. 

I have no idea what you did, and it's almost impossible to guess because you have only pasted in an error message instead of attaching your actual document. That is not helpful.

If I paste it into a paragraph of a Document in 2D Input mode then it works for me.
 sigh.mw

@Al86 Here are two ways, given you expression (with parameters).

HH := 5*log[10]((c/H_0)*Int(1/(A*(1+zp)^4+B*(1+z)^3+C)^(1/2)/10,
                            zp=0..z,
                            method=_d01ajc, epsilon=1e-5)):

# 1st way, plots:-display and multiple `plot` calls.

plots:-display(
  plot(eval(HH,[A=2, B=3, C=4, H_0=1, c=299792458]), z=1e-7 .. 1.0,
       thickness=3, color=red, smartview=false),
  plot(eval(HH,[A=4, B=5, C=7, H_0=1, c=299792458]), z=1e-7 .. 1.0,
       thickness=3, color=blue, smartview=false),
  plot(eval(HH,[A=8, B=7, C=11, H_0=1, c=299792458]), z=1e-7 .. 1.0,
       thickness=3, color=green, smartview=false)
);

# 2nd way, a single `plot` call, with a list of expressions.

plot( [ eval(HH,[A=2, B=3, C=4, H_0=1, c=299792458]),
        eval(HH,[A=4, B=5, C=7, H_0=1, c=299792458]),
        eval(HH,[A=8, B=7, C=11, H_0=1, c=299792458]) ],
     z=1e-7 .. 1.0,
     color=[red,blue,green],
     thickness=3, smartview=false);

@mary120 In your Maple 11 the elementwise operation denoted by rhs~ would not work. You could try changing part of Tom's code to map the rhs command, instead.

In particular, this piece,

res:= Matrix( [ [ x, U1(x)],
                  seq( map(rhs,sol(j)[1..2]), j=0..20)
                ]
              );

See revised attachment,  q_ac.mw

@tomleslie The Question was tagged as Maple 11 prior to your asking about it.

@Pemudahijrah01 You can follow the instruction in my Answer, to obtain an explicit solution. It will be huge.

If might be smaller if there were some conditions on the unknown parameters. Could you provide any?

What do you intend on doing with the solution?

@tomleslie As is indicated at the top of this thread, the OP is running Maple 11.

@NeillSmith That is why I asked (a few times) whether it would be adequate if only the D form were to be prettyprinted as you asked.

You can use the green up-arrow in the Mapleprimes editor to upload and attach files, and to inline .mw worksheets here.

restart;

with(Typesetting):
Settings(typesetprime=true):
Suppress(f(x)):

 

convert( eval(diff(f(x),x), x=3), D )

(D(f))(3)

eval(convert( Eval(diff(f(x),x), x=3), D ));

(D(f))(3)

eqn := f(x)^2 = (diff(f(x),x) + 7)^2 + diff(f(x),x,x)/15;

f(x)^2 = (diff(f(x), x)+7)^2+(1/15)*(diff(diff(f(x), x), x))

convert( eval(eqn, x=3), D );

f(3)^2 = ((D(f))(3)+7)^2+(1/15)*((D@@2)(f))(3)

eval(convert( Eval(eqn, x=3), D ));

f(3)^2 = ((D(f))(3)+7)^2+(1/15)*((D@@2)(f))(3)

 

Download prime_D.mw

I realize that you also want f(x) to display as is. That's a concession, when using Suppress(f(x)) . I have a way to get both the D(f)(3) form as well as f(x) to print as you want, while not suppressing the argument in the printing of f(x), but it involves a (re)implementation of `print/D` which maybe too dodgy.

@Al86 Use the plots:-display command to put multiple plots together.

You can simply put three plot calls inside that, each with its own values for A,B,C. (There are other ways, but that way you don't have the burden of understanding and remembering even more syntax.)

Are you going to clarify your earlier syntax, to let me know whether I got its meaning close to right? There's also the matter of scale, units, and accuracy.

@rlopez Yes, that's why I was asking whether the OP would be OK with just the D form working. It wasn't clear to me whether he really needed eval(diff(f(x),x),x=0) or its inert Eval form to also work, since both appeared in his worksheet.

But I suspect that you intended,
   D(f)(0)
instead of,
   D(f)(x)(0)
[edit] Those both prettyprint the same, in the form that was requested. But only the first of them makes proper sense in the context of the Question.

@DarkMath The solve command is a little quirky with regard to assumptions.

However,

solve({sin(x)},x,real,explicit,allsolutions,useassumptions)
  assuming -3/2*Pi<=x, x<=3/2*Pi;

                {x = -Pi}, {x = 0}, {x = Pi}

solve({sin(x)},x,real,explicit,allsolutions,useassumptions)
  assuming -5/2*Pi<=x, x<=5/2*Pi;

     {x = -2 Pi}, {x = -Pi}, {x = 0}, {x = Pi}, {x = 2 Pi}

Personally, I think that I'd first try using the restrictions as extra conditions in the first argument, over using them as assumptions.

It looks like you didn't notice the link from the solve Help page to the solve,details Help page. That has more information about some of those options. There is an example lower down that page which uses the explicit,allsolutions options on a trig expression and a domain restricted by two simple inequalities.

[edit] The functionality of the trig-solver was improved somewhat a few years ago, after which that option pair combination became more useful for such cases constrained by inequalities, and the example added to the Help page.) Prior to that the strongest univariate exact trig solver over a specified finite range was probably Student:-Calculus1:-Roots leveraging the internal `minimize/solve`, and which is still pretty good.

Now it gets trickier to explain. The real option is only documented as being relevant for parametric solving (of polynomial systems). But a few releases ago it started (sometimes) having an effect on other classes of problem. Sometimes it helps, and (much more rarely) it hinders. I try with and without, when pressed. I have previously submitted a bug report about lack of documentation on it. I believe that your sin(x) example works both with and without it. That is,

solve({sin(x),x>=-3*Pi/2,x<=3*Pi/2},x,explicit,allsolutions);

                {x = -Pi}, {x = 0}, {x = Pi}

solve({sin(x)},x,explicit,allsolutions,useassumptions)
  assuming x>=-3*Pi/2,x<=3*Pi/2;

                {x = -Pi}, {x = 0}, {x = Pi}

@NeillSmith I am asking whether it would be adequate or helpful if you could get (only) the D form to look like you want.

Would it serve if it was just for D form? 

For example, D(f)(x) and D(f)(3) rather than diff(f(x),x) and eval(diff(f(x),x),x=3) ?

How much direct manipulation do you need to do, where you might not conveniently be able to utilize convert(...,D) when needing to display?

In one of your Replies below you wrote, "How can I extract the numerical data of (x,U1) to use it in another software such as Origin?"

Does that simply mean that you want to export the numeric data that could be plotted (independent x values and corresponding dependent U1 values)?

Or do you want to be able to code-generate the piecewise polynomial interpolants that the numeric solver may have computed (in a a target language such as C, etc)? That would allow you to generate arbitrary [x,U1(x)] pairs of values, externally, or adaptively plot externally, etc.

@dharr I'll note that solve has been historically quirky wrt trig solving under bounds. For this example, Maple 2020 can do better but note 1) the calling sequence has to be of a particular kind, and 2) some aspect of that calling sequence are undocumented.

solve({sin(x),x>=-3*Pi/2,x<=3*Pi/2},x,real,explicit,allsolutions);

                   {x = -Pi}, {x = 0}, {x = Pi}

That functionality is leveraged in few places in the Library.

First 183 184 185 186 187 188 189 Last Page 185 of 608