File Exchange > Data Analysis >    Finding Roots of Equations

Author:
OriginLab Technical Support
Date Added:
11/6/2003
Last Update:
12/14/2014
Downloads (90 Days):
1
Total Ratings:
4
File Size:
1 KB
Average Rating:
File Name:
Find_Roots.opj
File Version:
1.00
Minimum Versions:
7.5
License:
Free
Type:
Example
Summary:

This Origin Project file can be used to find roots of equations. This project needs Origin version 7.5 or higher.

Screen Shot and Video:
Description:

This is an Active Origin Project - it uses a new feature of Origin 7.5 that allows attaching files to an OPJ. This OPJ has an Origin C file, a worksheet template, and a graph template attached to it.

How to find roots of equations:
-------------------------------
You need to issue a command from the script window, where you specify the equation and the x range in which to find roots. If roots are found for the equation in the specified x range, a graph of the equation is created and the roots are marked on the graph. A hidden worksheet is
also created that contains the data plotted in the graph. The roots are also reported to the script window.

For example, to find roots of the equation:
sin(x)/x = 0.1
in the x range of -10 to 10, enter the following command in the script window and press the Enter key:
find_roots "sin(x)/x-0.1" -10 10

Note that
1> The equation has to be written in the form f(x) = 0 and you then enter only the f(x) part in the command.
2> Only one variable is supported and it has to be named x.
3> The equation has to be entered with quotes around it.
4> In your equation, you can use any mathematical function that is part of the ANSI C function set, or is part of the Origin C function set. For example, there is no sec(x) in ANSI C. So you will need to write that as 1/cos(x).

Algorithm for finding roots:
----------------------------
This sample uses a very simple algorithm, as follows:
a> In the x range specified by user, all intervals that contain a sign change in the function are first located.
b> Each such interval is checked to see if the function is monotonic within that interval.
c> In each of the intervals where the function is monotonic, a bisectional root search is performed: The interval is successively divided in half until either the maximum number
of iterations is exceeded, or the root is found to a preset precision. The max iterations and root precision are set in the Origin C code as constants, and can be changed.

To view the code associated with this OPJ, go to
Code Builder (menu item: View|Code Builder) and look at the Origin C file called find_roots.c in the Project branch of the Code Builder workspace tree.

Updates:

Reviews and Comments:
08/11/2022OriginLabHi yahsi,
If I do not misunderstand your mean, you want to insert the graph into the cell of Worksheet, right?
You can right-click on the cell and then select "Insert Graph" to insert it.
https://www.originlab.com/doc/Origin-Help/InsObject-to-WksCell
Thanks
OriginLab

08/10/2022yahsiHow can I use it to be inserted into a cell in worksheet.

02/22/2012fandahan1987 

11/16/2003reza