File:TrivFctRootExm.pdf

Summary

Description
English: The function g: RR is a trivial 5th functional root of f: R+R+ defined by f(x) = sin(x). The computation of f(π/6) = 1/2 = g5(π/6) is shown. See File:TrivFctRootDef.pdf for the definition of g, given an arbitrary f: R+R+ and nN, and the computation of gn(x) = f(x) for all xR+.
Date
Source Own work
Author Jochen Burghardt
Other versions File:TrivFctRootExm.pdf * File:TrivFctRootExm svg.svg * File:TrivFctRootDef.pdf
C source code for example coordinates
#include <stdio.h>
#include <math.h>

static int const n = 5;
static double f(double x) { return sin(x); }

static double g(double x) {
    if (0.0           <= x                     )   return atan(x) - M_PI;
    if (-(n-1)*M_PI/2 <= x && x < 0            )   return x - M_PI/2;
    if (-n*M_PI/2     <= x && x < -(n-1)*M_PI/2)   return f(tan(x+n*M_PI/2));
    return 0.0;
}

int main(void) {
    int i;
    double gi; 
    while (1) {
        printf("enter:\n");
        scanf(" %lf",&gi);
        for (i=0; i<=n; ++i) {
            printf("g^%d(x) = %f\n",i,gi);
            gi = g(gi);
        }
    }   
    return 0;
}
Gnuplot source code
# given:
n = 5 
f(x) = sin(x)

# trivial function root:
g(x) =  ( 0 <= x                          ? atan(x) - pi                \
        : -(n-1)*pi/2 <= x && x < 0       ? x - pi/2            \
        : -n*pi/2 <= x && x < -(n-1)*pi/2 ? f(tan(x+n*pi/2))    \   
        :                                   0                   \
        )

xmin = -8
xmax = 7 
ymin = -8
ymax = 2 

set xrange[xmin:xmax]
set yrange[ymin:ymax]
set grid
set xtics pi/2
set ytics pi/2
set format x "%5.2f"
set format y "%5.2f"
set key right bottom

# coordinate cross:
set arrow from xmin , 0    to xmax , 0    nohead lt 8
set arrow from 0    , ymin to 0    , ymax nohead lt 8

# shift ranges:
set arrow from -1*pi/2 , ymin to -1*pi/2 , ymax nohead lt 5
set arrow from -2*pi/2 , ymin to -2*pi/2 , ymax nohead lt 5
set arrow from -3*pi/2 , ymin to -3*pi/2 , ymax nohead lt 5
set arrow from -4*pi/2 , ymin to -4*pi/2 , ymax nohead lt 5
set arrow from -5*pi/2 , ymin to -5*pi/2 , ymax nohead lc 5

# 1 input/output example f:
set arrow from 0.523599 , 0 to 0.523599 , 0.500000 lt 1

# 5 input/output examples g:
set arrow from  0.523599 , 0         to  0.523599 , -2.659245 lt 2
set arrow from  0.523599 , -2.659245 to -2.659245 , -2.659245 lt 2
set arrow from -2.659245 , -2.659245 to -2.659245 , -4.230041 lt 2
set arrow from -2.659245 , -4.230041 to -4.230041 , -4.230041 lt 2
set arrow from -4.230041 , -4.230041 to -4.230041 , -5.800837 lt 2
set arrow from -4.230041 , -5.800837 to -5.800837 , -5.800837 lt 2
set arrow from -5.800837 , -5.800837 to -5.800837 , -7.371634 lt 2
set arrow from -5.800837 , -7.371634 to -7.371634 , -7.371634 lt 2
set arrow from -7.371634 , -7.371634 to -7.371634 ,  0.500000 lt 2

  plot            x    with lines       lt 7
replot [x=0:xmax] f(x) with lines  lw 3 lt 1 title"f(x)"
replot            g(x) with lines  lw 3 lt 2
pause -1

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-4.0#TrivFctRootExm.pdf
Category:Self-published work Category:Composition (mappings) Category:Files by User:Jochen Burghardt Category:Images with Gnuplot source code Category:Sine function Category:Images with C source code
Category:CC-BY-SA-4.0 Category:Composition (mappings) Category:Files by User:Jochen Burghardt Category:Images with C source code Category:Images with Gnuplot source code Category:Self-published work Category:Sine function