LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Solving Math Expression using Labview

Solved!
Go to solution

Dear all,

 

I'm trying to solve a math expression with Labview. The expression i'm trying to solve is 4^x + 7x^3=200.

Let's say 200 = y. The task is that someone inserts a number "y" and Labview automatically calculates "x".

 

The way i'm trying to achieve this, is by increasing "x" slowly and put it in to the expression.

When "y" equals the preset "y" (set by a numeric control) everything stops and the numeric indicator shows "x".

 

I tried a couple of things but I can't get it to work properly, what am I doing wrong?

 

Kind regards,

 

Roy (the Netherlands)

0 Kudos
Message 1 of 12
(4,504 Views)
0 Kudos
Message 2 of 12
(4,501 Views)

It is not possible to express the formula as a polynomial as far as I know... see 4^x. 

 

Further your algorithm does not work because you are working with a certain precision. Each time you are increasing x with 1/100, 1/100 is your precision. You will have to take account of this in your algorithm because your answer which you compute will never be exactly 200, because your precision is finit, it will be something like 200,001094... != 200. So you have to compensate for this. (I changed this in your algorithm)

 

Further I do not think this would be my approach of solving this problem. It is sad that LabVIEW does not have a "solve" function like in Matlab. But for this case I would use one of the zero mathematic VI's located in "Mathematics -> Script & Formulas -> Zeros". I will not go into to much detail but... It concludes however some understanding of numerical methods, http://en.wikipedia.org/wiki/Numerical_analysis, and now especially in this case the field of finding the root of a formula, http://en.wikipedia.org/wiki/Root-finding_algorithm. When using root finding algorithms there are however ceveats.

1. You will have to define a range, start and end, in which the solution must lie. 

2. You will have to enter your formula as 4^x + 7x^3 - 200 = 0, instead of 4^x + 7x^3 = 200

3. For example if you choose to use Newton Raphsons method, the range which you define in, 1, can't, depending on the input formula, be to "broad", i.e. -5 to 5 but needs to be 2,6 to 2,8. If not choosen wisly the algorithm will never find a zero, if choosen wisley it will accumulate very fast. http://en.wikipedia.org/wiki/Newton%27s_method. Similar ceveats you will have for other root finding algorithms. 

Message 3 of 12
(4,489 Views)

A nice example about numerical methods is the following algorithm which no computer, with finit precision (which are all computers), can solve. 

 

x(k) = 111 - (1130 - (3000 / x(k-2))) / x(k-1)), with x(0) = 11/2 and x(1) = 61/11


Every computer will say the answer is 100 while the correct answer is 6.

 

ps. Waarvoor is de opdracht? Fontys Hogeschool?

0 Kudos
Message 4 of 12
(4,482 Views)
Woops, you're right. I read it as x^4.
0 Kudos
Message 5 of 12
(4,475 Views)

Hi,

 

you can abuse that your equation is strictly monotonic increasing.

Here's a rough draft.

 

Regards Florian

0 Kudos
Message 6 of 12
(4,456 Views)
Solution
Accepted by topic author Roy-R1

Zero finder ???

Here 2,790615

NR-zero.png

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 7 of 12
(4,442 Views)

Wouter,

 

Het is voor de Hanze Hogeschool. Heb jij een vergelijkbare opdracht gehad?

0 Kudos
Message 8 of 12
(4,411 Views)

Nee sorry, zit zelf op de TU in Eindhoven leren hier geen LabVIEW 😉 heb het geleerd op m'n HBO opleiding bij Fontys, waar we gewoon projecten kregen en geen kleine opdrachtjes, en via werk.

 

Maar ik zou gewoon aanhouden wat ik heb gepost (begrijp je het?). Mijn antwoord zou liever hetgene zijn wat Henrik Volkers heeft geplaatst, maar dan moet je wel de methode van Newton Raphson begrijpen, http://nl.wikipedia.org/wiki/Newton-Raphson. Denk zelf namelijk dat je leraar verwacht dat je iets in de trand van je huidige antwoord verwacht en niet m.b.v. newton raphson, maar dat kan je beter zelf inschatten.

0 Kudos
Message 9 of 12
(4,391 Views)

Deels begrijp ik het. Ik heb echter het idee dat bovenstaande oplossingen te complex zijn.

Ik zou het moeten kunnen oplossen na het bestuderen van de eerste 2 hoofdstukken uit de manual Smiley Wink

0 Kudos
Message 10 of 12
(4,365 Views)