turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-11-2014 12:09 PM

I want compute such formula. How could I get it ?

10= 1.2*(1+ x ) + 1.2*(1+ x )**2 + 1.2*(1+ x )**3 + 1.2*(1+ x )**4

I want x= ?

Thanks.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-11-2014 12:52 PM

For a 4th degree poynomial there will be generally 4 complex solutions. Looks like the polyroot() function is what you need, check the IML documentation. I suggest you first compute z = polyroot( {1.2 1.2 1.2 1.2 -10) to get the imaginary roots, then since z = 1 + x, x = z-1, just subtract 1 from the first column of z to get x, i. e.

proc iml;

a = {1.2 1.2 1.2 1.2 -10};

z = polyroot(a);

x = z - {1 0,1 0,1 0,1 0};

print x;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-11-2014 12:58 PM

Hi,

If you take 1.2 as a common above equation becomes

10=1.2{(1+x) + (1+x)**2 + (1+x)**3 + (1+x)**4}

10 = 1.2[{1-(x+1)**5}/{1-(x+1)} as a result of geometric series in (1+x)

and more simplified form is

1.2(x+1)**5 - 10x - 1=0

Hope this helps.

Thanks

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-11-2014 01:19 PM

If you want only the real roots on a bounded interval, use the FROOT function. See A simple way to find the root of a function of one variable - The DO Loop

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-12-2014 08:11 AM

Thanks **Hutch@sas ****stat@sas ** **Rick Wicklin ** . I just suppose SAS can give me a simple code to get X like **Hutch@sas** did .

Sorry .I can't mark it as answered , because I can't find that button .

Regrads

Xia Keshan

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-13-2014 06:39 AM

Here is the program from the blog post. I replaced the function in the post with the example that you give:

proc iml;

start Func(x);

fx = 1.2*(1+ x) + 1.2*(1+ x)##2 + 1.2*(1+ x)##3 + 1.2*(1+ x)##4;

return(fx - 10); /* find x where f(x)=10 */

finish;

intervals = {-4 -1, /* 1st interval [-4, -1] */

-1 1}; /* 2nd interval [-1, 1] */

z = froot("Func", intervals);

print z;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

07-13-2014 09:10 AM

Thanks Doctor **Rick Wicklin** ,

I think I should start to learn IML in near future .

I also can get it by brutally enumerate the X value . right ?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-14-2014 06:10 AM

Well, sort of. If you want a DATA step solution, there are ways that are better than enumeration. You can use the bisection method. Do an internet search and you'll find DATA step implementations of the bisection method, such as this one: http://analytics.ncsu.edu/sesug/2007/PO21.pdf The key is that these algorithms find the "zeros" (or roots) so you want to solve for the roots of f(x)-10=0.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

07-14-2014 08:20 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

07-13-2014 04:57 PM

You could hijack **proc nlin** to do the job:

**data test;**

**y = 10;**

**run;**

**proc nlin data=test;**

**parms x 0;**

**model y = 1.2*(1+ x ) + 1.2*(1+ x )**2 + 1.2*(1+ x )**3 + 1.2*(1+ x )**4 ;**

**run;**

PG

PG