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) - Сообщения

#1 Опубликовано: 16.10.2021 07:54:48
Stefano

Stefano

0 сообщений из 22 понравились пользователям.

Группа: 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 КиБ) скачан 64 раз(а).
filter maxima solve solution.pdf (126 КиБ) скачан 58 раз(а).

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 Опубликовано: 16.10.2021 10:17:22
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 Опубликовано: 16.10.2021 10:55:33
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

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

Solve Inverse [Seeded Scanner_roots].sm (16 КиБ) скачан 45 раз(а).
#4 Опубликовано: 16.10.2021 11:30:05
Stefano

Stefano

0 сообщений из 22 понравились пользователям.

Группа: 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 Опубликовано: 16.10.2021 12:04:58
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

What's "active AV"?


AV Anti Virus
It may be my Win 7 not recognizing your Win 10.
Promised *.PDF missing.
#6 Опубликовано: 16.10.2021 12:36:19
overlord

overlord

552 сообщений из 1332 понравились пользователям.

Группа: 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 Опубликовано: 16.10.2021 14:28:51
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Hi. You can try this approach.

filter maxima solve solution - choose.sm (8 КиБ) скачан 60 раз(а).

Imagen1.png

Best regards.
Alvaro.

#8 Опубликовано: 16.10.2021 14:46:57
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 КиБ) скачан 41 раз(а).
#9 Опубликовано: 18.10.2021 10:00:40
Stefano

Stefano

0 сообщений из 22 понравились пользователям.

Группа: 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 КиБ) скачан 60 раз(а).

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 Опубликовано: 18.10.2021 10:27:42
overlord

overlord

552 сообщений из 1332 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Alvaro Diaz Falconi 18.10.2021 13:47:00
#11 Опубликовано: 18.10.2021 12:06:39
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 Опубликовано: 18.10.2021 12:54:27
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

... the function at(2) is native local definition
... the function at(3) is used as differential operator.
#13 Опубликовано: 18.10.2021 13:46:19
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: 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 КиБ) скачан 44 раз(а).

Best regards.
Alvaro.
#14 Опубликовано: 18.10.2021 14:01:00
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: 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 Опубликовано: 18.10.2021 17:20:55
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote


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



at(3).PNG
#16 Опубликовано: 18.10.2021 17:23:39
overlord

overlord

552 сообщений из 1332 понравились пользователям.

Группа: 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
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений