Udate:Need Help with al_nleqsolve; Two Questions

Udate:Need Help with al_nleqsolve; Two Questions - How can f(t,u) plot since t is never defined??? - Messages

#1 Posted: 2/11/2025 10:32:37 AM
RegRetired

RegRetired

8 likes in 130 posts.

Group: User

Razonar first gave me this formalism for al_nleqsolve. His formalism works perfectly; however, mine does not.

Here is my example SMATH file.

AL_NLEQSOLVE FIT.sm (20 KiB) downloaded 68 time(s).

Sorry, I forgot to upload the data file. Here it is.
WORLD EMISSION DATA VS DATE.xlsx (24 KiB) downloaded 45 time(s).

Two questions:

1. How can the plot of f(t,u) work because t is never defined?
2. I don't understand why my alternate formalism in the cyan box is not equivalent.


Thanks,
Reg
Reg Curry Loveland, CO
#2 Posted: 2/13/2025 8:36:48 AM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Hi Reg. You can see the result stored in Plot by hovering over it. In the case of the first option, Plot stores a one-variable expression (i.e., a single unknown, t) and a two-column matrix, so the graphs will be a univariate function and a set of points on the plane.

first.png

To analyze the second option, the nleqsolve set up is correct, but Plot fails to find the values ​​of a,b,c inside the fit function.

sec.png

As a final comment, XY Plot can graph expressions with any unknown, while SMath's native plot can also do so, but only with the variable "x".

I hope this clarifies a little why the second option doesn't work.

Best regards.
Alvaro.
#3 Posted: 2/13/2025 10:08:34 AM
RegRetired

RegRetired

8 likes in 130 posts.

Group: User

Alvaro,
Thanks much. I understand that.

Here is my second question as reference in my pm to you. Actually it's two question?

1. How did you make the Data2 resident so the xlsx file is not needed.

2. Because the emissions level off between 2014-2023, I am trying to switch from the exponential fit up to 2014 to a linear fit between 2014-2023 and extend that forward. Here is my attempt.

CO2 FORCING SATURATION STUDY working.sm (46 KiB) downloaded 55 time(s).
WORLD EMISSION DATA VS DATE.xlsx (24 KiB) downloaded 42 time(s).

I get the linear result; however, it does not fit the data between 2014-2023. If I try to redefine X to XX for a subset of the data, I get the rows and columns don't match error as noted in the SMATH FILE. This redefinition of the data to a subset resembles how it would be done in MATHCAD to fit a subsection of data.

Thanks again,
Reg
Reg Curry Loveland, CO
#4 Posted: 2/13/2025 2:29:36 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Wrote

Alvaro,
Thanks much. I understand that.

Here is my second question as reference in my pm to you. Actually it's two question?

1. How did you make the Data2 resident so the xlsx file is not needed.

2. Because the emissions level off between 2014-2023, I am trying to switch from the exponential fit up to 2014 to a linear fit between 2014-2023 and extend that forward. Here is my attempt.

CO2 FORCING SATURATION STUDY working.sm (46 KiB) downloaded 55 time(s).
WORLD EMISSION DATA VS DATE.xlsx (24 KiB) downloaded 42 time(s).

I get the linear result; however, it does not fit the data between 2014-2023. If I try to redefine X to XX for a subset of the data, I get the rows and columns don't match error as noted in the SMATH FILE. This redefinition of the data to a subset resembles how it would be done in MATHCAD to fit a subsection of data.

Thanks again,
Reg



Hi Reg.
1. I use the "SMathMatrixEditor" utility from this post.

2. In general, you cannot vectorize matrix functions. In particular, in this case, you cannot vectorize "el(u,1)". In order to vectorize, the matrix functions that are required must already be evaluated, so it is necessary to introduce a and b

vec.png

CO2 FORCING SATURATION STUDY working 2.sm (73 KiB) downloaded 56 time(s).

Best regards.
Alvaro.
#5 Posted: 2/13/2025 3:28:26 PM
RegRetired

RegRetired

8 likes in 130 posts.

Group: User

Alvaro,

As always, t thanks much.

1. I need some time to work on embedding the Excel data into my SMATH spreadsheet.

2. There are some subtle things in SMATH that I do not understand yet, especially with al_nleqsolve.

Now, I need to incorporate your corrections into the integrals for the total CO2 concentration. I need to convert FIT2 to a function of a variable that can be used in the integral over s from 2014 to enddate.

This is where I was headed.
CO2 FORCING SATURATION STUDY.sm (55 KiB) downloaded 60 time(s).

Thanks again,
Reg

Reg Curry Loveland, CO
#6 Posted: 2/14/2025 8:25:27 AM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Hi Reg. This is my approach.

CO2 FORCING SATURATION STUDY 2.sm (63 KiB) downloaded 60 time(s).

Best regards,
Alvaro
#7 Posted: 2/14/2025 2:51:03 PM
RegRetired

RegRetired

8 likes in 130 posts.

Group: User

Alvaro,

Thanks as always.

You are a much more sophisticated programmer than me. I am rather pedestrian.

Here is my almost final version. It includes the Temperature Anomaly Calculation. I just need to add the satellite and surface data in the graph.
CO2 FORCING SATURATION STUDY W-EMBEDDED DATA.sm (192 KiB) downloaded 61 time(s).

The method you showed me for embedding data files is really useful.

Infrequently, SMATH crashes on me. It may be my 10 year old computer. When I include a separator in my file, and then try to move it with the mouse, it totally destroys all of my graph settings to the point that I have to delete the graphs and start over. This is how I move areas; so I thought I could move the separator the same way. If I add and delete spaces with the cursor and my keyboard that works fine. So, I have stopped using separators.

Take care.
Reg
Reg Curry Loveland, CO
#8 Posted: 2/15/2025 10:09:09 PM
overlord

overlord

554 likes in 1333 posts.

Group: Moderator

Wrote

Hi Reg.
1. I use the "SMathMatrixEditor" utility from this post.


Wow, I remembered first day I found this executable.
And now I realized this is not imported to SMath as native tool.
This should be a feature, not a separate tool.

Regards
1 users liked this post
churichuro 2/16/2025 1:03:00 AM
#9 Posted: 2/16/2025 5:28:01 AM
RegRetired

RegRetired

8 likes in 130 posts.

Group: User

I agree. It’s a very useful tool.
Reg
Reg Curry Loveland, CO
#10 Posted: 2/17/2025 5:47:23 AM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Wrote

... Infrequently, SMATH crashes on me. It may be my 10 year old computer. When I include a separator in my file, and then try to move it with the mouse, it totally destroys all of my graph settings to the point that I have to delete the graphs and start over. This is how I move areas; so I thought I could move the separator the same way. If I add and delete spaces with the cursor and my keyboard that works fine. So, I have stopped using separators.



On my Windows too, on 32 and 64 bit machines. If I want to move an area, I collapse it, cut it and paste it to the desired destination.

My version has a discrepancy with yours, although I don't understand where it could be: I check them and according to me they should be the same. (Area in yellow)

CO2 FORCING SATURATION STUDY 2.sm (116 KiB) downloaded 65 time(s).

CO2 FORCING SATURATION STUDY 2.pdf (634 KiB) downloaded 72 time(s).

Best regards.
Alvaro.
#11 Posted: 2/17/2025 7:46:05 AM
RegRetired

RegRetired

8 likes in 130 posts.

Group: User

I can only assume it is differences in the order of calculation between the two methods. Note that there is a slight difference between u.lin1 and u.lin2 in our versions. I assume it is the difference in how we define the subset of data between 2014 and 2023.

I have attached a pdf of my MATHCAD file that supposedly does the same calculation. There are small differences here also, but they manifest in a rather large difference in the result when the emission model reaches 1.5 °C. MATHCAD predicts 2128 and SMATH predicts 2120 for the same input constants…I think.
But we physicists usually do estimates to an order of magnitude. We are very happy with a factor of two. Our difference of 1233.2524/1156.6686 =1.07 makes us ecstatic.
MATHCAD CO2 FORCING.pdf (603 KiB) downloaded 63 time(s).
CO2 FORCING WITH SMATH.pdf (1 MiB) downloaded 53 time(s).
CO2 FORCING SATURATION STUDY W-EMBEDDED DATA.sm (593 KiB) downloaded 57 time(s).

I was not aware of the ODE solver; thanks for giving me more new information about SMATH.

I am becoming more comfortable with SMATH, although my long history with MATHCAD causes me to stumble frequently due to the small differences. One thing I really miss is MATHCAD’s plotting functions. I really miss the Trace function and the markers. But I can live with that if I am forced to get a new computer. Since PTC took over MATHCAD, they have stopped supporting MATHCAD 15, which is my version. Even though I have a perpetual license, they will not help me install it on a new computer. There a numerous negative reviews of PTC.

Take care,
Reg
Reg Curry Loveland, CO
#12 Posted: 2/18/2025 9:58:02 AM
RegRetired

RegRetired

8 likes in 130 posts.

Group: User

Alvaro,

Two things;

1. How do you create this syntax for Rkadapt.
Rkadapt.png

2. Your integral over tk is equal to my Y as far as I can tell.
CO2 FORCING SATURATION STUDY NEW.sm (599 KiB) downloaded 53 time(s).

I have tried numerous things, but I still don't understand the difference in the two methods.

Thanks much.
Reg
Reg Curry Loveland, CO
#13 Posted: 2/18/2025 2:49:49 PM
RegRetired

RegRetired

8 likes in 130 posts.

Group: User

FYI,

MATHCAD produces the same discrepancy between the two integral methods.

Screenshot 2025-02-17 232729.png

Screenshot 2025-02-17 234030.png




Reg
Reg Curry Loveland, CO
1 users liked this post
Alvaro Diaz Falconi 2/18/2025 11:56:00 PM
#14 Posted: 2/19/2025 12:17:46 AM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Wrote

... 1. How do you create this syntax for Rkadapt. ...



It is the syntax for an ode solver using the "Mathcad toolbox"

Wrote

... 2. Your integral over tk is equal to my Y as far as I can tell.



Thank you for confirming that I am not making some basic mistake, at least the mistake is somewhat hidden, in case there is one. If it were a derivative, one can expect anything, since it is a very unstable numerical procedure, but when it comes to integrals it is supposed to be stable and robust. What's more, it is supposed to be continuous on the right, but one can always find examples that complicate things.

Best regards.
Alvaro.


#15 Posted: 2/19/2025 3:29:34 AM
RegRetired

RegRetired

8 likes in 130 posts.

Group: User

👍👍
Reg Curry Loveland, CO
  • New Posts New Posts
  • No New Posts No New Posts