Calculating Equation

Aldrin, take a deep breath. It’s likely that your plugin isn’t installed correctly. The problem has nothing to do with your project.

Go to the Explorer. Open the applications folder, select the Xojo folder. You should have a plugins folder. In there you should have the Big Float plugin.

https://res.cloudinary.com/dgawps4u6/image/upload/v1545049735/Plugin.png

This is the folder structure for the downloaded big float.

in the Xojo folder …
copy the fpplugin in the xojo/plugins folder (in the C:\programs\xojo folder)

Now I have Pasted the fbplugin in the plugins folder, errors have been solved and now I can able to run the program. Thanks for the wonderful help, Let me check the output and message here. Once again Thanks for all.

This is the input parameter equation, which I am facing NAN(IND) as Output.

https://res.cloudinary.com/dgawps4u6/raw/upload/v1545134585/equation.txt

The fpPlugIn does not produce NaN’s. So, this wouldn’t be the result of a BigFloat operation. That would result in one of:
fpBadInputException
fpDivideByZeroException
fpNilObjectException
fpNegativeNumberException
fpNegativeOrZeroException
fpBadEntryNumberException
fpOverflowOrNegativeException
fpPrecisionNotMetException

If you’re using the BigFloat ExpressionEvaluator class to parse and evaluate the formula, then it should catch the exception and return “NaN” not “NaN(IND)”.

In general, when you get a NaN of any type, it means that you attempted an illegal math operation such as divide by zero, square root of a negative number, logarithm of zero or negative number, etc.

I would recommend that you start with a much simpler mathematical expression for debugging, and once you’re satisfied that it’s working with a simple expression, then you can try that huge one.

Edit:
When you had stated earlier that you were trying to assign a 50000 character string value, I took that to mean that you needed to use extended precision math. Now, after looking at the formula that you’re trying to evaluate, I see that most of the constants have only 3 or 4 decimal places of precision. So, I suspect that you don’t need anything more precise than regular double precision at best.

I think, at this point, we need to get a more detailed description of exactly what you are trying to accomplish. Otherwise, we’re likely to end up going down the wrong path.

I plugged your expression into my ExpressionEvaluator example app, and the good news is that it parsed correctly. However, when evaluated it does indeed produce a NaN. I added a bit of diagnostic code to find out where this occurs and this is what it produced:
Invalid result NaN occurred after 2016 operations. Operation: “/” (Division), Operands: “0.0786962” “0”
So, it’s trying to divide by zero.

We tried this same equation in Matlab and Java Language and we got the expected output, but in xojo only we are facing these issues.

For 4000 characters I can able to get the expected output in xojo, above 50000 characters I was not able to receive the output.

dim fin,z as BigFloat
fin= new BigFloat(result)

here result hold 50000 characters and also getting the error

Exception err
if err isA fpBadEntryNumberException then
MsgBox “Bad entry number!”
else
MsgBox “Unknown error!”
endif

In the console, I am getting unknown error but not producing the exact output.

I pasted your expression directly into an assignment statement in the XOJO code editor and ran it. It gives a result of 19.99723.

I don’t know why the ExpressionEvaluator produced an error. It may be due to a difference in how operator precedence is handled. I’ve noticed a difference between various software packages in how they handle precedence of the exponentiation operator.

Can you send me the code which has got the output? And also how to calculate the given equation other than expression evaluator in xojo.

The forum won’t let me post such a large chunk of text. So I omitted the middle part:

[code]dim a As Double=((2.727*((2.762+4.792*(sqrt((0.086*((0.0-((1.0*( _
(4–45)/44.784)+0.0)/0.999))^2+(0.0-((1.0*((5-102)/5166)+0.0)/0.998))^2+ _
(0.0-((1.0*((4-0.2)/0.3)+0.0)/0.999))^2+(0.0-((1.0*( _
(5-0)/100)+0.0)/0.996))^2+(0.0-((1.0*((4-1)/6)+0.0)/0.998))^2+ _
(0.0-((1.0*((5-0.1)/0.9)+0.0)/0.998))^2+(0.0-((1.0*( _
(4-0.3)/0.5)+0.0)/0.998))^2+(0.0-((1.0*((5-0)/15)+0.0)/0.999))^2))+1))-1.024* _
(sqrt((0.144*((0.207-((1.0*((4–45)/44.784)+0.0)/0.999))^2+ _
.
.
.
((4-1)/6)+0.0)/0.998))^2+(0.054-((1.0*((5-0.1)/0.9)+0.0)/0.998))^2+ _
(0.949-((1.0*((4-0.3)/0.5)+0.0)/0.998))^2+(0.967-((1.0* _
((5-0)/15)+0.0)/0.999))^2))+1))-2.321*(sqrt((0.113*((0.008- _
((1.0*((4–45)/44.784)+0.0)/0.999))^2+(0.049-((1.0*( _
(5-102)/5166)+0.0)/0.998))^2+(0.588-((1.0*((4-0.2)/0.3)+0.0)/0.999))^2+ _
(0.859-((1.0*((5-0)/100)+0.0)/0.996))^2+(0.990-((1.0* _
((4-1)/6)+0.0)/0.998))^2+(0.013-((1.0*((5-0.1)/0.9)+0.0)/0.998))^2+ _
(0.988-((1.0*((4-0.3)/0.5)+0.0)/0.998))^2+(0.246-((1.0* _
((5-0)/15)+0.0)/0.999))^2))+1)))/1)-2.896)/1.0)

TextArea1.Text= str(a)
[/code]
XOJO didn’t like it as a one line formula. So, I split it into a multi-line statement using the underscore character at the end of each line.

Sure but I also tried with the full equation with the static variable, but if it comes as dynamic it is not producing the output.

Perhaps XojoScript would be a good solution here.

How to use XojoScript for this Equation using a variable, Please let me know.

Drop a XojoScript object on your window. In Window.Open, set the script’s context to the window. That will give the script access to the properties of the window. So if you have 2 properties on the window

Result as String   // your equation
ResultValue as Double   // the evaluated value

Then in the window’s Open event set the context

XojoScript1.Context = self

When you have a Result string that you want to evaluate, you create a source code string similar to your hard coded code above, and pass it to the script

dim s as string = "ResultValue = " + Result
XojoScript1.Run
msgbox str(ResultValue)

ResultValue as Double // the evaluated value

In this variable it is not calculating the output, I have used like this in the code

Dim ResultValue as Double
resultvalue = val(result)

Here result is the input parameter from DB.

Are you using a XojoScript? If so, you shouldn’t Dim ResultValue. Use the one in the window.

I used like this

dim Result as String // your equation
dim ResultValue as Double // the evaluated value
dim a as XojoScript

a.Context = self

dim s as string = "ResultValue = " + Result
a.Run
msgbox str(ResultValue)

[quote=418658:@Aldrin Mathias]dim Result as String // your equation
dim ResultValue as Double // the evaluated value
[/quote]
These create local variables that are not available to the script. They must be properties of the window.

@Tim Hare Thanks For the help, I tried with xojoscript and I got the expected output. But only one confusion why we are using xojoscript and it is having any disadvantages…?