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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Solve nonlinear equation using NAG function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

aplotnikov

Germany
165 Posts

Posted - 07/11/2022 :  11:25:42 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

I would like to solve a nonlinear equation like
x=asin(1/(a+b*x))
for different sets of parameters (a,b). I can do it easily in R - the solution exists always for all the reasonable combinations of parameters, but I need a solution in Origin implemented as OriginC function without any connection to R.

There are several NAG functions suited for this purpose, but I didn't find any example of a call with user-defined coefficients, etc.

I guess, I need to use
NAG_comm
structure for this purpose. An illustrative example I would appreciate.

PS. I haven't succeed to solve this equation using EquationSolver.opx. Is it possible at all?

Thanks in advance.

Edited by - aplotnikov on 07/11/2022 11:27:43 AM

Echo_Chu

China
Posts

Posted - 07/13/2022 :  01:34:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It looks there is no problem to solve your equation with Equation Solver . Please look at the image below as an example. In the example I set a = 1 and b=2. You can set a and b to any other set of value as you needs.



Echo
OriginLab Technical Support
Go to Top of Page

aplotnikov

Germany
165 Posts

Posted - 07/13/2022 :  04:18:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Echo,

Thanks for a helpful hint! However I need to solve the equation for hundreds points. Thus, a more convenient solution using NAG function is still necessary. The C-code of the EquationSolver.opx may be very illustrative.

Regards,

Alexei
Go to Top of Page

Castiel

343 Posts

Posted - 07/13/2022 :  10:30:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by aplotnikov

Hello,

I would like to solve a nonlinear equation like
x=asin(1/(a+b*x))
for different sets of parameters (a,b). I can do it easily in R - the solution exists always for all the reasonable combinations of parameters, but I need a solution in Origin implemented as OriginC function without any connection to R.

There are several NAG functions suited for this purpose, but I didn't find any example of a call with user-defined coefficients, etc.

I guess, I need to use
NAG_comm
structure for this purpose. An illustrative example I would appreciate.

PS. I haven't succeed to solve this equation using EquationSolver.opx. Is it possible at all?

Thanks in advance.



https://www.nag.com/numeric/cl/nagdoc_cl26/html/c05/c05qbc.html
You can find an example from the above link.


------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
Go to Top of Page

aplotnikov

Germany
165 Posts

Posted - 07/14/2022 :  08:08:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Castiel,

Thanks for reply!

I read this description already - I always try to RTFM first. :) unfortunately this description contains neither the answer on my question nor any relevant example.

Regards,

Alexei
Go to Top of Page

YimingChen

1623 Posts

Posted - 07/14/2022 :  10:31:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is a simplified version of the Equation Solver app using the same nag function. To check the source code, you can go to the Code Builder window (press Alt + 4 in Origin workspace). In the Workspace panel on the left, right-click on the Apps folder and choose Add Existing Folder.... Then add the NonlinearSolver folder. Then you should be able to check the source code. Hope it helps.

https://my.originlab.com/ftp/forum_and_kbase/Images/NonlinearSolver.zip

James

Edited by - YimingChen on 07/14/2022 10:32:49 AM
Go to Top of Page

Castiel

343 Posts

Posted - 07/14/2022 :  10:48:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by aplotnikov

Hi Castiel,

Thanks for reply!

I read this description already - I always try to RTFM first. :) unfortunately this description contains neither the answer on my question nor any relevant example.

Regards,

Alexei



It does have an example. See 10.1 from that very webpage.


10.1
Program Text
Program Text (c05qbce.c)

10.2
Program Data
None.
10.3
Program Results
Program Results (c05qbce.r)


------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
Go to Top of Page

aplotnikov

Germany
165 Posts

Posted - 07/14/2022 :  11:18:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There is a difference between an example and a relevant example. I am trying to understand, how exactly I can transfer coefficients (not the x-values!) into the function fcn(). There is noting on this topic in the description you are referring to.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000