Get multiple solutions for one variable from Maxima Solve()

Get multiple solutions for one variable from Maxima Solve() - How to get multiple solutions when the variable name is the same? (Assign() is not enough) - Messages

#1 Posted: 10/16/2021 7:54:48 AM
Stefano

Stefano

0 likes in 22 posts.

Group: User

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 (22 KiB) downloaded 65 time(s).
filter maxima solve solution.pdf (126 KiB) downloaded 59 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"). 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
#2 Posted: 10/16/2021 10:17:22 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

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]
#3 Posted: 10/16/2021 10:55:33 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

... here is a typical seeded roots scanner.
You can spline for in-situ calculation.

Solve Inverse [Seeded Scanner_roots].sm (16 KiB) downloaded 45 time(s).
#4 Posted: 10/16/2021 11:30:05 AM
Stefano

Stefano

0 likes in 22 posts.

Group: User

Wrote

Wrote

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.
#5 Posted: 10/16/2021 12:04:58 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

What's "active AV"?


AV Anti Virus
It may be my Win 7 not recognizing your Win 10.
Promised *.PDF missing.
#6 Posted: 10/16/2021 12:36:19 PM
overlord

overlord

552 likes in 1332 posts.

Group: Moderator

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
#7 Posted: 10/16/2021 2:28:51 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Hi. You can try this approach.

filter maxima solve solution - choose.sm (8 KiB) downloaded 61 time(s).

Imagen1.png

Best regards.
Alvaro.

#8 Posted: 10/16/2021 2:46:57 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

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 (188 KiB) downloaded 42 time(s).
#9 Posted: 10/18/2021 10:00:40 AM
Stefano

Stefano

0 likes in 22 posts.

Group: User

Wrote

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"); maple would work though.


Wrote

Hi. You can try this approach.

filter maxima solve solution - choose.sm (8 KiB) downloaded 61 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.
#10 Posted: 10/18/2021 10:27:42 AM
overlord

overlord

552 likes in 1332 posts.

Group: Moderator

Wrote

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.
1 users liked this post
Alvaro Diaz Falconi 10/18/2021 1:47:00 PM
#11 Posted: 10/18/2021 12:06:39 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

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.
#12 Posted: 10/18/2021 12:54:27 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

... the function at(2) is native local definition
... the function at(3) is used as differential operator.
#13 Posted: 10/18/2021 1:46:19 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Wrote

... 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 (11 KiB) downloaded 46 time(s).

Best regards.
Alvaro.
#14 Posted: 10/18/2021 2:01:00 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Wrote

Wrote

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/forum/yaf_postsm7966_Function-as-a-program.aspx#post7966

Best regards.
Alvaro.
#15 Posted: 10/18/2021 5:20:55 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote


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



at(3).PNG
#16 Posted: 10/18/2021 5:23:39 PM
overlord

overlord

552 likes in 1332 posts.

Group: Moderator

Wrote

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
  • New Posts New Posts
  • No New Posts No New Posts