# Finding numerical values to an equation describing a hyperplane or a plane (any software suggestion?)

The following equation $$0.27a+0.1b+0.13c=70$$ can admit many solution. Is there any software/methods I can use so that I can have a large list of all the possible numerical solutions to this equation?

The background to such a problem

So I am designing for my friend a recipe, and I know chicken, yoghurt and eggs, contain 0.27g, 0.1g and 0.13g of proteins per gram respectively. Suppose I would like to have 70g of proteins, what are the combinations of the respective amount of food to make up the desired amount of proteins? In principle I can just determine randomly the amount of chicken I'd like to have and that of eggs and solve for the remaining term, but is there anything I can do so that I can have a list of all possible positive solutions to choose from (to save the hassles?)?

• There are infinitely many! So generating a list is not feasible, do you have any more constraints? – caverac May 19 at 13:21
• Perhaps a, b, c should all be positive, and the solution should be within a certain radius of the orthocenter of the triangle. I ask this question purely to see if it is possible to be shown some solutions of an equation of a plane. I remember in a calculus course the professor showed us a software in which I can see the values of another variable changing when I am scrolling between different values of a variable, all related by an equation. So my question can also be if there is any software that allows me to do just that but now with more variables. – hephaes May 19 at 13:45

That equation has infinitely many solutions, corresponding to the points on the triangle in three dimensions whose vertices correspond to all chicken, all yoghurt and all eggs. So a list is impossible.

I suspect that the recipe would not produce a tasty dish at or near any of those extreme points.

Perhaps you should precompute a short list of solutions near the center of the triangle and give your friend that list.

• Thank you. Can it be done with MATLAB? And suppose there are many more variables, is there any way to define the centre of that hyper pyramid? – hephaes May 19 at 13:36
• I'm pretty sure MATLAB can help. You can step through values for two of the ingredients and compute the third. Look up barycentric coordinates (en.wikipedia.org/wiki/Barycentric_coordinate_system). – Ethan Bolker May 19 at 13:48

If we admit that $$(a,b,c)$$ are integer, you could consider that you face a diophantine equation in three variables $$27a+10b+13c=7000$$

Have a look here to get the approach and the solutions $$a=10k-9m\qquad b=700-27k+2m\qquad c=m$$ Since all of them must be positive, this restricts the range of the solutions. It is very easy to code.

I would suggest formulating this as a linear programming problem. Rather than generating a list of feasible solutions and then choosing one manually, the LP will have an objective function so that the model will choose for you, based on some criterion that you establish. For example each food in the diet can have a cost (which you want to minimize) or a taste score (which you want to maximize). In fact this is a classic LP problem called the diet problem.

• I suppose that this must be solved by programming methods. Could you suggest where I should explore to solve this kind of problem with MATLAB/other languages? – hephaes May 19 at 14:34
• A quick google search of “linear programming solver + [matlab or your language of choice]” will turn up lots of options. If you are new to linear programming I’d recommend using a modeling language like AMPL or GAMS, or something like the python package PuLP. – LarrySnyder610 May 19 at 22:04