3

Can anyone please help. I'm following a tutorial found here as I have a situation where I have to get the equation of a line in point slope form i.e. y−y1=m(x−x1).

I get up to step 3 of the tutorial no problem, but then I got stuck. In order to go from this equation y−3=**3/11**(x−4) to this 11y−33=3(x−4) (getting rid of the fraction on the right), I have to multiply by 11 on both sides.

However, my problem is that I obviously wont be using fractions but floating point decimal numbers in C#. So my values would be 0.272727 rather than 3/11. So what would I need to multiply with on both sides to give me correct answer? Or can this even be done?

My question is this, how can I get from this y−3=**0.272727**(x−4) to 11y−33=3(x−4) in decimal form?

Does anyone have any suggestions or alternatives that I can use?

Thanks in advance

heyred
  • 2,031
  • 8
  • 44
  • 89
  • 1
    Write `3.0/11` instead of 3 and the whole expression becomes floating point. Then you can do whatever. – Oliver Apr 03 '12 at 13:01
  • I still don't know how this is going to solve my problem as I only have the decimal number to start with (the tutorial page and formulas are purely for reference and not the actual values I'm using). And even if I do convert it to a decimal like so 3.0/11 I'm still back at square 1. How do I then get rid of that decimal? Maybe I'm not understanding the explanation fully – heyred Apr 03 '12 at 13:18

3 Answers3

1

Fraction Class

You can actually use Fractions in C# Using it, you avoid the deviation of the rounding.

Pedro Ferreira
  • 629
  • 3
  • 8
1

I think your mistaking the equation solving step for the calculation. You need to first solve your equation to some form you can actually compute. Normal programming languages (not true for Mathematic etc) can't deal with symbolic calculations or unknowns. They can only compute the result of an expression given conrete values for all variables used

Niklas Schnelle
  • 1,139
  • 1
  • 9
  • 11
  • "Normal programming languages" hm What's normal? You have plenty of API's out there to deal with symbolic calculations and unknowns. Example: [Wolframalpha API](http://products.wolframalpha.com/developers/) – Pedro Ferreira Apr 03 '12 at 13:12
  • Yeah sorry maybe I worded it wrong. But I do realise that I have to solve the equation first before I can calculate the values. I know how to do the calculations one I have the equation solved, but solving the equation has thrown up this issue for me – heyred Apr 03 '12 at 13:35
  • Yes, but when trying to solve some equation to use it in a program again and again it's impractical to solve it every time. And you can't use statically compiled code to do the calculation if you need to figure out the equation beforehand. Still using Wolfram Alpha might be a great idea to first solve it and then use it, though doing it by hand might be a good excercise – Niklas Schnelle Apr 03 '12 at 13:35
  • When it is performance critical you should definitely use simple doubles computed from your fraction because that's what your CPU can calculate with – Niklas Schnelle Apr 03 '12 at 13:36
  • Based on what @Hans Moolman posted, yes the equation's are pretty much static as long as he inserts them ordered by the values he wants. Wolframalpha is capable of solving multiple equations giving the unknowns results. So CPU wise shouldnt be much of a issue. – Pedro Ferreira Apr 03 '12 at 13:46
0

Firstly, before trying to run the expression which calculates your equation you should detect which value has the denominator with a substring, or wathever else, after that, multiply your equation , and after that try to calculate it. Or, another way is to use The class FRACTION

mihai
  • 2,746
  • 3
  • 35
  • 56