C_R

3562 Reputation

21 Badges

6 years, 86 days

MaplePrimes Activity


These are replies submitted by C_R

@sand15 

I had time to study your code. Great stuff, really!

Your code contains two essential elements required to automate model finding: Generating models from a model type and determining residuals. I assume that dedicated Symbolic Regression software packages allow for further user input as:

- complexity (length of the model, leaft count, ...)

- accuracy (allowed error)

- objective function for the residuals (Maples Optimization package has an option for that)

- model type selector 

Please make the reply above an answer that I can vote up for it.

Please also consider making the reply with your lost comments a post that more users can read it. I think symbolic regression is of general interest and Maple has already many functions on board that are required for a dedicated command or application.

@sand15 

Yes I am very interested. All what I have tried was not satisfying.

@dharr 

My requirement: An algorithm (not me) that searches for a model that fits a given data set best.

My best guess for the dataset above is a periodic function with a modulated argument. With that guess I could establish a few models and then try non-linear regression on them and compare the fidelity of the fits.

Symbolic regression is supposed to do this for me (including even models I do not imagine).

@Ronan 

I have added an example to my original post. CurveFitting offers 9 models. I have try them all to find out which one is best. Splines, for example, work well for the example but the returned expression is large and piecewiese. That is not what I want.

Ideally symbolic regression returns "simple" models (in a compact form) automatically. Maybe a trig function with a "somehow" modulated argument could fit well. 

The interactive option is indeed helpfull in trying out models. Thank you.

@acer 

Now it makes sense. Thanks you!

@acer 

I would be interested if this was done intentionally. Thank you!

@acer 
In the above have replaced x by alpha:  

x=0.08718861663 alpha=0.08718861663

This is the value for alpha that plot computes for the second plot point and used in the JacobiCN call.

a := RootOf(JacobiCN(sqrt(2)*sqrt(alpha), sqrt(2)*_Z/2)^2*_Z^2 + _Z^2 - 2):
subs(alpha=0.08718861663,a);
      /                                          2              \
      |        /              (1/2)  1  (1/2)   \    2     2    |
RootOf|JacobiCN|0.2952771861 2     , - 2      _Z|  _Z  + _Z  - 2|
      \        \                     2          /               /

Sorry again for not beeing clear.

@acer

Sorry, for beeing not clear.

Tracing your example,
plot(a, alpha=0..0.5, adaptive=false, numpoints=7)
I see that plot calls fsolve for the second plot point this way

fsolve(JacobiCN(0.2952771861*2^(1/2), 1/2*2^(1/2)*t)^2*t^2 + t^2 - 2);

where 0.2952771861=sqrt(alpha).
This squared

0.2952771861^2 <> 0.5/(7 - 1);
                 0.08718861663 <> 0.08333333333

does not match exactly the sampling I would have expected for numpoints=7 over the length of 0.5 (of the range).

@one man 

The animation runs with the changes.

INSCRIBED_SPHERES_CILL_FOR_-_2025.mw

 

 

@acer 

I now understand that fsolve returns two roots at alpha=0. With the following conversion I cannot reproduce the change of roots anymore

a := RootOf(JacobiCN(sqrt(2)*sqrt(alpha), sqrt(2)*_Z/2)^2*_Z^2 + _Z^2 - 2);

b := convert(a, Elliptic_related);
         
plot(b, alpha = 0 .. 0.5);

This might be because sn looks considerably different in the above range and no change of sign of D(f)(x) might occur.

plot3d(JacobiSN(sqrt(2)*sqrt(alpha), sqrt(2)*_Z/2), alpha = 0 .. 0.2952771861^2, _Z = -20 .. 20);

The problem occurs elsewhere (with an unexpected drop in magnitude that should not be there; but this is off-topic).

I have no more rootfinding questions but still cannot explain why numpoints comes up with x=0.08718861663 alpha=0.08718861663 for the second plot point.

@Christopher2222

Thank you! 
I agree. With all the great tools we have at hand today we get numerical accuracy for free which does not mean that the fidelity of the models require it. Education should emphasize on what a particular problem requires in terms of accuracy.

Not so long ago the slide rule was good enough to bring man to the moon ... and back.
In Maple parlance Digits:=4

@one man 
The output of Isolate is different. Any idea why?

@acer 

Thank you. This is very helpful.
Before asking I tried plot(...) assuming positive. I see from

trace(fsolve);# I thought fsolve is builtin and therefore not traceable
a := RootOf(JacobiCN(sqrt(2)*sqrt(alpha), sqrt(2)*_Z/2)^2*_Z^2 + _Z^2 - 2);
(plot(b, alpha = 0 .. 0.5, adaptive = false, numpoints = 7) assuming positive);

that assuming has no effect on the calls to fsolve.
What I still do not understand is the second call to fsolve that returns a negative value whereas the first call returns a sequence (last element positive) and the third call to fsolve returns a positve value.
Even outside the plot call I see this pattern.

untrace(fsolve);
fsolve(sol^2 - 1);
fsolve(JacobiCN(0.2952771861*2^(1/2), 1/2*2^(1/2)*t)^2*t^2 + t^2 - 2);
fsolve(JacobiCN(0.4037956981*2^(1/2), 1/2*2^(1/2)*t)^2*t^2 + t^2 - 2);
                        -1.000000000, 1.

                          -1.042514994

                          1.077400841

Comparing this with

allvalues(RootOf(JacobiCN(0*2^(1/2), 1/2*2^(1/2)*t)^2*t^2 + t^2 - 2));
allvalues(RootOf(JacobiCN(0.2952771861*2^(1/2), 1/2*2^(1/2)*t)^2*t^2 + t^2 - 2));
allvalues(RootOf(JacobiCN(0.4037956981*2^(1/2), 1/2*2^(1/2)*t)^2*t^2 + t^2 - 2));
                             1, -1

                   1.042514994, -1.042514994

                   1.077400841, -1.077400841

gives a consistent ordering.

Increasing the plot range and the grid point proportionally

plot(a, alpha = 0 .. 0.5*30, adaptive = false, numpoints = 7*30)

shows the same negative value for the second plot point.
What makes the value of 0.2952771861 special that fsolve returns a negative value? Maybe it is cn that can get close to 1.

plot3d(JacobiCN(sqrt(2)*sqrt(alpha), sqrt(2)*_Z/2), alpha = 0 .. 0.2952771861^2, _Z = -20 .. 20)

 P.S.: there is something else that I cannot explain about the sampling of the seond point

0.2952771861^2 <> 0.5/(7 - 1);
                 0.08718861663 <> 0.08333333333

The animation is not working with Maple 2024 and 2025. That's what I get. Former versions work well

1 2 3 4 5 6 7 Last Page 1 of 70