Get Help

Turn on suggestions

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

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- A Programme works out all the possible answers?

Options

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

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

Showing results for

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-08-2014
06:43 AM

05-08-2014
06:43 AM

A Programme works out all the possible answers?

Hi,

I need some ideas on how to do the following:

I have two variables a and b, the sum of a & b is 10. I would like Mathcad to work out all the possibilities that give me a+b=10, and a keep in mind I would like them to be integers.

Thank you

Labels:

6 REPLIES 6

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-08-2014
07:26 AM

05-08-2014
07:26 AM

Re: A Programme works out all the possible answers?

If you just mean positive integers it's trivial:

or have I misunderstood what you are looking for?

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-08-2014
07:38 AM

05-08-2014
07:38 AM

Re: A Programme works out all the possible answers?

What if I have a, b, c, d and e?

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-08-2014
08:09 AM

05-08-2014
08:09 AM

Re: A Programme works out all the possible answers?

Here's a brute force and ignorance method, again assuming positive integers only.

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-08-2014
08:34 AM

05-08-2014
08:34 AM

Re: A Programme works out all the possible answers?

Thank you, The brute force is working:)

Just for the fun of it, insteade of 9 use 99!

I am using Mathcad Prime and still runing around without result!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-08-2014
12:38 PM

05-08-2014
12:38 PM

Re: A Programme works out all the possible answers?

HinndNaser wrote:

Thank you, The brute force is working:)

Just for the fun of it, insteade of 9 use 99!

I am using Mathcad Prime and still runing around without result!

It sure will be hard to find 99 numbers in the range of 1 to 9 which sum up to 10

Why not post the real problem you are working on? But whatever its is, Mathcad provides no clever algorithms to deal with integers, diophantic equations or number theory in general. So brute force seems to be a quick and dirty option, but with a lot of values to deal with and probably a wider range per variable, its not an option still anymore as it will take more time than you are willing and able to spend. So the problem might be solveable by an approach unique to that specific problem.

In case you are interested in a way to write a routine with an arbitrary number of variables on not a static number of nested for loops, take a look at the routine I posted here: http://communities.ptc.com/message/199660#199660

The routine sure could be modified to solve tasks as your with a variable number of arguments, arbitrary function s (not only summation of all arguments) and a target value (like th 10 in your example).

But it will very soon get too slow to be helpful.

You may also be interested in this thread: http://communities.ptc.com/message/194291#194291

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-08-2014
07:29 AM

05-08-2014
07:29 AM

Re: A Programme works out all the possible answers?

Are you placing bounds on a and b? Integers, fine. Positive? Or are negative values allowed? Count "0" as an integer?