The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 Solving Implicit Equations

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AKazak Posted - 06/26/2020 : 12:12:20 PM
OriginPro 2020b (64-bit) 9.7.5.184
Windows 7 Pro x64 SP1

Greetings!

Is there an easy way in Origin to get all X values matching to equations like this:


Thank you.


---
AK
16   L A T E S T    R E P L I E S    (Newest First)
Sam Fang Posted - 07/03/2020 : 03:14:35 AM
quote:
Originally posted by AKazak
Glad to read this.
Is this the near future?

---
AK



Hi AK,

I added it to our bug tracking database, ID: APPS-934. I will ask our developer to fix soon.

Sam
OriginLab Technical Services
AKazak Posted - 07/02/2020 : 11:48:21 AM
quote:
Originally posted by Sam Fang

quote:
Originally posted by AKazak
Dear Sam,

Got it, thank you.
Can I set each independent variables to point to specific single column-label-row cell?

---
AK



Hi AK,

Yes. We will support to define constants by column label row cell in Constants list box.

Sam
OriginLab Technical Services



Glad to read this.
Is this the near future?


---
AK
Sam Fang Posted - 07/01/2020 : 11:29:47 PM
quote:
Originally posted by AKazak
Dear Sam,

Got it, thank you.
Can I set each independent variables to point to specific single column-label-row cell?

---
AK



Hi AK,

Yes. We will support to define constants by column label row cell in Constants list box.

Sam
OriginLab Technical Services
cpyang Posted - 07/01/2020 : 3:13:09 PM
You can call Python from LT but beta1 only allow passing some strings to your Python code but you can easily access worksheet inside your Python code to put results in some columns.

We are now working on direct LT to Python with parameter passing, so in a week or so, we can release beta2 which has both OC and LT support to call Python functions with all basic scaler and vector passing back and forth.

CP
AKazak Posted - 07/01/2020 : 12:28:15 PM
quote:
Originally posted by lkb0221

Please try the following Python which I made with the awsome 2021 beta:

If not yet, install scipy from script window

pip install scipy


Python code:

from scipy.optimize import fsolve
from math import sin
import numpy as np
import originpro as op


def equation(x, *Params):
    sp, sm, D, Phi = Params
    return Phi*(sp-x)/(x+D*(sp-x))+(1-Phi)*(sm-x)/(x+D*(sm-x))
    #sp, sm, A, B, Phi = Params
    #return Phi*(sp-X)/(sp+A*X)-(1-Phi)*(sm-X)/(sm+B*X) 
    #return [Phi*(sp-X)/(sp+A*X)-(1-Phi)*(sm-X)/(sm+B*X) for x in X]


Phis = np.linspace(0, 1, 101, endpoint=True)
Xs = []
Params = (0.1, 0.001, 0.3333, )
for Phi in Phis:
    CurrentParam = Params + (Phi, )
    Xs.append(fsolve(equation, 0, args=CurrentParam))
wks = op.new_sheet()
wks.from_list(0, Phis, lname='Phi')
wks.from_list(1, Xs, lname='Root')
graph = op.new_graph(template='line')
plot = graph[0].add_plot(wks, coly=1, colx=0, type='line')
plot.color = '#167BB2'
graph[0].yscale = 2 
graph[0].set_xlim(begin=0, end=1, step=0.1)
graph[0].set_ylim(begin=6e-4, end=0.2, step=1)
graph[0].label('legend').remove()
graph.set_int('aa', 1)


Which will produce this graph:


FYI, for anyone being interested in this new version, you can request here:
https://www.originlab.com/doc/python/originpro



Great suggestion!
I will try this once install Origin 2021 Beta 1.

Can I run the Python script as a before-formula script in set column value dialog?


---
AK
AKazak Posted - 07/01/2020 : 12:23:35 PM
quote:
Originally posted by Sam Fang

Hi AK,

You'd better use constants instead of constant independent variables because too many independent variables may cause the problem to be complex.

We will support to define constant parameters in a list. I added it to our bug tracking database. It will be convenient and clear for your case.

Sam
OriginLab Technical Services



Dear Sam,

Got it, thank you.
Can I set each independent variables to point to specific single column-label-row cell?


---
AK
Sam Fang Posted - 07/01/2020 : 05:40:21 AM
quote:
Originally posted by AKazak

The results make sense.
However, I noticed that you replaced the equation parameters with the corresonding constants:
original equation: Phi*(0.1-x)*(x+1.0/3*(0.001-x)) + (1-Phi)*(0.001-x)*(x+1.0/3*(0.1-x)) = 0
modified equation: Phi*(Cp-x)/(x+D*(Cp-x))+(1-Phi)*(Cm-x)/(x+D*(Cm-x))=0

What is the problem with using equation parameters instead of constants?

---
AK



Hi AK,

You'd better use constants instead of constant independent variables because too many independent variables may cause the problem to be complex.

We will support to define constant parameters in a list. I added it to our bug tracking database. It will be convenient and clear for your case.

Sam
OriginLab Technical Services
AKazak Posted - 06/30/2020 : 05:39:19 AM
quote:
Originally posted by Sam Fang

Hi AK,

Thanks for your project file.

I defined the equation as folows:
Phi*(0.1-x)*(x+1.0/3*(0.001-x)) + (1-Phi)*(0.001-x)*(x+1.0/3*(0.1-x)) = 0


And set 1 to the initial value for x. The result looks like as below:
Can you check whether the result makes sense?

Thanks.

Sam
OriginLab Technical Services



The results make sense.
However, I noticed that you replaced the equation parameters with the corresonding constants:
original equation: Phi*(0.1-x)*(x+1.0/3*(0.001-x)) + (1-Phi)*(0.001-x)*(x+1.0/3*(0.1-x)) = 0
modified equation: Phi*(Cp-x)/(x+D*(Cp-x))+(1-Phi)*(Cm-x)/(x+D*(Cm-x))=0

What is the problem with using equation parameters instead of constants?


---
AK
Sam Fang Posted - 06/29/2020 : 11:02:41 PM
Hi AK,

Thanks for your project file.

I defined the equation as folows:
Phi*(0.1-x)*(x+1.0/3*(0.001-x)) + (1-Phi)*(0.001-x)*(x+1.0/3*(0.1-x)) = 0


And set 1 to the initial value for x. The result looks like as below:


Can you check whether the result makes sense?

Thanks.

quote:
Originally posted by AKazak
Dear Sam,

Please test the following example project:
https://my.originlab.com/ftp/forum_and_kbase/Images/CM Test.opj

---
AK



Sam
OriginLab Technical Services
lkb0221 Posted - 06/29/2020 : 5:13:41 PM
Please try the following Python which I made with the awsome 2021 beta:

If not yet, install scipy from script window

pip install scipy


Python code:

from scipy.optimize import fsolve
from math import sin
import numpy as np
import originpro as op


def equation(x, *Params):
    sp, sm, D, Phi = Params
    return Phi*(sp-x)/(x+D*(sp-x))+(1-Phi)*(sm-x)/(x+D*(sm-x))
    #sp, sm, A, B, Phi = Params
    #return Phi*(sp-X)/(sp+A*X)-(1-Phi)*(sm-X)/(sm+B*X) 
    #return [Phi*(sp-X)/(sp+A*X)-(1-Phi)*(sm-X)/(sm+B*X) for x in X]


Phis = np.linspace(0, 1, 101, endpoint=True)
Xs = []
Params = (0.1, 0.001, 0.3333, )
for Phi in Phis:
    CurrentParam = Params + (Phi, )
    Xs.append(fsolve(equation, 0, args=CurrentParam))
wks = op.new_sheet()
wks.from_list(0, Phis, lname='Phi')
wks.from_list(1, Xs, lname='Root')
graph = op.new_graph(template='line')
plot = graph[0].add_plot(wks, coly=1, colx=0, type='line')
plot.color = '#167BB2'
graph[0].yscale = 2 
graph[0].set_xlim(begin=0, end=1, step=0.1)
graph[0].set_ylim(begin=6e-4, end=0.2, step=1)
graph[0].label('legend').remove()
graph.set_int('aa', 1)


Which will produce this graph:


FYI, for anyone being interested in this new version, you can request here:
https://www.originlab.com/doc/python/originpro
EleanorGagne Posted - 06/29/2020 : 10:21:54 AM
I love to solve quadratic equations...
AKazak Posted - 06/29/2020 : 09:32:07 AM
quote:
Originally posted by Sam Fang

Hi AK,

You can check Initial Values for Dependent Variables in the dialog, set a positive value for initial x, and the final solution of x may be positive values.

If the problem still exists, you can tell us other parameter values, we can try it.
e.g. do you want to solve x=f(sp, sm, phi), and A, B are constants?

quote:
Originally posted by AKazak

Tried applying Equation Solver app to solve the above equation, but for about 1/3 of all points, it returns non-realistic negative values of x.
Is there a way to set some conditions on the searched solution?



Sam
OriginLab Technical Services


Dear Sam,

Please test the following example project:
https://my.originlab.com/ftp/forum_and_kbase/Images/CM Test.opj

---
AK
Sam Fang Posted - 06/29/2020 : 03:53:55 AM
Hi AK,

You can check Initial Values for Dependent Variables in the dialog, set a positive value for initial x, and the final solution of x may be positive values.

If the problem still exists, you can tell us other parameter values, we can try it.
e.g. do you want to solve x=f(sp, sm, phi), and A, B are constants?

quote:
Originally posted by AKazak

Tried applying Equation Solver app to solve the above equation, but for about 1/3 of all points, it returns non-realistic negative values of x.
Is there a way to set some conditions on the searched solution?




Sam
OriginLab Technical Services
AKazak Posted - 06/26/2020 : 5:06:24 PM
Tried applying Equation Solver app to solve the above equation, but for about 1/3 of all points, it returns non-realistic negative values of x.
Is there a way to set some conditions on the searched solution?

Thank you.


---
AK
AKazak Posted - 06/26/2020 : 12:49:39 PM
quote:
Originally posted by aplotnikov

It's a simple quadratic equation.



Sure, that was an example.
Anyway, is there a tool to solve such unresolved equations?


---
AK
aplotnikov Posted - 06/26/2020 : 12:16:17 PM
It's a simple quadratic equation.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000