Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline kompre  
#1 Posted : 16 October 2021 13:54:48(UTC)
kompre


Rank: Member

Groups: Registered
Joined: 05/08/2021(UTC)
Posts: 22
Italy

Hi,

I've became an addicted of the Maxima Solve() function, but I am finding some trouble handling cases where one variable has multiple solutions.

Let's say for example that my expression is defined as "x^2-1=0"; the Solve() function will return the correct two solutions for "x" (-1, +1), but they are in boolean format and of not use without an assignment.

Normally I would use the Assign() function to extract and assign the values to the variables, but since the variable name is the same for both solutions, I end up with only one value for "x=+1": I suspect that the Assign function simply loops across the element of the list of solutions and the "x" is overwritten each times, this only the last value on the list is returned.

I know I can access the system of solution returned by the Solve() function by index, but I would like to be able to programmatically save all solutions, or filter down to the valid solution based on a criteria that fit the problem (e.g. I just want positive value for x, or within certain boundary).

I thought I could insert boundary condition (e.g. "x>0" in the system of equations to feed to the Solve() function, but it is not accepted as proper input

I have devised a for-loop to extract all the solutions and convert them to a list (vector) and even filter to just the one I need, but to me it seems a little convoluted for such a common problem that ought to be a better solutions.

filter maxima solve solution.sm (23kb) downloaded 30 time(s).
filter maxima solve solution.pdf (127kb) downloaded 21 time(s).

Lastly, I am aware of the bulit-in solve() function, which will return a vector of solutions, and where I can define the boundary where to find the solution, but I know it does it numerically and will not work if I have some undefined variables (e.g. "x^2-a"Wink. Maybe the maple solve could work if expect only one variable (because solutions are not ordered), but I would like to stick with Maxima.

Is there a better way?

EDIT: attached pdf version

Edited by user 16 October 2021 17:26:56(UTC)  | Reason: Not specified

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Jean Giraud  
#2 Posted : 16 October 2021 16:17:22(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: kompre Go to Quoted Post
Is there a better way?

Your document does not open incorrect format
Was never clearly explained ... may be caused from your active AV.
Find more in Samples Solve root LAGRANGIAN [few days ago]
Offline Jean Giraud  
#3 Posted : 16 October 2021 16:55:33(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
... here is a typical seeded roots scanner.
You can spline for in-situ calculation.

Solve Inverse [Seeded Scanner_roots].sm (17kb) downloaded 14 time(s).
Offline kompre  
#4 Posted : 16 October 2021 17:30:05(UTC)
kompre


Rank: Member

Groups: Registered
Joined: 05/08/2021(UTC)
Posts: 22
Italy

Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: kompre Go to Quoted Post
Is there a better way?

Your document does not open incorrect format
Was never clearly explained ... may be caused from your active AV.
Find more in Samples Solve root LAGRANGIAN [few days ago]



Not sure why you can't open the file, I've tried it on two different machine and for me works fine. What's "active AV"?

By the way I've attached at the original post the pdf version of what the file looks like to me, to avoid misunderstanding with someone that could have different plugin installed from me.
Offline Jean Giraud  
#5 Posted : 16 October 2021 18:04:58(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: kompre Go to Quoted Post
What's "active AV"?

AV Anti Virus
It may be my Win 7 not recognizing your Win 10.
Promised *.PDF missing.
Offline overlord  
#6 Posted : 16 October 2021 18:36:19(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,126
Turkey

Was thanked: 507 time(s) in 338 post(s)
Nothing is wrong with file, believe me everybody else can open it. There is no "incorrect format" bug within your file.
However it has some non standard fonts may result misbehave of smath. Manually replacing them with Arial via a text editor shall correct it.

I couldn't check it with maxima since smath linux version doesn't have Maxima support.
But with maple or standard solve() there are solutions.

Regards

Edited by user 16 October 2021 18:48:16(UTC)  | Reason: Not specified

Offline Razonar  
#7 Posted : 16 October 2021 20:28:51(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi. You can try this approach.

filter maxima solve solution - choose.sm (9kb) downloaded 23 time(s).

Imagen1.png

Best regards.
Alvaro.

Offline Jean Giraud  
#8 Posted : 16 October 2021 20:46:57(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: kompre Go to Quoted Post
I've became an addicted of the Maxima Solve() function, but I am finding some trouble handling cases where one variable has multiple solutions.

That visit will help.

Solve roots LAGRANGIAN.sm (189kb) downloaded 11 time(s).
Offline kompre  
#9 Posted : 18 October 2021 16:00:40(UTC)
kompre


Rank: Member

Groups: Registered
Joined: 05/08/2021(UTC)
Posts: 22
Italy

Originally Posted by: overlord Go to Quoted Post
However it has some non standard fonts may result misbehave of smath. Manually replacing them with Arial via a text editor shall correct it.


Gotcha. Haven't thought about font shenanigans!

I couldn't check it with maxima since smath linux version doesn't have Maxima support.
But with maple or standard solve() there are solutions.


Ah, too bad! Maxima is very good and convenient for solving system of equation and multiple variables. Standard solve() will not work if there is an undefined parameter (e.g. "x^2-b"Wink; maple would work though.


Originally Posted by: Razonar Go to Quoted Post
Hi. You can try this approach.

filter maxima solve solution - choose.sm (9kb) downloaded 23 time(s).

Imagen1.png

Best regards.
Alvaro.



Thanks! Very interesting use of the at() function, I didn't know it could be used with Boolean also. I not fully understand what the line() does to Solve(), but I tried without and and seen for myself that it will not work without.
Offline overlord  
#10 Posted : 18 October 2021 16:27:42(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,126
Turkey

Was thanked: 507 time(s) in 338 post(s)
Originally Posted by: kompre Go to Quoted Post
I not fully understand what the line() does to Solve(), but I tried without and and seen for myself that it will not work without.

There was a post sent by Razonar why line() needed sometimes. I will try to find it.
thanks 1 user thanked overlord for this useful post.
on 18/10/2021(UTC)
Offline Jean Giraud  
#11 Posted : 18 October 2021 18:06:39(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Thanks! Very interesting use of the at() function, I didn't know it could be used with Boolean also. I not fully understand what the line() does to Solve(), but I tried without and and seen for myself that it will not work without.
..................
the line is local definition.
sols:=]for the double vertical ▄
back space on the 2nd one
in the active ▄ solve(x^2-9,x)
More down the document is of local definition style.
Offline Jean Giraud  
#12 Posted : 18 October 2021 18:54:27(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
... the function at(2) is native local definition
... the function at(3) is used as differential operator.
Offline Razonar  
#13 Posted : 18 October 2021 19:46:19(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Originally Posted by: kompre Go to Quoted Post
... I not fully understand what the line() does to Solve(), but I tried without and and seen for myself that it will not work without.


Hi. line( ) does the same as defining sols (u) = Solve (eq, u)

Imagen1.png

filter maxima solve solution - line.sm (12kb) downloaded 13 time(s).

Best regards.
Alvaro.

Edited by user 18 October 2021 19:53:40(UTC)  | Reason: Not specified

Offline Razonar  
#14 Posted : 18 October 2021 20:01:00(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Originally Posted by: overlord Go to Quoted Post
Originally Posted by: kompre Go to Quoted Post
I not fully understand what the line() does to Solve(), but I tried without and and seen for myself that it will not work without.

There was a post sent by Razonar why line() needed sometimes. I will try to find it.


Hi overlord. I don't know which one could be. This is 9 years old: https://en.smath.com/for...-a-program.aspx#post7966

Best regards.
Alvaro.

Edited by user 18 October 2021 20:07:52(UTC)  | Reason: Not specified

Offline Jean Giraud  
#15 Posted : 18 October 2021 23:20:55(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post

... the function at(2) is native local definition
... the function at(3) is used as differential operator.


at(3).PNG
Offline overlord  
#16 Posted : 18 October 2021 23:23:39(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,126
Turkey

Was thanked: 507 time(s) in 338 post(s)
Originally Posted by: Razonar Go to Quoted Post
Hi overlord. I don't know which one could be.

This one I guess.

https://en.smath.com/forum/yaf_postsm71525_Functions-as-arguments-of-other-functions.aspx#post71525
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.