acer

26362 Reputation

29 Badges

16 years, 319 days

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@mmcdara Sure.

I'd like to see Statistics:-NonlinearFit offer use of a global optimizer in general, with a variety of different objectives offered.

@mmcdara Yes, there are various mechanisms for doing similar. Using signum is nice and clean.

Originally I was writing code that programmatically determined the data splits and did fancy stuff. But then I reflected that the OP hadn't provided much backdrop and context, so threw it away.

I happened to choose,
     piecewise(x<=0, Fn, -eval(Fn,x=-x))
using only one of the formulas, because I was still mentally stuck on some general idea.

@mmcdara There are enough things unclear in the Question that I wasn't going to worry. (Is the OP looking for a globally best fit? Any fit? Is this the full data set? Etc.)

I recall that the OP's previous Question was also muddled.

[edit] If I cared a great deal about the quality of the fit then I wouldn't have rounded the coefficients to half-a-dozen decimal places. I was hoping that that OP would respond with some clarification, prompted by what I'd shown.

@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.

First 65 66 67 68 69 70 71 Last Page 67 of 489