FindRoot issue

FindRoot issue - Messages

#1 Posted: 5/3/2019 9:53:16 PM
Mo

Mo

0 likes in 34 posts.

Group: User

Hi,
I was trying to solve 2 equations and getting the root using FindRoot with weird results, that when substituting with the SMath results the equations don't yield to the same results.
I know using units seem to create problems, but it sometimes works and I need to solve this somehow.
any suggestion?
Test.jpg

Test.sm (287 KiB) downloaded 37 time(s).
#2 Posted: 5/3/2019 11:17:16 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

I was trying to solve 2 equations and getting the root using FindRoot with weird results, that when substituting with the SMath results the equations don't yield to the same results.
I know using units seem to create problems, but it sometimes works and I need to solve this somehow.
any suggestion?


1. I don't understand what you are trying to do.
2. Here is is a working example.
3. Your document is not backward compatible

Solve FindRoots LogLikely.sm (14 KiB) downloaded 49 time(s).

#3 Posted: 5/4/2019 7:01:20 AM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Somehow it works better reversing the unknowns... dunno why...

Also since you are working with units you have to pay attention at the required precision. The one shown in the function description is about the base units, m for the length and m^2 for the area.

Test - r0.sm (277 KiB) downloaded 34 time(s).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#4 Posted: 5/6/2019 1:21:12 PM
Mo

Mo

0 likes in 34 posts.

Group: User

Thank Davide and Jean,
Jean, as a structural engineer I deal a lot with units and creating a sheet without units is not professional and typically creates errors from users which we try to avoid. I read on other forums that the function works well without units (same as your sheet) so I prefer to find a way that works with units.

Davide, I am worried because this error should not occur.
I mean do I need to check every time I change my input that my output is correct?! and try to flip the variables to make it work? I tried your code in another old sheet and it did not work, I had to stick with the order a1=d first then the Area to make it work properly!!

Also, what happens if there are two positive real solutions, which one will be shown by SMath?

Thanks a lot for your help!!
#5 Posted: 5/6/2019 3:37:00 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Jean, as a structural engineer I deal a lot with units and creating a sheet without units is not professional and typically creates errors from users which we try to avoid. I read on other forums that the function works well without units (same as your sheet) so I prefer to find a way that works with units.


1. If it happens several roots, then solve(4)
2. Maple symbolic does not take units.
3. None of my Smath Process Control & Instrumentation [~ 100] carries units.
All results are in appropriate units ... [t/hr, mWc, cP ...]
4. What's the arc length unit => UnitGraphic that you can scale 1.23456789
5. Units were discussed ad nauseum Mathsoft Collaboratory.
Over 125000 exchange, not a single work sheet with units.
6. In few steps the resistance is no more Ohms ...
7. The unit system should be dead decoration, i.e: not sub-processing.

Cheers ... Jean

1 users liked this post
Mo 5/7/2019 6:09:00 PM
#6 Posted: 5/6/2019 4:49:54 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Wrote

Thank Davide and Jean,
Jean, as a structural engineer I deal a lot with units and creating a sheet without units is not professional and typically creates errors from users which we try to avoid. I read on other forums that the function works well without units (same as your sheet) so I prefer to find a way that works with units.

Davide, I am worried because this error should not occur.
I mean do I need to check every time I change my input that my output is correct?! and try to flip the variables to make it work? I tried your code in another old sheet and it did not work, I had to stick with the order a1=d first then the Area to make it work properly!!

Also, what happens if there are two positive real solutions, which one will be shown by SMath?

Thanks a lot for your help!!



If using the Maxima plugin is an option for you, then the solution is straightforward.
- Units are no problem for the plugin (they are converted into symbolic variables, Maxima itself isn't unit-aware).
- Multiple solutions are returned by Solve as a row vector of solutions (with each being a list of equations). You can pick the solution by
index and apply it using Assign().

I don't know how you can know in advance which solution to use. Perhaps the reasoning on which one to select can be cast into some test for index generation.

Best regards, Martin

test1_kr.png
test1_kr.sm (290 KiB) downloaded 36 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
2 users liked this post
sergio 5/6/2019 5:14:00 PM, Mo 5/7/2019 6:09:00 PM
#7 Posted: 5/6/2019 9:36:29 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

I read on other forums that the function works well without units (same as your sheet) so I prefer to find a way that works with units.


Just remember maths are unitless.
You are solving for two monkeys that you can't augment with units.
And you have only one project in hand, what about if you are contracted
for the entire British Empire ?
Examine the attached Colebrook.
In < one page maths, it solves a monster big pile of information.
More can be added for tabulation. Little modifications will solve
for as many fluids the plant will have [commonly 100's of fluids].
At the end: one page recast will produces several inches thick of
documents in no time in unit-result visible, consultable by more
than the piping design team, thinking in terms of the $ illuminatis.
Try unitless, plot something ...

Cheers ... Jean

Inst_Colebrook Pipe Data.sm (59 KiB) downloaded 31 time(s).


1 users liked this post
Mo 5/7/2019 6:09:00 PM
#8 Posted: 5/7/2019 1:08:56 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Think twice: 1.23456789*9.87654321= result + an empty place holder
What is the 2nd place holder for ? I know: the slipping bar for the parrot
Rather from uniless maths to validate the unit-result as desired.
Whereas the standard you are using has dimension then no need to carry units
as the standard tells what the unit-result is.
In your project, I trust you [that stuff is extraterrestrial to me].

UnitLess.PNG
1 users liked this post
Mo 5/7/2019 6:09:00 PM
#9 Posted: 5/7/2019 1:24:41 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

The SS 6179 document.

Solve Given_Find [Simple Demo].sm (68 KiB) downloaded 71 time(s).
1 users liked this post
Mo 5/7/2019 6:09:00 PM
#10 Posted: 5/7/2019 7:04:02 PM
Mo

Mo

0 likes in 34 posts.

Group: User

That Works, Thanks a lot Jean and Martin !!
  • New Posts New Posts
  • No New Posts No New Posts