Need an algorithm to calculate a function

In summary, the conversation revolves around the calculation of a table with x as the dependent variable using a given formula. The results obtained are not correct and the speaker is seeking help to find a general algorithm to solve the problem. One possible solution is suggested using power series inversion with the assumption of invertibility. The conversation also touches upon the topic of the 'Interesting Oscillator Potential'.
  • #1
Mentz114
5,432
292
I'm trying to calculate a table of x vs t, with x as the dependent variable from
this formula

[tex]t + C = \frac{1}{2}(x\sqrt( 1 - x^2) + arcsin(x) ) [/tex]

C=0.4783 is given when t=0 and x = 1/2

I thought it would be simple but my code is giving nonsensical results, viz.
a straight line ! I do get the correct answer when t =0 (1/2) and I can't find a fault in my code. My code also gives a straight line for

t = arcsin(x) + 0.5 which obviously wrong, since x = sin( t - 1/2).

Has anyone got a general algorithm for this ? I'm using simplex but I
haven't tried Newton-Ralphson

This is related to the 'Interesting Oscillator Potential' topic below.
 
Last edited:
Physics news on Phys.org
  • #2
You might use power series inversion:
1. Introduce the "tiny" variable [itex]\epsilon=x-\frac{1}{2}[/itex]
and find the first few Taylor series terms of the right-hand side about [itex]\epsilon=0[/itex]
You have now effectively found t as a power series in [itex]\epsilon[/itex]

2. Assume that this power series is invertible, i.e, it exists a function:
[tex]\epsilon(t)=\sum_{i=0}^{\infty}a_{i}t^{i}[/tex]

If you can find the coefficients [itex]a_{i}[/itex] you're finished! :smile:

3.Insert this power series on the epsilon places, and collect terms of equal power in t. (For each finite power of t, only a finite number of terms need to be collected.*)

4. Different powers of t are linearly independent functions, hence all coefficients of the powers must equal zero. This demand of zeroes furnishes you with the equations to determine the coefficients [itex]a_{i}[/itex]

*EDIT:
This requires that [itex]a_{0}=0[/itex].
This, however, holds, since [itex]\epsilon=0[/itex] when t=0.
 
Last edited:
  • #3
Thanks, arildno. Food for thought.
 

What is an algorithm?

An algorithm is a set of instructions or steps that are followed in order to solve a problem or perform a specific task. It is like a recipe for solving a problem.

Why is an algorithm necessary for calculating a function?

An algorithm is necessary because it allows us to break down a complex problem into smaller, more manageable steps. This makes it easier for us to solve the problem and ensures that we get the correct answer every time.

What are the key components of an algorithm for calculating a function?

The key components of an algorithm for calculating a function include identifying the input variables, determining the operations that need to be performed on the inputs, and specifying the output or result of the function.

How do I know if my algorithm is correct?

To ensure that your algorithm is correct, you can test it with different inputs and compare the outputs to the expected results. You can also use mathematical proofs or simulations to verify the correctness of your algorithm.

Can algorithms be used for any type of function?

Yes, algorithms can be used for any type of function as long as the inputs and operations are clearly defined. However, some functions may require more complex algorithms to accurately calculate their outputs.

Similar threads

  • Advanced Physics Homework Help
Replies
6
Views
2K
  • Advanced Physics Homework Help
Replies
6
Views
743
  • Advanced Physics Homework Help
Replies
3
Views
1K
  • Advanced Physics Homework Help
Replies
1
Views
605
  • Advanced Physics Homework Help
Replies
5
Views
629
  • Advanced Physics Homework Help
Replies
6
Views
1K
Replies
1
Views
734
  • Advanced Physics Homework Help
Replies
3
Views
1K
  • Advanced Physics Homework Help
Replies
10
Views
277
  • Advanced Physics Homework Help
Replies
4
Views
855
Back
Top