Solving fourth-degree equations app

In addition to what @ABG has already said, please keep in mind the the TextBox component does not give-out the input value until it loses its focus.
In other words, in your input boxes for the constants a,b,c,d if you leave the cursor in d (for example) and you press the button to "Solve for x", in effect the d value is still 0 (not entered). So, to be sure that all the inputs are truly set, once you've set the last one, move the cursor into another TextBox, already entered.
This operation will unfocus the last TextBox, and therefore also its value will be set.
(I fought this type of "error" in the past .... :fearful:so probably it could help you).
Then, I suggest you a slight modification, as below:


Give it a try.... :+1:

1 Like

It does not do any favors for any one trying to read your blocks if you leave them nested like an onion.

Can you switch them all to external form, to make the nesting easier to read?

I tried to download your blocks image, but it was too big.

I had to settle for this sea of blue.

Here's a more readable version of your onion, cauliflower style.

I notice repetition of this constant sub expression
blocks (1)

You could simplify the code by doing the constant calculation in a new variable. Think of a name for it, ThreeCubeRootsOfTwo.

I ran out of time expanding your blocks.

Maybe tomorrow I might have the energy to match them against your formulae.

1 Like

Could this be worked around by using the TextChanged block ?

1 Like

I've tried and the results don't change.

image

Try resubmitting sub-formulas to Wolfram and match its results against Do It runs against your block subformulas.

1 Like

I have been using chat gpt to apply a solved example to these equations but it also gave different and wrong results. Could all these laws and equations be wrong!!!



I leave that for you to discuss with ChatGPT.

Did I mention that you can validate a value of x by running it through the original formula and examining the results to see if they are zero.

I have tried all the equations and attempts and they all give wrong values Does anyone have proven equations that give correct values?

The AI2 Charts component has a Click detector.

You could code a generalized polynomial plotter (coefficient list, lower and upper bounds, step size) and have it zoom in a step each time the user clicks on a likely spot on the graph.

This makes the user the solver, at least numerically.

I would code one for you, but I am supposed to be asleep now.

Is there a way to integrate Python code into App Inventor to solve the equation?

Lotsa luck with that.

I whipped up a polynomial editor and plotter today, but it needs a little cleanup on the editting side for the coefficient stack. (I made it general purpose, so it could accept any polynomial and represent it internally as a list of the coefficients for exponents 0,1,2,...

The coefficient entry is a bit awkward, and I could touch it up next week.

Here it is, if you would like to play with it.
polynomial_plotter.aia (7.5 KB)

image

Next week I may have time to clean it up.

2 Likes

Last minute cleanup, for missing coefficients:
polynomial_plotter (1).aia (7.7 KB)

1 Like

Even with python, you would have to import a package such as numpy or decimal to use higher-precision floats.

ChatGPT can make mistakes while doing very simple math, so I'm not too surprised it breaks down when trying to calculate this.

I noticed that every time I ask him the same question he gives a different result and each AI platform gives a different result !!

Is it possible for App Inventor to give incorrect results if the calculations are large and complex?

I'm still trying to find a way to find the four roots of x with one click and the only way so far is for those equations to be true.

Finally after trouble I found a simpler formula on Wikipedia, and it give me 4 correct solutions :rocket:

Four_Roots(2).aia (509.1 KB)

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.